From c05fa894e6b8b921a22404c496f67b0afe2da2f1 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 10 Jun 2019 14:05:51 -0700 Subject: [PATCH] Compatibility pass on flutter/painting tests for JavaScript compilation. (3) (#33352) --- dev/bots/test.dart | 1 + .../flutter/lib/src/painting/box_shadow.dart | 2 +- .../beveled_rectangle_border_test.dart | 4 ++-- .../test/painting/border_rtl_test.dart | 20 +++++++++---------- .../test/painting/circle_border_test.dart | 2 +- .../continous_rectangle_border_test.dart | 10 +++++----- .../test/painting/decoration_test.dart | 1 + .../test/painting/image_cache_test.dart | 5 ++++- .../test/painting/image_provider_test.dart | 2 +- .../test/painting/image_resolution_test.dart | 4 ++-- .../test/painting/notched_shapes_test.dart | 2 +- .../rounded_rectangle_border_test.dart | 2 +- .../test/painting/stadium_border_test.dart | 2 +- .../test/painting/text_painter_test.dart | 20 +++++++++---------- .../test/painting/text_style_test.dart | 6 +++--- 15 files changed, 44 insertions(+), 39 deletions(-) diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 26d35d9d47..23d2b9ef3d 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -343,6 +343,7 @@ Future _runTests() async { Future _runWebTests() async { await _runFlutterWebTest(path.join(flutterRoot, 'packages', 'flutter'), expectFailure: false, tests: [ 'test/foundation/', + 'test/painting/', 'test/scheduler/', ]); } diff --git a/packages/flutter/lib/src/painting/box_shadow.dart b/packages/flutter/lib/src/painting/box_shadow.dart index 1b2715bd42..04a86e127f 100644 --- a/packages/flutter/lib/src/painting/box_shadow.dart +++ b/packages/flutter/lib/src/painting/box_shadow.dart @@ -131,5 +131,5 @@ class BoxShadow extends ui.Shadow { int get hashCode => hashValues(color, offset, blurRadius, spreadRadius); @override - String toString() => 'BoxShadow($color, $offset, $blurRadius, $spreadRadius)'; + String toString() => 'BoxShadow($color, $offset, ${debugFormatDouble(blurRadius)}, ${debugFormatDouble(spreadRadius)})'; } diff --git a/packages/flutter/test/painting/beveled_rectangle_border_test.dart b/packages/flutter/test/painting/beveled_rectangle_border_test.dart index 9417741bb1..3dc442e04d 100644 --- a/packages/flutter/test/painting/beveled_rectangle_border_test.dart +++ b/packages/flutter/test/painting/beveled_rectangle_border_test.dart @@ -42,7 +42,7 @@ void main() { const BorderSide side = BorderSide(width: 4.0); expect(const BeveledRectangleBorder(side: side).getOuterPath(rect1), looksLikeRect1); expect(const BeveledRectangleBorder(side: side).getInnerPath(rect1), looksLikeInnerPath); - }); + }, skip: isBrowser); test('BeveledRectangleBorder non-zero BorderRadius', () { const Rect rect = Rect.fromLTRB(10.0, 20.0, 30.0, 40.0); @@ -55,6 +55,6 @@ void main() { ); expect(border.getOuterPath(rect), looksLikeRect); expect(border.getInnerPath(rect), looksLikeRect); - }); + }, skip: isBrowser); } diff --git a/packages/flutter/test/painting/border_rtl_test.dart b/packages/flutter/test/painting/border_rtl_test.dart index 8af690c042..2ae2de3cc5 100644 --- a/packages/flutter/test/painting/border_rtl_test.dart +++ b/packages/flutter/test/painting/border_rtl_test.dart @@ -314,14 +314,14 @@ void main() { ], ), ); - }); + }, skip: isBrowser); test('BorderDirectional constructor', () { expect(() => BorderDirectional(top: nonconst(null)), throwsAssertionError); expect(() => BorderDirectional(start: nonconst(null)), throwsAssertionError); expect(() => BorderDirectional(end: nonconst(null)), throwsAssertionError); expect(() => BorderDirectional(bottom: nonconst(null)), throwsAssertionError); - }); + }, skip: isBrowser); test('BorderDirectional.merge', () { const BorderSide magenta3 = BorderSide(color: Color(0xFFFF00FF), width: 3.0); @@ -360,7 +360,7 @@ void main() { ), throwsAssertionError, ); - }); + }, skip: isBrowser); test('BorderDirectional.dimensions', () { expect( @@ -372,7 +372,7 @@ void main() { ).dimensions, const EdgeInsetsDirectional.fromSTEB(2.0, 3.0, 7.0, 5.0), ); - }); + }, skip: isBrowser); test('BorderDirectional.isUniform', () { expect( @@ -442,7 +442,7 @@ void main() { const BorderDirectional().isUniform, true, ); - }); + }, skip: isBrowser); test('BorderDirectional.add - all directional', () { const BorderSide magenta3 = BorderSide(color: Color(0xFFFF00FF), width: 3.0); @@ -478,7 +478,7 @@ void main() { expect(bZ + bZ, bZ); expect(b0 + bZ, bZ); expect(bZ + b0, bZ); - }); + }, skip: isBrowser); test('BorderDirectional.add', () { const BorderSide side1 = BorderSide(color: Color(0x11111111)); @@ -530,7 +530,7 @@ void main() { expect((borderDirectionalWithStart + borderWithoutSides).toString(), '${const BorderDirectional(start: side1, top: doubleSide2, bottom: doubleSide2)}'); expect((borderDirectionalWithEnd + borderWithoutSides).toString(), '${const BorderDirectional(end: side1, top: doubleSide2, bottom: doubleSide2)}'); expect((borderDirectionalWithoutSides + borderWithoutSides).toString(), '${const Border(top: doubleSide2, bottom: doubleSide2)}'); - }); + }, skip: isBrowser); test('BorderDirectional.scale', () { const BorderSide magenta3 = BorderSide(color: Color(0xFFFF00FF), width: 3.0); @@ -544,7 +544,7 @@ void main() { expect(bY0.scale(3.0), bY0); const BorderDirectional bY2 = BorderDirectional(top: yellow2); expect(bY2.scale(0.0), bY0); - }); + }, skip: isBrowser); test('BorderDirectional.lerp', () { const BorderDirectional directionalWithTop10 = BorderDirectional(top: BorderSide(width: 10.0)); @@ -618,7 +618,7 @@ void main() { }, paintsAssertion, // no TextDirection ); - }); + }, skip: isBrowser); test('BorderDirectional hashCode', () { final BorderSide side = BorderSide(width: nonconst(2.0)); @@ -668,5 +668,5 @@ void main() { expect(decoration2.padding, const EdgeInsetsDirectional.fromSTEB(2.0, 0.0, 0.0, 0.0)); expect(decoration2.scale(2.0), decoration4); expect(BoxDecoration.lerp(decoration2, decoration6, 0.5), decoration4); - }); + }, skip: isBrowser); } diff --git a/packages/flutter/test/painting/circle_border_test.dart b/packages/flutter/test/painting/circle_border_test.dart index 232c2cbf92..d1ab6d047d 100644 --- a/packages/flutter/test/painting/circle_border_test.dart +++ b/packages/flutter/test/painting/circle_border_test.dart @@ -26,5 +26,5 @@ void main() { paints ..circle(x: 25.0, y: 40.0, radius: 10.0, strokeWidth: 10.0), ); - }); + }, skip: isBrowser); } diff --git a/packages/flutter/test/painting/continous_rectangle_border_test.dart b/packages/flutter/test/painting/continous_rectangle_border_test.dart index ae039f64ff..7e648f89e9 100644 --- a/packages/flutter/test/painting/continous_rectangle_border_test.dart +++ b/packages/flutter/test/painting/continous_rectangle_border_test.dart @@ -42,7 +42,7 @@ void main() { const BorderSide side = BorderSide(width: 4.0); expect(const ContinuousRectangleBorder(side: side).getOuterPath(rect1), looksLikeRect1); expect(const ContinuousRectangleBorder(side: side).getInnerPath(rect1), looksLikeInnerPath); - }); + }, skip: isBrowser); test('ContinuousRectangleBorder non-zero BorderRadius', () { const Rect rect = Rect.fromLTRB(10.0, 20.0, 30.0, 40.0); @@ -55,7 +55,7 @@ void main() { ); expect(border.getOuterPath(rect), looksLikeRect); expect(border.getInnerPath(rect), looksLikeRect); - }); + }, skip: isBrowser); testWidgets('Golden test even radii', (WidgetTester tester) async { await tester.pumpWidget(RepaintBoundary( @@ -74,7 +74,7 @@ void main() { matchesGoldenFile('continuous_rectangle_border.golden_test_even_radii.png'), skip: !isLinux, ); - }); + }, skip: isBrowser); testWidgets('Golden test varying radii', (WidgetTester tester) async { await tester.pumpWidget(RepaintBoundary( @@ -96,7 +96,7 @@ void main() { matchesGoldenFile('continuous_rectangle_border.golden_test_varying_radii.png'), skip: !isLinux, ); - }); + }, skip: isBrowser); testWidgets('Golden test large radii', (WidgetTester tester) async { await tester.pumpWidget(RepaintBoundary( @@ -115,6 +115,6 @@ void main() { matchesGoldenFile('continuous_rectangle_border.golden_test_large_radii.png'), skip: !isLinux, ); - }); + }, skip: isBrowser); } diff --git a/packages/flutter/test/painting/decoration_test.dart b/packages/flutter/test/painting/decoration_test.dart index 9c0609d3ac..c5ae1e5d05 100644 --- a/packages/flutter/test/painting/decoration_test.dart +++ b/packages/flutter/test/painting/decoration_test.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. +@TestOn('!chrome') import 'dart:async'; import 'dart:typed_data'; import 'dart:ui' as ui show Image, ImageByteFormat, ColorFilter; diff --git a/packages/flutter/test/painting/image_cache_test.dart b/packages/flutter/test/painting/image_cache_test.dart index 0b5b33cb76..13b14bf861 100644 --- a/packages/flutter/test/painting/image_cache_test.dart +++ b/packages/flutter/test/painting/image_cache_test.dart @@ -9,8 +9,11 @@ import '../rendering/rendering_tester.dart'; import 'mocks_for_image_cache.dart'; void main() { - TestRenderingFlutterBinding(); // initializes the imageCache group(ImageCache, () { + setUpAll(() { + TestRenderingFlutterBinding(); // initializes the imageCache + }); + tearDown(() { imageCache.clear(); imageCache.maximumSize = 1000; diff --git a/packages/flutter/test/painting/image_provider_test.dart b/packages/flutter/test/painting/image_provider_test.dart index 769952eb78..448330b86a 100644 --- a/packages/flutter/test/painting/image_provider_test.dart +++ b/packages/flutter/test/painting/image_provider_test.dart @@ -175,7 +175,7 @@ void main() { debugNetworkImageHttpClientProvider = () => client2; await loadNetworkImage(); expect(capturedErrors, ['client1', 'client2']); - }); + }, skip: isBrowser); test('Propagates http client errors during resolve()', () async { when(httpClient.getUrl(any)).thenThrow(Error()); diff --git a/packages/flutter/test/painting/image_resolution_test.dart b/packages/flutter/test/painting/image_resolution_test.dart index 7208645916..2d22052d7e 100644 --- a/packages/flutter/test/painting/image_resolution_test.dart +++ b/packages/flutter/test/painting/image_resolution_test.dart @@ -147,7 +147,7 @@ void main() { expect(bundleKey.scale, 1.0); })); }); - }); + }, skip: isBrowser); group('Regression - When assets available are 1.0 and 3.0 check devices with a range of scales', () { const String mainAssetPath = 'assets/normalFolder/normalFile.png'; @@ -203,6 +203,6 @@ void main() { test('Typical case 4.0', () { _buildBundleAndTestVariantLogic(4.0, 3.0, variantPath); }); - }); + }, skip: isBrowser); } diff --git a/packages/flutter/test/painting/notched_shapes_test.dart b/packages/flutter/test/painting/notched_shapes_test.dart index 35d674a04a..05b991e006 100644 --- a/packages/flutter/test/painting/notched_shapes_test.dart +++ b/packages/flutter/test/painting/notched_shapes_test.dart @@ -81,7 +81,7 @@ void main() { sampleSize: 100, ), ); - }); + }, skip: isBrowser); test('AutomaticNotchedShape - no guest', () { expect( diff --git a/packages/flutter/test/painting/rounded_rectangle_border_test.dart b/packages/flutter/test/painting/rounded_rectangle_border_test.dart index 6b1fd2419d..9fa7d1f101 100644 --- a/packages/flutter/test/painting/rounded_rectangle_border_test.dart +++ b/packages/flutter/test/painting/rounded_rectangle_border_test.dart @@ -91,5 +91,5 @@ void main() { expect(direct50, indirect50); expect(direct50.hashCode, indirect50.hashCode); expect(direct50.toString(), indirect50.toString()); - }); + }, skip: isBrowser); } diff --git a/packages/flutter/test/painting/stadium_border_test.dart b/packages/flutter/test/painting/stadium_border_test.dart index 9326e27d9e..6739d881c3 100644 --- a/packages/flutter/test/painting/stadium_border_test.dart +++ b/packages/flutter/test/painting/stadium_border_test.dart @@ -84,7 +84,7 @@ void main() { expect(direct50, indirect50); expect(direct50.hashCode, indirect50.hashCode); expect(direct50.toString(), indirect50.toString()); - }); + }, skip: isBrowser); test('StadiumBorder and RoundedRectBorder', () { const StadiumBorder stadium = StadiumBorder(side: BorderSide.none); diff --git a/packages/flutter/test/painting/text_painter_test.dart b/packages/flutter/test/painting/text_painter_test.dart index cfa5f56883..1c354f687b 100644 --- a/packages/flutter/test/painting/text_painter_test.dart +++ b/packages/flutter/test/painting/text_painter_test.dart @@ -31,7 +31,7 @@ void main() { painter.layout(); caretOffset = painter.getOffsetForCaret(ui.TextPosition(offset: text.length), ui.Rect.zero); expect(caretOffset.dx, painter.width); - }); + }, skip: isBrowser); test('TextPainter null text test', () { final TextPainter painter = TextPainter() @@ -56,7 +56,7 @@ void main() { expect(caretOffset.dx, 0); caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 1), ui.Rect.zero); expect(caretOffset.dx, 0); - }); + }, skip: isBrowser); test('TextPainter caret emoji test', () { final TextPainter painter = TextPainter() @@ -120,7 +120,7 @@ void main() { expect(caretOffset.dx, 112); // 🇸 caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 22), ui.Rect.zero); expect(caretOffset.dx, 112); // 🇸 - }); + }, skip: isBrowser); test('TextPainter caret center space test', () { final TextPainter painter = TextPainter() @@ -142,7 +142,7 @@ void main() { expect(caretOffset.dx, 35); caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 2), ui.Rect.zero); expect(caretOffset.dx, 49); - }); + }, skip: isBrowser); test('TextPainter error test', () { final TextPainter painter = TextPainter(textDirection: TextDirection.ltr); @@ -170,7 +170,7 @@ void main() { ); painter.layout(); expect(painter.size, const Size(123.0, 123.0)); - }); + }, skip: isBrowser); test('TextPainter textScaleFactor test', () { final TextPainter painter = TextPainter( @@ -187,7 +187,7 @@ void main() { ); painter.layout(); expect(painter.size, const Size(20.0, 20.0)); - }); + }, skip: isBrowser); test('TextPainter default text height is 14 pixels', () { final TextPainter painter = TextPainter( @@ -197,7 +197,7 @@ void main() { painter.layout(); expect(painter.preferredLineHeight, 14.0); expect(painter.size, const Size(14.0, 14.0)); - }); + }, skip: isBrowser); test('TextPainter sets paragraph size from root', () { final TextPainter painter = TextPainter( @@ -207,7 +207,7 @@ void main() { painter.layout(); expect(painter.preferredLineHeight, 100.0); expect(painter.size, const Size(100.0, 100.0)); - }); + }, skip: isBrowser); test('TextPainter intrinsic dimensions', () { const TextStyle style = TextStyle( @@ -634,7 +634,7 @@ void main() { ); expect(caretOffset.dx, closeTo(0.0, 0.0001)); expect(caretOffset.dy, closeTo(0.0, 0.0001)); - }); + }, skip: isBrowser); test('TextPainter widget span', () { final TextPainter painter = TextPainter() @@ -728,5 +728,5 @@ void main() { expect(painter.inlinePlaceholderBoxes[11], const TextBox.fromLTRBD(250, 30, 300, 60, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes[12], const TextBox.fromLTRBD(300, 30, 351, 60, TextDirection.ltr)); expect(painter.inlinePlaceholderBoxes[13], const TextBox.fromLTRBD(351, 30, 401, 60, TextDirection.ltr)); - }); + }, skip: isBrowser); } diff --git a/packages/flutter/test/painting/text_style_test.dart b/packages/flutter/test/painting/text_style_test.dart index c88f6fd104..43512dcf45 100644 --- a/packages/flutter/test/painting/text_style_test.dart +++ b/packages/flutter/test/painting/text_style_test.dart @@ -180,7 +180,7 @@ void main() { final ui.ParagraphStyle ps5 = s5.getParagraphStyle(); expect(ps5, equals(ui.ParagraphStyle(fontWeight: FontWeight.w700, fontSize: 12.0, height: 123.0))); expect(ps5.toString(), 'ParagraphStyle(textAlign: unspecified, textDirection: unspecified, fontWeight: FontWeight.w700, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 12.0, height: 123.0x, ellipsis: unspecified, locale: unspecified)'); - }); + }, skip: isBrowser); test('TextStyle with text direction', () { @@ -212,7 +212,7 @@ void main() { const TextStyle s10 = TextStyle(fontFamilyFallback: [], package: 'p'); expect(s10.fontFamilyFallback, []); - }); + }, skip: isBrowser); test('TextStyle font family fallback', () { const TextStyle s1 = TextStyle(fontFamilyFallback: ['Roboto', 'test']); @@ -237,7 +237,7 @@ void main() { final ui.TextStyle uis1 = s2.getTextStyle(); expect(uis1.toString(), 'TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, decorationThickness: unspecified, fontWeight: unspecified, fontStyle: unspecified, textBaseline: unspecified, fontFamily: foo, fontFamilyFallback: [Roboto, test], fontSize: unspecified, letterSpacing: unspecified, wordSpacing: unspecified, height: unspecified, locale: unspecified, background: unspecified, foreground: unspecified, shadows: unspecified, fontFeatures: unspecified)'); - }); + }, skip: isBrowser); test('TextStyle.debugLabel', () { const TextStyle unknown = TextStyle();