diff --git a/lib/web_ui/dev/browser_lock.yaml b/lib/web_ui/dev/browser_lock.yaml index 09f2f56ab5673..b1a83fe5869a0 100644 --- a/lib/web_ui/dev/browser_lock.yaml +++ b/lib/web_ui/dev/browser_lock.yaml @@ -34,7 +34,7 @@ ios-safari: # `heightOfHeader` is the number of pixels taken by the phone's header menu # and the browsers address bar. # TODO: https://github.com/flutter/flutter/issues/65672 - heightOfHeader: 282 + heightOfHeader: 189 # `heightOfFooter` is the number of pixels taken by the phone's navigation # menu. heightOfFooter: 250 @@ -45,7 +45,8 @@ ios-safari: # phone screeen we enlarge or shrink the area by applying a linear # transformation by a scale_factor (a.k.a. we perform isotropic scaling). # This value will be differ depending on the phone. - scaleFactor: 1.15 + # For iOS 13.0 iPhone 11 Pro, this number is 1.15. + scaleFactor: 1.00 ## geckodriver is used for testing Firefox Browser. It works with multiple ## Firefox Browser versions. diff --git a/lib/web_ui/dev/goldens_lock.yaml b/lib/web_ui/dev/goldens_lock.yaml index 1c38c1ca3a378..067577a642f6f 100644 --- a/lib/web_ui/dev/goldens_lock.yaml +++ b/lib/web_ui/dev/goldens_lock.yaml @@ -1,2 +1,2 @@ repository: https://github.com/flutter/goldens.git -revision: b6efc75885c23f0b5c485d8bd659ed339feec9ec +revision: 1a4722227af42c3f51450266016b1a07ae459e73 diff --git a/lib/web_ui/dev/test_platform.dart b/lib/web_ui/dev/test_platform.dart index cc0a5d58feda0..18dd92cf1c45e 100644 --- a/lib/web_ui/dev/test_platform.dart +++ b/lib/web_ui/dev/test_platform.dart @@ -197,7 +197,17 @@ class BrowserPlatform extends PlatformPlugin { 'golden_files', ); } else { - await fetchGoldens(); + // On LUCI MacOS bots the goldens are fetched by the recipe code. + // Fetch the goldens if: + // - Tests are running on a local machine. + // - Tests are running on an OS other than macOS. + if (!isLuci || !Platform.isMacOS) { + await fetchGoldens(); + } else { + if (!env.environment.webUiGoldensRepositoryDirectory.existsSync()) { + throw Exception('The goldens directory must have been copied'); + } + } goldensDirectory = p.join( env.environment.webUiGoldensRepositoryDirectory.path, 'engine', @@ -212,7 +222,7 @@ class BrowserPlatform extends PlatformPlugin { )); if (!file.existsSync() && !write) { return ''' -Golden file $filename does not exist. +Golden file $filename does not exist on path ${file.absolute.path} To automatically create this file call matchGoldenFile('$filename', write: true). '''; diff --git a/lib/web_ui/dev/test_runner.dart b/lib/web_ui/dev/test_runner.dart index e459a0c0efcff..5ad1b3b53dfc3 100644 --- a/lib/web_ui/dev/test_runner.dart +++ b/lib/web_ui/dev/test_runner.dart @@ -397,12 +397,13 @@ class TestCommand extends Command with ArgUtils { 'test', )); - // Screenshot tests and smoke tests only run on: "Chrome/iOS Safari locally" - // or "Chrome on a Linux bot". We can remove the Linux bot restriction - // after solving the git issue faced on macOS and Windows bots: + // Screenshot tests and smoke tests only run on: "Chrome/iOS Safari" + // locally and on LUCI. They are not available on Windows bots: // TODO: https://github.com/flutter/flutter/issues/63710 if ((isChrome && isLuci && io.Platform.isLinux) || - ((isChrome || isSafariIOS) && !isLuci)) { + ((isChrome || isSafariIOS) && !isLuci) || + (isSafariIOS && isLuci)) { + print('INFO: Also running the screenshot tests.'); // 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. diff --git a/lib/web_ui/test/golden_files/smoke_test.iOS_Safari.png b/lib/web_ui/test/golden_files/smoke_test.iOS_Safari.png index bd156b44e38a5..7f2995f12a42c 100644 Binary files a/lib/web_ui/test/golden_files/smoke_test.iOS_Safari.png and b/lib/web_ui/test/golden_files/smoke_test.iOS_Safari.png differ 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 962d930d8884f..e5581be96687a 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 @@ -108,7 +108,9 @@ void testMain() async { rc.restore(); await _checkScreenshot(rc, 'canvas_image_blend_group$blendGroup', maxDiffRatePercent: 8.0); - }); + }, + skip: browserEngine == BrowserEngine.webkit && + operatingSystem == OperatingSystem.iOs); } // Regression test for https://github.com/flutter/flutter/issues/56971 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 307cdb583caad..1822bc1c3e985 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 @@ -75,7 +75,8 @@ void testMain() async { builder.pop(); // offset } - void _paintBitmapCanvasShadow(double elevation, Offset offset, bool transparentOccluder) { + void _paintBitmapCanvasShadow( + double elevation, Offset offset, bool transparentOccluder) { final SurfacePath path = SurfacePath() ..addRect(const Rect.fromLTRB(0, 0, 20, 20)); builder.pushOffset(offset.dx, offset.dy); @@ -168,4 +169,15 @@ void testMain() async { }, testOn: 'chrome', ); + + /// For dart testing having `no tests ran` in a file is considered an error + /// and result in exit code 1. + /// See: https://github.com/dart-lang/test/pull/1173 + /// + /// Since screenshot tests run one by one and exit code is checked immediately + /// after that a test file that only runs in chrome will break the other + /// browsers. This method is added as a bandaid solution. + test('dummy tests to pass on other browsers', () async { + expect(2 + 2, 4); + }); } 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 eece5fcd5e295..8b46adcb3846f 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 @@ -15,11 +15,17 @@ void main() { internalBootstrapBrowserTest(() => testMain); } +/// Whether we are running on iOS Safari. +// TODO: https://github.com/flutter/flutter/issues/66656 +bool get isIosSafari => browserEngine == BrowserEngine.webkit && + operatingSystem == OperatingSystem.iOs; + void testMain() async { final EngineScubaTester scuba = await EngineScubaTester.initialize( viewportSize: const Size(600, 600), ); + setUpStableTestFonts(); testEachCanvas('draws paragraphs with placeholders', (EngineCanvas canvas) { @@ -40,7 +46,9 @@ void testMain() async { } recordingCanvas.endRecording(); recordingCanvas.apply(canvas, screenRect); - return scuba.diffCanvasScreenshot(canvas, 'text_with_placeholders'); + if (!isIosSafari) { + return scuba.diffCanvasScreenshot(canvas, 'text_with_placeholders'); + } }); testEachCanvas('text alignment and placeholders', (EngineCanvas canvas) {