Transport e2e based perforamnce test to integration_test and remove duplicate watchPerformance (#67594)

This commit is contained in:
Ming Lyu (CareF)
2020-10-17 23:37:03 -04:00
committed by GitHub
parent 4a32e52460
commit 92f82c7b88
9 changed files with 32 additions and 129 deletions

View File

@@ -52,7 +52,7 @@ dev_dependencies:
flutter_goldens:
sdk: flutter
test: 1.16.0-nullsafety.5
e2e: 0.7.0+1
integration_test: 0.9.2+1
_fe_analyzer_shared: 7.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
analyzer: 0.39.17 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
@@ -277,4 +277,4 @@ flutter:
- asset: packages/flutter_gallery_assets/fonts/merriweather/Merriweather-Regular.ttf
- asset: packages/flutter_gallery_assets/fonts/merriweather/Merriweather-Light.ttf
# PUBSPEC CHECKSUM: 1f3d
# PUBSPEC CHECKSUM: c70e

View File

@@ -1,46 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui';
import 'package:flutter/scheduler.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:e2e/e2e.dart';
bool _firstRun = true;
// TODO(CareF): move this to e2e after FrameTimingSummarizer goes into stable
// branch (#63537)
/// watches the [FrameTiming] of `action` and report it to the e2e binding.
Future<void> watchPerformance(
E2EWidgetsFlutterBinding binding,
Future<void> action(), {
String reportKey = 'performance',
}) async {
assert(() {
if (_firstRun) {
debugPrint(kDebugWarning);
_firstRun = false;
}
return true;
}());
// The engine could batch FrameTimings and send them only once per second.
// Delay for a sufficient time so either old FrameTimings are flushed and not
// interfering our measurements here, or new FrameTimings are all reported.
Future<void> delayForFrameTimings() =>
Future<void>.delayed(const Duration(seconds: 2));
await delayForFrameTimings(); // flush old FrameTimings
final List<FrameTiming> frameTimings = <FrameTiming>[];
final TimingsCallback watcher = frameTimings.addAll;
binding.addTimingsCallback(watcher);
await action();
await delayForFrameTimings(); // make sure all FrameTimings are reported
binding.removeTimingsCallback(watcher);
final FrameTimingSummarizer frameTimes = FrameTimingSummarizer(frameTimings);
binding.reportData = <String, dynamic>{reportKey: frameTimes.summary};
}

View File

@@ -6,13 +6,12 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:e2e/e2e.dart';
import 'package:integration_test/integration_test.dart';
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
import 'package:flutter_gallery/gallery/demos.dart';
import 'package:flutter_gallery/demo_lists.dart';
import 'e2e_utils.dart';
import 'run_demos.dart';
const List<String> kSkippedDemos = <String>[];
@@ -27,8 +26,8 @@ List<String> _allDemos = kAllGalleryDemos.map(
void main([List<String> args = const <String>[]]) {
final bool withSemantics = args.contains('--with_semantics');
final E2EWidgetsFlutterBinding binding =
E2EWidgetsFlutterBinding.ensureInitialized() as E2EWidgetsFlutterBinding;
final IntegrationTestWidgetsFlutterBinding binding =
IntegrationTestWidgetsFlutterBinding.ensureInitialized() as IntegrationTestWidgetsFlutterBinding;
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
group('flutter gallery transitions on e2e', () {
testWidgets('find.bySemanticsLabel', (WidgetTester tester) async {
@@ -44,7 +43,7 @@ void main([List<String> args = const <String>[]]) {
runApp(const GalleryApp(testMode: true));
await tester.pumpAndSettle();
// Collect timeline data for just a limited set of demos to avoid OOMs.
await watchPerformance(binding, () async {
await binding.watchPerformance(() async {
await runDemos(kProfiledDemos, tester);
});

View File

@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:e2e/e2e_driver.dart' as driver;
import 'package:integration_test/integration_test_driver.dart' as driver;
Future<void> main() => driver.e2eDriver(
Future<void> main() => driver.integrationDriver(
timeout: const Duration(minutes: 5),
responseDataCallback: (Map<String, dynamic> data) async {
await driver.writeResponseData(