From c18c8bd0c006b0555b10fc5b00768c5f58e57f21 Mon Sep 17 00:00:00 2001 From: nturgut Date: Sat, 8 Aug 2020 23:28:45 -0700 Subject: [PATCH 01/25] change from build_runner to dart2js --- lib/web_ui/dev/test_platform.dart | 17 +++-- lib/web_ui/dev/test_runner.dart | 102 +++++++++++++----------------- 2 files changed, 56 insertions(+), 63 deletions(-) diff --git a/lib/web_ui/dev/test_platform.dart b/lib/web_ui/dev/test_platform.dart index 20e16be900217..0bdc99140dfa8 100644 --- a/lib/web_ui/dev/test_platform.dart +++ b/lib/web_ui/dev/test_platform.dart @@ -407,6 +407,7 @@ Golden file $filename did not match the image generated by the test. throw ArgumentError('$browser is not a browser.'); } + // Remove. Is this code still useful. var htmlPath = p.withoutExtension(path) + '.html'; if (File(htmlPath).existsSync() && !File(htmlPath).readAsStringSync().contains('packages/test/dart.js')) { @@ -811,15 +812,21 @@ class BrowserManager { controller = deserializeSuite(path, currentPlatform(_runtime), suiteConfig, await _environment, suiteChannel, message); + final String mapFileName = p.basename(path); + final String pathToTest = p.dirname(path); + final String mapPath = p.join( env.environment.webUiRootDir.path, 'build', - '$path.browser_test.dart.js.map', + '$pathToTest', + '$mapFileName.browser_test.dart.js.map' ); - PackageConfig packageConfig = await loadPackageConfigUri( - await Isolate.packageConfig); - Map packageMap = - {for (var p in packageConfig.packages) p.name: p.packageUriRoot}; + + PackageConfig packageConfig = + await loadPackageConfigUri(await Isolate.packageConfig); + Map packageMap = { + for (var p in packageConfig.packages) p.name: p.packageUriRoot + }; final JSStackTraceMapper mapper = JSStackTraceMapper( await File(mapPath).readAsString(), mapUrl: p.toUri(mapPath), diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index e9f57b32f0153..735be6382824b 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -130,6 +130,7 @@ class TestCommand extends Command with ArgUtils { /// Collect information on the bot. final MacOSInfo macOsInfo = new MacOSInfo(); await macOsInfo.printInformation(); + /// Tests may fail on the CI, therefore exit test_runner. if (isLuci) { return true; @@ -279,8 +280,7 @@ class TestCommand extends Command with ArgUtils { bool get isFirefox => browser == 'firefox'; /// Whether [browser] is set to "safari". - bool get isSafariOnMacOS => browser == 'safari' - && io.Platform.isMacOS; + bool get isSafariOnMacOS => browser == 'safari' && io.Platform.isMacOS; /// Use system flutter instead of cloning the repository. /// @@ -452,65 +452,51 @@ class TestCommand extends Command with ArgUtils { /// /// [targets] must not be null. /// - /// When building for CanvasKit we have to use a separate `build.canvaskit.yaml` - /// config file. Otherwise, `build.html.yaml` is used. Because `build_runner` - /// overwrites the output directories, we redirect the CanvasKit output to a - /// separate directory, then copy the files back to `build/test`. - Future _buildTests({List targets, bool forCanvasKit}) async { - print( - 'Building ${targets.length} targets for ${forCanvasKit ? 'CanvasKit' : 'HTML'}'); - final String canvasKitOutputRelativePath = - path.join('.dart_tool', 'canvaskit_tests'); - List arguments = [ - 'run', - 'build_runner', - 'build', - '--enable-experiment=non-nullable', - 'test', - '-o', - forCanvasKit ? canvasKitOutputRelativePath : 'build', - '--config', - // CanvasKit uses `build.canvaskit.yaml`, which HTML Uses `build.html.yaml`. - forCanvasKit ? 'canvaskit' : 'html', - for (FilePath path in targets) ...[ - '--build-filter=${path.relativeToWebUi}.js', - '--build-filter=${path.relativeToWebUi}.browser_test.dart.js', - ], - ]; - - final int exitCode = await runProcess( - environment.pubExecutable, - arguments, - workingDirectory: environment.webUiRootDir.path, - environment: { - // This determines the number of concurrent dart2js processes. - // - // By default build_runner uses 4 workers. - // - // In a testing on a 32-core 132GB workstation increasing this number to - // 32 sped up the build from ~4min to ~1.5min. - if (io.Platform.environment.containsKey('BUILD_MAX_WORKERS_PER_TASK')) - 'BUILD_MAX_WORKERS_PER_TASK': - io.Platform.environment['BUILD_MAX_WORKERS_PER_TASK'], - }, - ); + /// Uses `dart2js` for building the tests. + /// + /// When building for CanvasKit we have to use extra argument + /// `DFLUTTER_WEB_USE_SKIA=true`. + Future _buildTests( + {List targets, bool forCanvasKit = false}) async { + print('Building ${targets.length} targets for HTML'); + + for (FilePath file in targets) { + final targetFileName = file.relativeToWebUi + .replaceFirst('.dart', '.dart.browser_test.dart.js'); + final String targetPath = path.join('build', targetFileName); + print('target path: $targetPath current file: ${file.relativeToWebUi}'); + + final io.Directory directoryToTarget = io.Directory(path.join( + environment.webUiBuildDir.path, path.dirname(file.relativeToWebUi))); + + if (!directoryToTarget.existsSync()) { + directoryToTarget.createSync(recursive: true); + } - if (exitCode != 0) { - throw ToolException( - 'Failed to compile tests. Compiler exited with exit code $exitCode'); - } + List arguments = [ + '--no-minify', + '--disable-inlining', + '--enable-asserts', + '--enable-experiment=non-nullable', + '--no-sound-null-safety', + if (forCanvasKit) '-DFLUTTER_WEB_USE_SKIA=true', + '-O2', + '-o', + '${targetPath}', // target path + '${file.relativeToWebUi}', // current path + ]; + + final int exitCode = await runProcess( + environment.dart2jsExecutable, + arguments, + workingDirectory: environment.webUiRootDir.path, + // environment. + ); - if (forCanvasKit) { - final io.Directory canvasKitTemporaryOutputDirectory = io.Directory( - path.join(environment.webUiRootDir.path, canvasKitOutputRelativePath, - 'test', 'canvaskit')); - final io.Directory canvasKitOutputDirectory = io.Directory( - path.join(environment.webUiBuildDir.path, 'test', 'canvaskit')); - if (await canvasKitOutputDirectory.exists()) { - await canvasKitOutputDirectory.delete(recursive: true); + if (exitCode != 0) { + throw ToolException( + 'Failed to compile tests. Dart2js exited with exit code $exitCode'); } - await canvasKitTemporaryOutputDirectory - .rename(canvasKitOutputDirectory.path); } } From 4d3d80bcff5365da88cacff2f77de6362537514f Mon Sep 17 00:00:00 2001 From: nturgut Date: Sun, 9 Aug 2020 15:36:39 -0700 Subject: [PATCH 02/25] add internalBootstrapBrowserTest to some of the tests --- lib/web_ui/test/alarm_clock_test.dart | 5 +++++ lib/web_ui/test/canvaskit/canvaskit_api_test.dart | 5 +++++ lib/web_ui/test/canvaskit/path_metrics_test.dart | 5 +++++ lib/web_ui/test/canvaskit/skia_objects_cache_test.dart | 5 +++++ lib/web_ui/test/clipboard_test.dart | 7 ++++++- lib/web_ui/test/color_test.dart | 7 ++++++- lib/web_ui/test/dom_renderer_test.dart | 7 ++++++- lib/web_ui/test/engine/frame_reference_test.dart | 5 +++++ lib/web_ui/test/engine/history_test.dart | 5 +++++ lib/web_ui/test/engine/image/html_image_codec_test.dart | 7 ++++++- lib/web_ui/test/engine/navigation_test.dart | 5 +++++ lib/web_ui/test/engine/path_metrics_test.dart | 7 ++++++- lib/web_ui/test/engine/pointer_binding_test.dart | 8 ++++++-- lib/web_ui/test/engine/profiler_test.dart | 5 +++++ lib/web_ui/test/engine/recording_canvas_test.dart | 7 ++++++- lib/web_ui/test/engine/semantics/accessibility_test.dart | 7 ++++++- .../test/engine/semantics/semantics_helper_test.dart | 8 ++++++-- lib/web_ui/test/engine/semantics/semantics_test.dart | 5 +++++ lib/web_ui/test/engine/services/serialization_test.dart | 7 ++++++- lib/web_ui/test/engine/surface/scene_builder_test.dart | 9 ++++++++- lib/web_ui/test/engine/surface/surface_test.dart | 5 +++++ lib/web_ui/test/engine/ulps_test.dart | 5 +++++ lib/web_ui/test/engine/util_test.dart | 8 ++++++-- lib/web_ui/test/engine/web_experiments_test.dart | 5 +++++ lib/web_ui/test/engine/window_test.dart | 5 +++++ 25 files changed, 139 insertions(+), 15 deletions(-) diff --git a/lib/web_ui/test/alarm_clock_test.dart b/lib/web_ui/test/alarm_clock_test.dart index 3a90f955b4db5..b56d0dc27d798 100644 --- a/lib/web_ui/test/alarm_clock_test.dart +++ b/lib/web_ui/test/alarm_clock_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. // @dart = 2.6 +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:quiver/testing/async.dart'; import 'package:quiver/time.dart'; @@ -10,6 +11,10 @@ import 'package:quiver/time.dart'; import 'package:ui/src/engine.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group(AlarmClock, () { _alarmClockTests(); }); diff --git a/lib/web_ui/test/canvaskit/canvaskit_api_test.dart b/lib/web_ui/test/canvaskit/canvaskit_api_test.dart index 23da3c3d28f56..9847ca29a1dd0 100644 --- a/lib/web_ui/test/canvaskit/canvaskit_api_test.dart +++ b/lib/web_ui/test/canvaskit/canvaskit_api_test.dart @@ -5,6 +5,7 @@ // @dart = 2.6 import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; @@ -14,6 +15,10 @@ import 'common.dart'; import 'test_data.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('CanvasKit API', () { setUpAll(() async { await ui.webOnlyInitializePlatform(); diff --git a/lib/web_ui/test/canvaskit/path_metrics_test.dart b/lib/web_ui/test/canvaskit/path_metrics_test.dart index 62bde94a8678b..eece12c15b572 100644 --- a/lib/web_ui/test/canvaskit/path_metrics_test.dart +++ b/lib/web_ui/test/canvaskit/path_metrics_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. // @dart = 2.6 +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; @@ -11,6 +12,10 @@ import 'package:ui/ui.dart' as ui; import 'common.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('Path Metrics', () { setUpAll(() async { await ui.webOnlyInitializePlatform(); diff --git a/lib/web_ui/test/canvaskit/skia_objects_cache_test.dart b/lib/web_ui/test/canvaskit/skia_objects_cache_test.dart index 4b66374a9c114..08e0cb3d55837 100644 --- a/lib/web_ui/test/canvaskit/skia_objects_cache_test.dart +++ b/lib/web_ui/test/canvaskit/skia_objects_cache_test.dart @@ -5,6 +5,7 @@ // @dart = 2.6 import 'package:mockito/mockito.dart'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart' as ui; @@ -13,6 +14,10 @@ import 'package:ui/src/engine.dart'; import 'common.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('skia_objects_cache', () { _tests(); // TODO: https://github.com/flutter/flutter/issues/60040 diff --git a/lib/web_ui/test/clipboard_test.dart b/lib/web_ui/test/clipboard_test.dart index eb67e5beff575..e0c526176e831 100644 --- a/lib/web_ui/test/clipboard_test.dart +++ b/lib/web_ui/test/clipboard_test.dart @@ -7,11 +7,16 @@ import 'dart:async'; import 'dart:typed_data'; import 'package:mockito/mockito.dart'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart' as ui; import 'package:ui/src/engine.dart'; -Future main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { await ui.webOnlyInitializeTestDomRenderer(); group('message handler', () { const String testText = 'test text'; diff --git a/lib/web_ui/test/color_test.dart b/lib/web_ui/test/color_test.dart index 8d53b77f73659..d48ea0bef83cb 100644 --- a/lib/web_ui/test/color_test.dart +++ b/lib/web_ui/test/color_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'package:ui/ui.dart'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; +void main() { + internalBootstrapBrowserTest(() => testMain); +} + class NotAColor extends Color { const NotAColor(int value) : super(value); } -void main() { +void testMain() { test('color accessors should work', () { const Color foo = Color(0x12345678); expect(foo.alpha, equals(0x12)); diff --git a/lib/web_ui/test/dom_renderer_test.dart b/lib/web_ui/test/dom_renderer_test.dart index ca9d6804a47c8..514c54d4160bc 100644 --- a/lib/web_ui/test/dom_renderer_test.dart +++ b/lib/web_ui/test/dom_renderer_test.dart @@ -5,10 +5,15 @@ // @dart = 2.6 import 'dart:html' as html; -import 'package:ui/src/engine.dart'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; +import 'package:ui/src/engine.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { test('creating elements works', () { final DomRenderer renderer = DomRenderer(); final html.Element element = renderer.createElement('div'); diff --git a/lib/web_ui/test/engine/frame_reference_test.dart b/lib/web_ui/test/engine/frame_reference_test.dart index 6ccd91c57b207..0658f8258ba7c 100644 --- a/lib/web_ui/test/engine/frame_reference_test.dart +++ b/lib/web_ui/test/engine/frame_reference_test.dart @@ -4,9 +4,14 @@ // @dart = 2.6 import 'package:ui/src/engine.dart'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('CrossFrameCache', () { test('Reuse returns no object when cache empty', () { final CrossFrameCache cache = CrossFrameCache(); diff --git a/lib/web_ui/test/engine/history_test.dart b/lib/web_ui/test/engine/history_test.dart index 58d536aff4785..4d621117a633c 100644 --- a/lib/web_ui/test/engine/history_test.dart +++ b/lib/web_ui/test/engine/history_test.dart @@ -10,6 +10,7 @@ import 'dart:async'; import 'dart:html' as html; import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; @@ -29,6 +30,10 @@ const MethodCodec codec = JSONMethodCodec(); void emptyCallback(ByteData date) {} void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('$BrowserHistory', () { final PlatformMessagesSpy spy = PlatformMessagesSpy(); diff --git a/lib/web_ui/test/engine/image/html_image_codec_test.dart b/lib/web_ui/test/engine/image/html_image_codec_test.dart index 853e102f82e23..d29df24ff44f7 100644 --- a/lib/web_ui/test/engine/image/html_image_codec_test.dart +++ b/lib/web_ui/test/engine/image/html_image_codec_test.dart @@ -3,11 +3,16 @@ // found in the LICENSE file. // @dart = 2.6 +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart' as ui; import 'package:ui/src/engine.dart'; -Future main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { await ui.webOnlyInitializeTestDomRenderer(); group('HtmCodec', () { test('loads sample image', () async { diff --git a/lib/web_ui/test/engine/navigation_test.dart b/lib/web_ui/test/engine/navigation_test.dart index 8266fd7ec9904..d4ac941d3de59 100644 --- a/lib/web_ui/test/engine/navigation_test.dart +++ b/lib/web_ui/test/engine/navigation_test.dart @@ -5,6 +5,7 @@ // @dart = 2.6 import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart' as engine; @@ -15,6 +16,10 @@ const engine.MethodCodec codec = engine.JSONMethodCodec(); void emptyCallback(ByteData date) {} void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { setUp(() { engine.window.locationStrategy = _strategy = engine.TestLocationStrategy(); }); diff --git a/lib/web_ui/test/engine/path_metrics_test.dart b/lib/web_ui/test/engine/path_metrics_test.dart index f4181f3917a49..a8938f913d99f 100644 --- a/lib/web_ui/test/engine/path_metrics_test.dart +++ b/lib/web_ui/test/engine/path_metrics_test.dart @@ -4,14 +4,19 @@ import 'dart:math' as math; -import 'package:ui/ui.dart'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; +import 'package:ui/ui.dart'; import '../matchers.dart'; const double kTolerance = 0.001; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('PathMetric length', () { test('empty path', () { Path path = Path(); diff --git a/lib/web_ui/test/engine/pointer_binding_test.dart b/lib/web_ui/test/engine/pointer_binding_test.dart index 5f6ac793c38ff..091cde33fc52f 100644 --- a/lib/web_ui/test/engine/pointer_binding_test.dart +++ b/lib/web_ui/test/engine/pointer_binding_test.dart @@ -6,11 +6,11 @@ import 'dart:html' as html; import 'dart:js_util' as js_util; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; -import 'package:test/test.dart'; - const int _kNoButtonChange = -1; const PointerSupportDetector _defaultSupportDetector = PointerSupportDetector(); @@ -40,6 +40,10 @@ bool get isIosSafari => (browserEngine == BrowserEngine.webkit && operatingSystem == OperatingSystem.iOs); void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { html.Element glassPane = domRenderer.glassPaneElement; setUp(() { diff --git a/lib/web_ui/test/engine/profiler_test.dart b/lib/web_ui/test/engine/profiler_test.dart index 0314ee9c8ef6a..49f11242c860d 100644 --- a/lib/web_ui/test/engine/profiler_test.dart +++ b/lib/web_ui/test/engine/profiler_test.dart @@ -6,11 +6,16 @@ import 'dart:html' as html; import 'dart:js_util' as js_util; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { setUp(() { Profiler.isBenchmarkMode = true; Profiler.ensureInitialized(); diff --git a/lib/web_ui/test/engine/recording_canvas_test.dart b/lib/web_ui/test/engine/recording_canvas_test.dart index d997f811b862c..7bd1a9810eef4 100644 --- a/lib/web_ui/test/engine/recording_canvas_test.dart +++ b/lib/web_ui/test/engine/recording_canvas_test.dart @@ -3,13 +3,18 @@ // found in the LICENSE file. // @dart = 2.6 +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart'; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import '../mock_engine_canvas.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { RecordingCanvas underTest; MockEngineCanvas mockCanvas; final Rect screenRect = Rect.largest; diff --git a/lib/web_ui/test/engine/semantics/accessibility_test.dart b/lib/web_ui/test/engine/semantics/accessibility_test.dart index 767d4742ad0ea..6eb3366668752 100644 --- a/lib/web_ui/test/engine/semantics/accessibility_test.dart +++ b/lib/web_ui/test/engine/semantics/accessibility_test.dart @@ -6,8 +6,9 @@ import 'dart:async' show Future; import 'dart:html'; -import 'package:ui/src/engine.dart'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; +import 'package:ui/src/engine.dart'; const MessageCodec codec = StandardMessageCodec(); const String testMessage = 'This is an tooltip.'; @@ -16,6 +17,10 @@ const Map testInput = { }; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { AccessibilityAnnouncements accessibilityAnnouncements; group('$AccessibilityAnnouncements', () { diff --git a/lib/web_ui/test/engine/semantics/semantics_helper_test.dart b/lib/web_ui/test/engine/semantics/semantics_helper_test.dart index cd3e0e9e561d9..56fb691d117a1 100644 --- a/lib/web_ui/test/engine/semantics/semantics_helper_test.dart +++ b/lib/web_ui/test/engine/semantics/semantics_helper_test.dart @@ -5,11 +5,15 @@ // @dart = 2.6 import 'dart:html' as html; -import 'package:ui/src/engine.dart'; - +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; +import 'package:ui/src/engine.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('$DesktopSemanticsEnabler', () { DesktopSemanticsEnabler desktopSemanticsEnabler; html.Element _placeholder; diff --git a/lib/web_ui/test/engine/semantics/semantics_test.dart b/lib/web_ui/test/engine/semantics/semantics_test.dart index 016c94f0c5f7c..d3b0e52eb0180 100644 --- a/lib/web_ui/test/engine/semantics/semantics_test.dart +++ b/lib/web_ui/test/engine/semantics/semantics_test.dart @@ -12,6 +12,7 @@ import 'dart:typed_data'; import 'package:mockito/mockito.dart'; import 'package:quiver/testing/async.dart'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; @@ -24,6 +25,10 @@ DateTime _testTime = DateTime(2018, 12, 17); EngineSemanticsOwner semantics() => EngineSemanticsOwner.instance; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { setUp(() { EngineSemanticsOwner.debugResetSemantics(); }); diff --git a/lib/web_ui/test/engine/services/serialization_test.dart b/lib/web_ui/test/engine/services/serialization_test.dart index f0f0b58fd4900..e7eb72b7f73c9 100644 --- a/lib/web_ui/test/engine/services/serialization_test.dart +++ b/lib/web_ui/test/engine/services/serialization_test.dart @@ -5,11 +5,16 @@ // @dart = 2.6 import 'dart:typed_data'; +import 'package:test/test.dart'; +import 'package:test/bootstrap/browser.dart'; import 'package:ui/ui.dart'; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('Write and read buffer round-trip', () { test('of single byte', () { final WriteBuffer write = WriteBuffer(); diff --git a/lib/web_ui/test/engine/surface/scene_builder_test.dart b/lib/web_ui/test/engine/surface/scene_builder_test.dart index f01864fde9f0a..e57a41a99cc97 100644 --- a/lib/web_ui/test/engine/surface/scene_builder_test.dart +++ b/lib/web_ui/test/engine/surface/scene_builder_test.dart @@ -8,14 +8,21 @@ import 'dart:async'; import 'dart:html' as html; import 'dart:js_util' as js_util; + +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' hide window; -import 'package:test/test.dart'; + import '../../matchers.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { setUpAll(() async { await webOnlyInitializeEngine(); }); diff --git a/lib/web_ui/test/engine/surface/surface_test.dart b/lib/web_ui/test/engine/surface/surface_test.dart index 9da82f026821e..d7dbe9c827afd 100644 --- a/lib/web_ui/test/engine/surface/surface_test.dart +++ b/lib/web_ui/test/engine/surface/surface_test.dart @@ -8,9 +8,14 @@ import 'dart:html' as html; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('Surface', () { setUp(() { SurfaceSceneBuilder.debugForgetFrameScene(); diff --git a/lib/web_ui/test/engine/ulps_test.dart b/lib/web_ui/test/engine/ulps_test.dart index 9d993e92eb262..d0a26c45faad7 100644 --- a/lib/web_ui/test/engine/ulps_test.dart +++ b/lib/web_ui/test/engine/ulps_test.dart @@ -3,10 +3,15 @@ // found in the LICENSE file. import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('Float Int conversions', (){ test('Should convert signbit to 2\'s compliment', () { expect(signBitTo2sCompliment(0), 0); diff --git a/lib/web_ui/test/engine/util_test.dart b/lib/web_ui/test/engine/util_test.dart index 51d58c2b11810..9ff47eb2b3e14 100644 --- a/lib/web_ui/test/engine/util_test.dart +++ b/lib/web_ui/test/engine/util_test.dart @@ -5,9 +5,9 @@ // @dart = 2.6 import 'dart:typed_data'; -import 'package:ui/src/engine.dart'; - +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; +import 'package:ui/src/engine.dart'; final Float32List identityTransform = Matrix4.identity().storage; final Float32List xTranslation = (Matrix4.identity()..translate(10)).storage; @@ -17,6 +17,10 @@ final Float32List scaleAndTranslate2d = (Matrix4.identity()..scale(2, 3, 1)..tra final Float32List rotation2d = (Matrix4.identity()..rotateZ(0.2)).storage; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { test('transformKindOf and isIdentityFloat32ListTransform identify matrix kind', () { expect(transformKindOf(identityTransform), TransformKind.identity); expect(isIdentityFloat32ListTransform(identityTransform), isTrue); diff --git a/lib/web_ui/test/engine/web_experiments_test.dart b/lib/web_ui/test/engine/web_experiments_test.dart index 7f06f9639641b..c0f0a4f7f05f2 100644 --- a/lib/web_ui/test/engine/web_experiments_test.dart +++ b/lib/web_ui/test/engine/web_experiments_test.dart @@ -6,12 +6,17 @@ import 'dart:html' as html; import 'dart:js_util' as js_util; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; const bool _defaultUseCanvasText = true; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { setUp(() { WebExperiments.ensureInitialized(); }); diff --git a/lib/web_ui/test/engine/window_test.dart b/lib/web_ui/test/engine/window_test.dart index d73fcfdf94e94..ae97dceb8678b 100644 --- a/lib/web_ui/test/engine/window_test.dart +++ b/lib/web_ui/test/engine/window_test.dart @@ -7,11 +7,16 @@ import 'dart:async'; import 'dart:html' as html; import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart' as ui; import 'package:ui/src/engine.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { test('onTextScaleFactorChanged preserves the zone', () { final Zone innerZone = Zone.current.fork(); From 96630cb9ebc64f14de27835e6f14c7b5799c744d Mon Sep 17 00:00:00 2001 From: nturgut Date: Sun, 9 Aug 2020 16:02:37 -0700 Subject: [PATCH 03/25] add internalBootstrapBrowserTest to all remaining tests --- lib/web_ui/test/canvas_test.dart | 5 +++++ .../test/engine/surface/path/path_winding_test.dart | 7 ++++++- lib/web_ui/test/geometry_test.dart | 9 +++++++-- .../engine/backdrop_filter_golden_test.dart | 9 +++++++-- .../golden_tests/engine/canvas_arc_golden_test.dart | 11 ++++++++--- .../golden_tests/engine/canvas_blend_golden_test.dart | 8 ++++++-- .../golden_tests/engine/canvas_clip_path_test.dart | 9 +++++++-- .../test/golden_tests/engine/canvas_context_test.dart | 9 +++++++-- .../engine/canvas_draw_image_golden_test.dart | 9 +++++++-- .../golden_tests/engine/canvas_draw_picture_test.dart | 9 +++++++-- .../golden_tests/engine/canvas_draw_points_test.dart | 10 +++++++--- .../test/golden_tests/engine/canvas_golden_test.dart | 9 +++++++-- .../engine/canvas_image_blend_mode_test.dart | 9 +++++++-- .../golden_tests/engine/canvas_lines_golden_test.dart | 9 +++++++-- .../golden_tests/engine/canvas_mask_filter_test.dart | 9 +++++++-- .../golden_tests/engine/canvas_rect_golden_test.dart | 9 +++++++-- .../test/golden_tests/engine/canvas_reuse_test.dart | 9 +++++++-- .../golden_tests/engine/canvas_rrect_golden_test.dart | 9 +++++++-- .../engine/canvas_stroke_joins_golden_test.dart | 11 ++++++++--- .../engine/canvas_stroke_rects_golden_test.dart | 11 ++++++++--- .../golden_tests/engine/canvas_winding_rule_test.dart | 9 +++++++-- .../golden_tests/engine/compositing_golden_test.dart | 9 +++++++-- .../test/golden_tests/engine/conic_golden_test.dart | 9 +++++++-- .../engine/draw_vertices_golden_test.dart | 9 +++++++-- .../engine/linear_gradient_golden_test.dart | 3 ++- .../engine/multiline_text_clipping_golden_test.dart | 1 + .../test/golden_tests/engine/path_metrics_test.dart | 9 +++++++-- .../golden_tests/engine/path_to_svg_golden_test.dart | 9 +++++++-- .../test/golden_tests/engine/path_transform_test.dart | 9 +++++++-- .../test/golden_tests/engine/picture_golden_test.dart | 7 ++++++- .../engine/radial_gradient_golden_test.dart | 9 +++++++-- .../engine/recording_canvas_golden_test.dart | 9 +++++++-- .../test/golden_tests/engine/shadow_golden_test.dart | 9 +++++++-- .../engine/text_overflow_golden_test.dart | 7 ++++++- .../golden_tests/engine/text_style_golden_test.dart | 7 ++++++- .../test/golden_tests/golden_failure_smoke_test.dart | 5 +++++ .../test/golden_tests/golden_success_smoke_test.dart | 7 ++++++- lib/web_ui/test/gradient_test.dart | 9 +++++++-- lib/web_ui/test/hash_codes_test.dart | 5 +++++ lib/web_ui/test/keyboard_test.dart | 8 ++++++-- lib/web_ui/test/locale_test.dart | 8 ++++++-- lib/web_ui/test/paragraph_builder_test.dart | 8 ++++++-- lib/web_ui/test/paragraph_test.dart | 9 +++++++-- lib/web_ui/test/path_test.dart | 5 +++++ lib/web_ui/test/rect_test.dart | 8 ++++++-- lib/web_ui/test/rrect_test.dart | 8 ++++++-- lib/web_ui/test/text/font_collection_test.dart | 9 +++++++-- lib/web_ui/test/text/font_loading_test.dart | 7 ++++++- lib/web_ui/test/text/line_breaker_test.dart | 5 +++++ lib/web_ui/test/text/measurement_test.dart | 9 +++++++-- lib/web_ui/test/text/word_breaker_test.dart | 5 +++++ lib/web_ui/test/text_editing_test.dart | 9 +++++++-- lib/web_ui/test/text_test.dart | 7 ++++++- lib/web_ui/test/title_test.dart | 7 ++++++- lib/web_ui/test/window_test.dart | 5 +++++ 55 files changed, 349 insertions(+), 89 deletions(-) diff --git a/lib/web_ui/test/canvas_test.dart b/lib/web_ui/test/canvas_test.dart index 609f848695218..53635e0e3ccee 100644 --- a/lib/web_ui/test/canvas_test.dart +++ b/lib/web_ui/test/canvas_test.dart @@ -6,11 +6,16 @@ import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'mock_engine_canvas.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { setUpAll(() { WebExperiments.ensureInitialized(); }); diff --git a/lib/web_ui/test/engine/surface/path/path_winding_test.dart b/lib/web_ui/test/engine/surface/path/path_winding_test.dart index 905fc6c8f153f..32133e648285b 100644 --- a/lib/web_ui/test/engine/surface/path/path_winding_test.dart +++ b/lib/web_ui/test/engine/surface/path/path_winding_test.dart @@ -5,12 +5,17 @@ // @dart = 2.10 import 'dart:math' as math; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart' hide window; import 'package:ui/src/engine.dart'; -/// Test winding and convexity of a path. void main() { + internalBootstrapBrowserTest(() => testMain); +} + +/// Test winding and convexity of a path. +void testMain() { group('Convexity', () { test('Empty path should be convex', () { final SurfacePath path = SurfacePath(); diff --git a/lib/web_ui/test/geometry_test.dart b/lib/web_ui/test/geometry_test.dart index ba2272a3a387c..07ad7601d8d5d 100644 --- a/lib/web_ui/test/geometry_test.dart +++ b/lib/web_ui/test/geometry_test.dart @@ -6,11 +6,16 @@ import 'dart:math' as math show sqrt; import 'dart:math' show pi; -import 'package:ui/ui.dart'; - +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; +import 'package:ui/ui.dart'; + void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { test('Offset.direction', () { expect(const Offset(0.0, 0.0).direction, 0.0); expect(const Offset(0.0, 1.0).direction, pi / 2.0); diff --git a/lib/web_ui/test/golden_tests/engine/backdrop_filter_golden_test.dart b/lib/web_ui/test/golden_tests/engine/backdrop_filter_golden_test.dart index 5b0cc417e1397..797b1cf6b34d1 100644 --- a/lib/web_ui/test/golden_tests/engine/backdrop_filter_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/backdrop_filter_golden_test.dart @@ -5,15 +5,20 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart'; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; final Rect region = Rect.fromLTWH(0, 0, 500, 500); -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { setUp(() async { debugShowClipLayers = true; SurfaceSceneBuilder.debugForgetFrameScene(); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_arc_golden_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_arc_golden_test.dart index 88e85ab9c95da..888a3f4f1e27a 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_arc_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_arc_golden_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'dart:html' as html; import 'dart:math' as math; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final Rect region = Rect.fromLTWH(0, 0, 400, 600); BitmapCanvas canvas; @@ -107,4 +112,4 @@ void paintArc(BitmapCanvas canvas, Offset offset, ..strokeWidth = 2 ..color = Color(0x61000000) // black38 ..style = PaintingStyle.stroke); -} \ No newline at end of file +} diff --git a/lib/web_ui/test/golden_tests/engine/canvas_blend_golden_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_blend_golden_test.dart index 8407e48766b33..39cfcb4b27feb 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_blend_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_blend_golden_test.dart @@ -6,13 +6,17 @@ import 'dart:html' as html; import 'dart:js_util' as js_util; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; +void main() { + internalBootstrapBrowserTest(() => testMain); +} -void main() async { +void testMain() async { const double screenWidth = 600.0; const double screenHeight = 800.0; const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_clip_path_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_clip_path_test.dart index d01620921c1d7..1436e934a59fa 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_clip_path_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_clip_path_test.dart @@ -6,13 +6,18 @@ import 'dart:html' as html; import 'dart:js_util' as js_util; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart' as engine; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { const double screenWidth = 600.0; const double screenHeight = 800.0; const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_context_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_context_test.dart index 927bf2a300fbd..226b8c8a61095 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_context_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_context_test.dart @@ -5,14 +5,19 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart' as engine; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; +void main() { + internalBootstrapBrowserTest(() => testMain); +} + /// Tests context save/restore. -void main() async { +void testMain() async { const double screenWidth = 600.0; const double screenHeight = 800.0; const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_draw_image_golden_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_draw_image_golden_test.dart index 8a08c22a21aef..16efb34e3fe78 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_draw_image_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_draw_image_golden_test.dart @@ -7,15 +7,20 @@ import 'dart:html' as html; import 'dart:math' as math; import 'dart:js_util' as js_util; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart'; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; import 'scuba.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { const double screenWidth = 600.0; const double screenHeight = 800.0; const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_draw_picture_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_draw_picture_test.dart index de4c52cebb1d2..b70666711f5ba 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_draw_picture_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_draw_picture_test.dart @@ -5,15 +5,20 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart'; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; final Rect region = Rect.fromLTWH(0, 0, 500, 100); -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { setUp(() async { debugShowClipLayers = true; SurfaceSceneBuilder.debugForgetFrameScene(); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_draw_points_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_draw_points_test.dart index 8688140b290f2..c3e6adaa0469c 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_draw_points_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_draw_points_test.dart @@ -6,14 +6,18 @@ import 'dart:html' as html; import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; - import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final Rect region = Rect.fromLTWH(0, 0, 400, 600); BitmapCanvas canvas; diff --git a/lib/web_ui/test/golden_tests/engine/canvas_golden_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_golden_test.dart index ce55498eba86a..a072d025974fd 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_golden_test.dart @@ -6,15 +6,20 @@ import 'dart:html' as html; import 'dart:math' as math; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; import 'scuba.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final Rect region = Rect.fromLTWH(0, 0, 500, 100); BitmapCanvas canvas; diff --git a/lib/web_ui/test/golden_tests/engine/canvas_image_blend_mode_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_image_blend_mode_test.dart index ca30387f99319..962d930d8884f 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_image_blend_mode_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_image_blend_mode_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { const double screenWidth = 600.0; const double screenHeight = 800.0; const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_lines_golden_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_lines_golden_test.dart index 215d51da5c29e..8447c26806d47 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_lines_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_lines_golden_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final Rect region = Rect.fromLTWH(0, 0, 300, 300); BitmapCanvas canvas; diff --git a/lib/web_ui/test/golden_tests/engine/canvas_mask_filter_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_mask_filter_test.dart index a808a57a28598..1f3184c67a097 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_mask_filter_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_mask_filter_test.dart @@ -7,13 +7,18 @@ import 'dart:html' as html; import 'dart:math' as math; import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart' as ui; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { // Commit a recording canvas to a bitmap, and compare with the expected Future _checkScreenshot(RecordingCanvas rc, String fileName, ui.Rect screenRect, {bool write = false}) async { final EngineCanvas engineCanvas = BitmapCanvas(screenRect); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_rect_golden_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_rect_golden_test.dart index ea77b27ccd802..07d19e51dc902 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_rect_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_rect_golden_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final Rect region = Rect.fromLTWH(0, 0, 150, 420); BitmapCanvas canvas; diff --git a/lib/web_ui/test/golden_tests/engine/canvas_reuse_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_reuse_test.dart index 469cc2f88faf8..2bd62f258fa20 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_reuse_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_reuse_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { const double screenWidth = 600.0; const double screenHeight = 800.0; const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight); diff --git a/lib/web_ui/test/golden_tests/engine/canvas_rrect_golden_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_rrect_golden_test.dart index 95d977993704c..1506419d20e74 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_rrect_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_rrect_golden_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final Rect region = Rect.fromLTWH(8, 8, 500, 100); // Compensate for old scuba tester padding BitmapCanvas canvas; diff --git a/lib/web_ui/test/golden_tests/engine/canvas_stroke_joins_golden_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_stroke_joins_golden_test.dart index 0a85cc25f96aa..8ae75205bfb47 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_stroke_joins_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_stroke_joins_golden_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final Rect region = Rect.fromLTWH(0, 0, 300, 300); BitmapCanvas canvas; @@ -68,4 +73,4 @@ void paintStrokeJoins(BitmapCanvas canvas) { end = end.translate(0, 20); } } -} \ No newline at end of file +} diff --git a/lib/web_ui/test/golden_tests/engine/canvas_stroke_rects_golden_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_stroke_rects_golden_test.dart index 447f9706030ec..4a81d2fe52665 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_stroke_rects_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_stroke_rects_golden_test.dart @@ -6,13 +6,18 @@ import 'dart:html' as html; import 'dart:math' as math; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final Rect region = Rect.fromLTWH(0, 0, 300, 300); BitmapCanvas canvas; @@ -63,4 +68,4 @@ void paintSideBySideRects(BitmapCanvas canvas) { ..style = PaintingStyle.stroke ..strokeWidth = 4 ..color = Color(0x7fffff00)); -} \ No newline at end of file +} diff --git a/lib/web_ui/test/golden_tests/engine/canvas_winding_rule_test.dart b/lib/web_ui/test/golden_tests/engine/canvas_winding_rule_test.dart index 556705953bc23..e48001071a301 100644 --- a/lib/web_ui/test/golden_tests/engine/canvas_winding_rule_test.dart +++ b/lib/web_ui/test/golden_tests/engine/canvas_winding_rule_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final Rect region = Rect.fromLTWH(0, 0, 500, 500); BitmapCanvas canvas; diff --git a/lib/web_ui/test/golden_tests/engine/compositing_golden_test.dart b/lib/web_ui/test/golden_tests/engine/compositing_golden_test.dart index 5a8616f02a803..04dce71d0b986 100644 --- a/lib/web_ui/test/golden_tests/engine/compositing_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/compositing_golden_test.dart @@ -6,16 +6,21 @@ import 'dart:html' as html; import 'dart:math' as math; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart'; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import '../../matchers.dart'; import 'package:web_engine_tester/golden_tester.dart'; final Rect region = Rect.fromLTWH(0, 0, 500, 100); -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { setUp(() async { debugShowClipLayers = true; SurfaceSceneBuilder.debugForgetFrameScene(); diff --git a/lib/web_ui/test/golden_tests/engine/conic_golden_test.dart b/lib/web_ui/test/golden_tests/engine/conic_golden_test.dart index bcf69c155e212..9362cccebd3b9 100644 --- a/lib/web_ui/test/golden_tests/engine/conic_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/conic_golden_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final Rect region = Rect.fromLTWH(8, 8, 600, 800); // Compensate for old scuba tester padding Future testPath(Path path, String scubaFileName) async { diff --git a/lib/web_ui/test/golden_tests/engine/draw_vertices_golden_test.dart b/lib/web_ui/test/golden_tests/engine/draw_vertices_golden_test.dart index 765c614ae4cfc..68a2136343791 100644 --- a/lib/web_ui/test/golden_tests/engine/draw_vertices_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/draw_vertices_golden_test.dart @@ -6,13 +6,18 @@ import 'dart:html' as html; import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { const double screenWidth = 600.0; const double screenHeight = 800.0; const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight); diff --git a/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart b/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart index cbeadad84a958..3f1141b17325e 100644 --- a/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart @@ -6,9 +6,10 @@ import 'dart:html' as html; import 'dart:math' as math; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; diff --git a/lib/web_ui/test/golden_tests/engine/multiline_text_clipping_golden_test.dart b/lib/web_ui/test/golden_tests/engine/multiline_text_clipping_golden_test.dart index cd3378b569896..d7a9fd131403d 100644 --- a/lib/web_ui/test/golden_tests/engine/multiline_text_clipping_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/multiline_text_clipping_golden_test.dart @@ -5,6 +5,7 @@ // @dart = 2.6 import 'dart:math' as math; +import 'package:test/bootstrap/browser.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; diff --git a/lib/web_ui/test/golden_tests/engine/path_metrics_test.dart b/lib/web_ui/test/golden_tests/engine/path_metrics_test.dart index 8695296ab9dbd..380036ba18dde 100644 --- a/lib/web_ui/test/golden_tests/engine/path_metrics_test.dart +++ b/lib/web_ui/test/golden_tests/engine/path_metrics_test.dart @@ -5,14 +5,19 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import '../../matchers.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { const double screenWidth = 600.0; const double screenHeight = 800.0; const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight); diff --git a/lib/web_ui/test/golden_tests/engine/path_to_svg_golden_test.dart b/lib/web_ui/test/golden_tests/engine/path_to_svg_golden_test.dart index f657f36a5ae02..03d9f0c1ad2e7 100644 --- a/lib/web_ui/test/golden_tests/engine/path_to_svg_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/path_to_svg_golden_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final Rect region = Rect.fromLTWH(8, 8, 600, 800); // Compensate for old scuba tester padding Future testPath(Path path, String scubaFileName, {Paint paint, double maxDiffRatePercent = null}) async { diff --git a/lib/web_ui/test/golden_tests/engine/path_transform_test.dart b/lib/web_ui/test/golden_tests/engine/path_transform_test.dart index 789f0259eeee6..0f968ba72b056 100644 --- a/lib/web_ui/test/golden_tests/engine/path_transform_test.dart +++ b/lib/web_ui/test/golden_tests/engine/path_transform_test.dart @@ -6,13 +6,18 @@ import 'dart:html' as html; import 'dart:math' as math; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { const double screenWidth = 600.0; const double screenHeight = 800.0; const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight); diff --git a/lib/web_ui/test/golden_tests/engine/picture_golden_test.dart b/lib/web_ui/test/golden_tests/engine/picture_golden_test.dart index af959cd4fe6c8..1c61fff196a09 100644 --- a/lib/web_ui/test/golden_tests/engine/picture_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/picture_golden_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('Picture', () { test('toImage produces an image', () async { final EnginePictureRecorder recorder = ui.PictureRecorder(); diff --git a/lib/web_ui/test/golden_tests/engine/radial_gradient_golden_test.dart b/lib/web_ui/test/golden_tests/engine/radial_gradient_golden_test.dart index 4fb58ebc3df94..098233fe1cfb3 100644 --- a/lib/web_ui/test/golden_tests/engine/radial_gradient_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/radial_gradient_golden_test.dart @@ -5,13 +5,18 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { const double screenWidth = 600.0; const double screenHeight = 800.0; const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight); diff --git a/lib/web_ui/test/golden_tests/engine/recording_canvas_golden_test.dart b/lib/web_ui/test/golden_tests/engine/recording_canvas_golden_test.dart index 618c7e9ac973e..4d69f8955ad6a 100644 --- a/lib/web_ui/test/golden_tests/engine/recording_canvas_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/recording_canvas_golden_test.dart @@ -7,14 +7,19 @@ import 'dart:html' as html; import 'dart:math' as math; import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; import '../../matchers.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { const double screenWidth = 600.0; const double screenHeight = 800.0; const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight); diff --git a/lib/web_ui/test/golden_tests/engine/shadow_golden_test.dart b/lib/web_ui/test/golden_tests/engine/shadow_golden_test.dart index c6f98e4e5d91b..307cdb583caad 100644 --- a/lib/web_ui/test/golden_tests/engine/shadow_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/shadow_golden_test.dart @@ -5,9 +5,10 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; import 'package:web_engine_tester/golden_tester.dart'; @@ -15,7 +16,11 @@ import 'scuba.dart'; const Color _kShadowColor = Color.fromARGB(255, 0, 0, 0); -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final Rect region = Rect.fromLTWH(0, 0, 550, 300); SurfaceSceneBuilder builder; diff --git a/lib/web_ui/test/golden_tests/engine/text_overflow_golden_test.dart b/lib/web_ui/test/golden_tests/engine/text_overflow_golden_test.dart index 507be4fd33df9..dc243b2ab711d 100644 --- a/lib/web_ui/test/golden_tests/engine/text_overflow_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/text_overflow_golden_test.dart @@ -5,6 +5,7 @@ // @dart = 2.6 import 'dart:async'; +import 'package:test/bootstrap/browser.dart'; import 'package:ui/ui.dart' hide window; import 'package:ui/src/engine.dart'; @@ -21,7 +22,11 @@ const String veryLong = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'; const String longUnbreakable = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final EngineScubaTester scuba = await EngineScubaTester.initialize( viewportSize: const Size(800, 800), ); diff --git a/lib/web_ui/test/golden_tests/engine/text_style_golden_test.dart b/lib/web_ui/test/golden_tests/engine/text_style_golden_test.dart index 9727dd596c38f..5f31ca6ada828 100644 --- a/lib/web_ui/test/golden_tests/engine/text_style_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/text_style_golden_test.dart @@ -3,12 +3,17 @@ // found in the LICENSE file. // @dart = 2.6 +import 'package:test/bootstrap/browser.dart'; import 'package:ui/ui.dart'; import 'package:ui/src/engine.dart'; import 'scuba.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final EngineScubaTester scuba = await EngineScubaTester.initialize( viewportSize: const Size(800, 800), ); diff --git a/lib/web_ui/test/golden_tests/golden_failure_smoke_test.dart b/lib/web_ui/test/golden_tests/golden_failure_smoke_test.dart index 882bdb60e3f75..7a0cfc7c621e0 100644 --- a/lib/web_ui/test/golden_tests/golden_failure_smoke_test.dart +++ b/lib/web_ui/test/golden_tests/golden_failure_smoke_test.dart @@ -5,11 +5,16 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart'; import 'package:web_engine_tester/golden_tester.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { test('screenshot test reports failure', () async { html.document.body.innerHtml = 'Text that does not appear on the screenshot!'; await matchGoldenFile('__local__/smoke_test.png', region: Rect.fromLTWH(0, 0, 320, 200)); diff --git a/lib/web_ui/test/golden_tests/golden_success_smoke_test.dart b/lib/web_ui/test/golden_tests/golden_success_smoke_test.dart index 97d505511a709..563e3e92c7269 100644 --- a/lib/web_ui/test/golden_tests/golden_success_smoke_test.dart +++ b/lib/web_ui/test/golden_tests/golden_success_smoke_test.dart @@ -5,12 +5,17 @@ // @dart = 2.6 import 'dart:html' as html; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart'; import 'package:ui/src/engine.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { debugEmulateFlutterTesterEnvironment = true; await webOnlyInitializePlatform(assetManager: WebOnlyMockAssetManager()); diff --git a/lib/web_ui/test/gradient_test.dart b/lib/web_ui/test/gradient_test.dart index a0df9ebdde051..b4335dd353228 100644 --- a/lib/web_ui/test/gradient_test.dart +++ b/lib/web_ui/test/gradient_test.dart @@ -3,11 +3,16 @@ // found in the LICENSE file. // @dart = 2.6 -import 'package:ui/ui.dart'; - +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; +import 'package:ui/ui.dart'; + void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { test('Gradient.radial with no focal point', () { expect( Gradient.radial( diff --git a/lib/web_ui/test/hash_codes_test.dart b/lib/web_ui/test/hash_codes_test.dart index 7349dc7398edc..cca96671b711a 100644 --- a/lib/web_ui/test/hash_codes_test.dart +++ b/lib/web_ui/test/hash_codes_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. // @dart = 2.6 +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart'; @@ -13,6 +14,10 @@ import 'package:ui/ui.dart'; const int _kBiggestExactJavaScriptInt = 9007199254740992; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { test('hashValues can hash lots of huge values effectively', () { expect( hashValues( diff --git a/lib/web_ui/test/keyboard_test.dart b/lib/web_ui/test/keyboard_test.dart index 3a819d6ffbf90..4b68cec6e2e13 100644 --- a/lib/web_ui/test/keyboard_test.dart +++ b/lib/web_ui/test/keyboard_test.dart @@ -8,12 +8,16 @@ import 'dart:js_util' as js_util; import 'dart:typed_data'; import 'package:quiver/testing/async.dart'; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; -import 'package:test/test.dart'; - void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('Keyboard', () { /// Used to save and restore [ui.window.onPlatformMessage] after each test. ui.PlatformMessageCallback savedCallback; diff --git a/lib/web_ui/test/locale_test.dart b/lib/web_ui/test/locale_test.dart index eb9331b465e59..316a42ae1101f 100644 --- a/lib/web_ui/test/locale_test.dart +++ b/lib/web_ui/test/locale_test.dart @@ -3,11 +3,15 @@ // found in the LICENSE file. // @dart = 2.6 -import 'package:ui/ui.dart'; - +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; +import 'package:ui/ui.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { test('Locale', () { const Null $null = null; expect(const Locale('en').toString(), 'en'); diff --git a/lib/web_ui/test/paragraph_builder_test.dart b/lib/web_ui/test/paragraph_builder_test.dart index 54a3bcf53b046..fe3041bc1539f 100644 --- a/lib/web_ui/test/paragraph_builder_test.dart +++ b/lib/web_ui/test/paragraph_builder_test.dart @@ -3,12 +3,16 @@ // found in the LICENSE file. // @dart = 2.6 +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; -import 'package:test/test.dart'; - void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { setUpAll(() { WebExperiments.ensureInitialized(); }); diff --git a/lib/web_ui/test/paragraph_test.dart b/lib/web_ui/test/paragraph_test.dart index 7082a8fd0254e..df3f45edf2e6f 100644 --- a/lib/web_ui/test/paragraph_test.dart +++ b/lib/web_ui/test/paragraph_test.dart @@ -3,10 +3,11 @@ // found in the LICENSE file. // @dart = 2.6 +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' hide window; -import 'package:test/test.dart'; void testEachMeasurement(String description, VoidCallback body, {bool skip}) { test('$description (dom measurement)', () async { @@ -31,7 +32,11 @@ void testEachMeasurement(String description, VoidCallback body, {bool skip}) { }, skip: skip); } -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { await webOnlyInitializeTestDomRenderer(); // Ahem font uses a constant ideographic/alphabetic baseline ratio. diff --git a/lib/web_ui/test/path_test.dart b/lib/web_ui/test/path_test.dart index 04461410cae5d..6f19c9cc8f439 100644 --- a/lib/web_ui/test/path_test.dart +++ b/lib/web_ui/test/path_test.dart @@ -7,6 +7,7 @@ import 'dart:js_util' as js_util; import 'dart:html' as html; import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart' hide window; import 'package:ui/src/engine.dart'; @@ -14,6 +15,10 @@ import 'package:ui/src/engine.dart'; import 'matchers.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('Path', () { test('Should have no subpaths when created', () { final SurfacePath path = SurfacePath(); diff --git a/lib/web_ui/test/rect_test.dart b/lib/web_ui/test/rect_test.dart index e5719e711603f..a526b4590e9dc 100644 --- a/lib/web_ui/test/rect_test.dart +++ b/lib/web_ui/test/rect_test.dart @@ -3,11 +3,15 @@ // found in the LICENSE file. // @dart = 2.6 -import 'package:ui/ui.dart'; - +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; +import 'package:ui/ui.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { test('rect accessors', () { const Rect r = Rect.fromLTRB(1.0, 3.0, 5.0, 7.0); expect(r.left, equals(1.0)); diff --git a/lib/web_ui/test/rrect_test.dart b/lib/web_ui/test/rrect_test.dart index b9d1f59e07ae1..02943b8413adc 100644 --- a/lib/web_ui/test/rrect_test.dart +++ b/lib/web_ui/test/rrect_test.dart @@ -3,11 +3,15 @@ // found in the LICENSE file. // @dart = 2.6 -import 'package:ui/ui.dart'; - +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; +import 'package:ui/ui.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { test('RRect.contains()', () { final RRect rrect = RRect.fromRectAndCorners( const Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), diff --git a/lib/web_ui/test/text/font_collection_test.dart b/lib/web_ui/test/text/font_collection_test.dart index ec5590f008a23..b6423378ef6b0 100644 --- a/lib/web_ui/test/text/font_collection_test.dart +++ b/lib/web_ui/test/text/font_collection_test.dart @@ -5,11 +5,16 @@ // @dart = 2.6 import 'dart:html' as html; -import 'package:ui/src/engine.dart'; - +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; +import 'package:ui/src/engine.dart'; + void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('$FontManager', () { FontManager fontManager; const String _testFontUrl = 'packages/ui/assets/ahem.ttf'; diff --git a/lib/web_ui/test/text/font_loading_test.dart b/lib/web_ui/test/text/font_loading_test.dart index 5b34d9d9346ae..81ff90eb568b8 100644 --- a/lib/web_ui/test/text/font_loading_test.dart +++ b/lib/web_ui/test/text/font_loading_test.dart @@ -8,11 +8,16 @@ import 'dart:convert'; import 'dart:html' as html; import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart' as ui; import 'package:ui/src/engine.dart'; -Future main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { await ui.webOnlyInitializeTestDomRenderer(); group('loadFontFromList', () { const String _testFontUrl = 'packages/ui/assets/ahem.ttf'; diff --git a/lib/web_ui/test/text/line_breaker_test.dart b/lib/web_ui/test/text/line_breaker_test.dart index b1a29013a1006..f536729faeeaa 100644 --- a/lib/web_ui/test/text/line_breaker_test.dart +++ b/lib/web_ui/test/text/line_breaker_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. // @dart = 2.10 +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; @@ -11,6 +12,10 @@ import 'package:ui/ui.dart'; import 'line_breaker_test_data.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('nextLineBreak', () { test('Does not go beyond the ends of a string', () { expect(split('foo'), [ diff --git a/lib/web_ui/test/text/measurement_test.dart b/lib/web_ui/test/text/measurement_test.dart index 5e5e61d65b2e5..dbe170b74e2d9 100644 --- a/lib/web_ui/test/text/measurement_test.dart +++ b/lib/web_ui/test/text/measurement_test.dart @@ -5,10 +5,12 @@ // @dart = 2.6 @TestOn('chrome || firefox') +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; + import 'package:ui/ui.dart' as ui; import 'package:ui/src/engine.dart'; -import 'package:test/test.dart'; final ui.ParagraphStyle ahemStyle = ui.ParagraphStyle( fontFamily: 'ahem', @@ -47,8 +49,11 @@ void testMeasurements(String description, MeasurementTestBody body, { skip: skipCanvas, ); } +void main() { + internalBootstrapBrowserTest(() => testMain); +} -void main() async { +void testMain() async { await ui.webOnlyInitializeTestDomRenderer(); group('$RulerManager', () { diff --git a/lib/web_ui/test/text/word_breaker_test.dart b/lib/web_ui/test/text/word_breaker_test.dart index 54ae7dd33c6cb..15966c9bce2ec 100644 --- a/lib/web_ui/test/text/word_breaker_test.dart +++ b/lib/web_ui/test/text/word_breaker_test.dart @@ -3,11 +3,16 @@ // found in the LICENSE file. // @dart = 2.6 +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('$WordBreaker', () { test('Does not go beyond the ends of a string', () { expect(WordBreaker.prevBreakIndex('foo', 0), 0); diff --git a/lib/web_ui/test/text_editing_test.dart b/lib/web_ui/test/text_editing_test.dart index dab4297fbb0db..8e5eeb36a31ea 100644 --- a/lib/web_ui/test/text_editing_test.dart +++ b/lib/web_ui/test/text_editing_test.dart @@ -8,10 +8,11 @@ import 'dart:html'; import 'dart:js_util' as js_util; import 'dart:typed_data'; -import 'package:ui/src/engine.dart' hide window; - +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; +import 'package:ui/src/engine.dart' hide window; + import 'matchers.dart'; import 'spy.dart'; @@ -57,6 +58,10 @@ void trackInputAction(String inputAction) { } void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { tearDown(() { lastEditingState = null; lastInputAction = null; diff --git a/lib/web_ui/test/text_test.dart b/lib/web_ui/test/text_test.dart index 266d88d1eecae..35861b2eda6c0 100644 --- a/lib/web_ui/test/text_test.dart +++ b/lib/web_ui/test/text_test.dart @@ -5,6 +5,7 @@ // @dart = 2.6 import 'dart:html'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart'; @@ -12,7 +13,11 @@ import 'package:ui/src/engine.dart'; import 'matchers.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { const double baselineRatio = 1.1662499904632568; await webOnlyInitializeTestDomRenderer(); diff --git a/lib/web_ui/test/title_test.dart b/lib/web_ui/test/title_test.dart index c076e2acdd138..af366760e49b9 100644 --- a/lib/web_ui/test/title_test.dart +++ b/lib/web_ui/test/title_test.dart @@ -5,11 +5,16 @@ // @dart = 2.6 import 'dart:html'; +import 'package:test/bootstrap/browser.dart'; +import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; -import 'package:test/test.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { const MethodCodec codec = JSONMethodCodec(); group('Title', () { diff --git a/lib/web_ui/test/window_test.dart b/lib/web_ui/test/window_test.dart index 8924a06798d5f..44894d8bc8dfe 100644 --- a/lib/web_ui/test/window_test.dart +++ b/lib/web_ui/test/window_test.dart @@ -8,6 +8,7 @@ import 'dart:html' as html; import 'dart:js_util' as js_util; import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; @@ -16,6 +17,10 @@ const MethodCodec codec = JSONMethodCodec(); void emptyCallback(ByteData date) {} void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { test('window.defaultRouteName should not change', () { window.locationStrategy = TestLocationStrategy.fromEntry(TestHistoryEntry('initial state', null, '/initial')); expect(window.defaultRouteName, '/initial'); From 01d0bb0e49bd8d1c884c3cba419dfd5a1e7d53f9 Mon Sep 17 00:00:00 2001 From: nturgut Date: Mon, 10 Aug 2020 15:20:16 -0700 Subject: [PATCH 04/25] make tests build in paralel. Total time dropped from 586 to 177 seconds for 8 core MacBook --- lib/web_ui/dev/test_runner.dart | 154 ++++++++++++++++++++++---------- 1 file changed, 109 insertions(+), 45 deletions(-) diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index 735be6382824b..398e6b79679f5 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -4,11 +4,13 @@ // @dart = 2.6 import 'dart:async'; +import 'dart:isolate'; import 'dart:io' as io; import 'package:args/command_runner.dart'; import 'package:meta/meta.dart'; import 'package:path/path.dart' as path; +import 'package:quiver/iterables.dart'; import 'package:test_core/src/runner/hack_register_platform.dart' as hack; // ignore: implementation_imports import 'package:test_api/src/backend/runtime.dart'; // ignore: implementation_imports @@ -38,6 +40,9 @@ enum TestTypesRequested { all, } +/// How many isolates does the test build is distributed. +const int numberOfIsolates = 8; + class TestCommand extends Command with ArgUtils { TestCommand() { argParser @@ -241,11 +246,12 @@ class TestCommand extends Command with ArgUtils { } if (htmlTargets.isNotEmpty) { - await _buildTests(targets: htmlTargets, forCanvasKit: false); + await _buildTestsInParallel(targets: htmlTargets, forCanvasKit: false); } if (canvasKitTargets.isNotEmpty) { - await _buildTests(targets: canvasKitTargets, forCanvasKit: true); + await _buildTestsInParallel( + targets: canvasKitTargets, forCanvasKit: true); } stopwatch.stop(); print('The build took ${stopwatch.elapsedMilliseconds ~/ 1000} seconds.'); @@ -448,56 +454,101 @@ class TestCommand extends Command with ArgUtils { timestampFile.writeAsStringSync(timestamp); } - /// Builds the specific test [targets]. - /// - /// [targets] must not be null. - /// - /// Uses `dart2js` for building the tests. - /// - /// When building for CanvasKit we have to use extra argument - /// `DFLUTTER_WEB_USE_SKIA=true`. - Future _buildTests( + Future _buildTestsInParallel( {List targets, bool forCanvasKit = false}) async { - print('Building ${targets.length} targets for HTML'); - - for (FilePath file in targets) { - final targetFileName = file.relativeToWebUi - .replaceFirst('.dart', '.dart.browser_test.dart.js'); - final String targetPath = path.join('build', targetFileName); - print('target path: $targetPath current file: ${file.relativeToWebUi}'); + final double numberOfTargetsPerIsolate = targets.length / numberOfIsolates; + Iterable> targetsPerIsolate = + partition(targets, numberOfTargetsPerIsolate.ceil()); + final List> completers = List.empty(growable: true); + int i = 1; + for (final List t in targetsPerIsolate) { + final Completer completer = new Completer(); + print('INFO: Isolate no $i will start'); + _buildTestsInIsolates(completer, + input: TestBuildIsolateInput(t, forCanvasKit: forCanvasKit), + forCanvasKit: forCanvasKit); + completers.add(completer); + i++; + } + await Future.wait(completers.map((e) => e.future)); + } - final io.Directory directoryToTarget = io.Directory(path.join( - environment.webUiBuildDir.path, path.dirname(file.relativeToWebUi))); + void _buildTestsInIsolates(Completer completer, + {TestBuildIsolateInput input, bool forCanvasKit = false}) async { + final ReceivePort receivePort = new ReceivePort(); + final Isolate isolate = await Isolate.spawn(continuesBuilding, receivePort.sendPort); - if (!directoryToTarget.existsSync()) { - directoryToTarget.createSync(recursive: true); + receivePort.listen((dynamic message) async { + if (message is SendPort) { + // Record isolate send port. + final SendPort sendPort = message; + sendPort.send(input); } + if (message is String) { + if (message != 'pass') { + throw ToolException('Failed to compile tests with error $message'); + } + receivePort.close(); + } + }, onDone: () { + completer.complete(); + isolate.kill(priority: Isolate.immediate); + }); + } - List arguments = [ - '--no-minify', - '--disable-inlining', - '--enable-asserts', - '--enable-experiment=non-nullable', - '--no-sound-null-safety', - if (forCanvasKit) '-DFLUTTER_WEB_USE_SKIA=true', - '-O2', - '-o', - '${targetPath}', // target path - '${file.relativeToWebUi}', // current path - ]; - - final int exitCode = await runProcess( - environment.dart2jsExecutable, - arguments, - workingDirectory: environment.webUiRootDir.path, - // environment. - ); + /// The main method for building the test files. + /// + /// This method runs inside the isolates. + /// + /// There are [numberOfIsolates] running in parallel. + static void continuesBuilding(SendPort sendPort) async { + final ReceivePort receivePort = new ReceivePort(); + sendPort.send(receivePort.sendPort); + await receivePort.listen((dynamic message) async { + final TestBuildIsolateInput isolateInput = + message as TestBuildIsolateInput; + final List targets = isolateInput.targets; + + for (FilePath file in targets) { + final targetFileName = file.relativeToWebUi + .replaceFirst('.dart', '.dart.browser_test.dart.js'); + final String targetPath = path.join('build', targetFileName); + + final io.Directory directoryToTarget = io.Directory(path.join( + environment.webUiBuildDir.path, + path.dirname(file.relativeToWebUi))); + + if (!directoryToTarget.existsSync()) { + directoryToTarget.createSync(recursive: true); + } - if (exitCode != 0) { - throw ToolException( - 'Failed to compile tests. Dart2js exited with exit code $exitCode'); + List arguments = [ + '--no-minify', + '--disable-inlining', + '--enable-asserts', + '--enable-experiment=non-nullable', + '--no-sound-null-safety', + if (isolateInput.forCanvasKit) '-DFLUTTER_WEB_USE_SKIA=true', + '-O2', + '-o', + '${targetPath}', + '${file}', + ]; + + final int exitCode = await runProcess( + environment.dart2jsExecutable, + arguments, + workingDirectory: environment.webUiRootDir.path, + ); + + if (exitCode != 0) { + print('>>> Exception finish of isolate $exitCode.' + 'target failed: ${file.relativeToWebUi}'); + sendPort.send('failure'); + } } - } + sendPort.send('pass'); + }); } /// Runs a batch of tests. @@ -568,3 +619,16 @@ void _copyTestFontsIntoWebUi() { sourceTtf.copySync(destinationTtfPath); } } + +/// This objest is used as an input message to the isolates that builds the +/// test files. +class TestBuildIsolateInput { + /// List of targets to build. + final List targets; + /// Whether these tests should be build for CanvasKit. + /// + /// `-DFLUTTER_WEB_USE_SKIA=true` is passed to dart2js for CanvasKit. + final bool forCanvasKit; + + TestBuildIsolateInput(this.targets, {this.forCanvasKit = false}); +} From 4136fd895782f2bb46d2b732793b5852eaadca47 Mon Sep 17 00:00:00 2001 From: nturgut Date: Tue, 11 Aug 2020 17:22:04 -0700 Subject: [PATCH 05/25] change isolates with pool --- lib/web_ui/dev/test_runner.dart | 158 +++++++++++++------------------- 1 file changed, 64 insertions(+), 94 deletions(-) diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index 398e6b79679f5..1a817936aab8c 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -10,6 +10,7 @@ import 'dart:io' as io; import 'package:args/command_runner.dart'; import 'package:meta/meta.dart'; import 'package:path/path.dart' as path; +import 'package:pool/pool.dart'; import 'package:quiver/iterables.dart'; import 'package:test_core/src/runner/hack_register_platform.dart' as hack; // ignore: implementation_imports @@ -40,9 +41,6 @@ enum TestTypesRequested { all, } -/// How many isolates does the test build is distributed. -const int numberOfIsolates = 8; - class TestCommand extends Command with ArgUtils { TestCommand() { argParser @@ -104,6 +102,9 @@ class TestCommand extends Command with ArgUtils { TestTypesRequested testTypesRequested = null; + /// How many dart2js build tasks are running at the same time. + final Pool _pool = Pool(8); + /// Check the flags to see what type of tests are requested. TestTypesRequested findTestType() { if (boolArg('unit-tests-only') && boolArg('integration-tests-only')) { @@ -456,99 +457,67 @@ class TestCommand extends Command with ArgUtils { Future _buildTestsInParallel( {List targets, bool forCanvasKit = false}) async { - final double numberOfTargetsPerIsolate = targets.length / numberOfIsolates; - Iterable> targetsPerIsolate = - partition(targets, numberOfTargetsPerIsolate.ceil()); - final List> completers = List.empty(growable: true); - int i = 1; - for (final List t in targetsPerIsolate) { - final Completer completer = new Completer(); - print('INFO: Isolate no $i will start'); - _buildTestsInIsolates(completer, - input: TestBuildIsolateInput(t, forCanvasKit: forCanvasKit), - forCanvasKit: forCanvasKit); - completers.add(completer); - i++; - } - await Future.wait(completers.map((e) => e.future)); - } + final List buildInputs = targets + .map((FilePath f) => TestBuildInput(f, forCanvasKit: forCanvasKit)).toList(); - void _buildTestsInIsolates(Completer completer, - {TestBuildIsolateInput input, bool forCanvasKit = false}) async { - final ReceivePort receivePort = new ReceivePort(); - final Isolate isolate = await Isolate.spawn(continuesBuilding, receivePort.sendPort); - - receivePort.listen((dynamic message) async { - if (message is SendPort) { - // Record isolate send port. - final SendPort sendPort = message; - sendPort.send(input); - } - if (message is String) { - if (message != 'pass') { - throw ToolException('Failed to compile tests with error $message'); - } - receivePort.close(); + final results = _pool.forEach( + buildInputs, + _buildTest, + ); + await for (final bool isSuccess in results) { + if (!isSuccess) { + throw ToolException('Failed to compile tests.'); } - }, onDone: () { - completer.complete(); - isolate.kill(priority: Isolate.immediate); - }); + } } - /// The main method for building the test files. + /// Builds the specific test [targets]. /// - /// This method runs inside the isolates. + /// [targets] must not be null. /// - /// There are [numberOfIsolates] running in parallel. - static void continuesBuilding(SendPort sendPort) async { - final ReceivePort receivePort = new ReceivePort(); - sendPort.send(receivePort.sendPort); - await receivePort.listen((dynamic message) async { - final TestBuildIsolateInput isolateInput = - message as TestBuildIsolateInput; - final List targets = isolateInput.targets; - - for (FilePath file in targets) { - final targetFileName = file.relativeToWebUi - .replaceFirst('.dart', '.dart.browser_test.dart.js'); - final String targetPath = path.join('build', targetFileName); - - final io.Directory directoryToTarget = io.Directory(path.join( - environment.webUiBuildDir.path, - path.dirname(file.relativeToWebUi))); - - if (!directoryToTarget.existsSync()) { - directoryToTarget.createSync(recursive: true); - } + /// Uses `dart2js` for building the tests. + /// + /// When building for CanvasKit we have to use extra argument + /// `DFLUTTER_WEB_USE_SKIA=true`. + Future _buildTest(TestBuildInput input) async { + final targetFileName = input.target.relativeToWebUi + .replaceFirst('.dart', '.dart.browser_test.dart.js'); + final String targetPath = path.join('build', targetFileName); + + final io.Directory directoryToTarget = io.Directory(path.join( + environment.webUiBuildDir.path, + path.dirname(input.target.relativeToWebUi))); + + if (!directoryToTarget.existsSync()) { + directoryToTarget.createSync(recursive: true); + } - List arguments = [ - '--no-minify', - '--disable-inlining', - '--enable-asserts', - '--enable-experiment=non-nullable', - '--no-sound-null-safety', - if (isolateInput.forCanvasKit) '-DFLUTTER_WEB_USE_SKIA=true', - '-O2', - '-o', - '${targetPath}', - '${file}', - ]; - - final int exitCode = await runProcess( - environment.dart2jsExecutable, - arguments, - workingDirectory: environment.webUiRootDir.path, - ); + List arguments = [ + '--no-minify', + '--disable-inlining', + '--enable-asserts', + '--enable-experiment=non-nullable', + '--no-sound-null-safety', + if (input.forCanvasKit) '-DFLUTTER_WEB_USE_SKIA=true', + '-O2', + '-o', + '${targetPath}', // target path. + '${input.target.relativeToWebUi}', // current path. + ]; - if (exitCode != 0) { - print('>>> Exception finish of isolate $exitCode.' - 'target failed: ${file.relativeToWebUi}'); - sendPort.send('failure'); - } - } - sendPort.send('pass'); - }); + final int exitCode = await runProcess( + environment.dart2jsExecutable, + arguments, + workingDirectory: environment.webUiRootDir.path, + ); + + if (exitCode != 0) { + print('ERROR: Failed to compile test ${input.target}. ' + 'Dart2js exited with exit code $exitCode'); + return false; + } else { + return true; + } } /// Runs a batch of tests. @@ -620,15 +589,16 @@ void _copyTestFontsIntoWebUi() { } } -/// This objest is used as an input message to the isolates that builds the -/// test files. -class TestBuildIsolateInput { - /// List of targets to build. - final List targets; +/// This objest is used as an input message to the PoolResources that are +/// building the tests. +class TestBuildInput { + /// Target to build. + final FilePath target; + /// Whether these tests should be build for CanvasKit. /// /// `-DFLUTTER_WEB_USE_SKIA=true` is passed to dart2js for CanvasKit. final bool forCanvasKit; - TestBuildIsolateInput(this.targets, {this.forCanvasKit = false}); + TestBuildInput(this.target, {this.forCanvasKit = false}); } From 96e4a04c2bb6311adf19f0892b924074a3cd4990 Mon Sep 17 00:00:00 2001 From: nturgut Date: Tue, 11 Aug 2020 17:32:21 -0700 Subject: [PATCH 06/25] fixing analysis errors --- lib/web_ui/dev/test_runner.dart | 2 -- .../test/golden_tests/engine/linear_gradient_golden_test.dart | 1 - .../engine/multiline_text_clipping_golden_test.dart | 1 - 3 files changed, 4 deletions(-) diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index 1a817936aab8c..d462884b16be2 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -4,14 +4,12 @@ // @dart = 2.6 import 'dart:async'; -import 'dart:isolate'; import 'dart:io' as io; import 'package:args/command_runner.dart'; import 'package:meta/meta.dart'; import 'package:path/path.dart' as path; import 'package:pool/pool.dart'; -import 'package:quiver/iterables.dart'; import 'package:test_core/src/runner/hack_register_platform.dart' as hack; // ignore: implementation_imports import 'package:test_api/src/backend/runtime.dart'; // ignore: implementation_imports diff --git a/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart b/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart index 3f1141b17325e..1234a42f0d321 100644 --- a/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart @@ -6,7 +6,6 @@ import 'dart:html' as html; import 'dart:math' as math; -import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart'; diff --git a/lib/web_ui/test/golden_tests/engine/multiline_text_clipping_golden_test.dart b/lib/web_ui/test/golden_tests/engine/multiline_text_clipping_golden_test.dart index d7a9fd131403d..cd3378b569896 100644 --- a/lib/web_ui/test/golden_tests/engine/multiline_text_clipping_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/multiline_text_clipping_golden_test.dart @@ -5,7 +5,6 @@ // @dart = 2.6 import 'dart:math' as math; -import 'package:test/bootstrap/browser.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; From 7da0438c9b2248a9aa7fdcfbddf96497989a58b4 Mon Sep 17 00:00:00 2001 From: nturgut Date: Wed, 12 Aug 2020 15:51:20 -0700 Subject: [PATCH 07/25] skipping canvaskit tests for ios-safari --- lib/web_ui/dev/test_runner.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index d462884b16be2..fd38031c951c4 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -248,7 +248,9 @@ class TestCommand extends Command with ArgUtils { await _buildTestsInParallel(targets: htmlTargets, forCanvasKit: false); } - if (canvasKitTargets.isNotEmpty) { + // Currently iOS Safari tests are running on simulator, which does not + // support canvaskit backend. + if (canvasKitTargets.isNotEmpty && !isSafariOnIOS) { await _buildTestsInParallel( targets: canvasKitTargets, forCanvasKit: true); } @@ -287,6 +289,9 @@ class TestCommand extends Command with ArgUtils { /// Whether [browser] is set to "safari". bool get isSafariOnMacOS => browser == 'safari' && io.Platform.isMacOS; + /// Whether [browser] is "safari" running on "iOS". + bool get isSafariOnIOS => browser == 'ios-safari' && io.Platform.isIOS; + /// Use system flutter instead of cloning the repository. /// /// Read the flag help for more details. Uses PATH to locate flutter. From 4fad7781656b272664d7052d46f279b8db3b3347 Mon Sep 17 00:00:00 2001 From: nturgut Date: Wed, 12 Aug 2020 17:36:40 -0700 Subject: [PATCH 08/25] copy image files to the build directory --- lib/web_ui/dev/test_runner.dart | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index fd38031c951c4..1ab969e53bb59 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -250,10 +250,35 @@ class TestCommand extends Command with ArgUtils { // Currently iOS Safari tests are running on simulator, which does not // support canvaskit backend. - if (canvasKitTargets.isNotEmpty && !isSafariOnIOS) { + if (canvasKitTargets.isNotEmpty) { await _buildTestsInParallel( targets: canvasKitTargets, forCanvasKit: true); } + + // Copy image files under build directory. + // A side effect is this file copies all the images btween, even only one target + // test is asked to run. + final List contents = + environment.webUiTestDir.listSync(recursive: true); + for (final io.FileSystemEntity entity in contents) { + if (entity is io.File) { + final String basename = path.basename(entity.path); + if (basename.contains('.png')) { + final String directoryPath = path.relative(path.dirname(entity.path), + from: environment.webUiRootDir.path); + final io.Directory directory = io.Directory( + path.join(environment.webUiBuildDir.path, directoryPath)); + if (!directory.existsSync()) { + directory.createSync(recursive: true); + } + final String pathRelativeToWebUi = path.relative(entity.absolute.path, + from: environment.webUiRootDir.path); + entity.copySync( + path.join(environment.webUiBuildDir.path, pathRelativeToWebUi)); + } + } + } + stopwatch.stop(); print('The build took ${stopwatch.elapsedMilliseconds ~/ 1000} seconds.'); } @@ -461,7 +486,8 @@ class TestCommand extends Command with ArgUtils { Future _buildTestsInParallel( {List targets, bool forCanvasKit = false}) async { final List buildInputs = targets - .map((FilePath f) => TestBuildInput(f, forCanvasKit: forCanvasKit)).toList(); + .map((FilePath f) => TestBuildInput(f, forCanvasKit: forCanvasKit)) + .toList(); final results = _pool.forEach( buildInputs, From b494c444cb97018610253aca9be3b0e6a0f8003a Mon Sep 17 00:00:00 2001 From: nturgut Date: Wed, 12 Aug 2020 18:56:19 -0700 Subject: [PATCH 09/25] adding internalBootstrapBrowserTest to newly added tests --- lib/web_ui/test/canvaskit/image_test.dart | 5 +++++ lib/web_ui/test/canvaskit/shader_test.dart | 5 +++++ lib/web_ui/test/canvaskit/vertices_test.dart | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/lib/web_ui/test/canvaskit/image_test.dart b/lib/web_ui/test/canvaskit/image_test.dart index 8ba442c7d495d..d8e3995da43d3 100644 --- a/lib/web_ui/test/canvaskit/image_test.dart +++ b/lib/web_ui/test/canvaskit/image_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. // @dart = 2.6 +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; @@ -11,6 +12,10 @@ import 'common.dart'; import 'test_data.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('CanvasKit image', () { setUpAll(() async { await ui.webOnlyInitializePlatform(); diff --git a/lib/web_ui/test/canvaskit/shader_test.dart b/lib/web_ui/test/canvaskit/shader_test.dart index 8e4ec00a98b1f..dfa3f2dd12b04 100644 --- a/lib/web_ui/test/canvaskit/shader_test.dart +++ b/lib/web_ui/test/canvaskit/shader_test.dart @@ -5,6 +5,7 @@ // @dart = 2.6 import 'dart:typed_data'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; @@ -13,6 +14,10 @@ import 'common.dart'; import 'test_data.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('CanvasKit shaders', () { setUpAll(() async { await ui.webOnlyInitializePlatform(); diff --git a/lib/web_ui/test/canvaskit/vertices_test.dart b/lib/web_ui/test/canvaskit/vertices_test.dart index a223245337061..0f0263a04eb7b 100644 --- a/lib/web_ui/test/canvaskit/vertices_test.dart +++ b/lib/web_ui/test/canvaskit/vertices_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. // @dart = 2.6 +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; @@ -10,6 +11,10 @@ import 'package:ui/ui.dart' as ui; import 'common.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { group('Vertices', () { setUpAll(() async { await ui.webOnlyInitializePlatform(); From 96f7adb5eb358678f6e23868c6e96e597086b1cf Mon Sep 17 00:00:00 2001 From: nturgut Date: Wed, 12 Aug 2020 19:34:44 -0700 Subject: [PATCH 10/25] add internalBootstrapBrowserTest to faling path iterator test --- lib/web_ui/test/engine/surface/path/path_iterator_test.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/web_ui/test/engine/surface/path/path_iterator_test.dart b/lib/web_ui/test/engine/surface/path/path_iterator_test.dart index 28c3f261fcefa..3e4c21e029930 100644 --- a/lib/web_ui/test/engine/surface/path/path_iterator_test.dart +++ b/lib/web_ui/test/engine/surface/path/path_iterator_test.dart @@ -5,9 +5,14 @@ import 'dart:typed_data'; import 'package:ui/src/engine.dart'; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() { final Float32List points = Float32List(PathIterator.kMaxBufferSize); group('PathIterator', () { From 6cba9c0832305e88fac6e727520d826f0f6e6a8a Mon Sep 17 00:00:00 2001 From: nturgut Date: Wed, 12 Aug 2020 23:14:07 -0700 Subject: [PATCH 11/25] necessary changes to make chrome windows work --- lib/web_ui/dev/browser_lock.yaml | 2 +- lib/web_ui/dev/common.dart | 4 ++-- lib/web_ui/dev/test_runner.dart | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/web_ui/dev/browser_lock.yaml b/lib/web_ui/dev/browser_lock.yaml index 57fbf7a6816fe..3d72c24d2acbb 100644 --- a/lib/web_ui/dev/browser_lock.yaml +++ b/lib/web_ui/dev/browser_lock.yaml @@ -5,7 +5,7 @@ chrome: # is not working with chrome.binary option. Linux: 741412 Mac: 735194 - Win: 735105 + Win: 768975 firefox: version: '72.0' edge: diff --git a/lib/web_ui/dev/common.dart b/lib/web_ui/dev/common.dart index 588fe67eedf6f..511794a1e92f3 100644 --- a/lib/web_ui/dev/common.dart +++ b/lib/web_ui/dev/common.dart @@ -59,11 +59,11 @@ class _WindowsBinding implements PlatformBinding { @override String getChromeDownloadUrl(String version) => - 'https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Win%2F${version}%2Fchrome-win32.zip?alt=media'; + 'https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Win%2F${version}%2Fchrome-win.zip?alt=media'; @override String getChromeExecutablePath(io.Directory versionDir) => - path.join(versionDir.path, 'chrome-win32', 'chrome'); + path.join(versionDir.path, 'chrome-win', 'chrome.exe'); @override String getFirefoxDownloadUrl(String version) => diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index 1ab969e53bb59..b2de69bca5d46 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -314,9 +314,6 @@ class TestCommand extends Command with ArgUtils { /// Whether [browser] is set to "safari". bool get isSafariOnMacOS => browser == 'safari' && io.Platform.isMacOS; - /// Whether [browser] is "safari" running on "iOS". - bool get isSafariOnIOS => browser == 'ios-safari' && io.Platform.isIOS; - /// Use system flutter instead of cloning the repository. /// /// Read the flag help for more details. Uses PATH to locate flutter. From eb3a263db228f365f6dc5ebbffbcf7bb3410bc8d Mon Sep 17 00:00:00 2001 From: nturgut Date: Wed, 12 Aug 2020 23:25:21 -0700 Subject: [PATCH 12/25] in windows test in chrome instead of edge. our edge code was for legacy edge --- lib/web_ui/dev/felt_windows.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/web_ui/dev/felt_windows.bat b/lib/web_ui/dev/felt_windows.bat index bacd1b0d50975..d71ec3cc58a22 100644 --- a/lib/web_ui/dev/felt_windows.bat +++ b/lib/web_ui/dev/felt_windows.bat @@ -57,7 +57,7 @@ IF %orTempValue%==0 ( :: TODO(nurhan): The batch script does not support snanphot option. :: Support snapshot option. CALL :installdeps -IF %1==test (%DART_SDK_DIR%\bin\dart "%DEV_DIR%\felt.dart" %* --browser=edge) ELSE ( %DART_SDK_DIR%\bin\dart "%DEV_DIR%\felt.dart" %* ) +IF %1==test (%DART_SDK_DIR%\bin\dart "%DEV_DIR%\felt.dart" %* --browser=chrome) ELSE ( %DART_SDK_DIR%\bin\dart "%DEV_DIR%\felt.dart" %* ) EXIT /B 0 @@ -66,6 +66,6 @@ ECHO "Running \`pub get\` in 'engine/src/flutter/web_sdk/web_engine_tester'" cd "%FLUTTER_DIR%web_sdk\web_engine_tester" CALL %PUB_DIR% get ECHO "Running \`pub get\` in 'engine/src/flutter/lib/web_ui'" -cd %WEB_UI_DIR% +cd %WEB_UI_DIR% CALL %PUB_DIR% get EXIT /B 0 From 8dc6f2c3fb246dd2f6b42760812790acc130d78e Mon Sep 17 00:00:00 2001 From: nturgut Date: Thu, 13 Aug 2020 14:54:54 -0700 Subject: [PATCH 13/25] do not run golden unit tests on Windows LUCI bots for now --- lib/web_ui/dev/test_runner.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index b2de69bca5d46..584d3b6d53f24 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -340,8 +340,10 @@ class TestCommand extends Command with ArgUtils { 'test', )); - // Screenshot tests and smoke tests only run in Chrome. - if (isChrome) { + // Screenshot tests and smoke tests only run on: "Chrome locally" or + // "Chrome on a Linux bot". We can remove the Linux bot restriction after: + // TODO: https://github.com/flutter/flutter/issues/63710 + if ((isChrome && isLuci && io.Platform.isLinux) || (isChrome && !isLuci)) { // Separate screenshot tests from unit-tests. Screenshot tests must run // one at a time. Otherwise, they will end up screenshotting each other. // This is not an issue for unit-tests. From 140f1d7c6b3027e7dcfd4b14acd9f600b9c26b0b Mon Sep 17 00:00:00 2001 From: nturgut Date: Fri, 14 Aug 2020 18:12:28 -0700 Subject: [PATCH 14/25] addressing reviewer comments. Adding a method for deciding when to run integration tests. --- lib/web_ui/dev/test_platform.dart | 29 ++++++------ lib/web_ui/dev/test_runner.dart | 77 ++++++++++++++++++++++--------- 2 files changed, 67 insertions(+), 39 deletions(-) diff --git a/lib/web_ui/dev/test_platform.dart b/lib/web_ui/dev/test_platform.dart index 0bdc99140dfa8..afd944de4c9be 100644 --- a/lib/web_ui/dev/test_platform.dart +++ b/lib/web_ui/dev/test_platform.dart @@ -407,15 +407,15 @@ Golden file $filename did not match the image generated by the test. throw ArgumentError('$browser is not a browser.'); } - // Remove. Is this code still useful. - var htmlPath = p.withoutExtension(path) + '.html'; - if (File(htmlPath).existsSync() && - !File(htmlPath).readAsStringSync().contains('packages/test/dart.js')) { - throw LoadException( - path, - '"${htmlPath}" must contain .'); - } + // // Remove. Is this code still useful. + // var htmlPath = p.withoutExtension(path) + '.html'; + // if (File(htmlPath).existsSync() && + // !File(htmlPath).readAsStringSync().contains('packages/test/dart.js')) { + // throw LoadException( + // path, + // '"${htmlPath}" must contain .'); + // } if (_closed) { return null; @@ -812,15 +812,12 @@ class BrowserManager { controller = deserializeSuite(path, currentPlatform(_runtime), suiteConfig, await _environment, suiteChannel, message); - final String mapFileName = p.basename(path); + final String sourceMapFileName = + '${p.basename(path)}.browser_test.dart.js.map'; final String pathToTest = p.dirname(path); - final String mapPath = p.join( - env.environment.webUiRootDir.path, - 'build', - '$pathToTest', - '$mapFileName.browser_test.dart.js.map' - ); + final String mapPath = p.join(env.environment.webUiRootDir.path, + 'build', '$pathToTest', '$sourceMapFileName'); PackageConfig packageConfig = await loadPackageConfigUri(await Isolate.packageConfig); diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index 584d3b6d53f24..a8705cd37f0a7 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -147,9 +147,7 @@ class TestCommand extends Command with ArgUtils { case TestTypesRequested.integration: return runIntegrationTests(); case TestTypesRequested.all: - // TODO(nurhan): https://github.com/flutter/flutter/issues/53322 - // TODO(nurhan): Expand browser matrix for felt integration tests. - if (runAllTests && (isChrome || isSafariOnMacOS || isFirefox)) { + if (runAllTests && isIntegrationTestsAvailable) { bool unitTestResult = await runUnitTests(); bool integrationTestResult = await runIntegrationTests(); if (integrationTestResult != unitTestResult) { @@ -255,29 +253,27 @@ class TestCommand extends Command with ArgUtils { targets: canvasKitTargets, forCanvasKit: true); } - // Copy image files under build directory. - // A side effect is this file copies all the images btween, even only one target - // test is asked to run. + // Copy image files from test/ to build/test/. + // A side effect is this file copies all the images even when only one + // target test is asked to run. final List contents = environment.webUiTestDir.listSync(recursive: true); - for (final io.FileSystemEntity entity in contents) { - if (entity is io.File) { - final String basename = path.basename(entity.path); - if (basename.contains('.png')) { - final String directoryPath = path.relative(path.dirname(entity.path), - from: environment.webUiRootDir.path); - final io.Directory directory = io.Directory( - path.join(environment.webUiBuildDir.path, directoryPath)); - if (!directory.existsSync()) { - directory.createSync(recursive: true); - } - final String pathRelativeToWebUi = path.relative(entity.absolute.path, - from: environment.webUiRootDir.path); - entity.copySync( - path.join(environment.webUiBuildDir.path, pathRelativeToWebUi)); + contents.whereType().forEach((final io.File entity) { + final String basename = path.basename(entity.path); + if (basename.contains('.png')) { + final String directoryPath = path.relative(path.dirname(entity.path), + from: environment.webUiRootDir.path); + final io.Directory directory = io.Directory( + path.join(environment.webUiBuildDir.path, directoryPath)); + if (!directory.existsSync()) { + directory.createSync(recursive: true); } + final String pathRelativeToWebUi = path.relative(entity.absolute.path, + from: environment.webUiRootDir.path); + entity.copySync( + path.join(environment.webUiBuildDir.path, pathRelativeToWebUi)); } - } + }); stopwatch.stop(); print('The build took ${stopwatch.elapsedMilliseconds ~/ 1000} seconds.'); @@ -314,6 +310,41 @@ class TestCommand extends Command with ArgUtils { /// Whether [browser] is set to "safari". bool get isSafariOnMacOS => browser == 'safari' && io.Platform.isMacOS; + /// Due to efficiancy constraints, Chrome integration tests only run on + /// Linux on LUCI. + /// + /// They run on all platforms for local. + bool get isChromeIntegrationTestAvailable => + (isChrome && isLuci && io.Platform.isLinux) || (isChrome && !isLuci); + + /// Due to efficiancy constraints, Firefox integration tests only run on + /// Linux on LUCI. + /// + /// For now Firefox integration tests only run on Linux and Mac on local. + /// + // TODO: https://github.com/flutter/flutter/issues/63710 + bool get isFirefoxIntegrationTestAvailable => + (isFirefox && isLuci && io.Platform.isLinux) || + (isFirefox && !isLuci && !io.Platform.isWindows); + + /// Latest versions of Safari Desktop are only available on MacOS. + /// + /// Integration testing on LUCI is not supported at the moment. + // TODO: https://github.com/flutter/flutter/issues/63710 + bool get isSafariIntegrationTestAvailable => + (isSafariOnMacOS && isLuci && io.Platform.isLinux) || + (isSafariOnMacOS && !isLuci && !io.Platform.isWindows); + + /// Due to various factors integration tests might be missing on a given, + /// platform and given environment. + /// See: [isChromeIntegrationTestAvailable] + /// See: [isSafariIntegrationTestAvailable] + /// See: [isFirefoxIntegrationTestAvailable] + bool get isIntegrationTestsAvailable => + isChrome && isChromeIntegrationTestAvailable || + isFirefox && isFirefoxIntegrationTestAvailable || + isSafariOnMacOS && isSafariIntegrationTestAvailable; + /// Use system flutter instead of cloning the repository. /// /// Read the flag help for more details. Uses PATH to locate flutter. @@ -540,7 +571,7 @@ class TestCommand extends Command with ArgUtils { ); if (exitCode != 0) { - print('ERROR: Failed to compile test ${input.target}. ' + io.stderr.writeln('ERROR: Failed to compile test ${input.target}. ' 'Dart2js exited with exit code $exitCode'); return false; } else { From b070e8c4e3f901777d13a02a5e1295af9afb16aa Mon Sep 17 00:00:00 2001 From: nturgut Date: Fri, 14 Aug 2020 18:18:30 -0700 Subject: [PATCH 15/25] remove lines that I forgot to remove --- lib/web_ui/dev/test_platform.dart | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/web_ui/dev/test_platform.dart b/lib/web_ui/dev/test_platform.dart index afd944de4c9be..f93ea17ab9272 100644 --- a/lib/web_ui/dev/test_platform.dart +++ b/lib/web_ui/dev/test_platform.dart @@ -407,16 +407,6 @@ Golden file $filename did not match the image generated by the test. throw ArgumentError('$browser is not a browser.'); } - // // Remove. Is this code still useful. - // var htmlPath = p.withoutExtension(path) + '.html'; - // if (File(htmlPath).existsSync() && - // !File(htmlPath).readAsStringSync().contains('packages/test/dart.js')) { - // throw LoadException( - // path, - // '"${htmlPath}" must contain .'); - // } - if (_closed) { return null; } From c4772d1132b5f2226a8e7786a6975e28a024f86c Mon Sep 17 00:00:00 2001 From: nturgut Date: Fri, 14 Aug 2020 19:14:55 -0700 Subject: [PATCH 16/25] fixing analysis error. add issue for todo --- lib/web_ui/dev/test_platform.dart | 1 - lib/web_ui/dev/test_runner.dart | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/web_ui/dev/test_platform.dart b/lib/web_ui/dev/test_platform.dart index f93ea17ab9272..72393d8605e7f 100644 --- a/lib/web_ui/dev/test_platform.dart +++ b/lib/web_ui/dev/test_platform.dart @@ -34,7 +34,6 @@ import 'package:test_core/src/runner/environment.dart'; // ignore: implementatio import 'package:test_core/src/util/io.dart'; // ignore: implementation_imports import 'package:test_core/src/runner/configuration.dart'; // ignore: implementation_imports -import 'package:test_core/src/runner/load_exception.dart'; // ignore: implementation_imports import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart' as wip; diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index a8705cd37f0a7..905f94af832e6 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -322,7 +322,7 @@ class TestCommand extends Command with ArgUtils { /// /// For now Firefox integration tests only run on Linux and Mac on local. /// - // TODO: https://github.com/flutter/flutter/issues/63710 + // TODO: https://github.com/flutter/flutter/issues/63832 bool get isFirefoxIntegrationTestAvailable => (isFirefox && isLuci && io.Platform.isLinux) || (isFirefox && !isLuci && !io.Platform.isWindows); From d18f41822a1e7dc2515cc3d72b2f29f358ca5ac7 Mon Sep 17 00:00:00 2001 From: nturgut Date: Fri, 14 Aug 2020 20:51:32 -0700 Subject: [PATCH 17/25] add bootstap to a test file --- .../test/golden_tests/engine/text_placeholders_test.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/web_ui/test/golden_tests/engine/text_placeholders_test.dart b/lib/web_ui/test/golden_tests/engine/text_placeholders_test.dart index 9c1d6a50dc3ef..e89bc7ee69a7a 100644 --- a/lib/web_ui/test/golden_tests/engine/text_placeholders_test.dart +++ b/lib/web_ui/test/golden_tests/engine/text_placeholders_test.dart @@ -4,6 +4,7 @@ // @dart = 2.6 // import 'package:image/image.dart'; +import 'package:test/bootstrap/browser.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; @@ -11,7 +12,11 @@ import 'scuba.dart'; typedef PaintTest = void Function(RecordingCanvas recordingCanvas); -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { final EngineScubaTester scuba = await EngineScubaTester.initialize( viewportSize: const Size(600, 600), ); From 1bcf1f06e006c29b2969c269d073712ed4b9b472 Mon Sep 17 00:00:00 2001 From: Nurhan Turgut Date: Fri, 14 Aug 2020 22:29:48 -0700 Subject: [PATCH 18/25] adding bootstrap to another test --- .../golden_tests/engine/linear_gradient_golden_test.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart b/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart index 1234a42f0d321..6eccec76d3234 100644 --- a/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/linear_gradient_golden_test.dart @@ -6,13 +6,18 @@ import 'dart:html' as html; import 'dart:math' as math; +import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/ui.dart' hide TextStyle; import 'package:ui/src/engine.dart'; import 'package:web_engine_tester/golden_tester.dart'; -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { const double screenWidth = 600.0; const double screenHeight = 800.0; const Rect screenRect = Rect.fromLTWH(0, 0, screenWidth, screenHeight); From 04e8d7c4c6f7ea56f402ac710abaee4f2073c337 Mon Sep 17 00:00:00 2001 From: nturgut Date: Sat, 15 Aug 2020 10:05:34 -0700 Subject: [PATCH 19/25] add internalBootstrapBrowserTest to a golden test --- .../engine/multiline_text_clipping_golden_test.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/web_ui/test/golden_tests/engine/multiline_text_clipping_golden_test.dart b/lib/web_ui/test/golden_tests/engine/multiline_text_clipping_golden_test.dart index cd3378b569896..fd9efc8bfb44d 100644 --- a/lib/web_ui/test/golden_tests/engine/multiline_text_clipping_golden_test.dart +++ b/lib/web_ui/test/golden_tests/engine/multiline_text_clipping_golden_test.dart @@ -5,6 +5,7 @@ // @dart = 2.6 import 'dart:math' as math; +import 'package:test/bootstrap/browser.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart'; @@ -12,7 +13,11 @@ import 'scuba.dart'; typedef PaintTest = void Function(RecordingCanvas recordingCanvas); -void main() async { +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +void testMain() async { // Scuba doesn't give us viewport smaller than 472px wide. final EngineScubaTester scuba = await EngineScubaTester.initialize( viewportSize: const Size(600, 600), From 1af5a2373c0a48f92025419fae12d6cb2c33fa79 Mon Sep 17 00:00:00 2001 From: Nurhan Turgut Date: Mon, 17 Aug 2020 00:09:04 -0700 Subject: [PATCH 20/25] return test result in bat file. use archieve package to unzip --- lib/web_ui/dev/chrome_installer.dart | 62 ++++++++++++++++++++++------ lib/web_ui/dev/felt_windows.bat | 2 +- lib/web_ui/pubspec.yaml | 1 + 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/lib/web_ui/dev/chrome_installer.dart b/lib/web_ui/dev/chrome_installer.dart index 6f46c2a57d903..f952c17612a79 100644 --- a/lib/web_ui/dev/chrome_installer.dart +++ b/lib/web_ui/dev/chrome_installer.dart @@ -3,8 +3,11 @@ // found in the LICENSE file. // @dart = 2.6 +import 'dart:async'; import 'dart:io' as io; +import 'package:archive/archive.dart'; +import 'package:archive/archive_io.dart'; import 'package:args/args.dart'; import 'package:http/http.dart'; import 'package:meta/meta.dart'; @@ -186,7 +189,7 @@ class ChromeInstaller { } else if (versionDir.existsSync() && isLuci) { print('INFO: Chrome version directory in LUCI: ' '${versionDir.path}'); - } else if(!versionDir.existsSync() && isLuci) { + } else if (!versionDir.existsSync() && isLuci) { // Chrome should have been deployed as a CIPD package on LUCI. // Throw if it does not exists. throw StateError('Failed to locate Chrome on LUCI on path:' @@ -196,6 +199,8 @@ class ChromeInstaller { versionDir.createSync(recursive: true); } + print('starting chrome download'); + final String url = PlatformBinding.instance.getChromeDownloadUrl(version); final StreamedResponse download = await client.send(Request( 'GET', @@ -206,20 +211,51 @@ class ChromeInstaller { io.File(path.join(versionDir.path, 'chrome.zip')); await download.stream.pipe(downloadedFile.openWrite()); - final io.ProcessResult unzipResult = await io.Process.run('unzip', [ - downloadedFile.path, - '-d', - versionDir.path, - ]); - - if (unzipResult.exitCode != 0) { - throw BrowserInstallerException( - 'Failed to unzip the downloaded Chrome archive ${downloadedFile.path}.\n' - 'With the version path ${versionDir.path}\n' - 'The unzip process exited with code ${unzipResult.exitCode}.'); + print('File downloaded for chrome :${downloadedFile.path}'); + + /// Windows LUCI bots does not have a `unzip`. Instead we are + /// using `archive` pub package. + if (io.Platform.isWindows) { + print('stopwatch started'); + final Stopwatch stopwatch = Stopwatch()..start(); + + // Read the Zip file from disk. + final bytes = downloadedFile.readAsBytesSync(); + + final dynamic archive = ZipDecoder().decodeBytes(bytes); + + // Extract the contents of the Zip archive to disk. + for (final file in archive) { + final dynamic filename = file.name; + if (file.isFile) { + final data = file.content as List; + io.File(path.join(versionDir.path, filename)) + ..createSync(recursive: true) + ..writeAsBytesSync(data); + } else { + io.Directory(path.join(versionDir.path, filename)) + ..create(recursive: true); + } + } + + stopwatch.stop(); + print('The unzip took ${stopwatch.elapsedMilliseconds ~/ 1000} seconds.'); + } else { + final io.ProcessResult unzipResult = + await io.Process.run('unzip', [ + downloadedFile.path, + '-d', + versionDir.path, + ]); + if (unzipResult.exitCode != 0) { + throw BrowserInstallerException( + 'Failed to unzip the downloaded Chrome archive ${downloadedFile.path}.\n' + 'With the version path ${versionDir.path}\n' + 'The unzip process exited with code ${unzipResult.exitCode}.'); + } } - downloadedFile.deleteSync(); + //downloadedFile.deleteSync(); } void close() { diff --git a/lib/web_ui/dev/felt_windows.bat b/lib/web_ui/dev/felt_windows.bat index d71ec3cc58a22..2ae0e2ab8b125 100644 --- a/lib/web_ui/dev/felt_windows.bat +++ b/lib/web_ui/dev/felt_windows.bat @@ -59,7 +59,7 @@ IF %orTempValue%==0 ( CALL :installdeps IF %1==test (%DART_SDK_DIR%\bin\dart "%DEV_DIR%\felt.dart" %* --browser=chrome) ELSE ( %DART_SDK_DIR%\bin\dart "%DEV_DIR%\felt.dart" %* ) -EXIT /B 0 +EXIT /B %ERRORLEVEL% :installdeps ECHO "Running \`pub get\` in 'engine/src/flutter/web_sdk/web_engine_tester'" diff --git a/lib/web_ui/pubspec.yaml b/lib/web_ui/pubspec.yaml index 34a4ee540ec85..6defcc3037efe 100644 --- a/lib/web_ui/pubspec.yaml +++ b/lib/web_ui/pubspec.yaml @@ -9,6 +9,7 @@ dependencies: dev_dependencies: analyzer: 0.39.15 + archive: 2.0.13 http: 0.12.1 image: 2.1.13 js: 0.6.1+1 From 349a1a948d95e963abdfd1d5c78ee2e8d204e64b Mon Sep 17 00:00:00 2001 From: Nurhan Turgut Date: Mon, 17 Aug 2020 00:15:41 -0700 Subject: [PATCH 21/25] fixing logs for chrome_installer --- lib/web_ui/dev/chrome_installer.dart | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/web_ui/dev/chrome_installer.dart b/lib/web_ui/dev/chrome_installer.dart index f952c17612a79..b5242efa6df44 100644 --- a/lib/web_ui/dev/chrome_installer.dart +++ b/lib/web_ui/dev/chrome_installer.dart @@ -199,7 +199,7 @@ class ChromeInstaller { versionDir.createSync(recursive: true); } - print('starting chrome download'); + print('INFO: Starting Chrome download.'); final String url = PlatformBinding.instance.getChromeDownloadUrl(version); final StreamedResponse download = await client.send(Request( @@ -211,12 +211,9 @@ class ChromeInstaller { io.File(path.join(versionDir.path, 'chrome.zip')); await download.stream.pipe(downloadedFile.openWrite()); - print('File downloaded for chrome :${downloadedFile.path}'); - /// Windows LUCI bots does not have a `unzip`. Instead we are /// using `archive` pub package. if (io.Platform.isWindows) { - print('stopwatch started'); final Stopwatch stopwatch = Stopwatch()..start(); // Read the Zip file from disk. @@ -239,7 +236,7 @@ class ChromeInstaller { } stopwatch.stop(); - print('The unzip took ${stopwatch.elapsedMilliseconds ~/ 1000} seconds.'); + print('INFO: The unzip took ${stopwatch.elapsedMilliseconds ~/ 1000} seconds.'); } else { final io.ProcessResult unzipResult = await io.Process.run('unzip', [ @@ -255,7 +252,7 @@ class ChromeInstaller { } } - //downloadedFile.deleteSync(); + downloadedFile.deleteSync(); } void close() { From 9434a4143a449b936a3f3ae44ccb9de0759e41df Mon Sep 17 00:00:00 2001 From: nturgut Date: Mon, 17 Aug 2020 08:49:55 -0700 Subject: [PATCH 22/25] use archieve and archieve entity instead of dynamic --- lib/web_ui/dev/chrome_installer.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/web_ui/dev/chrome_installer.dart b/lib/web_ui/dev/chrome_installer.dart index b5242efa6df44..795e3afdb4883 100644 --- a/lib/web_ui/dev/chrome_installer.dart +++ b/lib/web_ui/dev/chrome_installer.dart @@ -219,11 +219,11 @@ class ChromeInstaller { // Read the Zip file from disk. final bytes = downloadedFile.readAsBytesSync(); - final dynamic archive = ZipDecoder().decodeBytes(bytes); + final Archive archive = ZipDecoder().decodeBytes(bytes); // Extract the contents of the Zip archive to disk. - for (final file in archive) { - final dynamic filename = file.name; + for (final ArchiveFile file in archive) { + final String filename = file.name; if (file.isFile) { final data = file.content as List; io.File(path.join(versionDir.path, filename)) From eddb2e770a9db66513eace3fcc46916b660b8faa Mon Sep 17 00:00:00 2001 From: nturgut Date: Mon, 17 Aug 2020 10:27:40 -0700 Subject: [PATCH 23/25] adding comments for windows platform archieve part --- lib/web_ui/dev/chrome_installer.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/web_ui/dev/chrome_installer.dart b/lib/web_ui/dev/chrome_installer.dart index 795e3afdb4883..3766488f497dd 100644 --- a/lib/web_ui/dev/chrome_installer.dart +++ b/lib/web_ui/dev/chrome_installer.dart @@ -213,6 +213,11 @@ class ChromeInstaller { /// Windows LUCI bots does not have a `unzip`. Instead we are /// using `archive` pub package. + /// + /// We didn't use `archieve` on Mac/Linux since the new files have + /// permission issues. For now we are not able change file permissions + /// from dart. + /// See: https://github.com/dart-lang/sdk/issues/15078. if (io.Platform.isWindows) { final Stopwatch stopwatch = Stopwatch()..start(); From dd1236dea6a1888e63eb5cc3391737380d162ced Mon Sep 17 00:00:00 2001 From: nturgut Date: Mon, 17 Aug 2020 14:33:45 -0700 Subject: [PATCH 24/25] addressing reviewer comments --- lib/web_ui/dev/test_platform.dart | 2 +- lib/web_ui/dev/test_runner.dart | 64 ++++++++++++++----------------- 2 files changed, 30 insertions(+), 36 deletions(-) diff --git a/lib/web_ui/dev/test_platform.dart b/lib/web_ui/dev/test_platform.dart index 72393d8605e7f..341d9b245ee37 100644 --- a/lib/web_ui/dev/test_platform.dart +++ b/lib/web_ui/dev/test_platform.dart @@ -806,7 +806,7 @@ class BrowserManager { final String pathToTest = p.dirname(path); final String mapPath = p.join(env.environment.webUiRootDir.path, - 'build', '$pathToTest', '$sourceMapFileName'); + 'build', pathToTest, sourceMapFileName); PackageConfig packageConfig = await loadPackageConfigUri(await Isolate.packageConfig); diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index 905f94af832e6..14a34d5eea4df 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -259,20 +259,17 @@ class TestCommand extends Command with ArgUtils { final List contents = environment.webUiTestDir.listSync(recursive: true); contents.whereType().forEach((final io.File entity) { - final String basename = path.basename(entity.path); - if (basename.contains('.png')) { - final String directoryPath = path.relative(path.dirname(entity.path), - from: environment.webUiRootDir.path); - final io.Directory directory = io.Directory( - path.join(environment.webUiBuildDir.path, directoryPath)); - if (!directory.existsSync()) { - directory.createSync(recursive: true); - } - final String pathRelativeToWebUi = path.relative(entity.absolute.path, - from: environment.webUiRootDir.path); - entity.copySync( - path.join(environment.webUiBuildDir.path, pathRelativeToWebUi)); + final String directoryPath = path.relative(path.dirname(entity.path), + from: environment.webUiRootDir.path); + final io.Directory directory = io.Directory( + path.join(environment.webUiBuildDir.path, directoryPath)); + if (!directory.existsSync()) { + directory.createSync(recursive: true); } + final String pathRelativeToWebUi = path.relative(entity.absolute.path, + from: environment.webUiRootDir.path); + entity.copySync( + path.join(environment.webUiBuildDir.path, pathRelativeToWebUi)); }); stopwatch.stop(); @@ -310,8 +307,8 @@ class TestCommand extends Command with ArgUtils { /// Whether [browser] is set to "safari". bool get isSafariOnMacOS => browser == 'safari' && io.Platform.isMacOS; - /// Due to efficiancy constraints, Chrome integration tests only run on - /// Linux on LUCI. + /// Due to lack of resources Chrome integration tests only run on Linux on + /// LUCI. /// /// They run on all platforms for local. bool get isChromeIntegrationTestAvailable => @@ -327,23 +324,21 @@ class TestCommand extends Command with ArgUtils { (isFirefox && isLuci && io.Platform.isLinux) || (isFirefox && !isLuci && !io.Platform.isWindows); - /// Latest versions of Safari Desktop are only available on MacOS. + /// Latest versions of Safari Desktop are only available on macOS. /// /// Integration testing on LUCI is not supported at the moment. // TODO: https://github.com/flutter/flutter/issues/63710 - bool get isSafariIntegrationTestAvailable => - (isSafariOnMacOS && isLuci && io.Platform.isLinux) || - (isSafariOnMacOS && !isLuci && !io.Platform.isWindows); + bool get isSafariIntegrationTestAvailable => isSafariOnMacOS && !isLuci; - /// Due to various factors integration tests might be missing on a given, + /// Due to various factors integration tests might be missing on a given /// platform and given environment. /// See: [isChromeIntegrationTestAvailable] /// See: [isSafariIntegrationTestAvailable] /// See: [isFirefoxIntegrationTestAvailable] bool get isIntegrationTestsAvailable => - isChrome && isChromeIntegrationTestAvailable || - isFirefox && isFirefoxIntegrationTestAvailable || - isSafariOnMacOS && isSafariIntegrationTestAvailable; + isChromeIntegrationTestAvailable || + isFirefoxIntegrationTestAvailable || + isSafariIntegrationTestAvailable; /// Use system flutter instead of cloning the repository. /// @@ -534,18 +529,18 @@ class TestCommand extends Command with ArgUtils { /// /// [targets] must not be null. /// - /// Uses `dart2js` for building the tests. + /// Uses `dart2js` for building the test. /// /// When building for CanvasKit we have to use extra argument /// `DFLUTTER_WEB_USE_SKIA=true`. Future _buildTest(TestBuildInput input) async { - final targetFileName = input.target.relativeToWebUi - .replaceFirst('.dart', '.dart.browser_test.dart.js'); + final targetFileName = + '${input.path.relativeToWebUi}.browser_test.dart.js'; final String targetPath = path.join('build', targetFileName); final io.Directory directoryToTarget = io.Directory(path.join( environment.webUiBuildDir.path, - path.dirname(input.target.relativeToWebUi))); + path.dirname(input.path.relativeToWebUi))); if (!directoryToTarget.existsSync()) { directoryToTarget.createSync(recursive: true); @@ -560,8 +555,8 @@ class TestCommand extends Command with ArgUtils { if (input.forCanvasKit) '-DFLUTTER_WEB_USE_SKIA=true', '-O2', '-o', - '${targetPath}', // target path. - '${input.target.relativeToWebUi}', // current path. + targetPath, // target path. + '${input.path.relativeToWebUi}', // current path. ]; final int exitCode = await runProcess( @@ -571,7 +566,7 @@ class TestCommand extends Command with ArgUtils { ); if (exitCode != 0) { - io.stderr.writeln('ERROR: Failed to compile test ${input.target}. ' + io.stderr.writeln('ERROR: Failed to compile test ${input.path}. ' 'Dart2js exited with exit code $exitCode'); return false; } else { @@ -648,16 +643,15 @@ void _copyTestFontsIntoWebUi() { } } -/// This objest is used as an input message to the PoolResources that are -/// building the tests. +/// Used as an input message to the PoolResources that are building a test. class TestBuildInput { - /// Target to build. - final FilePath target; + /// Test to build. + final FilePath path; /// Whether these tests should be build for CanvasKit. /// /// `-DFLUTTER_WEB_USE_SKIA=true` is passed to dart2js for CanvasKit. final bool forCanvasKit; - TestBuildInput(this.target, {this.forCanvasKit = false}); + TestBuildInput(this.path, {this.forCanvasKit = false}); } From 0553059f8b9cadaffcf70a3a54651d4f1ce7e6ce Mon Sep 17 00:00:00 2001 From: nturgut Date: Mon, 17 Aug 2020 15:11:50 -0700 Subject: [PATCH 25/25] change readme file --- lib/web_ui/dev/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/web_ui/dev/README.md b/lib/web_ui/dev/README.md index 5903f07e9327a..c230932e9231a 100644 --- a/lib/web_ui/dev/README.md +++ b/lib/web_ui/dev/README.md @@ -41,9 +41,7 @@ felt build [-w] -j 100 If you are a Google employee, you can use an internal instance of Goma to parallelize your builds. Because Goma compiles code on remote servers, this option is effective even on low-powered laptops. -By default, when compiling Dart code to JavaScript, we use 4 `dart2js` workers. -If you need to increase or reduce the number of workers, set the `BUILD_MAX_WORKERS_PER_TASK` -environment variable to the desired number. +By default, when compiling Dart code to JavaScript, we use 8 `dart2js` workers. ## Running web engine tests