[web] Remove spam from test output (#161774)

| Before | After |
|-|-|
|
![image](https://github.com/user-attachments/assets/30689c9e-ae99-41ff-bbf6-cb4b0f2c1a6a)
|
![image](https://github.com/user-attachments/assets/a73a7536-cade-475e-9e16-96eda73fc6f5)
|
This commit is contained in:
Mouad Debbar 2025-01-22 14:22:59 -05:00 committed by GitHub
parent c8e34e067c
commit 8752f481c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 68 additions and 70 deletions

View File

@ -104,19 +104,21 @@ class CopyArtifactsStep implements PipelineStep {
await copyTestFonts();
await copySkiaTestImages();
await copyFlutterJsFiles(flutterJsSourceDirectory);
final copied = <String>[];
if (artifactDeps.canvasKit) {
print('Copying CanvasKit...');
copied.add('CanvasKit');
await copyWasmLibrary('canvaskit', canvaskitSourceDirectory, 'canvaskit');
}
if (artifactDeps.canvasKitChromium) {
print('Copying CanvasKit (Chromium)...');
copied.add('CanvasKit (Chromium)');
await copyWasmLibrary('canvaskit', canvaskitChromiumSourceDirectory, 'canvaskit/chromium');
}
if (artifactDeps.skwasm) {
print('Copying Skwasm...');
copied.add('Skwasm');
await copyWasmLibrary('skwasm', skwasmSourceDirectory, 'canvaskit');
await copyWasmLibrary('skwasm_st', skwasmStSourceDirectory, 'canvaskit');
}
print('Copied artifacts: ${copied.join(', ')}');
}
Future<void> copyTestFonts() async {

View File

@ -173,15 +173,15 @@ 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.
print('Did not create SkiaGoldClient. Reason: Multiple compile configs.');
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
print('Did not create SkiaGoldClient. Reason: Safari browser.');
return null;
}
final Renderer renderer = suite.testBundle.compileConfigs.first.renderer;
@ -204,14 +204,15 @@ 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');
final (success, reason) = await _checkSkiaClient(skiaClient);
if (success) {
print('Created SkiaGoldClient. Dimensions: $dimensions');
return skiaClient;
}
print('Did not create SkiaGoldClient. Reason: $reason.');
if (requireSkiaGold) {
throw ToolExit('Skia Gold is required but is unavailable.');
}
@ -220,13 +221,13 @@ class RunSuiteStep implements PipelineStep {
}
/// Checks whether the Skia Client is usable in this environment.
Future<bool> _checkSkiaClient(SkiaGoldClient skiaClient) async {
Future<(bool, String?)> _checkSkiaClient(SkiaGoldClient skiaClient) async {
// Now let's check whether Skia Gold is reachable or not.
if (isLuci) {
if (SkiaGoldClient.isAvailable()) {
try {
await skiaClient.auth();
return true;
return (true, null);
} catch (e) {
print(e);
}
@ -235,14 +236,14 @@ class RunSuiteStep implements PipelineStep {
try {
// Check if we can reach Gold.
await skiaClient.getExpectationForTest('');
return true;
return (true, null);
} on io.OSError catch (_) {
print('OSError occurred, could not reach Gold.');
return (false, 'OSError occurred, could not reach Gold');
} on io.SocketException catch (_) {
print('SocketException occurred, could not reach Gold.');
return (false, 'SocketException occurred, could not reach Gold');
}
}
return false;
return (false, 'Unknown');
}
}

View File

@ -135,7 +135,7 @@ class ChannelBuffers {
final _Channel channel = _channels.putIfAbsent(name, () => _Channel());
if (channel.push(_StoredMessage(data, callback))) {
assert(() {
print(
engine.printWarning(
'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 '
'framework has had an opportunity to register a listener. See the ChannelBuffers '

View File

@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'package:ui/src/engine/dom.dart';
import 'package:ui/src/engine/util.dart' show setElementStyle;
import 'package:ui/src/engine/util.dart';
import '../hot_restart_cache_handler.dart' show registerElementForCleanup;
import 'embedding_strategy.dart';
@ -70,10 +70,9 @@ class FullPageEmbeddingStrategy implements EmbeddingStrategy {
// to avoid UI flicker during hot restart. Hot restart will clean up the
// old meta tag synchronously with the first post-restart frame.
if (!viewportMeta.hasAttribute('flt-viewport')) {
print(
'WARNING: found an existing <meta name="viewport"> tag. Flutter '
'Web uses its own viewport configuration for better compatibility '
'with Flutter. This tag will be replaced.',
printWarning(
'Found an existing <meta name="viewport"> tag. Flutter Web uses its own viewport '
'configuration for better compatibility with Flutter. This tag will be replaced.',
);
}
return true;

View File

@ -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')

View File

@ -38,7 +38,6 @@ void testMain() {
JSAny? engineInitializer;
void didCreateEngineInitializerMock(JSAny? obj) {
print('obj: $obj');
engineInitializer = obj;
}

View File

@ -135,14 +135,17 @@ 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,
);
});
}

View File

@ -8,6 +8,7 @@ library;
import 'package:test/bootstrap/browser.dart';
import 'package:test/test.dart';
import 'package:ui/src/engine/dom.dart';
import 'package:ui/src/engine/util.dart';
import 'package:ui/src/engine/view_embedder/embedding_strategy/full_page_embedding_strategy.dart';
void main() {
@ -17,6 +18,12 @@ void main() {
void doTests() {
group('initialize', () {
test('Prepares target environment', () {
final warnings = <String>[];
final oldPrintWarning = printWarning;
printWarning = (String message) {
warnings.add(message);
};
final DomElement target = domDocument.body!;
final DomHTMLMetaElement meta = createDomHTMLMetaElement();
meta
@ -52,6 +59,10 @@ void doTests() {
isTrue,
reason: 'Should install flutter viewport meta tag.',
);
expect(warnings, hasLength(1), reason: 'Should print a warning to the user.');
expect(warnings.single, contains(RegExp(r'Found an existing.*meta.*viewport')));
printWarning = oldPrintWarning;
});
});

View File

@ -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();

View File

@ -181,22 +181,18 @@ Future<void> testMain() async {
void _testCullRectComputation() {
// Draw a picture larger that screen. Verify that cull rect is equal to screen
// bounds.
test(
'fills screen bounds',
() async {
final ui.SceneBuilder builder = ui.SceneBuilder();
drawWithBitmapCanvas(builder, (RecordingCanvas canvas) {
canvas.drawCircle(ui.Offset.zero, 10000, SurfacePaint()..style = ui.PaintingStyle.fill);
});
builder.build();
test('fills screen bounds', () async {
final ui.SceneBuilder builder = ui.SceneBuilder();
drawWithBitmapCanvas(builder, (RecordingCanvas canvas) {
canvas.drawCircle(ui.Offset.zero, 10000, SurfacePaint()..style = ui.PaintingStyle.fill);
});
builder.build();
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''',
);
final PersistedPicture picture = enumeratePictures().single;
expect(picture.optimalLocalCullRect, const ui.Rect.fromLTRB(0, 0, 500, 100));
// 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.
@ -263,27 +259,23 @@ void _testCullRectComputation() {
// Draw a picture smaller than the screen. Offset it such that the picture
// overflows screen bounds. Verify that the cull rect is the intersection
// between screen bounds and paint bounds.
test(
'offset overflows paint bounds',
() async {
final ui.SceneBuilder builder = ui.SceneBuilder();
test('offset overflows paint bounds', () async {
final ui.SceneBuilder builder = ui.SceneBuilder();
builder.pushOffset(0, 90);
drawWithBitmapCanvas(builder, (RecordingCanvas canvas) {
canvas.drawCircle(ui.Offset.zero, 20, SurfacePaint()..style = ui.PaintingStyle.fill);
});
builder.pop();
builder.pushOffset(0, 90);
drawWithBitmapCanvas(builder, (RecordingCanvas canvas) {
canvas.drawCircle(ui.Offset.zero, 20, SurfacePaint()..style = ui.PaintingStyle.fill);
});
builder.pop();
builder.build();
builder.build();
final PersistedPicture picture = enumeratePictures().single;
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''',
);
final PersistedPicture picture = enumeratePictures().single;
expect(picture.debugExactGlobalCullRect, const ui.Rect.fromLTRB(0, 70, 20, 100));
expect(picture.optimalLocalCullRect, const ui.Rect.fromLTRB(0, -20, 20, 10));
// 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.