diff --git a/ci/builders/linux_web_engine.json b/ci/builders/linux_web_engine.json index a47980e6dd244..f4159952eafc2 100644 --- a/ci/builders/linux_web_engine.json +++ b/ci/builders/linux_web_engine.json @@ -70,7 +70,7 @@ } }, { - "name": "web_tests/test_bundles/dart2js-html-engine", + "name": "web_tests/test_bundles/dart2js-html-html", "drone_dimensions": [ "device_type=none", "os=Linux" @@ -78,11 +78,11 @@ "generators": { "tasks": [ { - "name": "compile bundle dart2js-html-engine", + "name": "compile bundle dart2js-html-html", "parameters": [ "test", "--compile", - "--bundle=dart2js-html-engine" + "--bundle=dart2js-html-html" ], "scripts": [ "flutter/lib/web_ui/dev/felt" @@ -92,7 +92,7 @@ } }, { - "name": "web_tests/test_bundles/dart2js-html-html", + "name": "web_tests/test_bundles/dart2js-html-ui", "drone_dimensions": [ "device_type=none", "os=Linux" @@ -100,11 +100,11 @@ "generators": { "tasks": [ { - "name": "compile bundle dart2js-html-html", + "name": "compile bundle dart2js-html-ui", "parameters": [ "test", "--compile", - "--bundle=dart2js-html-html" + "--bundle=dart2js-html-ui" ], "scripts": [ "flutter/lib/web_ui/dev/felt" @@ -114,7 +114,7 @@ } }, { - "name": "web_tests/test_bundles/dart2js-html-ui", + "name": "web_tests/test_bundles/dart2js-canvaskit-engine", "drone_dimensions": [ "device_type=none", "os=Linux" @@ -122,11 +122,11 @@ "generators": { "tasks": [ { - "name": "compile bundle dart2js-html-ui", + "name": "compile bundle dart2js-canvaskit-engine", "parameters": [ "test", "--compile", - "--bundle=dart2js-html-ui" + "--bundle=dart2js-canvaskit-engine" ], "scripts": [ "flutter/lib/web_ui/dev/felt" @@ -180,7 +180,7 @@ } }, { - "name": "web_tests/test_bundles/dart2wasm-html-engine", + "name": "web_tests/test_bundles/dart2wasm-canvaskit-engine", "drone_dimensions": [ "device_type=none", "os=Linux" @@ -188,11 +188,11 @@ "generators": { "tasks": [ { - "name": "compile bundle dart2wasm-html-engine", + "name": "compile bundle dart2wasm-canvaskit-engine", "parameters": [ "test", "--compile", - "--bundle=dart2wasm-html-engine" + "--bundle=dart2wasm-canvaskit-engine" ], "scripts": [ "flutter/lib/web_ui/dev/felt" @@ -260,12 +260,12 @@ }, "dependencies": [ "web_tests/artifacts", - "web_tests/test_bundles/dart2js-html-engine", "web_tests/test_bundles/dart2js-html-html", "web_tests/test_bundles/dart2js-html-ui", + "web_tests/test_bundles/dart2js-canvaskit-engine", "web_tests/test_bundles/dart2js-canvaskit-canvaskit", "web_tests/test_bundles/dart2js-canvaskit-ui", - "web_tests/test_bundles/dart2wasm-html-engine", + "web_tests/test_bundles/dart2wasm-canvaskit-engine", "web_tests/test_bundles/dart2wasm-skwasm-ui", "web_tests/test_bundles/fallbacks" ], @@ -281,29 +281,29 @@ ], "tasks": [ { - "name": "run suite chrome-dart2js-html-engine", + "name": "run suite chrome-dart2js-html-html", "parameters": [ "test", "--run", - "--suite=chrome-dart2js-html-engine" + "--suite=chrome-dart2js-html-html" ], "script": "flutter/lib/web_ui/dev/felt" }, { - "name": "run suite chrome-dart2js-html-html", + "name": "run suite chrome-dart2js-html-ui", "parameters": [ "test", "--run", - "--suite=chrome-dart2js-html-html" + "--suite=chrome-dart2js-html-ui" ], "script": "flutter/lib/web_ui/dev/felt" }, { - "name": "run suite chrome-dart2js-html-ui", + "name": "run suite chrome-dart2js-canvaskit-engine", "parameters": [ "test", "--run", - "--suite=chrome-dart2js-html-ui" + "--suite=chrome-dart2js-canvaskit-engine" ], "script": "flutter/lib/web_ui/dev/felt" }, @@ -344,11 +344,11 @@ "script": "flutter/lib/web_ui/dev/felt" }, { - "name": "run suite chrome-dart2wasm-html-engine", + "name": "run suite chrome-dart2wasm-canvaskit-engine", "parameters": [ "test", "--run", - "--suite=chrome-dart2wasm-html-engine" + "--suite=chrome-dart2wasm-canvaskit-engine" ], "script": "flutter/lib/web_ui/dev/felt" }, @@ -412,9 +412,9 @@ }, "dependencies": [ "web_tests/artifacts", - "web_tests/test_bundles/dart2js-html-engine", "web_tests/test_bundles/dart2js-html-html", "web_tests/test_bundles/dart2js-html-ui", + "web_tests/test_bundles/dart2js-canvaskit-engine", "web_tests/test_bundles/dart2js-canvaskit-canvaskit", "web_tests/test_bundles/dart2js-canvaskit-ui", "web_tests/test_bundles/fallbacks" @@ -431,29 +431,29 @@ ], "tasks": [ { - "name": "run suite firefox-dart2js-html-engine", + "name": "run suite firefox-dart2js-html-html", "parameters": [ "test", "--run", - "--suite=firefox-dart2js-html-engine" + "--suite=firefox-dart2js-html-html" ], "script": "flutter/lib/web_ui/dev/felt" }, { - "name": "run suite firefox-dart2js-html-html", + "name": "run suite firefox-dart2js-html-ui", "parameters": [ "test", "--run", - "--suite=firefox-dart2js-html-html" + "--suite=firefox-dart2js-html-ui" ], "script": "flutter/lib/web_ui/dev/felt" }, { - "name": "run suite firefox-dart2js-html-ui", + "name": "run suite firefox-dart2js-canvaskit-engine", "parameters": [ "test", "--run", - "--suite=firefox-dart2js-html-ui" + "--suite=firefox-dart2js-canvaskit-engine" ], "script": "flutter/lib/web_ui/dev/felt" }, @@ -500,9 +500,9 @@ }, "dependencies": [ "web_tests/artifacts", - "web_tests/test_bundles/dart2js-html-engine", "web_tests/test_bundles/dart2js-html-html", "web_tests/test_bundles/dart2js-html-ui", + "web_tests/test_bundles/dart2js-canvaskit-engine", "web_tests/test_bundles/dart2js-canvaskit-canvaskit", "web_tests/test_bundles/dart2js-canvaskit-ui", "web_tests/test_bundles/fallbacks" @@ -515,29 +515,29 @@ ], "tasks": [ { - "name": "run suite safari-dart2js-html-engine", + "name": "run suite safari-dart2js-html-html", "parameters": [ "test", "--run", - "--suite=safari-dart2js-html-engine" + "--suite=safari-dart2js-html-html" ], "script": "flutter/lib/web_ui/dev/felt" }, { - "name": "run suite safari-dart2js-html-html", + "name": "run suite safari-dart2js-html-ui", "parameters": [ "test", "--run", - "--suite=safari-dart2js-html-html" + "--suite=safari-dart2js-html-ui" ], "script": "flutter/lib/web_ui/dev/felt" }, { - "name": "run suite safari-dart2js-html-ui", + "name": "run suite safari-dart2js-canvaskit-engine", "parameters": [ "test", "--run", - "--suite=safari-dart2js-html-ui" + "--suite=safari-dart2js-canvaskit-engine" ], "script": "flutter/lib/web_ui/dev/felt" }, @@ -583,12 +583,12 @@ }, "dependencies": [ "web_tests/artifacts", - "web_tests/test_bundles/dart2js-html-engine", "web_tests/test_bundles/dart2js-html-html", "web_tests/test_bundles/dart2js-html-ui", + "web_tests/test_bundles/dart2js-canvaskit-engine", "web_tests/test_bundles/dart2js-canvaskit-canvaskit", "web_tests/test_bundles/dart2js-canvaskit-ui", - "web_tests/test_bundles/dart2wasm-html-engine", + "web_tests/test_bundles/dart2wasm-canvaskit-engine", "web_tests/test_bundles/dart2wasm-skwasm-ui", "web_tests/test_bundles/fallbacks" ], @@ -604,29 +604,29 @@ ], "tasks": [ { - "name": "run suite chrome-dart2js-html-engine", + "name": "run suite chrome-dart2js-html-html", "parameters": [ "test", "--run", - "--suite=chrome-dart2js-html-engine" + "--suite=chrome-dart2js-html-html" ], "script": "flutter/lib/web_ui/dev/felt" }, { - "name": "run suite chrome-dart2js-html-html", + "name": "run suite chrome-dart2js-html-ui", "parameters": [ "test", "--run", - "--suite=chrome-dart2js-html-html" + "--suite=chrome-dart2js-html-ui" ], "script": "flutter/lib/web_ui/dev/felt" }, { - "name": "run suite chrome-dart2js-html-ui", + "name": "run suite chrome-dart2js-canvaskit-engine", "parameters": [ "test", "--run", - "--suite=chrome-dart2js-html-ui" + "--suite=chrome-dart2js-canvaskit-engine" ], "script": "flutter/lib/web_ui/dev/felt" }, @@ -667,11 +667,11 @@ "script": "flutter/lib/web_ui/dev/felt" }, { - "name": "run suite chrome-dart2wasm-html-engine", + "name": "run suite chrome-dart2wasm-canvaskit-engine", "parameters": [ "test", "--run", - "--suite=chrome-dart2wasm-html-engine" + "--suite=chrome-dart2wasm-canvaskit-engine" ], "script": "flutter/lib/web_ui/dev/felt" }, diff --git a/lib/web_ui/dev/test_platform.dart b/lib/web_ui/dev/test_platform.dart index adde6032593c1..d1e4396648ee7 100644 --- a/lib/web_ui/dev/test_platform.dart +++ b/lib/web_ui/dev/test_platform.dart @@ -89,7 +89,7 @@ class BrowserPlatform extends PlatformPlugin { .add(_createSourceHandler()) // Serves files from the root of web_ui. Some tests download assets that are embedded - // directly in the test folder, such as test/engine/image/sample_image1.png etc + // directly in the test folder, such as test/html/image/sample_image1.png etc .add(createStaticHandler(env.environment.webUiRootDir.path)) // Serves absolute package URLs (i.e. not /packages/* but /Users/user/*/hosted/pub.dartlang.org/*). diff --git a/lib/web_ui/test/canvaskit/semantics_test.dart b/lib/web_ui/test/canvaskit/semantics_test.dart deleted file mode 100644 index ce4b8598de419..0000000000000 --- a/lib/web_ui/test/canvaskit/semantics_test.dart +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -@TestOn('chrome || safari || firefox') -library; - -import 'dart:async'; - -import 'package:test/bootstrap/browser.dart'; -import 'package:test/test.dart'; - -import '../engine/semantics/semantics_test.dart'; -import 'common.dart'; - -void main() { - internalBootstrapBrowserTest(() => testMain); -} - -// Run the same semantics tests in CanvasKit mode because as of today we do not -// yet share platform view logic with the HTML renderer, which affects -// semantics. -Future testMain() async { - group('CanvasKit semantics', () { - setUpCanvasKitTest(withImplicitView: true); - - runSemanticsTests(); - }); -} diff --git a/lib/web_ui/test/common/test_initialization.dart b/lib/web_ui/test/common/test_initialization.dart index 2f0c943462151..a766291c0263d 100644 --- a/lib/web_ui/test/common/test_initialization.dart +++ b/lib/web_ui/test/common/test_initialization.dart @@ -51,6 +51,23 @@ void setUpUnitTests({ }); } +void setUpImplicitView() { + late engine.EngineFlutterWindow myWindow; + + final engine.EnginePlatformDispatcher dispatcher = engine.EnginePlatformDispatcher.instance; + + setUp(() { + myWindow = engine.EngineFlutterView.implicit(dispatcher, null); + dispatcher.viewManager.registerView(myWindow); + }); + + tearDown(() async { + dispatcher.viewManager.unregisterView(myWindow.viewId); + await myWindow.resetHistory(); + myWindow.dispose(); + }); +} + Future bootstrapAndRunApp({bool withImplicitView = false}) async { final Completer completer = Completer(); await ui_web.bootstrapEngine(runApp: () => completer.complete()); diff --git a/lib/web_ui/test/engine/clipboard_test.dart b/lib/web_ui/test/engine/clipboard_test.dart index bad7902156ca6..61357850cc635 100644 --- a/lib/web_ui/test/engine/clipboard_test.dart +++ b/lib/web_ui/test/engine/clipboard_test.dart @@ -16,7 +16,7 @@ void main() { } Future testMain() async { - setUpUnitTests(); + setUpImplicitView(); group('message handler', () { const String testText = 'test text'; diff --git a/lib/web_ui/test/engine/composition_test.dart b/lib/web_ui/test/engine/composition_test.dart index 4785ed9acd14e..57451e0751613 100644 --- a/lib/web_ui/test/engine/composition_test.dart +++ b/lib/web_ui/test/engine/composition_test.dart @@ -51,7 +51,7 @@ GloballyPositionedTextEditingStrategy _enableEditingStrategy({ } Future testMain() async { - await bootstrapAndRunApp(withImplicitView: true); + setUpImplicitView(); const String fakeComposingText = 'ImComposingText'; @@ -323,6 +323,14 @@ Future testMain() async { _inputElement.dispatchEvent(createDomCompositionEvent( _MockWithCompositionAwareMixin._kCompositionUpdate, { 'data': newComposingText })); + // On Chrome and Safari, a `compositionupdate` event automatically + // triggers a `selectionchange` event, which leads to triggering + // `DefaultTextEditingStrategy.handleChange`. + // + // But in Firefox, `selectionchange` event is not triggered, so we need to + // manually dispatch an `input` event to trigger + // `DefaultTextEditingStrategy.handleChange`. + _inputElement.dispatchEvent(createDomInputEvent('input')); await containExpect; }); diff --git a/lib/web_ui/test/engine/dom_http_fetch_test.dart b/lib/web_ui/test/engine/dom_http_fetch_test.dart index fbe48969d4890..ac2bf7ac33dda 100644 --- a/lib/web_ui/test/engine/dom_http_fetch_test.dart +++ b/lib/web_ui/test/engine/dom_http_fetch_test.dart @@ -9,15 +9,11 @@ import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; -import '../common/test_initialization.dart'; - void main() { internalBootstrapBrowserTest(() => testMain); } Future testMain() async { - await bootstrapAndRunApp(); - // Test successful HTTP roundtrips where the server returns a happy status // code and a payload. await _testSuccessfulPayloads(); diff --git a/lib/web_ui/test/engine/history_test.dart b/lib/web_ui/test/engine/history_test.dart index 91b99f36cfeb5..4d3e80fa9955d 100644 --- a/lib/web_ui/test/engine/history_test.dart +++ b/lib/web_ui/test/engine/history_test.dart @@ -37,9 +37,7 @@ void main() { } void testMain() { - setUpAll(() async { - await bootstrapAndRunApp(withImplicitView: true); - }); + setUpImplicitView(); test('createHistoryForExistingState', () { TestUrlStrategy strategy; diff --git a/lib/web_ui/test/engine/image_format_detector_test.dart b/lib/web_ui/test/engine/image_format_detector_test.dart index 3781dac016aef..f2aac31955147 100644 --- a/lib/web_ui/test/engine/image_format_detector_test.dart +++ b/lib/web_ui/test/engine/image_format_detector_test.dart @@ -17,7 +17,7 @@ void main() { List? testFiles; Future testMain() async { - setUpUnitTests(); + setUpImplicitView(); Future> createTestFiles() async { final HttpFetchResponse listingResponse = await httpFetch('/test_images/'); diff --git a/lib/web_ui/test/engine/image_to_byte_data_test.dart b/lib/web_ui/test/engine/image_to_byte_data_test.dart index 306e50c560ec2..13c61ccddf9c8 100644 --- a/lib/web_ui/test/engine/image_to_byte_data_test.dart +++ b/lib/web_ui/test/engine/image_to_byte_data_test.dart @@ -16,7 +16,7 @@ void main() { } Future testMain() async { - setUpUnitTests(); + setUpImplicitView(); Future createTestImageByColor(Color color) async { final EnginePictureRecorder recorder = EnginePictureRecorder(); diff --git a/lib/web_ui/test/engine/initialization_test.dart b/lib/web_ui/test/engine/initialization_test.dart index 6f889fce724ed..2fbb2f76e15f6 100644 --- a/lib/web_ui/test/engine/initialization_test.dart +++ b/lib/web_ui/test/engine/initialization_test.dart @@ -52,7 +52,8 @@ void testMain() { expect(engineInitializer, isNotNull); expect(js_util.hasProperty(engineInitializer!, 'initializeEngine'), isTrue, reason: 'Missing FlutterEngineInitializer method: initializeEngine.'); expect(js_util.hasProperty(engineInitializer!, 'autoStart'), isTrue, reason: 'Missing FlutterEngineInitializer method: autoStart.'); - }); + // https://github.com/flutter/flutter/issues/160096 + }, skip: ui_web.browser.isFirefox); test('bootstrapEngine does auto-start when _flutter.loader.didCreateEngineInitializer does not exist', () async { loader = null; @@ -81,7 +82,8 @@ void testMain() { // After starting the engine, the meta-generator tag should be on the page final DomElement? meta = domDocument.querySelector('meta[name=generator][content=Flutter]'); expect(meta, isNotNull, reason: 'The generator meta-tag should be added when Flutter initializes its UI.'); - }); + // https://github.com/flutter/flutter/issues/160096 + }, skip: ui_web.browser.isFirefox); // We cannot test anymore, because by now the engine has registered some stuff that can't be rewound back. // Like the `ext.flutter.disassemble` developer extension. diff --git a/lib/web_ui/test/engine/navigation_test.dart b/lib/web_ui/test/engine/navigation_test.dart index e3386e6c21c8e..d1d93fc7dc14d 100644 --- a/lib/web_ui/test/engine/navigation_test.dart +++ b/lib/web_ui/test/engine/navigation_test.dart @@ -43,19 +43,13 @@ void testMain() { group('with implicit view', () { late TestUrlStrategy strategy; - setUpAll(() async { - await bootstrapAndRunApp(withImplicitView: true); - }); + setUpImplicitView(); setUp(() async { strategy = TestUrlStrategy(); await implicitView.debugInitializeHistory(strategy, useSingle: true); }); - tearDown(() async { - await implicitView.resetHistory(); - }); - test('Tracks pushed, replaced and popped routes', () async { final Completer completer = Completer(); ui.PlatformDispatcher.instance.sendPlatformMessage( diff --git a/lib/web_ui/test/engine/platform_dispatcher/platform_dispatcher_test.dart b/lib/web_ui/test/engine/platform_dispatcher/platform_dispatcher_test.dart index c9f9e69f5b4ad..ea2e9b7037c0d 100644 --- a/lib/web_ui/test/engine/platform_dispatcher/platform_dispatcher_test.dart +++ b/lib/web_ui/test/engine/platform_dispatcher/platform_dispatcher_test.dart @@ -9,6 +9,7 @@ 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:ui/ui_web/src/ui_web.dart' as ui_web; import '../../common/test_initialization.dart'; @@ -17,13 +18,13 @@ void main() { } void testMain() { - setUpAll(() async { - await bootstrapAndRunApp(withImplicitView: true); - }); - group('PlatformDispatcher', () { late EnginePlatformDispatcher dispatcher; + setUpAll(() async { + await bootstrapAndRunApp(withImplicitView: true); + }); + setUp(() { dispatcher = EnginePlatformDispatcher(); }); @@ -435,7 +436,8 @@ void testMain() { expect(beginFrameCalled, true); expect(drawFrameCalled.isCompleted, true); }); - }); + // https://github.com/flutter/flutter/issues/160096 + }, skip: ui_web.browser.isFirefox); } class MockHighContrastSupport implements HighContrastSupport { diff --git a/lib/web_ui/test/engine/platform_views/content_manager_test.dart b/lib/web_ui/test/engine/platform_views/content_manager_test.dart index 6c214419c904d..544ab026fda20 100644 --- a/lib/web_ui/test/engine/platform_views/content_manager_test.dart +++ b/lib/web_ui/test/engine/platform_views/content_manager_test.dart @@ -14,9 +14,7 @@ void main() { } void testMain() { - setUpAll(() async { - await bootstrapAndRunApp(); - }); + setUpImplicitView(); group('PlatformViewManager', () { const String viewType = 'forTest'; diff --git a/lib/web_ui/test/engine/routing_test.dart b/lib/web_ui/test/engine/routing_test.dart index 5620868b0685a..641d922e0fc8b 100644 --- a/lib/web_ui/test/engine/routing_test.dart +++ b/lib/web_ui/test/engine/routing_test.dart @@ -11,8 +11,11 @@ import 'package:ui/ui.dart' as ui; import 'package:ui/ui_web/src/ui_web.dart' as ui_web; import '../common/matchers.dart'; +import '../common/test_initialization.dart'; import 'history_test.dart'; +EngineFlutterWindow get myWindow => EnginePlatformDispatcher.instance.implicitView!; + Map _tagStateWithSerialCount(dynamic state, int serialCount) { return { 'serialCount': serialCount, @@ -25,20 +28,7 @@ void main() { } void testMain() { - late EngineFlutterWindow myWindow; - - final EnginePlatformDispatcher dispatcher = EnginePlatformDispatcher.instance; - - setUp(() { - myWindow = EngineFlutterView.implicit(dispatcher, createDomHTMLDivElement()); - dispatcher.viewManager.registerView(myWindow); - }); - - tearDown(() async { - dispatcher.viewManager.unregisterView(myWindow.viewId); - await myWindow.resetHistory(); - myWindow.dispose(); - }); + setUpImplicitView(); // For now, web always has an implicit view provided by the web engine. test('EnginePlatformDispatcher.instance.implicitView should be non-null', () async { diff --git a/lib/web_ui/test/engine/scene_view_test.dart b/lib/web_ui/test/engine/scene_view_test.dart index 76e3b250d3dc3..1b253478ed348 100644 --- a/lib/web_ui/test/engine/scene_view_test.dart +++ b/lib/web_ui/test/engine/scene_view_test.dart @@ -154,9 +154,7 @@ void testMain() { late EngineSceneView sceneView; late StubPictureRenderer stubPictureRenderer; - setUpAll(() async { - await bootstrapAndRunApp(withImplicitView: true); - }); + setUpImplicitView(); setUp(() { stubPictureRenderer = StubPictureRenderer(); diff --git a/lib/web_ui/test/engine/semantics/semantics_auto_enable_test.dart b/lib/web_ui/test/engine/semantics/semantics_auto_enable_test.dart index bdd35a9fbbcca..00c4708027a57 100644 --- a/lib/web_ui/test/engine/semantics/semantics_auto_enable_test.dart +++ b/lib/web_ui/test/engine/semantics/semantics_auto_enable_test.dart @@ -22,7 +22,7 @@ void main() { } Future testMain() async { - await bootstrapAndRunApp(withImplicitView: true); + setUpImplicitView(); test('EngineSemanticsOwner auto-enables semantics on update', () async { expect(semantics().semanticsEnabled, isFalse); diff --git a/lib/web_ui/test/engine/semantics/semantics_multi_view_test.dart b/lib/web_ui/test/engine/semantics/semantics_multi_view_test.dart index 56f940f37ee27..fc38923e6e8fc 100644 --- a/lib/web_ui/test/engine/semantics/semantics_multi_view_test.dart +++ b/lib/web_ui/test/engine/semantics/semantics_multi_view_test.dart @@ -10,7 +10,6 @@ import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; -import '../../common/test_initialization.dart'; import 'semantics_tester.dart'; void main() { @@ -20,8 +19,6 @@ void main() { } Future testMain() async { - await bootstrapAndRunApp(); - test('Can create multiple views each with its own semantics tree', () async { EngineSemantics.instance.semanticsEnabled = true; diff --git a/lib/web_ui/test/engine/semantics/semantics_placeholder_enable_test.dart b/lib/web_ui/test/engine/semantics/semantics_placeholder_enable_test.dart index ca0943fb56a40..b72726ed5736d 100644 --- a/lib/web_ui/test/engine/semantics/semantics_placeholder_enable_test.dart +++ b/lib/web_ui/test/engine/semantics/semantics_placeholder_enable_test.dart @@ -20,7 +20,7 @@ void main() { } Future testMain() async { - await bootstrapAndRunApp(withImplicitView: true); + setUpImplicitView(); test('EngineSemantics is enabled via a placeholder click', () async { expect(semantics().semanticsEnabled, isFalse); diff --git a/lib/web_ui/test/engine/semantics/semantics_test.dart b/lib/web_ui/test/engine/semantics/semantics_test.dart index 5975b9f6a2581..104fd56505685 100644 --- a/lib/web_ui/test/engine/semantics/semantics_test.dart +++ b/lib/web_ui/test/engine/semantics/semantics_test.dart @@ -35,6 +35,12 @@ void main() { } Future testMain() async { + if (ui_web.browser.isFirefox) { + // Firefox gets stuck in bootstrapAndRunApp for a mysterious reason. + // https://github.com/flutter/flutter/issues/160096 + return; + } + await bootstrapAndRunApp(withImplicitView: true); setUpRenderingForTests(); runSemanticsTests(); diff --git a/lib/web_ui/test/engine/semantics/semantics_text_test.dart b/lib/web_ui/test/engine/semantics/semantics_text_test.dart index 599d1f7dc66ca..8c4a97f8f73de 100644 --- a/lib/web_ui/test/engine/semantics/semantics_text_test.dart +++ b/lib/web_ui/test/engine/semantics/semantics_text_test.dart @@ -10,7 +10,6 @@ import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; -import '../../common/rendering.dart'; import '../../common/test_initialization.dart'; import 'semantics_tester.dart'; @@ -25,8 +24,7 @@ void main() { } Future testMain() async { - await bootstrapAndRunApp(withImplicitView: true); - setUpRenderingForTests(); + setUpImplicitView(); test('renders label text as DOM', () async { semantics() diff --git a/lib/web_ui/test/engine/semantics/text_field_test.dart b/lib/web_ui/test/engine/semantics/text_field_test.dart index 38cef56fa80e3..458e4f1ed4685 100644 --- a/lib/web_ui/test/engine/semantics/text_field_test.dart +++ b/lib/web_ui/test/engine/semantics/text_field_test.dart @@ -9,6 +9,7 @@ import 'package:test/bootstrap/browser.dart'; import 'package:test/test.dart'; import 'package:ui/src/engine.dart' hide window; import 'package:ui/ui.dart' as ui; +import 'package:ui/ui_web/src/ui_web.dart' as ui_web; import '../../common/test_initialization.dart'; import 'semantics_tester.dart'; @@ -35,9 +36,7 @@ void main() { } void testMain() { - setUpAll(() async { - await bootstrapAndRunApp(withImplicitView: true); - }); + setUpImplicitView(); setUp(() { EngineSemantics.debugResetSemantics(); @@ -474,7 +473,8 @@ void testMain() { ); strategy.disable(); - }); + // Firefox strips out `-webkit-text-security` from outerHTML. + }, skip: ui_web.browser.browserEngine == ui_web.BrowserEngine.firefox); test('Does not position or size its DOM element', () { strategy.enable( diff --git a/lib/web_ui/test/engine/surface/platform_view_test.dart b/lib/web_ui/test/engine/surface/platform_view_test.dart index 9281d73bb5ebe..88078efb036ef 100644 --- a/lib/web_ui/test/engine/surface/platform_view_test.dart +++ b/lib/web_ui/test/engine/surface/platform_view_test.dart @@ -10,20 +10,11 @@ import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; import 'package:ui/ui_web/src/ui_web.dart' as ui_web; -import '../../common/matchers.dart'; -import '../../common/test_initialization.dart'; - -const MethodCodec codec = StandardMethodCodec(); - void main() { internalBootstrapBrowserTest(() => testMain); } Future testMain() async { - await bootstrapAndRunApp(withImplicitView: true); - - late PersistedPlatformView view; - test('importing platformViewRegistry from dart:ui is deprecated', () { final void Function(String) oldPrintWarning = printWarning; @@ -45,75 +36,4 @@ Future testMain() async { printWarning = oldPrintWarning; }); - - group('PersistedPlatformView', () { - setUp(() async { - ui_web.platformViewRegistry.registerViewFactory( - 'test-0', - (int viewId) => createDomHTMLDivElement(), - ); - ui_web.platformViewRegistry.registerViewFactory( - 'test-1', - (int viewId) => createDomHTMLDivElement(), - ); - // Ensure the views are created... - await Future.wait(>[ - _createPlatformView(0, 'test-0'), - _createPlatformView(1, 'test-1'), - ]); - view = PersistedPlatformView(0, 0, 0, 100, 100)..build(); - }); - - group('update', () { - test('throws assertion error if called with different viewIds', () { - final PersistedPlatformView differentView = PersistedPlatformView(1, 1, 1, 100, 100)..build(); - expect(() { - view.update(differentView); - }, throwsAssertionError); - }); - }); - - group('canUpdateAsMatch', () { - test('returns true when viewId is the same', () { - final PersistedPlatformView sameView = PersistedPlatformView(0, 1, 1, 100, 100)..build(); - expect(view.canUpdateAsMatch(sameView), isTrue); - }); - - test('returns false when viewId is different', () { - final PersistedPlatformView differentView = PersistedPlatformView(1, 1, 1, 100, 100)..build(); - expect(view.canUpdateAsMatch(differentView), isFalse); - }); - - test('returns false when other view is not a PlatformView', () { - final PersistedOpacity anyView = PersistedOpacity(null, 1, ui.Offset.zero)..build(); - expect(view.canUpdateAsMatch(anyView), isFalse); - }); - }); - - group('createElement', () { - test('creates slot element that can receive pointer events', () { - final DomElement element = view.createElement(); - - expect(element.tagName, equalsIgnoringCase('flt-platform-view-slot')); - expect(element.style.pointerEvents, 'auto'); - }); - }); - }); -} - -// Sends a platform message to create a Platform View with the given id and viewType. -Future _createPlatformView(int id, String viewType) { - final Completer completer = Completer(); - ui.PlatformDispatcher.instance.sendPlatformMessage( - 'flutter/platform_views', - codec.encodeMethodCall(MethodCall( - 'create', - { - 'id': id, - 'viewType': viewType, - }, - )), - (dynamic _) => completer.complete(), - ); - return completer.future; } diff --git a/lib/web_ui/test/engine/text_editing_test.dart b/lib/web_ui/test/engine/text_editing_test.dart index bea5f02bf0d66..41b88887bf68a 100644 --- a/lib/web_ui/test/engine/text_editing_test.dart +++ b/lib/web_ui/test/engine/text_editing_test.dart @@ -64,11 +64,7 @@ void main() { } Future testMain() async { - setUpUnitTests( - withImplicitView: true, - emulateTesterEnvironment: false, - setUpTestViewDimensions: false - ); + setUpImplicitView(); setUp(() { domDocument.activeElement?.blur(); diff --git a/lib/web_ui/test/engine/window_test.dart b/lib/web_ui/test/engine/window_test.dart index 299490dc00c66..905c1416f7ba2 100644 --- a/lib/web_ui/test/engine/window_test.dart +++ b/lib/web_ui/test/engine/window_test.dart @@ -466,7 +466,7 @@ Future testMain() async { final DomElement host = createDomHTMLDivElement(); final EngineFlutterView view = EngineFlutterView(dispatcher, host); - expect(host.getAttribute('flt-renderer'), 'html (requested explicitly)'); + expect(host.getAttribute('flt-renderer'), 'canvaskit (requested explicitly)'); expect(host.getAttribute('flt-build-mode'), 'debug'); view.dispose(); diff --git a/lib/web_ui/test/felt_config.yaml b/lib/web_ui/test/felt_config.yaml index b081865921f76..5836919a36cf5 100644 --- a/lib/web_ui/test/felt_config.yaml +++ b/lib/web_ui/test/felt_config.yaml @@ -13,9 +13,9 @@ compile-configs: compiler: dart2js renderer: skwasm - - name: dart2wasm-html + - name: dart2wasm-canvaskit compiler: dart2wasm - renderer: html + renderer: canvaskit - name: dart2wasm-skwasm compiler: dart2wasm @@ -43,10 +43,6 @@ test-sets: directory: fallbacks test-bundles: - - name: dart2js-html-engine - test-set: engine - compile-configs: dart2js-html - - name: dart2js-html-html test-set: html compile-configs: dart2js-html @@ -55,6 +51,10 @@ test-bundles: test-set: ui compile-configs: dart2js-html + - name: dart2js-canvaskit-engine + test-set: engine + compile-configs: dart2js-canvaskit + - name: dart2js-canvaskit-canvaskit test-set: canvaskit compile-configs: dart2js-canvaskit @@ -63,9 +63,9 @@ test-bundles: test-set: ui compile-configs: dart2js-canvaskit - - name: dart2wasm-html-engine + - name: dart2wasm-canvaskit-engine test-set: engine - compile-configs: dart2wasm-html + compile-configs: dart2wasm-canvaskit - name: dart2wasm-skwasm-ui test-set: ui @@ -114,10 +114,6 @@ run-configs: canvaskit-variant: full test-suites: - - name: chrome-dart2js-html-engine - test-bundle: dart2js-html-engine - run-config: chrome - - name: chrome-dart2js-html-html test-bundle: dart2js-html-html run-config: chrome @@ -126,6 +122,11 @@ test-suites: test-bundle: dart2js-html-ui run-config: chrome + - name: chrome-dart2js-canvaskit-engine + test-bundle: dart2js-canvaskit-engine + run-config: chrome + artifact-deps: [ canvaskit_chromium ] + - name: chrome-dart2js-canvaskit-canvaskit test-bundle: dart2js-canvaskit-canvaskit run-config: chrome @@ -146,10 +147,6 @@ test-suites: run-config: chrome-full artifact-deps: [ canvaskit ] - - name: edge-dart2js-html-engine - test-bundle: dart2js-html-engine - run-config: edge - - name: edge-dart2js-html-html test-bundle: dart2js-html-html run-config: edge @@ -158,6 +155,11 @@ test-suites: test-bundle: dart2js-html-ui run-config: edge + - name: edge-dart2js-canvaskit-engine + test-bundle: dart2js-canvaskit-engine + run-config: edge + artifact-deps: [ canvaskit_chromium ] + - name: edge-dart2js-canvaskit-canvaskit test-bundle: dart2js-canvaskit-canvaskit run-config: edge @@ -178,10 +180,6 @@ test-suites: run-config: edge-full artifact-deps: [ canvaskit ] - - name: firefox-dart2js-html-engine - test-bundle: dart2js-html-engine - run-config: firefox - - name: firefox-dart2js-html-html test-bundle: dart2js-html-html run-config: firefox @@ -190,6 +188,11 @@ test-suites: test-bundle: dart2js-html-ui run-config: firefox + - name: firefox-dart2js-canvaskit-engine + test-bundle: dart2js-canvaskit-engine + run-config: firefox + artifact-deps: [ canvaskit ] + - name: firefox-dart2js-canvaskit-canvaskit test-bundle: dart2js-canvaskit-canvaskit run-config: firefox @@ -200,10 +203,6 @@ test-suites: run-config: firefox artifact-deps: [ canvaskit ] - - name: safari-dart2js-html-engine - test-bundle: dart2js-html-engine - run-config: safari - - name: safari-dart2js-html-html test-bundle: dart2js-html-html run-config: safari @@ -212,6 +211,11 @@ test-suites: test-bundle: dart2js-html-ui run-config: safari + - name: safari-dart2js-canvaskit-engine + test-bundle: dart2js-canvaskit-engine + run-config: safari + artifact-deps: [ canvaskit ] + - name: safari-dart2js-canvaskit-canvaskit test-bundle: dart2js-canvaskit-canvaskit run-config: safari @@ -222,9 +226,10 @@ test-suites: run-config: safari artifact-deps: [ canvaskit ] - - name: chrome-dart2wasm-html-engine - test-bundle: dart2wasm-html-engine + - name: chrome-dart2wasm-canvaskit-engine + test-bundle: dart2wasm-canvaskit-engine run-config: chrome + artifact-deps: [ canvaskit_chromium ] - name: chrome-coi-dart2wasm-skwasm-ui test-bundle: dart2wasm-skwasm-ui diff --git a/lib/web_ui/test/engine/canvas_test.dart b/lib/web_ui/test/html/canvas_test.dart similarity index 100% rename from lib/web_ui/test/engine/canvas_test.dart rename to lib/web_ui/test/html/canvas_test.dart diff --git a/lib/web_ui/test/engine/image/html_image_element_codec_test.dart b/lib/web_ui/test/html/image/html_image_element_codec_test.dart similarity index 100% rename from lib/web_ui/test/engine/image/html_image_element_codec_test.dart rename to lib/web_ui/test/html/image/html_image_element_codec_test.dart diff --git a/lib/web_ui/test/engine/image/sample_image1.png b/lib/web_ui/test/html/image/sample_image1.png similarity index 100% rename from lib/web_ui/test/engine/image/sample_image1.png rename to lib/web_ui/test/html/image/sample_image1.png diff --git a/lib/web_ui/test/engine/recording_canvas_test.dart b/lib/web_ui/test/html/recording_canvas_test.dart similarity index 100% rename from lib/web_ui/test/engine/recording_canvas_test.dart rename to lib/web_ui/test/html/recording_canvas_test.dart diff --git a/lib/web_ui/test/engine/surface/path/path_iterator_test.dart b/lib/web_ui/test/html/surface/path/path_iterator_test.dart similarity index 100% rename from lib/web_ui/test/engine/surface/path/path_iterator_test.dart rename to lib/web_ui/test/html/surface/path/path_iterator_test.dart diff --git a/lib/web_ui/test/engine/surface/path/path_winding_test.dart b/lib/web_ui/test/html/surface/path/path_winding_test.dart similarity index 100% rename from lib/web_ui/test/engine/surface/path/path_winding_test.dart rename to lib/web_ui/test/html/surface/path/path_winding_test.dart diff --git a/lib/web_ui/test/html/surface/platform_view_test.dart b/lib/web_ui/test/html/surface/platform_view_test.dart new file mode 100644 index 0000000000000..fe2a04508c264 --- /dev/null +++ b/lib/web_ui/test/html/surface/platform_view_test.dart @@ -0,0 +1,97 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:async'; + +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:ui/ui_web/src/ui_web.dart' as ui_web; + +import '../../common/matchers.dart'; +import '../../common/test_initialization.dart'; + +const MethodCodec codec = StandardMethodCodec(); + +void main() { + internalBootstrapBrowserTest(() => testMain); +} + +Future testMain() async { + await bootstrapAndRunApp(withImplicitView: true); + + late PersistedPlatformView view; + + group('PersistedPlatformView', () { + setUp(() async { + ui_web.platformViewRegistry.registerViewFactory( + 'test-0', + (int viewId) => createDomHTMLDivElement(), + ); + ui_web.platformViewRegistry.registerViewFactory( + 'test-1', + (int viewId) => createDomHTMLDivElement(), + ); + // Ensure the views are created... + await Future.wait(>[ + _createPlatformView(0, 'test-0'), + _createPlatformView(1, 'test-1'), + ]); + view = PersistedPlatformView(0, 0, 0, 100, 100)..build(); + }); + + group('update', () { + test('throws assertion error if called with different viewIds', () { + final PersistedPlatformView differentView = PersistedPlatformView(1, 1, 1, 100, 100)..build(); + expect(() { + view.update(differentView); + }, throwsAssertionError); + }); + }); + + group('canUpdateAsMatch', () { + test('returns true when viewId is the same', () { + final PersistedPlatformView sameView = PersistedPlatformView(0, 1, 1, 100, 100)..build(); + expect(view.canUpdateAsMatch(sameView), isTrue); + }); + + test('returns false when viewId is different', () { + final PersistedPlatformView differentView = PersistedPlatformView(1, 1, 1, 100, 100)..build(); + expect(view.canUpdateAsMatch(differentView), isFalse); + }); + + test('returns false when other view is not a PlatformView', () { + final PersistedOpacity anyView = PersistedOpacity(null, 1, ui.Offset.zero)..build(); + expect(view.canUpdateAsMatch(anyView), isFalse); + }); + }); + + group('createElement', () { + test('creates slot element that can receive pointer events', () { + final DomElement element = view.createElement(); + + expect(element.tagName, equalsIgnoringCase('flt-platform-view-slot')); + expect(element.style.pointerEvents, 'auto'); + }); + }); + }); +} + +// Sends a platform message to create a Platform View with the given id and viewType. +Future _createPlatformView(int id, String viewType) { + final Completer completer = Completer(); + ui.PlatformDispatcher.instance.sendPlatformMessage( + 'flutter/platform_views', + codec.encodeMethodCall(MethodCall( + 'create', + { + 'id': id, + 'viewType': viewType, + }, + )), + (dynamic _) => completer.complete(), + ); + return completer.future; +} diff --git a/lib/web_ui/test/engine/surface/scene_builder_test.dart b/lib/web_ui/test/html/surface/scene_builder_test.dart similarity index 100% rename from lib/web_ui/test/engine/surface/scene_builder_test.dart rename to lib/web_ui/test/html/surface/scene_builder_test.dart diff --git a/lib/web_ui/test/engine/surface/shaders/normalized_gradient_test.dart b/lib/web_ui/test/html/surface/shaders/normalized_gradient_test.dart similarity index 100% rename from lib/web_ui/test/engine/surface/shaders/normalized_gradient_test.dart rename to lib/web_ui/test/html/surface/shaders/normalized_gradient_test.dart diff --git a/lib/web_ui/test/engine/surface/shaders/shader_builder_test.dart b/lib/web_ui/test/html/surface/shaders/shader_builder_test.dart similarity index 100% rename from lib/web_ui/test/engine/surface/shaders/shader_builder_test.dart rename to lib/web_ui/test/html/surface/shaders/shader_builder_test.dart diff --git a/lib/web_ui/test/engine/surface/surface_test.dart b/lib/web_ui/test/html/surface/surface_test.dart similarity index 100% rename from lib/web_ui/test/engine/surface/surface_test.dart rename to lib/web_ui/test/html/surface/surface_test.dart