diff --git a/lib/web_ui/dev/steps/copy_artifacts_step.dart b/lib/web_ui/dev/steps/copy_artifacts_step.dart index 930b30ac9f894..2fc7294f1a0d0 100644 --- a/lib/web_ui/dev/steps/copy_artifacts_step.dart +++ b/lib/web_ui/dev/steps/copy_artifacts_step.dart @@ -37,18 +37,20 @@ class CopyArtifactsStep implements PipelineStep { await copyTestFonts(); await copySkiaTestImages(); await copyFlutterJsFiles(); + final copied = []; if (artifactDeps.canvasKit) { - print('Copying CanvasKit...'); + copied.add('CanvasKit'); await copyCanvasKitFiles('canvaskit', 'canvaskit'); } if (artifactDeps.canvasKitChromium) { - print('Copying CanvasKit (Chromium)...'); + copied.add('CanvasKit (Chromium)'); await copyCanvasKitFiles('canvaskit_chromium', 'canvaskit/chromium'); } if (artifactDeps.skwasm) { - print('Copying Skwasm...'); + copied.add('Skwasm'); await copySkwasm(); } + print('Copied artifacts: ${copied.join(', ')}'); } Future copyTestFonts() async { diff --git a/lib/web_ui/dev/steps/run_suite_step.dart b/lib/web_ui/dev/steps/run_suite_step.dart index 50f8336571edf..e6aa7efda777f 100644 --- a/lib/web_ui/dev/steps/run_suite_step.dart +++ b/lib/web_ui/dev/steps/run_suite_step.dart @@ -176,13 +176,11 @@ class RunSuiteStep implements PipelineStep { Future _createSkiaClient() async { if (suite.testBundle.compileConfigs.length > 1) { - print('Not creating skia client due to multiple compile configs'); // Multiple compile configs are only used for our fallback tests, which // do not collect goldens. return null; } if (suite.runConfig.browser == BrowserName.safari) { - print('Not creating skia client for Safari'); // Goldens from Safari produce too many diffs, disabled for now. // See https://github.com/flutter/flutter/issues/143591 return null; @@ -206,17 +204,17 @@ class RunSuiteStep implements PipelineStep { 'Renderer': rendererName, if (variant != null) 'CanvasKitVariant': variant.name, }; - print('Created Skia Gold Client. dimensions: $dimensions'); final SkiaGoldClient skiaClient = SkiaGoldClient( workDirectory, dimensions: dimensions, ); if (await _checkSkiaClient(skiaClient)) { - print('Successfully checked Skia Gold Client'); + print('Using SkiaGoldClient with dimensions: $dimensions'); return skiaClient; } + print('Could not connect to Skia Gold.'); if (requireSkiaGold) { throw ToolExit('Skia Gold is required but is unavailable.'); } diff --git a/lib/web_ui/lib/channel_buffers.dart b/lib/web_ui/lib/channel_buffers.dart index 48d777ce2d539..fdc9948284e42 100644 --- a/lib/web_ui/lib/channel_buffers.dart +++ b/lib/web_ui/lib/channel_buffers.dart @@ -126,10 +126,17 @@ class ChannelBuffers { final Map _channels = {}; + @visibleForTesting + bool debugPrintOverflowWarning = true; + void push(String name, ByteData? data, PlatformMessageResponseCallback callback) { final _Channel channel = _channels.putIfAbsent(name, () => _Channel()); if (channel.push(_StoredMessage(data, callback))) { assert(() { + if (!debugPrintOverflowWarning) { + return true; + } + print( 'A message on the $name channel was discarded before it could be handled.\n' 'This happens when a plugin sends messages to the framework side before the ' diff --git a/lib/web_ui/lib/src/engine/view_embedder/embedding_strategy/full_page_embedding_strategy.dart b/lib/web_ui/lib/src/engine/view_embedder/embedding_strategy/full_page_embedding_strategy.dart index 90de0467d295d..878b6d8c220cc 100644 --- a/lib/web_ui/lib/src/engine/view_embedder/embedding_strategy/full_page_embedding_strategy.dart +++ b/lib/web_ui/lib/src/engine/view_embedder/embedding_strategy/full_page_embedding_strategy.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:meta/meta.dart'; import 'package:ui/src/engine/dom.dart'; import 'package:ui/src/engine/util.dart' show setElementStyle; @@ -19,6 +20,9 @@ class FullPageEmbeddingStrategy implements EmbeddingStrategy { _setHostStyles(); } + @visibleForTesting + static bool debugPrintExistingMetaWarning = true; + @override final DomElement hostElement = domDocument.body!; @@ -65,6 +69,10 @@ class FullPageEmbeddingStrategy implements EmbeddingStrategy { for (final DomElement viewportMeta in domDocument.head!.querySelectorAll('meta[name="viewport"]')) { assert(() { + if (!debugPrintExistingMetaWarning) { + return true; + } + // Filter out the meta tag that the engine placed on the page. This is // to avoid UI flicker during hot restart. Hot restart will clean up the // old meta tag synchronously with the first post-restart frame. diff --git a/lib/web_ui/lib/ui.dart b/lib/web_ui/lib/ui.dart index 5dc40b227ecd9..56a12a45fd9d2 100644 --- a/lib/web_ui/lib/ui.dart +++ b/lib/web_ui/lib/ui.dart @@ -13,6 +13,8 @@ import 'dart:convert'; import 'dart:math' as math; import 'dart:typed_data'; +import 'package:meta/meta.dart'; + import 'src/engine.dart' as engine; import 'ui_web/src/ui_web.dart' as ui_web; diff --git a/lib/web_ui/test/canvaskit/canvaskit_api_tt_on_test.dart b/lib/web_ui/test/canvaskit/canvaskit_api_tt_on_test.dart index 1827f23ef6bd8..b243734df99ea 100644 --- a/lib/web_ui/test/canvaskit/canvaskit_api_tt_on_test.dart +++ b/lib/web_ui/test/canvaskit/canvaskit_api_tt_on_test.dart @@ -54,7 +54,6 @@ void testMainWithTTOn() { /// Enables Trusted Types by setting the appropriate meta tag in the DOM: /// void enableTrustedTypes() { - print('Enabling TrustedTypes in browser window...'); final DomHTMLMetaElement enableTTMeta = createDomHTMLMetaElement() ..setAttribute('http-equiv', 'Content-Security-Policy') ..content = "require-trusted-types-for 'script'"; diff --git a/lib/web_ui/test/common/test_initialization.dart b/lib/web_ui/test/common/test_initialization.dart index a766291c0263d..e801e7fb6e25a 100644 --- a/lib/web_ui/test/common/test_initialization.dart +++ b/lib/web_ui/test/common/test_initialization.dart @@ -66,9 +66,24 @@ void setUpImplicitView() { await myWindow.resetHistory(); myWindow.dispose(); }); + + ignoreUnhandledPlatformMessages(); +} + +// This is necessary in tests to avoid spamming the console with warnings. +// +// App lifecycle is one of the culprits here. It keeps trying to send messages +// to update the lifecycle state, but that leads to a warning because there's +// no platform message handler. +void ignoreUnhandledPlatformMessages() { + setUp(() { + ui.channelBuffers.debugPrintOverflowWarning = false; + }); } Future bootstrapAndRunApp({bool withImplicitView = false}) async { + ui.channelBuffers.debugPrintOverflowWarning = false; + final Completer completer = Completer(); await ui_web.bootstrapEngine(runApp: () => completer.complete()); await completer.future; diff --git a/lib/web_ui/test/engine/app_bootstrap_test.dart b/lib/web_ui/test/engine/app_bootstrap_test.dart index d9f55f6f6029b..522eba3c09a68 100644 --- a/lib/web_ui/test/engine/app_bootstrap_test.dart +++ b/lib/web_ui/test/engine/app_bootstrap_test.dart @@ -11,6 +11,8 @@ 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); } @@ -21,6 +23,8 @@ void testMain() { int initCalled = 0; int runCalled = 0; + ignoreUnhandledPlatformMessages(); + setUp(() { callOrder = 1; initCalled = 0; diff --git a/lib/web_ui/test/engine/channel_buffers_test.dart b/lib/web_ui/test/engine/channel_buffers_test.dart index 7bc79d3397957..56b46ebe8544d 100644 --- a/lib/web_ui/test/engine/channel_buffers_test.dart +++ b/lib/web_ui/test/engine/channel_buffers_test.dart @@ -86,6 +86,7 @@ void testMain() { final ByteData data = _makeByteData('bar'); final ui.ChannelBuffers buffers = ui.ChannelBuffers(); + buffers.debugPrintOverflowWarning = false; void callback(ByteData? responseData) {} _resize(buffers, channel, 0); buffers.push(channel, data, callback); @@ -115,6 +116,7 @@ void testMain() { final ByteData three = _makeByteData('three'); final ByteData four = _makeByteData('four'); final ui.ChannelBuffers buffers = ui.ChannelBuffers(); + buffers.debugPrintOverflowWarning = false; void callback(ByteData? responseData) {} _resize(buffers, channel, 3); buffers.push(channel, one, callback); @@ -185,6 +187,7 @@ void testMain() { final ByteData one = _makeByteData('one'); final ByteData two = _makeByteData('two'); final ui.ChannelBuffers buffers = ui.ChannelBuffers(); + buffers.debugPrintOverflowWarning = false; bool didCallCallback = false; void oneCallback(ByteData? responseData) { expect(responseData, isNull); @@ -214,6 +217,7 @@ void testMain() { test('ChannelBuffers.setListener', () async { final List log = []; final ui.ChannelBuffers buffers = ui.ChannelBuffers(); + buffers.debugPrintOverflowWarning = false; final ByteData one = _makeByteData('one'); final ByteData two = _makeByteData('two'); final ByteData three = _makeByteData('three'); diff --git a/lib/web_ui/test/engine/initialization_test.dart b/lib/web_ui/test/engine/initialization_test.dart index 2fbb2f76e15f6..88f6e952e9dbf 100644 --- a/lib/web_ui/test/engine/initialization_test.dart +++ b/lib/web_ui/test/engine/initialization_test.dart @@ -33,7 +33,6 @@ void testMain() { JSAny? engineInitializer; void didCreateEngineInitializerMock(JSAny? obj) { - print('obj: $obj'); engineInitializer = obj; } diff --git a/lib/web_ui/test/engine/pointer_binding/event_position_helper_test.dart b/lib/web_ui/test/engine/pointer_binding/event_position_helper_test.dart index 14f41dccbbf9a..7d582cdaf3710 100644 --- a/lib/web_ui/test/engine/pointer_binding/event_position_helper_test.dart +++ b/lib/web_ui/test/engine/pointer_binding/event_position_helper_test.dart @@ -12,6 +12,8 @@ import 'package:test/test.dart'; import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui show Offset; +import '../../common/test_initialization.dart'; + void main() { internalBootstrapBrowserTest(() => doTests); } @@ -29,6 +31,8 @@ void doTests() { return (await nextEvent) as DomPointerEvent; } + ignoreUnhandledPlatformMessages(); + group('computeEventOffsetToTarget', () { setUp(() { view = EngineFlutterView(EnginePlatformDispatcher.instance, domDocument.body!); @@ -135,10 +139,14 @@ void doTests() { test('Event dispatched by TalkBack gets a computed offset', () async { // Fill this in to test _computeOffsetForTalkbackEvent - }, skip: 'To be implemented!'); + + // To be implemented! + }, skip: true); test('Event dispatched on text editing node computes offset with framework geometry', () async { // Fill this in to test _computeOffsetForInputs - }, skip: 'To be implemented!'); + + // To be implemented! + }, skip: true); }); } diff --git a/lib/web_ui/test/engine/view_embedder/embedding_strategy/custom_element_embedding_strategy_test.dart b/lib/web_ui/test/engine/view_embedder/embedding_strategy/custom_element_embedding_strategy_test.dart index 0a954377f10c5..ee056b79cb901 100644 --- a/lib/web_ui/test/engine/view_embedder/embedding_strategy/custom_element_embedding_strategy_test.dart +++ b/lib/web_ui/test/engine/view_embedder/embedding_strategy/custom_element_embedding_strategy_test.dart @@ -10,6 +10,8 @@ import 'package:test/test.dart'; import 'package:ui/src/engine/dom.dart'; import 'package:ui/src/engine/view_embedder/embedding_strategy/custom_element_embedding_strategy.dart'; +import '../../../common/test_initialization.dart'; + void main() { internalBootstrapBrowserTest(() => doTests); } @@ -18,6 +20,8 @@ void doTests() { late CustomElementEmbeddingStrategy strategy; late DomElement target; + ignoreUnhandledPlatformMessages(); + group('initialize', () { setUp(() { target = createDomElement('this-is-the-target'); diff --git a/lib/web_ui/test/engine/view_embedder/embedding_strategy/embedding_strategy_test.dart b/lib/web_ui/test/engine/view_embedder/embedding_strategy/embedding_strategy_test.dart index f254455ecd58a..f5f5d619c929c 100644 --- a/lib/web_ui/test/engine/view_embedder/embedding_strategy/embedding_strategy_test.dart +++ b/lib/web_ui/test/engine/view_embedder/embedding_strategy/embedding_strategy_test.dart @@ -12,11 +12,15 @@ import 'package:ui/src/engine/view_embedder/embedding_strategy/custom_element_em import 'package:ui/src/engine/view_embedder/embedding_strategy/embedding_strategy.dart'; import 'package:ui/src/engine/view_embedder/embedding_strategy/full_page_embedding_strategy.dart'; +import '../../../common/test_initialization.dart'; + void main() { internalBootstrapBrowserTest(() => doTests); } void doTests() { + ignoreUnhandledPlatformMessages(); + group('Factory', () { test('Creates a FullPage instance when hostElement is null', () async { final EmbeddingStrategy strategy = EmbeddingStrategy.create(); diff --git a/lib/web_ui/test/engine/view_embedder/embedding_strategy/full_page_embedding_strategy_test.dart b/lib/web_ui/test/engine/view_embedder/embedding_strategy/full_page_embedding_strategy_test.dart index bb096227dbdd1..f96c34b856946 100644 --- a/lib/web_ui/test/engine/view_embedder/embedding_strategy/full_page_embedding_strategy_test.dart +++ b/lib/web_ui/test/engine/view_embedder/embedding_strategy/full_page_embedding_strategy_test.dart @@ -10,13 +10,18 @@ import 'package:test/test.dart'; import 'package:ui/src/engine/dom.dart'; import 'package:ui/src/engine/view_embedder/embedding_strategy/full_page_embedding_strategy.dart'; +import '../../../common/test_initialization.dart'; + void main() { internalBootstrapBrowserTest(() => doTests); } void doTests() { + ignoreUnhandledPlatformMessages(); + group('initialize', () { test('Prepares target environment', () { + FullPageEmbeddingStrategy.debugPrintExistingMetaWarning = false; final DomElement target = domDocument.body!; final DomHTMLMetaElement meta = createDomHTMLMetaElement(); meta @@ -49,6 +54,7 @@ void doTests() { expect(flutterMeta, isNotNull); expect(flutterMeta!.hasAttribute('flt-viewport'), isTrue, reason: 'Should install flutter viewport meta tag.'); + FullPageEmbeddingStrategy.debugPrintExistingMetaWarning = true; }); }); diff --git a/lib/web_ui/test/engine/window_test.dart b/lib/web_ui/test/engine/window_test.dart index 905c1416f7ba2..6f568a1b1e15f 100644 --- a/lib/web_ui/test/engine/window_test.dart +++ b/lib/web_ui/test/engine/window_test.dart @@ -13,28 +13,20 @@ import 'package:ui/src/engine.dart'; import 'package:ui/ui.dart' as ui; import '../common/matchers.dart'; +import '../common/test_initialization.dart'; const int kPhysicalKeyA = 0x00070004; const int kLogicalKeyA = 0x00000000061; +EnginePlatformDispatcher get dispatcher => EnginePlatformDispatcher.instance; +EngineFlutterWindow get myWindow => dispatcher.implicitView!; + void main() { internalBootstrapBrowserTest(() => testMain); } Future testMain() async { - 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(); test('onTextScaleFactorChanged preserves the zone', () { final Zone innerZone = Zone.current.fork(); @@ -473,6 +465,7 @@ Future testMain() async { }); test('in full-page mode, Flutter window replaces viewport meta tags', () { + FullPageEmbeddingStrategy.debugPrintExistingMetaWarning = false; final DomHTMLMetaElement existingMeta = createDomHTMLMetaElement() ..name = 'viewport' ..content = 'foo=bar'; @@ -493,6 +486,7 @@ Future testMain() async { expect(newMeta.content, contains('maximum-scale=1.0')); expect(newMeta.content, contains('user-scalable=no')); implicitView.dispose(); + FullPageEmbeddingStrategy.debugPrintExistingMetaWarning = true; }); test('auto-view-id', () { diff --git a/lib/web_ui/test/html/compositing/compositing_golden_test.dart b/lib/web_ui/test/html/compositing/compositing_golden_test.dart index a47d3f44ece5c..bd470bb020d05 100644 --- a/lib/web_ui/test/html/compositing/compositing_golden_test.dart +++ b/lib/web_ui/test/html/compositing/compositing_golden_test.dart @@ -214,9 +214,9 @@ void _testCullRectComputation() { final PersistedPicture picture = enumeratePictures().single; expect(picture.optimalLocalCullRect, const ui.Rect.fromLTRB(0, 0, 500, 100)); - }, skip: ''' - TODO(https://github.com/flutter/flutter/issues/40395) - Needs ability to set iframe to 500,100 size. Current screen seems to be 500,500'''); + // Needs ability to set iframe to 500,100 size. Current screen seems to be 500,500 + // https://github.com/flutter/flutter/issues/40395 + }, skip: true); // Draw a picture that overflows the screen. Verify that cull rect is the // intersection of screen bounds and paint bounds. @@ -297,9 +297,9 @@ void _testCullRectComputation() { expect( picture.debugExactGlobalCullRect, const ui.Rect.fromLTRB(0, 70, 20, 100)); expect(picture.optimalLocalCullRect, const ui.Rect.fromLTRB(0, -20, 20, 10)); - }, skip: ''' - TODO(https://github.com/flutter/flutter/issues/40395) - Needs ability to set iframe to 500,100 size. Current screen seems to be 500,500'''); + // Needs ability to set iframe to 500,100 size. Current screen seems to be 500,500 + // https://github.com/flutter/flutter/issues/40395 + }, skip: true); // Draw a picture inside a layer clip but fill all available space inside it. // Verify that the cull rect is equal to the layer clip.