diff --git a/.cirrus.yml b/.cirrus.yml index 39870aad57..8ec0a8a062 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -150,7 +150,6 @@ task: # As of October 2019, the Web shards needed more than 6G of RAM. CPU: 2 MEMORY: 8G - allow_failures: true script: - dart --enable-asserts ./dev/bots/test.dart @@ -160,7 +159,6 @@ task: # As of October 2019, the Web shards needed more than 6G of RAM. CPU: 2 MEMORY: 8G - allow_failures: true script: - dart --enable-asserts ./dev/bots/test.dart @@ -170,7 +168,6 @@ task: # As of October 2019, the Web shards needed more than 6G of RAM. CPU: 2 MEMORY: 8G - allow_failures: true script: - dart --enable-asserts ./dev/bots/test.dart @@ -180,7 +177,6 @@ task: # As of October 2019, the Web shards needed more than 6G of RAM. CPU: 2 MEMORY: 8G - allow_failures: true script: - dart --enable-asserts ./dev/bots/test.dart @@ -190,17 +186,33 @@ task: # As of October 2019, the Web shards needed more than 6G of RAM. CPU: 2 MEMORY: 8G - allow_failures: true script: - dart --enable-asserts ./dev/bots/test.dart - - name: web_tests-5_last-linux # last Web shard must end with _last + - name: web_tests-5-linux + only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'packages/flutter_web_plugins/**', 'bin/internal/**') || $CIRRUS_PR == ''" + environment: + # As of October 2019, the Web shards needed more than 6G of RAM. + CPU: 2 + MEMORY: 8G + script: + - dart --enable-asserts ./dev/bots/test.dart + + - name: web_tests-6-linux + only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'packages/flutter_web_plugins/**', 'bin/internal/**') || $CIRRUS_PR == ''" + environment: + # As of October 2019, the Web shards needed more than 6G of RAM. + CPU: 2 + MEMORY: 8G + script: + - dart --enable-asserts ./dev/bots/test.dart + + - name: web_tests-7_last-linux # last Web shard must end with _last only_if: "changesInclude('.cirrus.yml', 'dev/**', 'packages/flutter/**', 'packages/flutter_test/**', 'packages/flutter_tools/lib/src/test/**', 'packages/flutter_web_plugins/**', 'bin/internal/**') || $CIRRUS_PR == ''" environment: # As of October 2019, the Web shards needed more than 6G of RAM. CPU: 2 MEMORY: 8G - allow_failures: true script: - dart --enable-asserts ./dev/bots/test.dart diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 2286ce8b53..731c360100 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -50,7 +50,7 @@ const int kDeviceLabShardCount = 4; /// and make sure it runs _all_ shards. /// /// The last shard also runs the Web plugin tests. -const int kWebShardCount = 6; +const int kWebShardCount = 8; /// Maximum number of Web tests to run in a single `flutter test`. We found that /// large batches can get flaky, possibly because we reuse a single instance of @@ -63,7 +63,6 @@ const int kWebBatchSize = 20; const List kWebTestDirectoryBlacklist = [ 'cupertino', 'examples', - 'material', ]; const List kWebTestFileBlacklist = [ 'test/widgets/heroes_test.dart', @@ -77,6 +76,11 @@ const List kWebTestFileBlacklist = [ 'test/widgets/widget_inspector_test.dart', 'test/widgets/draggable_test.dart', 'test/widgets/shortcuts_test.dart', + 'test/material/text_form_field_test.dart', + 'test/material/banner_theme_test.dart', + 'test/material/popup_menu_test.dart', + 'test/material/data_table_test.dart', + 'test/material/toggle_buttons_test.dart', ]; /// When you call this, you can pass additional arguments to pass custom diff --git a/packages/flutter/lib/src/material/slider_theme.dart b/packages/flutter/lib/src/material/slider_theme.dart index 56dc9d5344..52282c19ec 100644 --- a/packages/flutter/lib/src/material/slider_theme.dart +++ b/packages/flutter/lib/src/material/slider_theme.dart @@ -2620,6 +2620,7 @@ class _PaddleSliderTrackShapePathPainter { // Adds an arc to the path that has the attributes passed in. This is // a convenience to make adding arcs have less boilerplate. static void _addArc(Path path, Offset center, double radius, double startAngle, double endAngle) { + assert(center.isFinite); final Rect arcRect = Rect.fromCircle(center: center, radius: radius); path.arcTo(arcRect, startAngle, endAngle - startAngle, false); } @@ -2692,6 +2693,12 @@ class _PaddleSliderTrackShapePathPainter { TextPainter labelPainter, Color strokePaintColor, ) { + if (scale == 0.0) { + // Zero scale essentially means "do not draw anything", so it's safe to just return. Otherwise, + // our math below will attempt to divide by zero and send needless NaNs to the engine. + return; + } + // The entire value indicator should scale with the size of the label, // to keep it large enough to encompass the label text. final double textScaleFactor = labelPainter.height / _labelTextDesignSize; diff --git a/packages/flutter/test/material/paginated_data_table_test.dart b/packages/flutter/test/material/paginated_data_table_test.dart index 0cb2543b6b..ca53caab3a 100644 --- a/packages/flutter/test/material/paginated_data_table_test.dart +++ b/packages/flutter/test/material/paginated_data_table_test.dart @@ -259,7 +259,7 @@ void main() { expect(find.text('501'), findsOneWidget); // Test that it fits: expect(tester.getTopRight(find.text('501')).dx, greaterThanOrEqualTo(tester.getTopRight(find.text('Rows per page:')).dx + 40.0)); - }); + }, skip: isBrowser); // TODO(yjbanov): https://github.com/flutter/flutter/issues/43433 testWidgets('PaginatedDataTable footer scrolls', (WidgetTester tester) async { final TestDataSource source = TestDataSource(); diff --git a/packages/flutter/test/material/slider_theme_test.dart b/packages/flutter/test/material/slider_theme_test.dart index c5c756e463..0fe0688602 100644 --- a/packages/flutter/test/material/slider_theme_test.dart +++ b/packages/flutter/test/material/slider_theme_test.dart @@ -814,10 +814,40 @@ void main() { await gesture.up(); }); + + testWidgets('PaddleRangeSliderValueIndicatorShape skips all painting at zero scale', (WidgetTester tester) async { + // Pump a slider with just a value indicator. + await tester.pumpWidget(_buildApp( + ThemeData().sliderTheme.copyWith( + trackHeight: 0, + overlayShape: SliderComponentShape.noOverlay, + thumbShape: SliderComponentShape.noThumb, + tickMarkShape: SliderTickMarkShape.noTickMark, + showValueIndicator: ShowValueIndicator.always, + rangeValueIndicatorShape: const PaddleRangeSliderValueIndicatorShape(), + ), + value: 0.5, + divisions: 4, + )); + + final RenderBox sliderBox = tester.firstRenderObject(find.byType(Slider)); + + // Tap the center of the track to kick off the animation of the value indicator. + final Offset center = tester.getCenter(find.byType(Slider)); + final TestGesture gesture = await tester.startGesture(center); + + // Nothing to paint at scale 0. + await tester.pump(); + expect(sliderBox, paintsNothing); + + // Painting a path for the value indicator. + await tester.pump(const Duration(milliseconds: 16)); + expect(sliderBox, paintsExactlyCountTimes(#drawPath, 1)); + + await gesture.up(); + }); } - - Widget _buildApp( SliderThemeData sliderTheme, { double value = 0.0, @@ -841,5 +871,3 @@ Widget _buildApp( ), ); } - - diff --git a/packages/flutter_tools/lib/src/build_runner/build_script.dart b/packages/flutter_tools/lib/src/build_runner/build_script.dart index 88c304d592..325121f384 100644 --- a/packages/flutter_tools/lib/src/build_runner/build_script.dart +++ b/packages/flutter_tools/lib/src/build_runner/build_script.dart @@ -278,7 +278,7 @@ Future main() async { // we don't have an embedder yet this is the lowest-most layer we can put // this stuff in. ui.debugEmulateFlutterTesterEnvironment = true; - await ui.webOnlyInitializeEngine(); + await ui.webOnlyInitializePlatform(); // TODO(flutterweb): remove need for dynamic cast. (ui.window as dynamic).debugOverrideDevicePixelRatio(3.0); (ui.window as dynamic).webOnlyDebugPhysicalSizeOverride = const ui.Size(2400, 1800); diff --git a/packages/flutter_tools/lib/src/build_runner/web_compilation_delegate.dart b/packages/flutter_tools/lib/src/build_runner/web_compilation_delegate.dart index d261247569..3a80cc646d 100644 --- a/packages/flutter_tools/lib/src/build_runner/web_compilation_delegate.dart +++ b/packages/flutter_tools/lib/src/build_runner/web_compilation_delegate.dart @@ -30,6 +30,7 @@ class BuildRunnerWebCompilationProxy extends WebCompilationProxy { Future initialize({ Directory projectDirectory, String testOutputDir, + List testFiles, BuildMode mode, String projectName, bool initializePlatform, @@ -46,8 +47,15 @@ class BuildRunnerWebCompilationProxy extends WebCompilationProxy { release: mode == BuildMode.release, profile: mode == BuildMode.profile, hasPlugins: hasWebPlugins, - includeTests: true, initializePlatform: initializePlatform, + testTargets: WebTestTargetManifest( + testFiles + .map((String absolutePath) { + final String relativePath = path.relative(absolutePath, from: projectDirectory.path); + return '${path.withoutExtension(relativePath)}.*'; + }) + .toList(), + ), ); client.startBuild(); bool success = true; diff --git a/packages/flutter_tools/lib/src/build_runner/web_fs.dart b/packages/flutter_tools/lib/src/build_runner/web_fs.dart index 3d83be8250..322ab33089 100644 --- a/packages/flutter_tools/lib/src/build_runner/web_fs.dart +++ b/packages/flutter_tools/lib/src/build_runner/web_fs.dart @@ -531,6 +531,16 @@ class ConnectionResult { final DebugConnection debugConnection; } +class WebTestTargetManifest { + WebTestTargetManifest(this.buildFilters); + + WebTestTargetManifest.all() : buildFilters = null; + + final List buildFilters; + + bool get hasBuildFilters => buildFilters != null && buildFilters.isNotEmpty; +} + /// A testable interface for starting a build daemon. class BuildDaemonCreator { const BuildDaemonCreator(); @@ -547,8 +557,8 @@ class BuildDaemonCreator { bool release = false, bool profile = false, bool hasPlugins = false, - bool includeTests = false, bool initializePlatform = true, + WebTestTargetManifest testTargets, }) async { try { final BuildDaemonClient client = await _connectClient( @@ -557,8 +567,9 @@ class BuildDaemonCreator { profile: profile, hasPlugins: hasPlugins, initializePlatform: initializePlatform, + testTargets: testTargets, ); - _registerBuildTargets(client, includeTests); + _registerBuildTargets(client, testTargets); return client; } on OptionsSkew { throwToolExit( @@ -571,7 +582,7 @@ class BuildDaemonCreator { void _registerBuildTargets( BuildDaemonClient client, - bool includeTests, + WebTestTargetManifest testTargets, ) { final OutputLocation outputLocation = OutputLocation((OutputLocationBuilder b) => b ..output = '' @@ -580,10 +591,15 @@ class BuildDaemonCreator { client.registerBuildTarget(DefaultBuildTarget((DefaultBuildTargetBuilder b) => b ..target = 'web' ..outputLocation = outputLocation?.toBuilder())); - if (includeTests) { - client.registerBuildTarget(DefaultBuildTarget((DefaultBuildTargetBuilder b) => b - ..target = 'test' - ..outputLocation = outputLocation?.toBuilder())); + if (testTargets != null) { + client.registerBuildTarget(DefaultBuildTarget((DefaultBuildTargetBuilder b) { + b.target = 'test'; + b.outputLocation = outputLocation?.toBuilder(); + if (testTargets.hasBuildFilters) { + b.buildFilters.addAll(testTargets.buildFilters); + } + return b; + })); } } @@ -593,29 +609,37 @@ class BuildDaemonCreator { bool profile, bool hasPlugins, bool initializePlatform, + WebTestTargetManifest testTargets, }) { final String flutterToolsPackages = fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools', '.packages'); final String buildScript = fs.path.join(Cache.flutterRoot, 'packages', 'flutter_tools', 'lib', 'src', 'build_runner', 'build_script.dart'); final String flutterWebSdk = artifacts.getArtifactPath(Artifact.flutterWebSdk); + + // On Windows we need to call the snapshot directly otherwise + // the process will start in a disjoint cmd without access to + // STDIO. + final List args = [ + artifacts.getArtifactPath(Artifact.engineDartBinary), + '--packages=$flutterToolsPackages', + buildScript, + 'daemon', + '--skip-build-script-check', + '--define', 'flutter_tools:ddc=flutterWebSdk=$flutterWebSdk', + '--define', 'flutter_tools:entrypoint=flutterWebSdk=$flutterWebSdk', + '--define', 'flutter_tools:entrypoint=release=$release', + '--define', 'flutter_tools:entrypoint=profile=$profile', + '--define', 'flutter_tools:shell=flutterWebSdk=$flutterWebSdk', + '--define', 'flutter_tools:shell=hasPlugins=$hasPlugins', + '--define', 'flutter_tools:shell=initializePlatform=$initializePlatform', + // The following will cause build runner to only build tests that were requested. + if (testTargets != null && testTargets.hasBuildFilters) + for (String buildFilter in testTargets.buildFilters) + '--build-filter=$buildFilter', + ]; + return BuildDaemonClient.connect( workingDirectory, - // On Windows we need to call the snapshot directly otherwise - // the process will start in a disjoint cmd without access to - // STDIO. - [ - artifacts.getArtifactPath(Artifact.engineDartBinary), - '--packages=$flutterToolsPackages', - buildScript, - 'daemon', - '--skip-build-script-check', - '--define', 'flutter_tools:ddc=flutterWebSdk=$flutterWebSdk', - '--define', 'flutter_tools:entrypoint=flutterWebSdk=$flutterWebSdk', - '--define', 'flutter_tools:entrypoint=release=$release', - '--define', 'flutter_tools:entrypoint=profile=$profile', - '--define', 'flutter_tools:shell=flutterWebSdk=$flutterWebSdk', - '--define', 'flutter_tools:shell=hasPlugins=$hasPlugins', - '--define', 'flutter_tools:shell=initializePlatform=$initializePlatform', - ], + args, logHandler: (ServerLog serverLog) { switch (serverLog.level) { case Level.SEVERE: diff --git a/packages/flutter_tools/lib/src/test/flutter_web_platform.dart b/packages/flutter_tools/lib/src/test/flutter_web_platform.dart index da969adc24..96fc9e445b 100644 --- a/packages/flutter_tools/lib/src/test/flutter_web_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_web_platform.dart @@ -139,7 +139,7 @@ class FlutterWebPlatform extends PlatformPlugin { requireJs.openRead(), headers: {'Content-Type': 'text/javascript'}, ); - } else if (request.requestedUri.path.contains('Ahem.ttf')) { + } else if (request.requestedUri.path.contains('ahem.ttf')) { return shelf.Response.ok(ahem.openRead()); } else if (request.requestedUri.path.contains('dart_sdk.js')) { return shelf.Response.ok( diff --git a/packages/flutter_tools/lib/src/test/runner.dart b/packages/flutter_tools/lib/src/test/runner.dart index 8e7f6fd3c5..f5681505a9 100644 --- a/packages/flutter_tools/lib/src/test/runner.dart +++ b/packages/flutter_tools/lib/src/test/runner.dart @@ -71,6 +71,7 @@ Future runTests( final bool result = await webCompilationProxy.initialize( projectDirectory: flutterProject.directory, testOutputDir: tempBuildDir, + testFiles: testFiles, projectName: flutterProject.manifest.appName, initializePlatform: true, ); diff --git a/packages/flutter_tools/lib/src/web/compile.dart b/packages/flutter_tools/lib/src/web/compile.dart index e567d9126a..51413ad0a0 100644 --- a/packages/flutter_tools/lib/src/web/compile.dart +++ b/packages/flutter_tools/lib/src/web/compile.dart @@ -75,6 +75,7 @@ class WebCompilationProxy { @required Directory projectDirectory, @required String projectName, String testOutputDir, + List testFiles, BuildMode mode, bool initializePlatform, }) async {