Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web] Remove spam from test output #57165

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/web_ui/dev/steps/copy_artifacts_step.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ class CopyArtifactsStep implements PipelineStep {
await copyTestFonts();
await copySkiaTestImages();
await copyFlutterJsFiles();
final copied = <String>[];
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<void> copyTestFonts() async {
Expand Down
6 changes: 2 additions & 4 deletions lib/web_ui/dev/steps/run_suite_step.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,11 @@ class RunSuiteStep implements PipelineStep {

Future<SkiaGoldClient?> _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;
Expand All @@ -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.');
}
Expand Down
7 changes: 7 additions & 0 deletions lib/web_ui/lib/channel_buffers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,17 @@ class ChannelBuffers {

final Map<String, _Channel> _channels = <String, _Channel>{};

@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 '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -19,6 +20,9 @@ class FullPageEmbeddingStrategy implements EmbeddingStrategy {
_setHostStyles();
}

@visibleForTesting
static bool debugPrintExistingMetaWarning = true;

@override
final DomElement hostElement = domDocument.body!;

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions lib/web_ui/lib/ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion lib/web_ui/test/canvaskit/canvaskit_api_tt_on_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ void testMainWithTTOn() {
/// Enables Trusted Types by setting the appropriate meta tag in the DOM:
/// <meta http-equiv="Content-Security-Policy" content="require-trusted-types-for 'script'">
void enableTrustedTypes() {
print('Enabling TrustedTypes in browser window...');
final DomHTMLMetaElement enableTTMeta = createDomHTMLMetaElement()
..setAttribute('http-equiv', 'Content-Security-Policy')
..content = "require-trusted-types-for 'script'";
Expand Down
15 changes: 15 additions & 0 deletions lib/web_ui/test/common/test_initialization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> bootstrapAndRunApp({bool withImplicitView = false}) async {
ui.channelBuffers.debugPrintOverflowWarning = false;

final Completer<void> completer = Completer<void>();
await ui_web.bootstrapEngine(runApp: () => completer.complete());
await completer.future;
Expand Down
4 changes: 4 additions & 0 deletions lib/web_ui/test/engine/app_bootstrap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -21,6 +23,8 @@ void testMain() {
int initCalled = 0;
int runCalled = 0;

ignoreUnhandledPlatformMessages();

setUp(() {
callOrder = 1;
initCalled = 0;
Expand Down
4 changes: 4 additions & 0 deletions lib/web_ui/test/engine/channel_buffers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -214,6 +217,7 @@ void testMain() {
test('ChannelBuffers.setListener', () async {
final List<String> log = <String>[];
final ui.ChannelBuffers buffers = ui.ChannelBuffers();
buffers.debugPrintOverflowWarning = false;
final ByteData one = _makeByteData('one');
final ByteData two = _makeByteData('two');
final ByteData three = _makeByteData('three');
Expand Down
1 change: 0 additions & 1 deletion lib/web_ui/test/engine/initialization_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ void testMain() {
JSAny? engineInitializer;

void didCreateEngineInitializerMock(JSAny? obj) {
print('obj: $obj');
engineInitializer = obj;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -29,6 +31,8 @@ void doTests() {
return (await nextEvent) as DomPointerEvent;
}

ignoreUnhandledPlatformMessages();

group('computeEventOffsetToTarget', () {
setUp(() {
view = EngineFlutterView(EnginePlatformDispatcher.instance, domDocument.body!);
Expand Down Expand Up @@ -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);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -18,6 +20,8 @@ void doTests() {
late CustomElementEmbeddingStrategy strategy;
late DomElement target;

ignoreUnhandledPlatformMessages();

group('initialize', () {
setUp(() {
target = createDomElement('this-is-the-target');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
});
});

Expand Down
20 changes: 7 additions & 13 deletions lib/web_ui/test/engine/window_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> 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();
Expand Down Expand Up @@ -473,6 +465,7 @@ Future<void> 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';
Expand All @@ -493,6 +486,7 @@ Future<void> 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', () {
Expand Down
12 changes: 6 additions & 6 deletions lib/web_ui/test/html/compositing/compositing_golden_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Loading