Transport e2e
based perforamnce test to integration_test
and remove duplicate watchPerformance
(#67594)
This commit is contained in:
parent
4a32e52460
commit
92f82c7b88
@ -46,7 +46,7 @@ dev_dependencies:
|
||||
flutter_test:
|
||||
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"
|
||||
@ -215,4 +215,4 @@ flutter:
|
||||
fonts:
|
||||
- asset: packages/flutter_gallery_assets/fonts/GalleryIcons.ttf
|
||||
|
||||
# PUBSPEC CHECKSUM: 9c4a
|
||||
# PUBSPEC CHECKSUM: c81b
|
||||
|
@ -7,13 +7,13 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:e2e/e2e.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
|
||||
import 'package:macrobenchmarks/src/simple_scroll.dart';
|
||||
|
||||
void main() {
|
||||
final E2EWidgetsFlutterBinding binding =
|
||||
E2EWidgetsFlutterBinding.ensureInitialized() as E2EWidgetsFlutterBinding;
|
||||
final IntegrationTestWidgetsFlutterBinding binding =
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized() as IntegrationTestWidgetsFlutterBinding;
|
||||
testWidgets(
|
||||
'Frame Counter and Input Delay for benchmarkLive',
|
||||
(WidgetTester tester) async {
|
||||
|
@ -2,14 +2,11 @@
|
||||
// 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_test/flutter_test.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:macrobenchmarks/common.dart';
|
||||
import 'package:e2e/e2e.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import 'package:macrobenchmarks/main.dart' as app;
|
||||
|
||||
typedef ControlCallback = Future<void> Function(WidgetController controller);
|
||||
@ -23,9 +20,9 @@ void macroPerfTestE2E(
|
||||
ControlCallback body,
|
||||
ControlCallback setup,
|
||||
}) {
|
||||
final WidgetsBinding _binding = E2EWidgetsFlutterBinding.ensureInitialized();
|
||||
assert(_binding is E2EWidgetsFlutterBinding);
|
||||
final E2EWidgetsFlutterBinding binding = _binding as E2EWidgetsFlutterBinding;
|
||||
final WidgetsBinding _binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
assert(_binding is IntegrationTestWidgetsFlutterBinding);
|
||||
final IntegrationTestWidgetsFlutterBinding binding = _binding as IntegrationTestWidgetsFlutterBinding;
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive;
|
||||
|
||||
testWidgets(testName, (WidgetTester tester) async {
|
||||
@ -60,7 +57,7 @@ void macroPerfTestE2E(
|
||||
await setup(tester);
|
||||
}
|
||||
|
||||
await watchPerformance(binding, () async {
|
||||
await binding.watchPerformance(() async {
|
||||
final Future<void> durationFuture = tester.binding.delayed(duration);
|
||||
if (body != null) {
|
||||
await body(tester);
|
||||
@ -69,29 +66,3 @@ void macroPerfTestE2E(
|
||||
});
|
||||
}, semanticsEnabled: false, timeout: Timeout(timeout));
|
||||
}
|
||||
|
||||
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;
|
||||
}());
|
||||
final List<FrameTiming> frameTimings = <FrameTiming>[];
|
||||
final TimingsCallback watcher = frameTimings.addAll;
|
||||
binding.addTimingsCallback(watcher);
|
||||
await action();
|
||||
binding.removeTimingsCallback(watcher);
|
||||
final FrameTimingSummarizer frameTimes = FrameTimingSummarizer(frameTimings);
|
||||
binding.reportData = <String, dynamic>{reportKey: frameTimes.summary};
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -2,29 +2,18 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:e2e/common.dart' as e2e;
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
import 'package:integration_test/integration_test_driver.dart' as driver;
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
Future<void> main() => driver.integrationDriver(
|
||||
timeout: const Duration(minutes: 1),
|
||||
responseDataCallback: (Map<String, dynamic> data) async {
|
||||
final Map<String, dynamic> benchmarkLiveResult =
|
||||
data['benchmarkLive'] as Map<String,dynamic>;
|
||||
final Map<String, dynamic> fullyLiveResult =
|
||||
data['fullyLive'] as Map<String,dynamic>;
|
||||
|
||||
Future<void> main() async {
|
||||
const Duration timeout = Duration(minutes: 1);
|
||||
const String testName = 'frame_policy';
|
||||
|
||||
final FlutterDriver driver = await FlutterDriver.connect();
|
||||
String jsonResult;
|
||||
jsonResult = await driver.requestData(null, timeout: timeout);
|
||||
final e2e.Response response = e2e.Response.fromJson(jsonResult);
|
||||
await driver.close();
|
||||
final Map<String, dynamic> benchmarkLiveResult =
|
||||
response.data['benchmarkLive'] as Map<String,dynamic>;
|
||||
final Map<String, dynamic> fullyLiveResult =
|
||||
response.data['fullyLive'] as Map<String,dynamic>;
|
||||
|
||||
if (response.allTestsPassed) {
|
||||
if(benchmarkLiveResult['frame_count'] as int < 10
|
||||
|| fullyLiveResult['frame_count'] as int < 10) {
|
||||
print('Failure Details:\nNot Enough frames collected:'
|
||||
@ -32,22 +21,12 @@ Future<void> main() async {
|
||||
'${fullyLiveResult['frameCount']}.');
|
||||
exit(1);
|
||||
}
|
||||
print('All tests passed.');
|
||||
const String destinationDirectory = 'build';
|
||||
await fs.directory(destinationDirectory).create(recursive: true);
|
||||
final File file = fs.file(path.join(
|
||||
destinationDirectory,
|
||||
'${testName}_event_delay.json'
|
||||
));
|
||||
await file.writeAsString(const JsonEncoder.withIndent(' ').convert(
|
||||
await driver.writeResponseData(
|
||||
<String, dynamic>{
|
||||
'benchmarkLive': benchmarkLiveResult,
|
||||
'fullyLive': fullyLiveResult,
|
||||
},
|
||||
));
|
||||
exit(0);
|
||||
} else {
|
||||
print('Failure Details:\n${response.formattedFailureDetails}');
|
||||
exit(1);
|
||||
testOutputFilename: 'frame_policy_event_delay',
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -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
|
||||
|
@ -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};
|
||||
}
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user