From b6a2efb7abf5785e29e72533f8ad506dd2dcde47 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Thu, 18 Apr 2019 16:08:09 -0700 Subject: [PATCH 01/18] Committing progress. Documentation and testing incomplete/in progress. Code cleanup needed as well. --- .../flutter_goldens/lib/flutter_goldens.dart | 51 +-- .../flutter_goldens_client/lib/client.dart | 377 ++++++++++++------ packages/flutter_test/lib/src/matchers.dart | 57 +++ 3 files changed, 324 insertions(+), 161 deletions(-) diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index 4f28df3576e..e02630b9c0d 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -1,8 +1,8 @@ // Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - import 'dart:async'; +import 'dart:io'; import 'dart:typed_data'; import 'package:file/file.dart'; @@ -12,6 +12,8 @@ import 'package:meta/meta.dart'; import 'package:flutter_goldens_client/client.dart'; export 'package:flutter_goldens_client/client.dart'; +//TODO(katelovett): Tests [flutter_goldens_test.dart] and inline documentation +const String _kFlutterRootKey = 'FLUTTER_ROOT'; /// Main method that can be used in a `flutter_test_config.dart` file to set /// [goldenFileComparator] to an instance of [FlutterGoldenFileComparator] that @@ -25,12 +27,14 @@ Future main(FutureOr testMain()) async { /// /// Within the https://github.com/flutter/flutter repository, it's important /// not to check-in binaries in order to keep the size of the repository to a -/// minimum. To satisfy this requirement, this comparator retrieves the golden -/// files from a sibling repository, `flutter/goldens`. +/// minimum. To satisfy this requirement, this comparator uses the +/// [SkiaGoldClient] to upload widgets for golden tests and process results. /// /// This comparator will locally clone the `flutter/goldens` repository into /// the `$FLUTTER_ROOT/bin/cache/pkg/goldens` folder, then perform the comparison against /// the files therein. +/// This comparator will instantiate the [SkiaGoldClient] and process the +/// results of the test. class FlutterGoldenFileComparator implements GoldenFileComparator { /// Creates a [FlutterGoldenFileComparator] that will resolve golden file /// URIs relative to the specified [basedir]. @@ -49,48 +53,36 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { @visibleForTesting final FileSystem fs; + /// Instance of the [SkiaGoldClient] for executing tests. + final SkiaGoldClient _skiaClient = SkiaGoldClient(); + /// Creates a new [FlutterGoldenFileComparator] that mirrors the relative /// path resolution of the default [goldenFileComparator]. /// - /// By the time the future completes, the clone of the `flutter/goldens` - /// repository is guaranteed to be ready use. - /// - /// The [goldens] and [defaultComparator] parameters are visible for testing + /// The [defaultComparator] parameter is visible for testing /// purposes only. static Future fromDefaultComparator({ - GoldensClient goldens, LocalFileComparator defaultComparator, }) async { defaultComparator ??= goldenFileComparator; - // Prepare the goldens repo. - goldens ??= GoldensClient(); - await goldens.prepare(); - // Calculate the appropriate basedir for the current test context. - final FileSystem fs = goldens.fs; + const FileSystem fs = LocalFileSystem(); final Directory testDirectory = fs.directory(defaultComparator.basedir); - final String testDirectoryRelativePath = fs.path.relative(testDirectory.path, from: goldens.flutterRoot.path); - return FlutterGoldenFileComparator(goldens.repositoryRoot.childDirectory(testDirectoryRelativePath).uri); + final Directory flutterRoot = fs.directory(Platform.environment[_kFlutterRootKey]); + final Directory goldenRoot = flutterRoot.childDirectory(fs.path.join('bin', 'cache', 'pkg', 'goldens')); + final String testDirectoryRelativePath = fs.path.relative(testDirectory.path, from: flutterRoot.path); + return FlutterGoldenFileComparator(goldenRoot.childDirectory(testDirectoryRelativePath).uri); } @override Future compare(Uint8List imageBytes, Uri golden) async { final File goldenFile = _getGoldenFile(golden); - if (!goldenFile.existsSync()) { - throw TestFailure('Could not be compared against non-existent file: "$golden"'); - } - final List goldenBytes = await goldenFile.readAsBytes(); - // TODO(tvolkert): Improve the intelligence of this comparison. - if (goldenBytes.length != imageBytes.length) { - return false; - } - for (int i = 0; i < goldenBytes.length; i++) { - if (goldenBytes[i] != imageBytes[i]) { - return false; - } - } - return true; + + bool authorized = await _skiaClient.auth(fs.directory(basedir)); + bool tested = await _skiaClient.imgtest(golden.path, goldenFile); + return true; // TEMP + //TODO(katelovett): Process results } @override @@ -103,4 +95,5 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { File _getGoldenFile(Uri uri) { return fs.directory(basedir).childFile(fs.file(uri).path); } + } diff --git a/packages/flutter_goldens_client/lib/client.dart b/packages/flutter_goldens_client/lib/client.dart index 6c290ed7939..4ff5ddfebf0 100644 --- a/packages/flutter_goldens_client/lib/client.dart +++ b/packages/flutter_goldens_client/lib/client.dart @@ -1,8 +1,9 @@ // Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - +//TODO(katelovett): Change to Skia Gold Client import 'dart:async'; +import 'dart:convert' as convert; import 'dart:io' as io; import 'package:file/file.dart'; @@ -13,165 +14,116 @@ import 'package:process/process.dart'; // If you are here trying to figure out how to use golden files in the Flutter // repo itself, consider reading this wiki page: // https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package%3Aflutter - +//TODO(katelovett): Tests [flutter_goldens_test.dart] and inline documentation const String _kFlutterRootKey = 'FLUTTER_ROOT'; +const String _kGoldctlKey = 'GOLDCTL'; +const String _kServiceAccountKey = 'GOLD_SERVICE_ACCOUNT'; +const String _kSkiaGoldInstance = 'SKIA_GOLD_INSTANCE'; -/// A class that represents a clone of the https://github.com/flutter/goldens -/// repository, nested within the `bin/cache` directory of the caller's Flutter -/// repository. -class GoldensClient { - /// Create a handle to a local clone of the goldens repository. - GoldensClient({ +class SkiaGoldClient { + SkiaGoldClient({ this.fs = const LocalFileSystem(), this.platform = const LocalPlatform(), this.process = const LocalProcessManager(), }); - /// The file system to use for storing the local clone of the repository. - /// - /// This is useful in tests, where a local file system (the default) can - /// be replaced by a memory file system. final FileSystem fs; - - /// A wrapper for the [dart:io.Platform] API. - /// - /// This is useful in tests, where the system platform (the default) can - /// be replaced by a mock platform instance. final Platform platform; - - /// A controller for launching subprocesses. - /// - /// This is useful in tests, where the real process manager (the default) - /// can be replaced by a mock process manager that doesn't really create - /// subprocesses. final ProcessManager process; + Directory _workDirectory; - RandomAccessFile _lock; + //TODO(katelovett): Environment variables swapped out for final CI implementation + String get _goldctl => platform.environment[_kGoldctlKey]; + String get _serviceAccount => platform.environment[_kServiceAccountKey]; + String get _skiaGoldInstance => platform.environment[_kSkiaGoldInstance]; + Directory get _flutterRoot => fs.directory(platform.environment[_kFlutterRootKey]); - /// The local [Directory] where the Flutter repository is hosted. - /// - /// Uses the [fs] file system. - Directory get flutterRoot => fs.directory(platform.environment[_kFlutterRootKey]); + Future auth(Directory workDirectory) async { + _workDirectory = workDirectory; + List authArguments = ['auth']; + if(_serviceAccount == null) + throw const NonZeroExitCode(1, 'No Service Account found.'); - /// The local [Directory] where the goldens repository is hosted. - /// - /// Uses the [fs] file system. - Directory get repositoryRoot => flutterRoot.childDirectory(fs.path.join('bin', 'cache', 'pkg', 'goldens')); + authArguments += [ + '--service-account', _serviceAccount, + '--work-dir', _workDirectory.childDirectory('temp').path, + ]; - /// Prepares the local clone of the `flutter/goldens` repository for golden - /// file testing. - /// - /// This ensures that the goldens repository has been cloned into its - /// expected location within `bin/cache` and that it is synced to the Git - /// revision specified in `bin/internal/goldens.version`. - /// - /// While this is preparing the repository, it obtains a file lock such that - /// [GoldensClient] instances in other processes or isolates will not - /// duplicate the work that this is doing. - Future prepare() async { - final String goldensCommit = await _getGoldensCommit(); - String currentCommit = await _getCurrentCommit(); - if (currentCommit != goldensCommit) { - await _obtainLock(); - try { - // Check the current commit again now that we have the lock. - currentCommit = await _getCurrentCommit(); - if (currentCommit != goldensCommit) { - if (currentCommit == null) { - await _initRepository(); - } - await _checkCanSync(); - await _syncTo(goldensCommit); - } - } finally { - await _releaseLock(); - } + final io.ProcessResult authResults = io.Process.runSync(_goldctl, authArguments); + if (authResults.exitCode != 0) { + final StringBuffer buf = StringBuffer(); + buf + ..writeln('Flutter + Skia Gold auth failed.') + ..writeln('stdout: ${authResults.stdout}') + ..writeln('stderr: ${authResults.stderr}'); + throw NonZeroExitCode(authResults.exitCode, buf.toString()); } + return true; } - Future _getGoldensCommit() async { - final File versionFile = flutterRoot.childFile(fs.path.join('bin', 'internal', 'goldens.version')); - return (await versionFile.readAsString()).trim(); + Future imgtest(String testName, File goldenFile) async { + List imgtestArguments = [ + 'imgtest', + 'add', + ]; + + final String commitHash = await _getCommitHash(); + final String keys = '${_workDirectory.path}keys.json'; + final String failures = '${_workDirectory.path}failures.json'; + await io.File(keys).writeAsString(_getKeysJSON()); + await io.File(failures).create(); + + imgtestArguments += [ + '--instance', _skiaGoldInstance, + '--work-dir', _workDirectory.childDirectory('temp').path, + '--commit', commitHash, + '--test-name', testName, + '--png-file', goldenFile.path, + '--keys-file', keys, + '--failure-file', failures, + '--passfail', + ]; + + if(imgtestArguments.contains(null)) { + final StringBuffer buf = StringBuffer(); + buf.writeln('null argument for Skia Gold imgtest:'); + imgtestArguments.forEach(buf.writeln); + throw NonZeroExitCode(1, buf.toString()); + } + + final io.ProcessResult imgtestResult = io.Process.runSync(_goldctl, imgtestArguments); + if (imgtestResult.exitCode != 0) { + final StringBuffer buf = StringBuffer(); + buf + ..writeln('Flutter + Skia Gold imgtest failed.') + ..writeln('If this is the first execution of this test, it may need to be triaged.') + ..writeln('\tIn this case, re-run the test after triage is completed.') + ..writeln('stdout: ${imgtestResult.stdout}') + ..writeln('stderr: ${imgtestResult.stderr}'); + throw NonZeroExitCode(imgtestResult.exitCode, buf.toString()); + } + return true; } - Future _getCurrentCommit() async { - if (!repositoryRoot.existsSync()) { + Future _getCommitHash() async { + if (!_flutterRoot.existsSync()) { return null; } else { final io.ProcessResult revParse = await process.run( ['git', 'rev-parse', 'HEAD'], - workingDirectory: repositoryRoot.path, + workingDirectory: _flutterRoot.path, ); return revParse.exitCode == 0 ? revParse.stdout.trim() : null; } } - Future _initRepository() async { - await repositoryRoot.create(recursive: true); - await _runCommands( - [ - 'git init', - 'git remote add upstream https://github.com/flutter/goldens.git', - 'git remote set-url --push upstream git@github.com:flutter/goldens.git', - ], - workingDirectory: repositoryRoot, - ); - } - - Future _checkCanSync() async { - final io.ProcessResult result = await process.run( - ['git', 'status', '--porcelain'], - workingDirectory: repositoryRoot.path, - ); - if (result.stdout.trim().isNotEmpty) { - final StringBuffer buf = StringBuffer(); - buf - ..writeln('flutter_goldens git checkout at ${repositoryRoot.path} has local changes and cannot be synced.') - ..writeln('To reset your client to a clean state, and lose any local golden test changes:') - ..writeln('cd ${repositoryRoot.path}') - ..writeln('git reset --hard HEAD') - ..writeln('git clean -x -d -f -f'); - throw NonZeroExitCode(1, buf.toString()); - } - } - - Future _syncTo(String commit) async { - await _runCommands( - [ - 'git pull upstream master', - 'git fetch upstream $commit', - 'git reset --hard FETCH_HEAD', - ], - workingDirectory: repositoryRoot, - ); - } - - Future _runCommands( - List commands, { - Directory workingDirectory, - }) async { - for (String command in commands) { - final List parts = command.split(' '); - final io.ProcessResult result = await process.run( - parts, - workingDirectory: workingDirectory?.path, - ); - if (result.exitCode != 0) { - throw NonZeroExitCode(result.exitCode, result.stderr); - } - } - } - - Future _obtainLock() async { - final File lockFile = flutterRoot.childFile(fs.path.join('bin', 'cache', 'goldens.lockfile')); - await lockFile.create(recursive: true); - _lock = await lockFile.open(mode: io.FileMode.write); - await _lock.lock(io.FileLock.blockingExclusive); - } - - Future _releaseLock() async { - await _lock.close(); - _lock = null; + String _getKeysJSON() { + return convert.json.encode( + { + 'Operating System' : io.Platform.operatingSystem, + 'Operating System Version' : io.Platform.operatingSystemVersion, + 'Dart Version' : io.Platform.version, + }); } } /// Exception that signals a process' exit with a non-zero exit code. @@ -194,3 +146,164 @@ class NonZeroExitCode implements Exception { return 'Exit code $exitCode: $stderr'; } } + +// +///// A class that represents a clone of the https://github.com/flutter/goldens +///// repository, nested within the `bin/cache` directory of the caller's Flutter +///// repository. +//class GoldensClient { +// /// Create a handle to a local clone of the goldens repository. +// GoldensClient({ +// this.fs = const LocalFileSystem(), +// this.platform = const LocalPlatform(), +// this.process = const LocalProcessManager(), +// }); +// +// /// The file system to use for storing the local clone of the repository. +// /// +// /// This is useful in tests, where a local file system (the default) can +// /// be replaced by a memory file system. +// final FileSystem fs; +// +// /// A wrapper for the [dart:io.Platform] API. +// /// +// /// This is useful in tests, where the system platform (the default) can +// /// be replaced by a mock platform instance. +// final Platform platform; +// +// /// A controller for launching subprocesses. +// /// +// /// This is useful in tests, where the real process manager (the default) +// /// can be replaced by a mock process manager that doesn't really create +// /// subprocesses. +// final ProcessManager process; +// +// RandomAccessFile _lock; +// +// /// The local [Directory] where the Flutter repository is hosted. +// /// +// /// Uses the [fs] file system. +// Directory get flutterRoot => fs.directory(platform.environment[_kFlutterRootKey]); +// +// /// The local [Directory] where the goldens repository is hosted. +// /// +// /// Uses the [fs] file system. +// Directory get repositoryRoot => flutterRoot.childDirectory(fs.path.join('bin', 'cache', 'pkg', 'goldens')); +// +// /// Prepares the local clone of the `flutter/goldens` repository for golden +// /// file testing. +// /// +// /// This ensures that the goldens repository has been cloned into its +// /// expected location within `bin/cache` and that it is synced to the Git +// /// revision specified in `bin/internal/goldens.version`. +// /// +// /// While this is preparing the repository, it obtains a file lock such that +// /// [GoldensClient] instances in other processes or isolates will not +// /// duplicate the work that this is doing. +// Future prepare() async { +// print('GoldensClient.prepare'); +// final String goldensCommit = await _getGoldensCommit(); +// String currentCommit = await _getCurrentCommit(); +// if (currentCommit != goldensCommit) { +// await _obtainLock(); +// try { +// // Check the current commit again now that we have the lock. +// currentCommit = await _getCurrentCommit(); +// if (currentCommit != goldensCommit) { +// if (currentCommit == null) { +// await _initRepository(); +// } +// await _checkCanSync(); +// await _syncTo(goldensCommit); +// } +// } finally { +// await _releaseLock(); +// } +// } +// } +// +// Future _getGoldensCommit() async { +// final File versionFile = flutterRoot.childFile(fs.path.join('bin', 'internal', 'goldens.version')); +// return (await versionFile.readAsString()).trim(); +// } +// +// Future _getCurrentCommit() async { +// if (!repositoryRoot.existsSync()) { +// return null; +// } else { +// final io.ProcessResult revParse = await process.run( +// ['git', 'rev-parse', 'HEAD'], +// workingDirectory: repositoryRoot.path, +// ); +// return revParse.exitCode == 0 ? revParse.stdout.trim() : null; +// } +// } +// +// Future _initRepository() async { +// await repositoryRoot.create(recursive: true); +// await _runCommands( +// [ +// 'git init', +// 'git remote add upstream https://github.com/flutter/goldens.git', +// 'git remote set-url --push upstream git@github.com:flutter/goldens.git', +// ], +// workingDirectory: repositoryRoot, +// ); +// } +// +// Future _checkCanSync() async { +// final io.ProcessResult result = await process.run( +// ['git', 'status', '--porcelain'], +// workingDirectory: repositoryRoot.path, +// ); +// if (result.stdout.trim().isNotEmpty) { +// final StringBuffer buf = StringBuffer(); +// buf +// ..writeln('flutter_goldens git checkout at ${repositoryRoot.path} has local changes and cannot be synced.') +// ..writeln('To reset your client to a clean state, and lose any local golden test changes:') +// ..writeln('cd ${repositoryRoot.path}') +// ..writeln('git reset --hard HEAD') +// ..writeln('git clean -x -d -f -f'); +// throw NonZeroExitCode(1, buf.toString()); +// } +// } +// +// Future _syncTo(String commit) async { +// await _runCommands( +// [ +// 'git pull upstream master', +// 'git fetch upstream $commit', +// 'git reset --hard FETCH_HEAD', +// ], +// workingDirectory: repositoryRoot, +// ); +// } +// +// Future _runCommands( +// List commands, { +// Directory workingDirectory, +// }) async { +// for (String command in commands) { +// final List parts = command.split(' '); +// final io.ProcessResult result = await process.run( +// parts, +// workingDirectory: workingDirectory?.path, +// ); +// if (result.exitCode != 0) { +// throw NonZeroExitCode(result.exitCode, result.stderr); +// } +// } +// } +// +// Future _obtainLock() async { +// final File lockFile = flutterRoot.childFile(fs.path.join('bin', 'cache', 'goldens.lockfile')); +// await lockFile.create(recursive: true); +// _lock = await lockFile.open(mode: io.FileMode.write); +// await _lock.lock(io.FileLock.blockingExclusive); +// } +// +// Future _releaseLock() async { +// await _lock.close(); +// _lock = null; +// } +//} \ No newline at end of file diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index 816cdeced49..6a3491b4d71 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -296,6 +296,16 @@ AsyncMatcher matchesGoldenFile(dynamic key) { throw ArgumentError('Unexpected type for golden file: ${key.runtimeType}'); } +/// TODO(katelovett): Documentation +AsyncMatcher matchesSkiaGoldFile(dynamic key) { + if (key is Uri) { + return _MatchesSkiaGoldFile(key); + } else if (key is String) { + return _MatchesSkiaGoldFile.forStringPath(key); + } + throw ArgumentError('Unexpected type for Skia Gold file: ${key.runtimeType}'); +} + /// Asserts that a [Finder], [Future], or [ui.Image] matches a /// reference image identified by [image]. /// @@ -1688,6 +1698,53 @@ class _MatchesGoldenFile extends AsyncMatcher { description.add('one widget whose rasterized image matches golden image "$key"'); } +class _MatchesSkiaGoldFile extends AsyncMatcher { + const _MatchesSkiaGoldFile(this.key); + + _MatchesSkiaGoldFile.forStringPath(String path) : key = Uri.parse(path); + + final Uri key; + + @override + Future matchAsync(dynamic item) async { + Future imageFuture; + if (item is Future) { + imageFuture = item; + }else if (item is ui.Image) { + imageFuture = Future.value(item); + } else { + final Finder finder = item; + final Iterable elements = finder.evaluate(); + if (elements.isEmpty) { + return 'could not be rendered because no widget was found.'; + } else if (elements.length > 1) { + return 'matched too many widgets.'; + } + imageFuture = _captureImage(elements.single); + } + + final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); + return binding.runAsync(() async { + final ui.Image image = await imageFuture; + final ByteData bytes = await image.toByteData(format: ui.ImageByteFormat.png) + .timeout(const Duration(seconds: 10), onTimeout: () => null); + if (bytes == null) + return 'Failed to generate screenshot from engine within the 10,000ms timeout'; + await goldenFileComparator.update(key, bytes.buffer.asUint8List()); + try { + final bool success = await goldenFileComparator.compare(null, key); + return success ? null : 'Skia Gold test fail.'; + } on TestFailure catch (ex) { + return ex.message; + } + }, additionalTime: const Duration(seconds: 11)); + } + + @override + Description describe(Description description) => + description.add('one widget whose rasterized images matches Skia Gold image $key'); +} + class _MatchesSemanticsData extends Matcher { _MatchesSemanticsData({ this.label, From 4f29c3104821cb901287af7c438a2733cf5e0cb8 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Fri, 19 Apr 2019 10:19:31 -0700 Subject: [PATCH 02/18] Updating inline documentation --- .../test/cupertino/date_picker_test.dart | 19 +- .../flutter_goldens/lib/flutter_goldens.dart | 9 +- .../flutter_goldens_client/lib/client.dart | 204 ++++-------------- 3 files changed, 58 insertions(+), 174 deletions(-) diff --git a/packages/flutter/test/cupertino/date_picker_test.dart b/packages/flutter/test/cupertino/date_picker_test.dart index e387d0b81f0..eff723fa28b 100644 --- a/packages/flutter/test/cupertino/date_picker_test.dart +++ b/packages/flutter/test/cupertino/date_picker_test.dart @@ -853,21 +853,26 @@ void main() { ) ); +// await expectLater( +// find.byType(CupertinoDatePicker), +// matchesGoldenFile('date_picker_test.datetime.initial.png'), +// skip: !Platform.isLinux +// ); + await expectLater( find.byType(CupertinoDatePicker), - matchesGoldenFile('date_picker_test.datetime.initial.png'), - skip: !Platform.isLinux + matchesSkiaGoldFile('date_picker_test.datetime.initial.png'), ); // Slightly drag the hour component to make the current hour off-center. await tester.drag(find.text('4'), Offset(0, _kRowOffset.dy / 2)); await tester.pump(); - await expectLater( - find.byType(CupertinoDatePicker), - matchesGoldenFile('date_picker_test.datetime.drag.png'), - skip: !Platform.isLinux - ); +// await expectLater( +// find.byType(CupertinoDatePicker), +// matchesGoldenFile('date_picker_test.datetime.drag.png'), +// skip: !Platform.isLinux +// ); }); } diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index e02630b9c0d..5ee18ead54a 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -9,6 +9,7 @@ import 'package:file/file.dart'; import 'package:file/local.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:meta/meta.dart'; +import 'package:test_api/test_api.dart' as test_package show TestFailure; import 'package:flutter_goldens_client/client.dart'; export 'package:flutter_goldens_client/client.dart'; @@ -77,12 +78,12 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { @override Future compare(Uint8List imageBytes, Uri golden) async { + final bool authorized = await _skiaClient.auth(fs.directory(basedir)); final File goldenFile = _getGoldenFile(golden); - bool authorized = await _skiaClient.auth(fs.directory(basedir)); - bool tested = await _skiaClient.imgtest(golden.path, goldenFile); - return true; // TEMP - //TODO(katelovett): Process results + if (!authorized) + throw test_package.TestFailure('Could not authorize golctl.'); + return await _skiaClient.imgtest(golden.path, goldenFile); } @override diff --git a/packages/flutter_goldens_client/lib/client.dart b/packages/flutter_goldens_client/lib/client.dart index 4ff5ddfebf0..29e724d21eb 100644 --- a/packages/flutter_goldens_client/lib/client.dart +++ b/packages/flutter_goldens_client/lib/client.dart @@ -20,24 +20,62 @@ const String _kGoldctlKey = 'GOLDCTL'; const String _kServiceAccountKey = 'GOLD_SERVICE_ACCOUNT'; const String _kSkiaGoldInstance = 'SKIA_GOLD_INSTANCE'; +/// A class that represents the Skia Gold client for golden file testing. class SkiaGoldClient { + /// Create a handle to a local workspace for the Skia Gold Client. SkiaGoldClient({ this.fs = const LocalFileSystem(), this.platform = const LocalPlatform(), this.process = const LocalProcessManager(), }); + /// The file system to use for storing local files for running imgtests. + /// + /// This is usefule in tests, where a local file system (the default) can be + /// replaced by a memory file system. final FileSystem fs; + + /// A wrapper for the [dart:io.Platform] API. + /// + /// This is useful in tests, where the system platform (the default) can be + /// replaced by a mock platform instance. final Platform platform; + + /// A controller for launching subprocesses. + /// + /// This is useful in tests, where the real process manager (the default) can + /// be replaced by a mock process manager that doesn't really create + /// subprocesses. final ProcessManager process; + Directory _workDirectory; - //TODO(katelovett): Environment variables swapped out for final CI implementation + //TODO(katelovett): Environment variables swapped out for CI implementation + /// The [path] to the local [Directory] where the goldctl tool is hosted. + /// + /// Uses the [platform] [environment] in this iteration. String get _goldctl => platform.environment[_kGoldctlKey]; + + /// The [path] to the local [Directory] where the service account key is + /// hosted. + /// + /// Uses the [platform] [environment] in this iteration. String get _serviceAccount => platform.environment[_kServiceAccountKey]; + + /// The name of the Skia Gold Flutter instance. + /// + /// Uses the [platform] [environment] in this iteration. String get _skiaGoldInstance => platform.environment[_kSkiaGoldInstance]; + + /// The local [Directory] where the Flutter repository is hosted. + /// + /// Uses the [fs] file system. Directory get _flutterRoot => fs.directory(platform.environment[_kFlutterRootKey]); + /// Prepares the local work space for golden file testing and initializes the + /// goldctl authorization for executing tests. + /// + /// This ensures that the goldctl tool is authorized and ready for testing. Future auth(Directory workDirectory) async { _workDirectory = workDirectory; List authArguments = ['auth']; @@ -61,6 +99,7 @@ class SkiaGoldClient { return true; } + Future imgtest(String testName, File goldenFile) async { List imgtestArguments = [ 'imgtest', @@ -145,165 +184,4 @@ class NonZeroExitCode implements Exception { String toString() { return 'Exit code $exitCode: $stderr'; } -} - -// -///// A class that represents a clone of the https://github.com/flutter/goldens -///// repository, nested within the `bin/cache` directory of the caller's Flutter -///// repository. -//class GoldensClient { -// /// Create a handle to a local clone of the goldens repository. -// GoldensClient({ -// this.fs = const LocalFileSystem(), -// this.platform = const LocalPlatform(), -// this.process = const LocalProcessManager(), -// }); -// -// /// The file system to use for storing the local clone of the repository. -// /// -// /// This is useful in tests, where a local file system (the default) can -// /// be replaced by a memory file system. -// final FileSystem fs; -// -// /// A wrapper for the [dart:io.Platform] API. -// /// -// /// This is useful in tests, where the system platform (the default) can -// /// be replaced by a mock platform instance. -// final Platform platform; -// -// /// A controller for launching subprocesses. -// /// -// /// This is useful in tests, where the real process manager (the default) -// /// can be replaced by a mock process manager that doesn't really create -// /// subprocesses. -// final ProcessManager process; -// -// RandomAccessFile _lock; -// -// /// The local [Directory] where the Flutter repository is hosted. -// /// -// /// Uses the [fs] file system. -// Directory get flutterRoot => fs.directory(platform.environment[_kFlutterRootKey]); -// -// /// The local [Directory] where the goldens repository is hosted. -// /// -// /// Uses the [fs] file system. -// Directory get repositoryRoot => flutterRoot.childDirectory(fs.path.join('bin', 'cache', 'pkg', 'goldens')); -// -// /// Prepares the local clone of the `flutter/goldens` repository for golden -// /// file testing. -// /// -// /// This ensures that the goldens repository has been cloned into its -// /// expected location within `bin/cache` and that it is synced to the Git -// /// revision specified in `bin/internal/goldens.version`. -// /// -// /// While this is preparing the repository, it obtains a file lock such that -// /// [GoldensClient] instances in other processes or isolates will not -// /// duplicate the work that this is doing. -// Future prepare() async { -// print('GoldensClient.prepare'); -// final String goldensCommit = await _getGoldensCommit(); -// String currentCommit = await _getCurrentCommit(); -// if (currentCommit != goldensCommit) { -// await _obtainLock(); -// try { -// // Check the current commit again now that we have the lock. -// currentCommit = await _getCurrentCommit(); -// if (currentCommit != goldensCommit) { -// if (currentCommit == null) { -// await _initRepository(); -// } -// await _checkCanSync(); -// await _syncTo(goldensCommit); -// } -// } finally { -// await _releaseLock(); -// } -// } -// } -// -// Future _getGoldensCommit() async { -// final File versionFile = flutterRoot.childFile(fs.path.join('bin', 'internal', 'goldens.version')); -// return (await versionFile.readAsString()).trim(); -// } -// -// Future _getCurrentCommit() async { -// if (!repositoryRoot.existsSync()) { -// return null; -// } else { -// final io.ProcessResult revParse = await process.run( -// ['git', 'rev-parse', 'HEAD'], -// workingDirectory: repositoryRoot.path, -// ); -// return revParse.exitCode == 0 ? revParse.stdout.trim() : null; -// } -// } -// -// Future _initRepository() async { -// await repositoryRoot.create(recursive: true); -// await _runCommands( -// [ -// 'git init', -// 'git remote add upstream https://github.com/flutter/goldens.git', -// 'git remote set-url --push upstream git@github.com:flutter/goldens.git', -// ], -// workingDirectory: repositoryRoot, -// ); -// } -// -// Future _checkCanSync() async { -// final io.ProcessResult result = await process.run( -// ['git', 'status', '--porcelain'], -// workingDirectory: repositoryRoot.path, -// ); -// if (result.stdout.trim().isNotEmpty) { -// final StringBuffer buf = StringBuffer(); -// buf -// ..writeln('flutter_goldens git checkout at ${repositoryRoot.path} has local changes and cannot be synced.') -// ..writeln('To reset your client to a clean state, and lose any local golden test changes:') -// ..writeln('cd ${repositoryRoot.path}') -// ..writeln('git reset --hard HEAD') -// ..writeln('git clean -x -d -f -f'); -// throw NonZeroExitCode(1, buf.toString()); -// } -// } -// -// Future _syncTo(String commit) async { -// await _runCommands( -// [ -// 'git pull upstream master', -// 'git fetch upstream $commit', -// 'git reset --hard FETCH_HEAD', -// ], -// workingDirectory: repositoryRoot, -// ); -// } -// -// Future _runCommands( -// List commands, { -// Directory workingDirectory, -// }) async { -// for (String command in commands) { -// final List parts = command.split(' '); -// final io.ProcessResult result = await process.run( -// parts, -// workingDirectory: workingDirectory?.path, -// ); -// if (result.exitCode != 0) { -// throw NonZeroExitCode(result.exitCode, result.stderr); -// } -// } -// } -// -// Future _obtainLock() async { -// final File lockFile = flutterRoot.childFile(fs.path.join('bin', 'cache', 'goldens.lockfile')); -// await lockFile.create(recursive: true); -// _lock = await lockFile.open(mode: io.FileMode.write); -// await _lock.lock(io.FileLock.blockingExclusive); -// } -// -// Future _releaseLock() async { -// await _lock.close(); -// _lock = null; -// } -//} \ No newline at end of file +} \ No newline at end of file From 9e3e44ee3d5bb390beb5af7fc88909238f607234 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Fri, 19 Apr 2019 11:32:16 -0700 Subject: [PATCH 03/18] Committing test progress. --- .../flutter_goldens/lib/flutter_goldens.dart | 7 +- .../test/flutter_goldens_test.dart | 106 ++++++++++-------- .../flutter_goldens_client/lib/client.dart | 16 +-- packages/flutter_test/test/matchers_test.dart | 82 ++++++++++++++ 4 files changed, 152 insertions(+), 59 deletions(-) diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index 5ee18ead54a..90a5f8bea89 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -1,6 +1,7 @@ // Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + import 'dart:async'; import 'dart:io'; import 'dart:typed_data'; @@ -13,7 +14,7 @@ import 'package:test_api/test_api.dart' as test_package show TestFailure; import 'package:flutter_goldens_client/client.dart'; export 'package:flutter_goldens_client/client.dart'; -//TODO(katelovett): Tests [flutter_goldens_test.dart] and inline documentation +//TODO(katelovett): Tests const String _kFlutterRootKey = 'FLUTTER_ROOT'; /// Main method that can be used in a `flutter_test_config.dart` file to set @@ -80,6 +81,9 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { Future compare(Uint8List imageBytes, Uri golden) async { final bool authorized = await _skiaClient.auth(fs.directory(basedir)); final File goldenFile = _getGoldenFile(golden); + if(!goldenFile.existsSync()) { + throw test_package.TestFailure('Could not be compared against non-existent file: "$golden"'); + } if (!authorized) throw test_package.TestFailure('Could not authorize golctl.'); @@ -96,5 +100,4 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { File _getGoldenFile(Uri uri) { return fs.directory(basedir).childFile(fs.file(uri).path); } - } diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart index 19645edc8f2..bdfe6305be8 100644 --- a/packages/flutter_goldens/test/flutter_goldens_test.dart +++ b/packages/flutter_goldens/test/flutter_goldens_test.dart @@ -14,49 +14,44 @@ import 'package:platform/platform.dart'; import 'package:process/process.dart'; const String _kFlutterRoot = '/flutter'; -const String _kRepositoryRoot = '$_kFlutterRoot/bin/cache/pkg/goldens'; -const String _kVersionFile = '$_kFlutterRoot/bin/internal/goldens.version'; -const String _kGoldensVersion = '123456abcdef'; +const String _kGoldenRoot = '$_kFlutterRoot/bin/cache/pkg/goldens'; +//const String _kVersionFile = '$_kFlutterRoot/bin/internal/goldens.version'; +//const String _kGoldensVersion = '123456abcdef'; void main() { MemoryFileSystem fs; FakePlatform platform; MockProcessManager process; + Directory flutter; + Directory golden; - setUp(() { + setUp(() async { fs = MemoryFileSystem(); platform = FakePlatform(environment: {'FLUTTER_ROOT': _kFlutterRoot}); process = MockProcessManager(); - fs.directory(_kFlutterRoot).createSync(recursive: true); - fs.directory(_kRepositoryRoot).createSync(recursive: true); - fs.file(_kVersionFile).createSync(recursive: true); - fs.file(_kVersionFile).writeAsStringSync(_kGoldensVersion); + flutter = await fs.directory(_kFlutterRoot).create(recursive: true); + golden = await fs.directory(_kGoldenRoot).create(recursive: true); + //fs.file(_kVersionFile).createSync(recursive: true); + //fs.file(_kVersionFile).writeAsStringSync(_kGoldensVersion); }); - group('GoldensClient', () { - GoldensClient goldens; + group('SkiaGoldClient', () { + SkiaGoldClient skiaGold; setUp(() { - goldens = GoldensClient( + skiaGold = SkiaGoldClient( fs: fs, platform: platform, process: process, ); }); - group('prepare', () { - test('performs minimal work if versions match', () async { - when(process.run(any, workingDirectory: anyNamed('workingDirectory'))) - .thenAnswer((_) => Future.value(io.ProcessResult(123, 0, _kGoldensVersion, ''))); - await goldens.prepare(); + group('auth', () { + + }); + + group('imgtest', () { - // Verify that we only spawned `git rev-parse HEAD` - final VerificationResult verifyProcessRun = - verify(process.run(captureAny, workingDirectory: captureAnyNamed('workingDirectory'))); - verifyProcessRun.called(1); - expect(verifyProcessRun.captured.first, ['git', 'rev-parse', 'HEAD']); - expect(verifyProcessRun.captured.last, _kRepositoryRoot); - }); }); }); @@ -74,21 +69,34 @@ void main() { group('fromDefaultComparator', () { test('calculates the basedir correctly', () async { - final MockGoldensClient goldens = MockGoldensClient(); - final MockLocalFileComparator defaultComparator = MockLocalFileComparator(); - final Directory flutterRoot = fs.directory('/foo')..createSync(recursive: true); - final Directory goldensRoot = flutterRoot.childDirectory('bar')..createSync(recursive: true); - when(goldens.fs).thenReturn(fs); - when(goldens.flutterRoot).thenReturn(flutterRoot); - when(goldens.repositoryRoot).thenReturn(goldensRoot); - when(defaultComparator.basedir).thenReturn(flutterRoot.childDirectory('baz').uri); - comparator = await FlutterGoldenFileComparator.fromDefaultComparator( - goldens: goldens, defaultComparator: defaultComparator); - expect(comparator.basedir, fs.directory('/foo/bar/baz').uri); +// final MockSkiaGoldClient skiaGold = MockSkiaGoldClient(); +// final MockLocalFileComparator defaultComparator = MockLocalFileComparator(); +// final Directory flutterRoot = fs.directory('/foo')..createSync(recursive: true); +// final Directory skiaGoldRoot = flutterRoot.childDirectory('bar')..createSync(recursive: true); +// when(skiaGold.fs).thenReturn(fs); +// when(skiaGold.flutterRoot).thenReturn(flutterRoot); +// when(skiaGold.repositoryRoot).thenReturn(skiaGoldRoot); +// when(defaultComparator.basedir).thenReturn(flutterRoot.childDirectory('baz').uri); +// comparator = await FlutterGoldenFileComparator.fromDefaultComparator( +// goldens: goldens, defaultComparator: defaultComparator); +// expect(comparator.basedir, fs.directory('/foo/bar/baz').uri); }); }); group('compare', () { + + test('throws if goldctl has not been authorized', () async { + // Create file + final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') + ..createSync(recursive: true); + try { + await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); + fail('TestFailure expected but not thrown'); + } on TestFailure catch (error) { + expect(error.message, contains('Could not authorize goldctl.')); + } + }); + test('throws if golden file is not found', () async { try { await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); @@ -98,21 +106,21 @@ void main() { } }); - test('returns false if golden bytes do not match', () async { - final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') - ..createSync(recursive: true); - goldenFile.writeAsBytesSync([4, 5, 6], flush: true); - final bool result = await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); - expect(result, isFalse); - }); +// test('returns false if skia gold test fails', () async { +// final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') +// ..createSync(recursive: true); +// goldenFile.writeAsBytesSync([4, 5, 6], flush: true); +// final bool result = await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); +// expect(result, isFalse); +// }); - test('returns true if golden bytes match', () async { - final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') - ..createSync(recursive: true); - goldenFile.writeAsBytesSync([1, 2, 3], flush: true); - final bool result = await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); - expect(result, isTrue); - }); +// test('returns true if skia gold test passes', () async { +// final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') +// ..createSync(recursive: true); +// goldenFile.writeAsBytesSync([1, 2, 3], flush: true); +// final bool result = await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); +// expect(result, isTrue); +// }); }); group('update', () { @@ -136,5 +144,5 @@ void main() { } class MockProcessManager extends Mock implements ProcessManager {} -class MockGoldensClient extends Mock implements GoldensClient {} +class MockSkiaGoldClient extends Mock implements SkiaGoldClient {} class MockLocalFileComparator extends Mock implements LocalFileComparator {} diff --git a/packages/flutter_goldens_client/lib/client.dart b/packages/flutter_goldens_client/lib/client.dart index 29e724d21eb..6e461f1935a 100644 --- a/packages/flutter_goldens_client/lib/client.dart +++ b/packages/flutter_goldens_client/lib/client.dart @@ -1,7 +1,7 @@ // Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -//TODO(katelovett): Change to Skia Gold Client + import 'dart:async'; import 'dart:convert' as convert; import 'dart:io' as io; @@ -14,7 +14,7 @@ import 'package:process/process.dart'; // If you are here trying to figure out how to use golden files in the Flutter // repo itself, consider reading this wiki page: // https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package%3Aflutter -//TODO(katelovett): Tests [flutter_goldens_test.dart] and inline documentation +//TODO(katelovett): Tests const String _kFlutterRootKey = 'FLUTTER_ROOT'; const String _kGoldctlKey = 'GOLDCTL'; const String _kServiceAccountKey = 'GOLD_SERVICE_ACCOUNT'; @@ -31,7 +31,7 @@ class SkiaGoldClient { /// The file system to use for storing local files for running imgtests. /// - /// This is usefule in tests, where a local file system (the default) can be + /// This is useful in tests, where a local file system (the default) can be /// replaced by a memory file system. final FileSystem fs; @@ -41,11 +41,11 @@ class SkiaGoldClient { /// replaced by a mock platform instance. final Platform platform; - /// A controller for launching subprocesses. + /// A controller for launching sub-processes. /// /// This is useful in tests, where the real process manager (the default) can /// be replaced by a mock process manager that doesn't really create - /// subprocesses. + /// sub-processes. final ProcessManager process; Directory _workDirectory; @@ -70,7 +70,7 @@ class SkiaGoldClient { /// The local [Directory] where the Flutter repository is hosted. /// /// Uses the [fs] file system. - Directory get _flutterRoot => fs.directory(platform.environment[_kFlutterRootKey]); + Directory get flutterRoot => fs.directory(platform.environment[_kFlutterRootKey]); /// Prepares the local work space for golden file testing and initializes the /// goldctl authorization for executing tests. @@ -145,12 +145,12 @@ class SkiaGoldClient { } Future _getCommitHash() async { - if (!_flutterRoot.existsSync()) { + if (!flutterRoot.existsSync()) { return null; } else { final io.ProcessResult revParse = await process.run( ['git', 'rev-parse', 'HEAD'], - workingDirectory: _flutterRoot.path, + workingDirectory: flutterRoot.path, ); return revParse.exitCode == 0 ? revParse.stdout.trim() : null; } diff --git a/packages/flutter_test/test/matchers_test.dart b/packages/flutter_test/test/matchers_test.dart index 29f0f72684b..e0255fab2e6 100644 --- a/packages/flutter_test/test/matchers_test.dart +++ b/packages/flutter_test/test/matchers_test.dart @@ -384,6 +384,88 @@ void main() { }); }); + group('matchesSkiaGoldFile', () { + _FakeComparator comparator; + + Widget boilerplate(Widget child) { + return Directionality( + textDirection: TextDirection.ltr, + child: child, + ); + } + + setUp(() { + comparator = _FakeComparator(); + goldenFileComparator = comparator; + }); + + group('matches', () { + testWidgets('if comparator succeeds', (WidgetTester tester) async { + await tester.pumpWidget(boilerplate(const Text('hello'))); + final Finder finder = find.byType(Text); + await expectLater(finder, matchesSkiaGoldFile('foo.png')); + expect(comparator.invocation, _ComparatorInvocation.compare); + expect(comparator.imageBytes, null); + expect(comparator.golden, Uri.parse('foo.png')); + }); + }); + + group('does not match', () { + testWidgets('if comparator returns false', (WidgetTester tester) async { + comparator.behavior = _ComparatorBehavior.returnFalse; + await tester.pumpWidget(boilerplate(const Text('hello'))); + final Finder finder = find.byType(Text); + try { + await expectLater(finder, matchesSkiaGoldFile('foo.png')); + fail('TestFailure expected but not thrown'); + } on TestFailure catch (error) { + expect(comparator.invocation, _ComparatorInvocation.compare); + expect(error.message, contains('does not match')); + } + }); + + testWidgets('if comparator throws', (WidgetTester tester) async { + comparator.behavior = _ComparatorBehavior.throwTestFailure; + await tester.pumpWidget(boilerplate(const Text('hello'))); + final Finder finder = find.byType(Text); + try { + await expectLater(finder, matchesSkiaGoldFile('foo.png')); + fail('TestFailure expected but not thrown'); + } on TestFailure catch (error) { + expect(comparator.invocation, _ComparatorInvocation.compare); + expect(error.message, contains('fake message')); + } + }); + + testWidgets('if finder finds no widgets', (WidgetTester tester) async { + await tester.pumpWidget(boilerplate(Container())); + final Finder finder = find.byType(Text); + try { + await expectLater(finder, matchesSkiaGoldFile('foo.png')); + fail('TestFailure expected but not thrown'); + } on TestFailure catch (error) { + expect(comparator.invocation, isNull); + expect(error.message, contains('no widget was found')); + } + }); + + testWidgets( + 'if finder finds multiple widgets', (WidgetTester tester) async { + await tester.pumpWidget(boilerplate(Column( + children: const [Text('hello'), Text('world')], + ))); + final Finder finder = find.byType(Text); + try { + await expectLater(finder, matchesSkiaGoldFile('foo.png')); + fail('TestFailure expected but not thrown'); + } on TestFailure catch (error) { + expect(comparator.invocation, isNull); + expect(error.message, contains('too many widgets')); + } + }); + }); + }); + group('matchesSemanticsData', () { testWidgets('matches SemanticsData', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); From 7e542fc334c183256b06f19e7e5474d742a95c4e Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Fri, 19 Apr 2019 14:33:49 -0700 Subject: [PATCH 04/18] Committing progress. --- .../flutter_goldens/lib/flutter_goldens.dart | 6 +++- .../test/flutter_goldens_test.dart | 11 ++++--- .../flutter_goldens_client/lib/client.dart | 7 +++-- packages/flutter_test/lib/src/matchers.dart | 29 ++++++++++++++++++- .../lib/src/commands/update_packages.dart | 14 ++++----- 5 files changed, 51 insertions(+), 16 deletions(-) diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index 90a5f8bea89..b56b91aceb9 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -14,7 +14,7 @@ import 'package:test_api/test_api.dart' as test_package show TestFailure; import 'package:flutter_goldens_client/client.dart'; export 'package:flutter_goldens_client/client.dart'; -//TODO(katelovett): Tests + const String _kFlutterRootKey = 'FLUTTER_ROOT'; /// Main method that can be used in a `flutter_test_config.dart` file to set @@ -80,6 +80,10 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { @override Future compare(Uint8List imageBytes, Uri golden) async { final bool authorized = await _skiaClient.auth(fs.directory(basedir)); + if(!authorized) { + //TODO(katelovett): Clean up for final CI implementation + return true; + } final File goldenFile = _getGoldenFile(golden); if(!goldenFile.existsSync()) { throw test_package.TestFailure('Could not be compared against non-existent file: "$golden"'); diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart index bdfe6305be8..6cebb3ab8c8 100644 --- a/packages/flutter_goldens/test/flutter_goldens_test.dart +++ b/packages/flutter_goldens/test/flutter_goldens_test.dart @@ -17,7 +17,7 @@ const String _kFlutterRoot = '/flutter'; const String _kGoldenRoot = '$_kFlutterRoot/bin/cache/pkg/goldens'; //const String _kVersionFile = '$_kFlutterRoot/bin/internal/goldens.version'; //const String _kGoldensVersion = '123456abcdef'; - +//TODO(katelovett): Finish testing void main() { MemoryFileSystem fs; FakePlatform platform; @@ -27,7 +27,10 @@ void main() { setUp(() async { fs = MemoryFileSystem(); - platform = FakePlatform(environment: {'FLUTTER_ROOT': _kFlutterRoot}); + platform = FakePlatform(environment: { + 'FLUTTER_ROOT': _kFlutterRoot, + //TODO Add other env vars for testing + }); process = MockProcessManager(); flutter = await fs.directory(_kFlutterRoot).create(recursive: true); golden = await fs.directory(_kGoldenRoot).create(recursive: true); @@ -87,8 +90,8 @@ void main() { test('throws if goldctl has not been authorized', () async { // Create file - final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') - ..createSync(recursive: true); + //final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') + //s ..createSync(recursive: true); try { await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); fail('TestFailure expected but not thrown'); diff --git a/packages/flutter_goldens_client/lib/client.dart b/packages/flutter_goldens_client/lib/client.dart index 6e461f1935a..cb36481db18 100644 --- a/packages/flutter_goldens_client/lib/client.dart +++ b/packages/flutter_goldens_client/lib/client.dart @@ -14,7 +14,7 @@ import 'package:process/process.dart'; // If you are here trying to figure out how to use golden files in the Flutter // repo itself, consider reading this wiki page: // https://github.com/flutter/flutter/wiki/Writing-a-golden-file-test-for-package%3Aflutter -//TODO(katelovett): Tests + const String _kFlutterRootKey = 'FLUTTER_ROOT'; const String _kGoldctlKey = 'GOLDCTL'; const String _kServiceAccountKey = 'GOLD_SERVICE_ACCOUNT'; @@ -79,8 +79,10 @@ class SkiaGoldClient { Future auth(Directory workDirectory) async { _workDirectory = workDirectory; List authArguments = ['auth']; + //TODO(katelovett): Cleanup for final CI implementation if(_serviceAccount == null) - throw const NonZeroExitCode(1, 'No Service Account found.'); + return false; + //throw const NonZeroExitCode(1, 'No Service Account found.'); authArguments += [ '--service-account', _serviceAccount, @@ -99,7 +101,6 @@ class SkiaGoldClient { return true; } - Future imgtest(String testName, File goldenFile) async { List imgtestArguments = [ 'imgtest', diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index 6a3491b4d71..7323ec9f8e3 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -296,7 +296,34 @@ AsyncMatcher matchesGoldenFile(dynamic key) { throw ArgumentError('Unexpected type for golden file: ${key.runtimeType}'); } -/// TODO(katelovett): Documentation +/// Asserts that a [Finder], [Future], or [ui.Image] matches the +/// golden image file identified by [key] through Skia Gold. +/// +/// For the case of a [Finder], the [Finder] must match exactly one widget and +/// the rendered image of the first [RepaintBoundary] ancestor of the widget is +/// treated as the image for the widget. +/// +/// [key] may be either a [Uri] or a [String] representation of a URI. +/// +/// This is an asynchronous matcher, meaning that callers should use +/// [expectLater] when using this matcher and await the future returned by +/// [expectLater]. +/// +/// ## Sample code +/// +/// ```dart +/// await expectLater(find.text('Save'), matchesSkiaGoldFile('save.png')); +/// await expectLater(image, matchesSkiaGoldFile('save.png')); +/// await expectLater(imageFuture, matchesSkiaGoldFile('save.png')); +/// ``` +/// +/// See also: +/// +/// * [FlutterGoldenFileComparator], which acts as the backend for this matcher. +/// * [SkiaGoldClient], which the [FlutterGoldenFileComparator] uses to execute +/// and process results of testing with Skia Gold. +/// * [flutter_test] for a discussion of test configurations, whereby callers +/// may swap out the backend for this matcher. AsyncMatcher matchesSkiaGoldFile(dynamic key) { if (key is Uri) { return _MatchesSkiaGoldFile(key); diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart index d18123ed132..1293ef6e6a9 100644 --- a/packages/flutter_tools/lib/src/commands/update_packages.dart +++ b/packages/flutter_tools/lib/src/commands/update_packages.dart @@ -136,13 +136,13 @@ class UpdatePackagesCommand extends FlutterCommand { // The dev/integration_tests/android_views integration test depends on an assets // package that is in the goldens repository. We need to make sure that the goldens // repository is cloned locally before we verify or update pubspecs. - printStatus('Cloning goldens repository...'); - try { - final GoldensClient goldensClient = GoldensClient(); - await goldensClient.prepare(); - } on NonZeroExitCode catch (e) { - throwToolExit(e.stderr, exitCode: e.exitCode); - } +// printStatus('Cloning goldens repository...'); +// try { +// final GoldensClient goldensClient = GoldensClient(); +// await goldensClient.prepare(); +// } on NonZeroExitCode catch (e) { +// throwToolExit(e.stderr, exitCode: e.exitCode); +// } if (isVerifyOnly) { bool needsUpdate = false; From beebd5c4a7c0c95381d88f96fc092811084af842 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Fri, 19 Apr 2019 15:00:13 -0700 Subject: [PATCH 05/18] Progress. --- .../test/cupertino/date_picker_test.dart | 1 - .../flutter_goldens/lib/flutter_goldens.dart | 14 ++++---- .../test/flutter_goldens_test.dart | 33 ++++++++++--------- .../lib/src/commands/update_packages.dart | 1 - 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/packages/flutter/test/cupertino/date_picker_test.dart b/packages/flutter/test/cupertino/date_picker_test.dart index eff723fa28b..4533c56c1ed 100644 --- a/packages/flutter/test/cupertino/date_picker_test.dart +++ b/packages/flutter/test/cupertino/date_picker_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; import 'dart:ui'; import 'package:flutter/cupertino.dart'; diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index b56b91aceb9..7aa23e9496c 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -79,18 +79,16 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { @override Future compare(Uint8List imageBytes, Uri golden) async { - final bool authorized = await _skiaClient.auth(fs.directory(basedir)); - if(!authorized) { - //TODO(katelovett): Clean up for final CI implementation - return true; - } final File goldenFile = _getGoldenFile(golden); if(!goldenFile.existsSync()) { throw test_package.TestFailure('Could not be compared against non-existent file: "$golden"'); } - - if (!authorized) - throw test_package.TestFailure('Could not authorize golctl.'); + final bool authorized = await _skiaClient.auth(fs.directory(basedir)); + if (!authorized) { + //TODO(katelovett): Clean up for final implementation + return true; + //throw test_package.TestFailure('Could not authorize golctl.'); + } return await _skiaClient.imgtest(golden.path, goldenFile); } diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart index 6cebb3ab8c8..99e2ddb5398 100644 --- a/packages/flutter_goldens/test/flutter_goldens_test.dart +++ b/packages/flutter_goldens/test/flutter_goldens_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' as io; import 'dart:typed_data'; import 'package:file/file.dart'; @@ -29,7 +28,7 @@ void main() { fs = MemoryFileSystem(); platform = FakePlatform(environment: { 'FLUTTER_ROOT': _kFlutterRoot, - //TODO Add other env vars for testing + //TODO(katelovett): Add other env vars for testing }); process = MockProcessManager(); flutter = await fs.directory(_kFlutterRoot).create(recursive: true); @@ -50,7 +49,9 @@ void main() { }); group('auth', () { - + // check for successful auth - return true + // check for unsuccessful auth - throw NonZeroExitCode + // check for unavailable auth (not on CI) - return false }); group('imgtest', () { @@ -88,18 +89,6 @@ void main() { group('compare', () { - test('throws if goldctl has not been authorized', () async { - // Create file - //final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') - //s ..createSync(recursive: true); - try { - await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); - fail('TestFailure expected but not thrown'); - } on TestFailure catch (error) { - expect(error.message, contains('Could not authorize goldctl.')); - } - }); - test('throws if golden file is not found', () async { try { await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); @@ -109,6 +98,18 @@ void main() { } }); + // TODO(katelovett): This is currently disabled in flutter_goldens.dart +// test('throws if goldctl has not been authorized', () async { +// // See that preceding test does not leave auth behind [52] +// try { +// await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); +// fail('TestFailure expected but not thrown'); +// } on TestFailure catch (error) { +// expect(error.message, contains('Could not authorize goldctl.')); +// } +// }); + // TODO(katelovett): Add methods to Mock SkiaGoldClient to inform the comparator + // TODO... and test for proper behavior. See matcher_test.dart for model // test('returns false if skia gold test fails', () async { // final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') // ..createSync(recursive: true); @@ -116,7 +117,7 @@ void main() { // final bool result = await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); // expect(result, isFalse); // }); - +// // test('returns true if skia gold test passes', () async { // final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') // ..createSync(recursive: true); diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart index 1293ef6e6a9..a7f581b8f42 100644 --- a/packages/flutter_tools/lib/src/commands/update_packages.dart +++ b/packages/flutter_tools/lib/src/commands/update_packages.dart @@ -6,7 +6,6 @@ import 'dart:async'; import 'dart:collection'; import 'package:meta/meta.dart'; -import 'package:flutter_goldens_client/client.dart'; import '../base/common.dart'; import '../base/file_system.dart'; From 8c59c524c9e629c5396789f70476cbf27b4896d8 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Tue, 23 Apr 2019 17:18:23 -0700 Subject: [PATCH 06/18] Swapping out matchesGoldenFile for matchesSkiaGoldFile for framework tests. --- .../flutter/test/cupertino/nav_bar_test.dart | 10 ++++++---- .../cupertino/segmented_control_test.dart | 13 ++++++++---- .../test/material/bottom_app_bar_test.dart | 10 +++++++--- .../material/bottom_app_bar_theme_test.dart | 5 +++-- .../material/bottom_navigation_bar_test.dart | 5 +++-- .../test/material/card_theme_test.dart | 5 +++-- .../test/material/dialog_theme_test.dart | 5 +++-- .../flutter/test/material/dropdown_test.dart | 10 ++++++---- .../material/floating_action_button_test.dart | 5 +++-- .../test/material/input_decorator_test.dart | 10 ++++++---- .../flutter/test/material/material_test.dart | 10 ++++++---- .../flutter/test/material/radio_test.dart | 5 +++-- .../test/material/tab_bar_theme_test.dart | 20 +++++++++++-------- 13 files changed, 70 insertions(+), 43 deletions(-) diff --git a/packages/flutter/test/cupertino/nav_bar_test.dart b/packages/flutter/test/cupertino/nav_bar_test.dart index 09419a0393f..981abbd880d 100644 --- a/packages/flutter/test/cupertino/nav_bar_test.dart +++ b/packages/flutter/test/cupertino/nav_bar_test.dart @@ -801,12 +801,13 @@ void main() { await expectLater( find.byType(RepaintBoundary).last, - matchesGoldenFile('nav_bar_test.standard_title.1.png'), + //matchesGoldenFile('nav_bar_test.standard_title.1.png'), + matchesSkiaGoldFile('nav_bar_test.standard_title.png'), ); }, // TODO(xster): remove once https://github.com/flutter/flutter/issues/17483 // is fixed. - skip: !Platform.isLinux, + // skip: !Platform.isLinux, ); testWidgets( @@ -835,12 +836,13 @@ void main() { await expectLater( find.byType(RepaintBoundary).last, - matchesGoldenFile('nav_bar_test.large_title.1.png'), + // matchesGoldenFile('nav_bar_test.large_title.1.png'), + matchesSkiaGoldFile('nav_bar_test.large_title.png'), ); }, // TODO(xster): remove once https://github.com/flutter/flutter/issues/17483 // is fixed. - skip: !Platform.isLinux, + // skip: !Platform.isLinux, ); diff --git a/packages/flutter/test/cupertino/segmented_control_test.dart b/packages/flutter/test/cupertino/segmented_control_test.dart index 1214541640d..479d7d1b7e2 100644 --- a/packages/flutter/test/cupertino/segmented_control_test.dart +++ b/packages/flutter/test/cupertino/segmented_control_test.dart @@ -1327,9 +1327,11 @@ void main() { await expectLater( find.byType(RepaintBoundary), - matchesGoldenFile('segmented_control_test.0.0.png'), + // matchesGoldenFile('segmented_control_test.0.0.png'), + matchesSkiaGoldFile('segmented_control_test.0.png'), ); - }, skip: !Platform.isLinux); + }, //skip: !Platform.isLinux + ); testWidgets('Golden Test Pressed State', (WidgetTester tester) async { final Map children = {}; @@ -1365,7 +1367,10 @@ void main() { await expectLater( find.byType(RepaintBoundary), - matchesGoldenFile('segmented_control_test.1.0.png'), + // matchesGoldenFile('segmented_control_test.1.0.png'), + matchesSkiaGoldFile('segmented_control_test.1.png'), ); - }, skip: !Platform.isLinux); + }, + // skip: !Platform.isLinux + ); } diff --git a/packages/flutter/test/material/bottom_app_bar_test.dart b/packages/flutter/test/material/bottom_app_bar_test.dart index 92929cfe40a..6f9ace8c55c 100644 --- a/packages/flutter/test/material/bottom_app_bar_test.dart +++ b/packages/flutter/test/material/bottom_app_bar_test.dart @@ -73,15 +73,19 @@ void main() { await pump(FloatingActionButtonLocation.endDocked); await expectLater( find.byKey(key), - matchesGoldenFile('bottom_app_bar.custom_shape.1.png'), + // matchesGoldenFile('bottom_app_bar.custom_shape.1.png'), + matchesSkiaGoldFile('bottom_app_bar.custom_shape.1.png'), ); await pump(FloatingActionButtonLocation.centerDocked); await tester.pumpAndSettle(); await expectLater( find.byKey(key), - matchesGoldenFile('bottom_app_bar.custom_shape.2.png'), + // matchesGoldenFile('bottom_app_bar.custom_shape.2.png'), + matchesSkiaGoldFile('bottom_app_bar.custom_shape.2.png'), ); - }, skip: !Platform.isLinux); + }, + // skip: !Platform.isLinux + ); testWidgets('color defaults to Theme.bottomAppBarColor', (WidgetTester tester) async { await tester.pumpWidget( diff --git a/packages/flutter/test/material/bottom_app_bar_theme_test.dart b/packages/flutter/test/material/bottom_app_bar_theme_test.dart index 0dd0fb77cc7..ff456aba12d 100644 --- a/packages/flutter/test/material/bottom_app_bar_theme_test.dart +++ b/packages/flutter/test/material/bottom_app_bar_theme_test.dart @@ -82,8 +82,9 @@ void main() { await expectLater( find.byKey(_painterKey), - matchesGoldenFile('bottom_app_bar_theme.custom_shape.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('bottom_app_bar_theme.custom_shape.png'), + //matchesGoldenFile('bottom_app_bar_theme.custom_shape.png'), + //skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index 76f1206de45..2d205ffdd6d 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -1148,8 +1148,9 @@ void main() { await tester.pump(const Duration(milliseconds: 30)); await expectLater( find.byType(BottomNavigationBar), - matchesGoldenFile('bottom_navigation_bar.shifting_transition.2.$pump.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('bottom_navigation_bar.shifting_transition.$pump.png'), + // matchesGoldenFile('bottom_navigation_bar.shifting_transition.2.$pump.png'), + // skip: !Platform.isLinux, ); } }); diff --git a/packages/flutter/test/material/card_theme_test.dart b/packages/flutter/test/material/card_theme_test.dart index d45de99831b..10904f4c85c 100644 --- a/packages/flutter/test/material/card_theme_test.dart +++ b/packages/flutter/test/material/card_theme_test.dart @@ -139,8 +139,9 @@ void main() { await expectLater( find.byKey(painterKey), - matchesGoldenFile('card_theme.custom_shape.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('card_theme.custom_shape.png'), + // matchesGoldenFile('card_theme.custom_shape.png'), + // skip: !Platform.isLinux, ); }); } diff --git a/packages/flutter/test/material/dialog_theme_test.dart b/packages/flutter/test/material/dialog_theme_test.dart index c682fdcd3e2..99794526186 100644 --- a/packages/flutter/test/material/dialog_theme_test.dart +++ b/packages/flutter/test/material/dialog_theme_test.dart @@ -132,8 +132,9 @@ void main() { await expectLater( find.byKey(_painterKey), - matchesGoldenFile('dialog_theme.dialog_with_custom_border.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('dialog_theme.dialog_with_custom_border.png'), + // matchesGoldenFile('dialog_theme.dialog_with_custom_border.png'), + // skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart index a5730c66c6e..a6eaf3912a2 100644 --- a/packages/flutter/test/material/dropdown_test.dart +++ b/packages/flutter/test/material/dropdown_test.dart @@ -141,8 +141,9 @@ void main() { assert(tester.renderObject(buttonFinder).attached); await expectLater( find.ancestor(of: buttonFinder, matching: find.byType(RepaintBoundary)).first, - matchesGoldenFile('dropdown_test.default.0.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('dropdown_test.default.png'), + // matchesGoldenFile('dropdown_test.default.0.png'), + // skip: !Platform.isLinux, ); }); @@ -154,8 +155,9 @@ void main() { assert(tester.renderObject(buttonFinder).attached); await expectLater( find.ancestor(of: buttonFinder, matching: find.byType(RepaintBoundary)).first, - matchesGoldenFile('dropdown_test.expanded.0.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('dropdown_test.expanded.png'), + // matchesGoldenFile('dropdown_test.expanded.0.png'), + // skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/material/floating_action_button_test.dart b/packages/flutter/test/material/floating_action_button_test.dart index b72eff81724..9bdd2941088 100644 --- a/packages/flutter/test/material/floating_action_button_test.dart +++ b/packages/flutter/test/material/floating_action_button_test.dart @@ -681,8 +681,9 @@ void main() { await tester.pump(const Duration(milliseconds: 1000)); await expectLater( find.byKey(key), - matchesGoldenFile('floating_action_button_test.clip.2.png'), // .clip.1.png is obsolete and can be removed - skip: !Platform.isLinux, + matchesSkiaGoldFile('floating_action_button_test.clip.png'), + // matchesGoldenFile('floating_action_button_test.clip.2.png'), // .clip.1.png is obsolete and can be removed + // skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 6697d224832..1df2e5b5bda 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -2020,15 +2020,17 @@ void main() { await tester.pumpWidget(buildFrame(TextDirection.ltr)); await expectLater( find.byType(InputDecorator), - matchesGoldenFile('input_decorator.outline_icon_label.ltr.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('input_decorator.outline_icon_label.ltr.png'), + // matchesGoldenFile('input_decorator.outline_icon_label.ltr.png'), + // skip: !Platform.isLinux, ); await tester.pumpWidget(buildFrame(TextDirection.rtl)); await expectLater( find.byType(InputDecorator), - matchesGoldenFile('input_decorator.outline_icon_label.rtl.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('input_decorator.outline_icon_label.rtl.png'), + // matchesGoldenFile('input_decorator.outline_icon_label.rtl.png'), + // skip: !Platform.isLinux, ); }, skip: !Platform.isLinux, diff --git a/packages/flutter/test/material/material_test.dart b/packages/flutter/test/material/material_test.dart index 2299e9b3ef7..6b2db358157 100644 --- a/packages/flutter/test/material/material_test.dart +++ b/packages/flutter/test/material/material_test.dart @@ -618,8 +618,9 @@ void main() { await expectLater( find.byKey(painterKey), - matchesGoldenFile('material.border_paint_above.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('material.border_paint_above.png'), + // matchesGoldenFile('material.border_paint_above.png'), + // skip: !Platform.isLinux, ); }); @@ -659,8 +660,9 @@ void main() { await expectLater( find.byKey(painterKey), - matchesGoldenFile('material.border_paint_below.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('material.border_paint_below.png'), + // matchesGoldenFile('material.border_paint_below.png'), + // skip: !Platform.isLinux, ); }); }); diff --git a/packages/flutter/test/material/radio_test.dart b/packages/flutter/test/material/radio_test.dart index 3be3d203f98..0c7d88119aa 100644 --- a/packages/flutter/test/material/radio_test.dart +++ b/packages/flutter/test/material/radio_test.dart @@ -277,8 +277,9 @@ void main() { await tester.pumpAndSettle(); await expectLater( find.byKey(painterKey), - matchesGoldenFile('radio.ink_ripple.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('radio.ink_ripple.png'), + // matchesGoldenFile('radio.ink_ripple.png'), + // skip: !Platform.isLinux, ); }); } diff --git a/packages/flutter/test/material/tab_bar_theme_test.dart b/packages/flutter/test/material/tab_bar_theme_test.dart index 23fef94a1b3..83aacd1474e 100644 --- a/packages/flutter/test/material/tab_bar_theme_test.dart +++ b/packages/flutter/test/material/tab_bar_theme_test.dart @@ -269,8 +269,9 @@ void main() { await expectLater( find.byKey(_painterKey), - matchesGoldenFile('tab_bar_theme.tab_indicator_size_tab.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('tab_bar_theme.tab_indicator_size_tab.png'), + // matchesGoldenFile('tab_bar_theme.tab_indicator_size_tab.png'), + // skip: !Platform.isLinux, ); }); @@ -281,8 +282,9 @@ void main() { await expectLater( find.byKey(_painterKey), - matchesGoldenFile('tab_bar_theme.tab_indicator_size_label.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('tab_bar_theme.tab_indicator_size_label.png'), + // matchesGoldenFile('tab_bar_theme.tab_indicator_size_label.png'), + // skip: !Platform.isLinux, ); }); @@ -298,8 +300,9 @@ void main() { await expectLater( find.byKey(_painterKey), - matchesGoldenFile('tab_bar_theme.custom_tab_indicator.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('tab_bar_theme.custom_tab_indicator.png'), + // matchesGoldenFile('tab_bar_theme.custom_tab_indicator.png'), + // skip: !Platform.isLinux, ); }); @@ -315,8 +318,9 @@ void main() { await expectLater( find.byKey(_painterKey), - matchesGoldenFile('tab_bar_theme.beveled_rect_indicator.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('tab_bar_theme.beveled_rect_indicator.png'), + // matchesGoldenFile('tab_bar_theme.beveled_rect_indicator.png'), + // skip: !Platform.isLinux, ); }); } From c5ba689e41a64da4be33ce961393d030f59cddcd Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Wed, 24 Apr 2019 10:37:31 -0700 Subject: [PATCH 07/18] Commented out skips in golden framework tests and transitioned from matchesGoldenFile to matchesSkiaGoldFile. --- .../test/material/input_decorator_test.dart | 2 +- .../continous_rectangle_border_test.dart | 15 ++- .../test/rendering/localized_fonts_test.dart | 15 ++- .../test/widgets/backdrop_filter_test.dart | 5 +- packages/flutter/test/widgets/clip_test.dart | 39 ++++-- .../widgets/editable_text_cursor_test.dart | 13 +- .../test/widgets/invert_colors_test.dart | 10 +- .../widgets/list_wheel_scroll_view_test.dart | 10 +- .../flutter/test/widgets/opacity_test.dart | 5 +- .../test/widgets/physical_model_test.dart | 5 +- .../flutter/test/widgets/shadow_test.dart | 47 ++++--- .../test/widgets/text_golden_test.dart | 100 +++++++++----- .../test/widgets/widget_inspector_test.dart | 125 +++++++++++------- 13 files changed, 243 insertions(+), 148 deletions(-) diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 1df2e5b5bda..315c28be4e8 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -2033,7 +2033,7 @@ void main() { // skip: !Platform.isLinux, ); }, - skip: !Platform.isLinux, +// skip: !Platform.isLinux, ); testWidgets('InputDecorationTheme.toString()', (WidgetTester tester) async { diff --git a/packages/flutter/test/painting/continous_rectangle_border_test.dart b/packages/flutter/test/painting/continous_rectangle_border_test.dart index 9ac2c0e12f7..765c4174414 100644 --- a/packages/flutter/test/painting/continous_rectangle_border_test.dart +++ b/packages/flutter/test/painting/continous_rectangle_border_test.dart @@ -72,8 +72,9 @@ void main() { await expectLater( find.byType(RepaintBoundary), - matchesGoldenFile('continuous_rectangle_border.golden_test_even_radii.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('continuous_rectangle_border.golden_test_even_radii.png'), +// matchesGoldenFile('continuous_rectangle_border.golden_test_even_radii.png'), +// skip: !Platform.isLinux, ); }); @@ -94,8 +95,9 @@ void main() { await expectLater( find.byType(RepaintBoundary), - matchesGoldenFile('continuous_rectangle_border.golden_test_varying_radii.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('continuous_rectangle_border.golden_test_varying_radii.png'), +// matchesGoldenFile('continuous_rectangle_border.golden_test_varying_radii.png'), +// skip: !Platform.isLinux, ); }); @@ -113,8 +115,9 @@ void main() { await expectLater( find.byType(RepaintBoundary), - matchesGoldenFile('continuous_rectangle_border.golden_test_large_radii.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('continuous_rectangle_border.golden_test_large_radii.png'), +// matchesGoldenFile('continuous_rectangle_border.golden_test_large_radii.png'), +// skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/rendering/localized_fonts_test.dart b/packages/flutter/test/rendering/localized_fonts_test.dart index 7ce046c1bcf..6cbc28577da 100644 --- a/packages/flutter/test/rendering/localized_fonts_test.dart +++ b/packages/flutter/test/rendering/localized_fonts_test.dart @@ -51,10 +51,11 @@ void main() { await expectLater( find.byType(RichText), - matchesGoldenFile('localized_fonts.rich_text.styled_text_span.png'), + matchesSkiaGoldFile('localized_fonts.rich_text.styled_text_span.png'), + // matchesGoldenFile('localized_fonts.rich_text.styled_text_span.png'), ); }, - skip: !Platform.isLinux, + //skip: !Platform.isLinux, ); testWidgets( @@ -103,10 +104,11 @@ void main() { await expectLater( find.byType(Row), - matchesGoldenFile('localized_fonts.text_ambient_locale.chars.png'), + matchesSkiaGoldFile('localized_fonts.text_ambient_locale.chars.png'), +// matchesGoldenFile('localized_fonts.text_ambient_locale.chars.png'), ); }, - skip: !Platform.isLinux, +// skip: !Platform.isLinux, ); testWidgets( @@ -147,10 +149,11 @@ void main() { await expectLater( find.byType(Row), - matchesGoldenFile('localized_fonts.text_explicit_locale.chars.png'), + matchesSkiaGoldFile('localized_fonts.text_explicit_locale.chars.png'), +// matchesGoldenFile('localized_fonts.text_explicit_locale.chars.png'), ); }, - skip: !Platform.isLinux, +// skip: !Platform.isLinux, ); } diff --git a/packages/flutter/test/widgets/backdrop_filter_test.dart b/packages/flutter/test/widgets/backdrop_filter_test.dart index df499b82536..11042fddda9 100644 --- a/packages/flutter/test/widgets/backdrop_filter_test.dart +++ b/packages/flutter/test/widgets/backdrop_filter_test.dart @@ -43,8 +43,9 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('backdrop_filter_test.cull_rect.1.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('backdrop_filter_test.cull_rect.png') +// matchesGoldenFile('backdrop_filter_test.cull_rect.1.png'), +// skip: !Platform.isLinux, ); }); } diff --git a/packages/flutter/test/widgets/clip_test.dart b/packages/flutter/test/widgets/clip_test.dart index 3c3b6da0bc5..8d3aecc1c02 100644 --- a/packages/flutter/test/widgets/clip_test.dart +++ b/packages/flutter/test/widgets/clip_test.dart @@ -288,7 +288,8 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.ClipRect.1.png'), + matchesSkiaGoldFile('clip.ClipRect.png'), +// matchesGoldenFile('clip.ClipRect.1.png'), ); }); @@ -328,7 +329,8 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.ClipRectOverlay.1.png'), + matchesSkiaGoldFile('clip.ClipRectOverlay.png') +// matchesGoldenFile('clip.ClipRectOverlay.1.png'), ); }); @@ -377,7 +379,8 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.ClipRRect.1.png'), + matchesSkiaGoldFile('clip.ClipRRect.png'), +// matchesGoldenFile('clip.ClipRRect.1.png'), ); }); @@ -420,7 +423,8 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.ClipOval.1.png'), + matchesSkiaGoldFile('clip.ClipOval.png'), +// matchesGoldenFile('clip.ClipOval.1.png'), ); }); @@ -468,7 +472,8 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.ClipPath.1.png'), + matchesSkiaGoldFile('clip.ClipPath.png'), +// matchesGoldenFile('clip.ClipPath.1.png'), ); }); @@ -513,7 +518,8 @@ void main() { await tester.pumpWidget(genPhysicalModel(Clip.antiAlias)); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.PhysicalModel.antiAlias.1.png'), + matchesSkiaGoldFile('clip.PhysicalModel.antiAlias.png'), +// matchesGoldenFile('clip.PhysicalModel.antiAlias.1.png'), ); }); @@ -521,7 +527,8 @@ void main() { await tester.pumpWidget(genPhysicalModel(Clip.hardEdge)); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.PhysicalModel.hardEdge.1.png'), + matchesSkiaGoldFile('clip.PhysicalModel.hardEdge.png'), +// matchesGoldenFile('clip.PhysicalModel.hardEdge.1.png'), ); }); @@ -531,7 +538,8 @@ void main() { await tester.pumpWidget(genPhysicalModel(Clip.antiAliasWithSaveLayer)); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.PhysicalModel.antiAliasWithSaveLayer.png'), + matchesSkiaGoldFile('clip.PhysicalModel.antiAliasWithSaveLayer.png'), +// matchesGoldenFile('clip.PhysicalModel.antiAliasWithSaveLayer.png'), ); }); @@ -573,7 +581,8 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.PhysicalModel.default.1.png'), + matchesSkiaGoldFile('clip.PhysicalModel.default.png'), +// matchesGoldenFile('clip.PhysicalModel.default.1.png'), ); }); @@ -622,7 +631,8 @@ void main() { await tester.pumpWidget(genPhysicalShape(Clip.antiAlias)); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.PhysicalShape.antiAlias.1.png'), + matchesSkiaGoldFile('clip.PhysicalShape.antiAlias.png'), +// matchesGoldenFile('clip.PhysicalShape.antiAlias.1.png'), ); }); @@ -630,7 +640,8 @@ void main() { await tester.pumpWidget(genPhysicalShape(Clip.hardEdge)); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.PhysicalShape.hardEdge.1.png'), + matchesSkiaGoldFile('clip.PhysicalShape.hardEdge.png'), +// matchesGoldenFile('clip.PhysicalShape.hardEdge.1.png'), ); }); @@ -638,7 +649,8 @@ void main() { await tester.pumpWidget(genPhysicalShape(Clip.antiAliasWithSaveLayer)); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.PhysicalShape.antiAliasWithSaveLayer.png'), + matchesSkiaGoldFile('clip.PhysicalShape.antiAliasWithSaveLayer.png'), +// matchesGoldenFile('clip.PhysicalShape.antiAliasWithSaveLayer.png'), ); }); @@ -684,7 +696,8 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('clip.PhysicalShape.default.1.png'), + matchesSkiaGoldFile('clip.PhysicalShape.default.png'), +// matchesGoldenFile('clip.PhysicalShape.default.1.png'), ); }); diff --git a/packages/flutter/test/widgets/editable_text_cursor_test.dart b/packages/flutter/test/widgets/editable_text_cursor_test.dart index ba232ddd441..72cfa0ca05a 100644 --- a/packages/flutter/test/widgets/editable_text_cursor_test.dart +++ b/packages/flutter/test/widgets/editable_text_cursor_test.dart @@ -91,9 +91,12 @@ void main() { await expectLater( find.byKey(const ValueKey(1)), - matchesGoldenFile('editable_text_test.0.0.png'), + matchesSkiaGoldFile('editable_text_test.0.png'), +// matchesGoldenFile('editable_text_test.0.0.png'), ); - }, skip: !Platform.isLinux); + }, + //skip: !Platform.isLinux + ); testWidgets('cursor layout has correct radius', (WidgetTester tester) async { final GlobalKey editableTextKey = GlobalKey(); @@ -142,9 +145,11 @@ void main() { await expectLater( find.byKey(const ValueKey(1)), - matchesGoldenFile('editable_text_test.1.0.png'), + matchesSkiaGoldFile('editable_text_test.1.png'), +// matchesGoldenFile('editable_text_test.1.0.png'), ); - }, skip: !Platform.isLinux); + }, //skip: !Platform.isLinux + ); testWidgets('Cursor animates on iOS', (WidgetTester tester) async { final Widget widget = MaterialApp( diff --git a/packages/flutter/test/widgets/invert_colors_test.dart b/packages/flutter/test/widgets/invert_colors_test.dart index 7a10975b68a..f306d3ce803 100644 --- a/packages/flutter/test/widgets/invert_colors_test.dart +++ b/packages/flutter/test/widgets/invert_colors_test.dart @@ -22,8 +22,9 @@ void main() { await expectLater( find.byType(RepaintBoundary), - matchesGoldenFile('invert_colors_test.0.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('invert_colors_test.0.png') +// matchesGoldenFile('invert_colors_test.0.png'), +// skip: !Platform.isLinux, ); }); @@ -41,8 +42,9 @@ void main() { await expectLater( find.byType(RepaintBoundary), - matchesGoldenFile('invert_colors_test.1.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('invert_colors_test.1.png'), +// matchesGoldenFile('invert_colors_test.1.png'), +// skip: !Platform.isLinux, ); }); } diff --git a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart index ef28545a596..80dc7332eda 100644 --- a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart +++ b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart @@ -492,8 +492,9 @@ void main() { await expectLater( find.byKey(const Key('list_wheel_scroll_view')), - matchesGoldenFile('list_wheel_scroll_view.center_child.magnified.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('list_wheel_scroll_view.center_child.magnified.png'), +// matchesGoldenFile('list_wheel_scroll_view.center_child.magnified.png'), +// skip: !Platform.isLinux, ); }); @@ -547,8 +548,9 @@ void main() { await expectLater( find.byKey(const Key('list_wheel_scroll_view')), - matchesGoldenFile('list_wheel_scroll_view.curved_wheel.left.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('list_wheel_scroll_view.curved_wheel.left.png'), +// matchesGoldenFile('list_wheel_scroll_view.curved_wheel.left.png'), +// skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/widgets/opacity_test.dart b/packages/flutter/test/widgets/opacity_test.dart index c28892b568e..e9c399d3fa1 100644 --- a/packages/flutter/test/widgets/opacity_test.dart +++ b/packages/flutter/test/widgets/opacity_test.dart @@ -179,8 +179,9 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('opacity_test.offset.1.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('opacity_test.offset.png'), +// matchesGoldenFile('opacity_test.offset.1.png'), +// skip: !Platform.isLinux, ); }); } diff --git a/packages/flutter/test/widgets/physical_model_test.dart b/packages/flutter/test/widgets/physical_model_test.dart index 2465d2e4e95..f33e4316694 100644 --- a/packages/flutter/test/widgets/physical_model_test.dart +++ b/packages/flutter/test/widgets/physical_model_test.dart @@ -66,8 +66,9 @@ void main() { expect(tester.takeException(), startsWith('A RenderFlex overflowed by ')); await expectLater( find.byKey(key), - matchesGoldenFile('physical_model_overflow.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('physical_model_overflow.png'), +// matchesGoldenFile('physical_model_overflow.png'), +// skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/widgets/shadow_test.dart b/packages/flutter/test/widgets/shadow_test.dart index dd90450181b..6f54504d0cc 100644 --- a/packages/flutter/test/widgets/shadow_test.dart +++ b/packages/flutter/test/widgets/shadow_test.dart @@ -25,18 +25,18 @@ void main() { ); await expectLater( find.byType(Container), - matchesGoldenFile('shadow.BoxDecoration.disabled.png'), + matchesSkiaGoldFile('shadow.BoxDecoration.disabled.png'), +// matchesGoldenFile('shadow.BoxDecoration.disabled.png'), ); debugDisableShadows = false; tester.binding.reassembleApplication(); await tester.pump(); - if (Platform.isLinux) { - // TODO(ianh): use the skip argument instead once that doesn't hang, https://github.com/dart-lang/test/issues/830 - await expectLater( - find.byType(Container), - matchesGoldenFile('shadow.BoxDecoration.enabled.png'), - ); // shadows render differently on different platforms - } + // TODO(ianh): [May no longer apply] use the skip argument instead once that doesn't hang, https://github.com/dart-lang/test/issues/830 + await expectLater( + find.byType(Container), + matchesSkiaGoldFile('shadow.BoxDecoration.enabled.png'), +// matchesGoldenFile('shadow.BoxDecoration.enabled.png'), + ); debugDisableShadows = true; }); @@ -61,11 +61,14 @@ void main() { await tester.pumpWidget(build(elevation)); await expectLater( find.byType(Container), - matchesGoldenFile('shadow.ShapeDecoration.$elevation.png'), + matchesSkiaGoldFile('shadow.ShapeDecoration.$elevation.png'), +// matchesGoldenFile('shadow.ShapeDecoration.$elevation.png'), ); } debugDisableShadows = true; - }, skip: !Platform.isLinux); // shadows render differently on different platforms + }, +// skip: !Platform.isLinux + ); // shadows render differently on different platforms testWidgets('Shadows with PhysicalLayer', (WidgetTester tester) async { await tester.pumpWidget( @@ -88,18 +91,18 @@ void main() { ); await expectLater( find.byType(Container), - matchesGoldenFile('shadow.PhysicalModel.disabled.png'), + matchesSkiaGoldFile('shadow.PhysicalModel.disabled.png'), +// matchesGoldenFile('shadow.PhysicalModel.disabled.png'), ); debugDisableShadows = false; tester.binding.reassembleApplication(); await tester.pump(); - if (Platform.isLinux) { - // TODO(ianh): use the skip argument instead once that doesn't hang, https://github.com/dart-lang/test/issues/830 - await expectLater( - find.byType(Container), - matchesGoldenFile('shadow.PhysicalModel.enabled.png'), - ); // shadows render differently on different platforms - } + // TODO(ianh): [May no longer apply] use the skip argument instead once that doesn't hang, https://github.com/dart-lang/test/issues/830 + await expectLater( + find.byType(Container), + matchesSkiaGoldFile('shadow.PhysicalModel.enabled.png'), +// matchesGoldenFile('shadow.PhysicalModel.enabled.png'), + ); debugDisableShadows = true; }); @@ -128,9 +131,11 @@ void main() { await tester.pumpWidget(build(elevation.toDouble())); await expectLater( find.byType(Container), - matchesGoldenFile('shadow.PhysicalShape.$elevation.1.png'), + matchesSkiaGoldFile('shadow.PhysicalModel.disabled.png'), +// matchesGoldenFile('shadow.PhysicalModel.disabled.png'), ); } debugDisableShadows = true; - }, skip: !Platform.isLinux); // shadows render differently on different platforms -} + }, +// skip: !Platform.isLinux + ); \ No newline at end of file diff --git a/packages/flutter/test/widgets/text_golden_test.dart b/packages/flutter/test/widgets/text_golden_test.dart index 5781c65aa1c..c79359af147 100644 --- a/packages/flutter/test/widgets/text_golden_test.dart +++ b/packages/flutter/test/widgets/text_golden_test.dart @@ -31,7 +31,8 @@ void main() { await expectLater( find.byType(Container), - matchesGoldenFile('text_golden.Centered.png'), + matchesSkiaGoldFile('text_golden.Centered.png'), +// matchesGoldenFile('text_golden.Centered.png'), ); await tester.pumpWidget( @@ -55,9 +56,12 @@ void main() { await expectLater( find.byType(Container), - matchesGoldenFile('text_golden.Centered.wrap.png'), + matchesSkiaGoldFile('text_golden.Centered.wrap.png'), +// matchesGoldenFile('text_golden.Centered.wrap.png'), ); - }, skip: !Platform.isLinux); + }, +// skip: !Platform.isLinux + ); testWidgets('Text Foreground', (WidgetTester tester) async { @@ -86,7 +90,8 @@ void main() { await expectLater( find.byType(RepaintBoundary), - matchesGoldenFile('text_golden.Foreground.gradient.png'), + matchesSkiaGoldFile('text_golden.Foreground.gradient.png'), +// matchesGoldenFile('text_golden.Foreground.gradient.png'), ); await tester.pumpWidget( @@ -108,7 +113,8 @@ void main() { await expectLater( find.byType(RepaintBoundary), - matchesGoldenFile('text_golden.Foreground.stroke.png'), + matchesSkiaGoldFile('text_golden.Foreground.stroke.png'), +// matchesGoldenFile('text_golden.Foreground.stroke.png'), ); await tester.pumpWidget( @@ -131,9 +137,12 @@ void main() { await expectLater( find.byType(RepaintBoundary), - matchesGoldenFile('text_golden.Foreground.stroke_and_gradient.png'), + matchesSkiaGoldFile('text_golden.Foreground.stroke_and_gradient.png'), +// matchesGoldenFile('text_golden.Foreground.stroke_and_gradient.png'), ); - }, skip: !Platform.isLinux); + }, +// skip: !Platform.isLinux + ); // TODO(garyq): This test requires an update when the background // drawing from the beginning of the line bug is fixed. The current @@ -181,9 +190,12 @@ void main() { await expectLater( find.byType(RepaintBoundary), - matchesGoldenFile('text_golden.Background.png'), + matchesSkiaGoldFile('text_golden.Background.png'), +// matchesGoldenFile('text_golden.Background.png'), ); - }, skip: !Platform.isLinux); + }, +// skip: !Platform.isLinux + ); testWidgets('Text Fade', (WidgetTester tester) async { await tester.pumpWidget( @@ -217,9 +229,12 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('text_golden.Fade.1.png'), + matchesSkiaGoldFile('text_golden.Fade.1.png'), +// matchesGoldenFile('text_golden.Fade.1.png'), ); - }, skip: !Platform.isLinux); + }, +// skip: !Platform.isLinux + ); testWidgets('Default Strut text', (WidgetTester tester) async { await tester.pumpWidget( @@ -242,10 +257,13 @@ void main() { ); await expectLater( find.byType(Container), - matchesGoldenFile('text_golden.StrutDefault.png'), + matchesSkiaGoldFile('text_golden.StrutDefault.png'), +// matchesGoldenFile('text_golden.StrutDefault.png'), ); - }, skip: true); // Should only be on linux (skip: !Platform.isLinux). - // Disabled for now until font inconsistency is resolved. + }, +// skip: true // Should only be on linux (skip: !Platform.isLinux). + // Disabled for now until font inconsistency is resolved. + ); testWidgets('Strut text 1', (WidgetTester tester) async { await tester.pumpWidget( @@ -270,10 +288,12 @@ void main() { ); await expectLater( find.byType(Container), - matchesGoldenFile('text_golden.Strut.1.1.png'), + matchesSkiaGoldFile('text_golden.Strut.1.png') +// matchesGoldenFile('text_golden.Strut.1.1.png'), ); - }, skip: true); // Should only be on linux (skip: !Platform.isLinux). - // Disabled for now until font inconsistency is resolved. + }, + // skip: true // Should only be on linux (skip: !Platform.isLinux). + ); // Disabled for now until font inconsistency is resolved. testWidgets('Strut text 2', (WidgetTester tester) async { await tester.pumpWidget( @@ -299,10 +319,12 @@ void main() { ); await expectLater( find.byType(Container), - matchesGoldenFile('text_golden.Strut.2.1.png'), + matchesSkiaGoldFile('text_golden.Strut.2.png') +// matchesGoldenFile('text_golden.Strut.2.1.png'), ); - }, skip: true); // Should only be on linux (skip: !Platform.isLinux). - // Disabled for now until font inconsistency is resolved. + }, + // skip: true // Should only be on linux (skip: !Platform.isLinux). + ); // Disabled for now until font inconsistency is resolved. testWidgets('Strut text rich', (WidgetTester tester) async { await tester.pumpWidget( @@ -351,10 +373,12 @@ void main() { ); await expectLater( find.byType(Container), - matchesGoldenFile('text_golden.Strut.3.1.png'), + matchesSkiaGoldFile('text_golden.Strut.3.png') +// matchesGoldenFile('text_golden.Strut.3.1.png'), ); - }, skip: true); // Should only be on linux (skip: !Platform.isLinux). - // Disabled for now until font inconsistency is resolved. + }, + // skip: true // Should only be on linux (skip: !Platform.isLinux). + ); // Disabled for now until font inconsistency is resolved. testWidgets('Strut text font fallback', (WidgetTester tester) async { // Font Fallback @@ -387,10 +411,12 @@ void main() { ); await expectLater( find.byType(Container), - matchesGoldenFile('text_golden.Strut.4.1.png'), + matchesSkiaGoldFile('text_golden.Strut.4.png') +// matchesGoldenFile('text_golden.Strut.4.1.png'), ); - }, skip: true); // Should only be on linux (skip: !Platform.isLinux). - // Disabled for now until font inconsistency is resolved. + }, + // skip: true // Should only be on linux (skip: !Platform.isLinux). + ); // Disabled for now until font inconsistency is resolved. testWidgets('Strut text rich forceStrutHeight', (WidgetTester tester) async { await tester.pumpWidget( @@ -439,10 +465,12 @@ void main() { ); await expectLater( find.byType(Container), - matchesGoldenFile('text_golden.StrutForce.1.1.png'), + matchesSkiaGoldFile('text_golden.StrutForce.1.png') +// matchesGoldenFile('text_golden.StrutForce.1.1.png'), ); - }, skip: true); // Should only be on linux (skip: !Platform.isLinux). - // Disabled for now until font inconsistency is resolved. + }, + // skip: true // Should only be on linux (skip: !Platform.isLinux). + ); // Disabled for now until font inconsistency is resolved. testWidgets('Decoration thickness', (WidgetTester tester) async { final TextDecoration allDecorations = TextDecoration.combine( @@ -478,9 +506,12 @@ void main() { ); await expectLater( find.byType(Container), - matchesGoldenFile('text_golden.Decoration.1.0.png'), + matchesSkiaGoldFile('text_golden.Decoration.1.png'), +// matchesGoldenFile('text_golden.Decoration.1.0.png'), ); - }, skip: !Platform.isLinux); // Coretext uses different thicknesses for decoration + }, +// skip: !Platform.isLinux + ); // Coretext uses different thicknesses for decoration testWidgets('Decoration thickness', (WidgetTester tester) async { final TextDecoration allDecorations = TextDecoration.combine( @@ -517,7 +548,10 @@ void main() { ); await expectLater( find.byType(Container), - matchesGoldenFile('text_golden.DecorationThickness.1.0.png'), + matchesSkiaGoldFile('text_golden.DecorationThickness.1.png'), +// matchesGoldenFile('text_golden.DecorationThickness.1.0.png'), ); - }, skip: !Platform.isLinux); // Coretext uses different thicknesses for decoration + }, +// skip: !Platform.isLinux + ); // Coretext uses different thicknesses for decoration } diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index 910ee83e086..dcb430cde02 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -1828,8 +1828,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { expect(expectedChildLayerCount, equals(2)); await expectLater( layer.toImage(renderObject.semanticBounds.inflate(50.0)), - matchesGoldenFile('inspector.repaint_boundary_margin.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.repaint_boundary_margin.png'), +// matchesGoldenFile('inspector.repaint_boundary_margin.png'), +// skip: !Platform.isLinux, ); // Regression test for how rendering with a pixel scale other than 1.0 @@ -1839,8 +1840,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { renderObject.semanticBounds.inflate(50.0), pixelRatio: 0.5, ), - matchesGoldenFile('inspector.repaint_boundary_margin_small.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.repaint_boundary_margin_small.png'), +// matchesGoldenFile('inspector.repaint_boundary_margin_small.png'), +// skip: !Platform.isLinux, ); await expectLater( @@ -1848,8 +1850,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { renderObject.semanticBounds.inflate(50.0), pixelRatio: 2.0, ), - matchesGoldenFile('inspector.repaint_boundary_margin_large.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.repaint_boundary_margin_large.png'), +// matchesGoldenFile('inspector.repaint_boundary_margin_large.png'), +// skip: !Platform.isLinux, ); final Layer layerParent = layer.parent; @@ -1864,8 +1867,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { width: 300.0, height: 300.0, ), - matchesGoldenFile('inspector.repaint_boundary.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.repaint_boundary.png'), +// matchesGoldenFile('inspector.repaint_boundary.png'), +// skip: !Platform.isLinux, ); // Verify that taking a screenshot didn't change the layers associated with @@ -1882,8 +1886,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 500.0, margin: 50.0, ), - matchesGoldenFile('inspector.repaint_boundary_margin.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.repaint_boundary_margin.png'), +// matchesGoldenFile('inspector.repaint_boundary_margin.png'), +// skip: !Platform.isLinux, ); // Verify that taking a screenshot didn't change the layers associated with @@ -1903,8 +1908,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 300.0, debugPaint: true, ), - matchesGoldenFile('inspector.repaint_boundary_debugPaint.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.repaint_boundary_debugPaint.png'), +// matchesGoldenFile('inspector.repaint_boundary_debugPaint.png'), +// skip: !Platform.isLinux, ); // Verify that taking a screenshot with debug paint on did not change // the number of children the layer has. @@ -1914,8 +1920,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { // hasn't changed the regular render of the widget. await expectLater( find.byType(RepaintBoundaryWithDebugPaint), - matchesGoldenFile('inspector.repaint_boundary.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.repaint_boundary.png'), +// matchesGoldenFile('inspector.repaint_boundary.png'), +// skip: !Platform.isLinux, ); expect(renderObject.debugLayer, equals(layer)); @@ -1928,8 +1935,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { width: 100.0, height: 100.0, ), - matchesGoldenFile('inspector.container.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.container.png'), +// matchesGoldenFile('inspector.container.png'), +// skip: !Platform.isLinux, ); await expectLater( @@ -1939,8 +1947,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 100.0, debugPaint: true, ), - matchesGoldenFile('inspector.container_debugPaint.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.container_debugPaint.png'), +// matchesGoldenFile('inspector.container_debugPaint.png'), +// skip: !Platform.isLinux, ); { @@ -1960,8 +1969,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 100.0, debugPaint: true, ), - matchesGoldenFile('inspector.container_debugPaint.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.container_debugPaint.png'), +// matchesGoldenFile('inspector.container_debugPaint.png'), +// skip: !Platform.isLinux, ); expect(container.debugNeedsLayout, isFalse); } @@ -1973,8 +1983,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { width: 50.0, height: 100.0, ), - matchesGoldenFile('inspector.container_small.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.container_small.png'), +// matchesGoldenFile('inspector.container_small.png'), +// skip: !Platform.isLinux, ); await expectLater( @@ -1984,8 +1995,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 400.0, maxPixelRatio: 3.0, ), - matchesGoldenFile('inspector.container_large.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.container_large.png'), +// matchesGoldenFile('inspector.container_large.png'), +// skip: !Platform.isLinux, ); // This screenshot will show the clip rect debug paint but no other @@ -1997,8 +2009,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 100.0, debugPaint: true, ), - matchesGoldenFile('inspector.clipRect_debugPaint.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.clipRect_debugPaint.png'), +// matchesGoldenFile('inspector.clipRect_debugPaint.png'), +// skip: !Platform.isLinux, ); final Element clipRect = find.byType(ClipRRect).evaluate().single; @@ -2014,8 +2027,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { // This golden image is platform dependent due to the clip icon. await expectLater( clipRectScreenshot, - matchesGoldenFile('inspector.clipRect_debugPaint_margin.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.clipRect_debugPaint_margin.png'), +// matchesGoldenFile('inspector.clipRect_debugPaint_margin.png'), +// skip: !Platform.isLinux, ); // Verify we get the same image if we go through the service extension @@ -2054,8 +2068,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 300.0, debugPaint: true, ), - matchesGoldenFile('inspector.padding_debugPaint.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.padding_debugPaint.png'), +// matchesGoldenFile('inspector.padding_debugPaint.png'), +// skip: !Platform.isLinux, ); // The bounds for this box crop its rendered content. @@ -2066,8 +2081,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 300.0, debugPaint: true, ), - matchesGoldenFile('inspector.sizedBox_debugPaint.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.sizedBox_debugPaint.png'), +// matchesGoldenFile('inspector.sizedBox_debugPaint.png'), +// skip: !Platform.isLinux, ); // Verify that setting a margin includes the previously cropped content. @@ -2079,8 +2095,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { margin: 50.0, debugPaint: true, ), - matchesGoldenFile('inspector.sizedBox_debugPaint_margin.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.sizedBox_debugPaint_margin.png'), +// matchesGoldenFile('inspector.sizedBox_debugPaint_margin.png'), +// skip: !Platform.isLinux, ); }); @@ -2151,8 +2168,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { await expectLater( find.byKey(mainStackKey), - matchesGoldenFile('inspector.composited_transform.only_offsets.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.composited_transform.only_offsets.png'), +// matchesGoldenFile('inspector.composited_transform.only_offsets.png'), +// skip: !Platform.isLinux, ); await expectLater( @@ -2161,14 +2179,16 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { width: 5000.0, height: 500.0, ), - matchesGoldenFile('inspector.composited_transform.only_offsets_follower.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.composited_transform.only_offsets_follower.png'), +// matchesGoldenFile('inspector.composited_transform.only_offsets_follower.png'), +// skip: !Platform.isLinux, ); await expectLater( WidgetInspectorService.instance.screenshot(find.byType(Stack).evaluate().first, width: 300.0, height: 300.0), - matchesGoldenFile('inspector.composited_transform.only_offsets_small.1.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.composited_transform.only_offsets_small.png'), +// matchesGoldenFile('inspector.composited_transform.only_offsets_small.1.png'), +// skip: !Platform.isLinux, ); await expectLater( @@ -2177,8 +2197,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { width: 500.0, height: 500.0, ), - matchesGoldenFile('inspector.composited_transform.only_offsets_target.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.composited_transform.only_offsets_target.png'), +// matchesGoldenFile('inspector.composited_transform.only_offsets_target.png'), +// skip: !Platform.isLinux, ); }); @@ -2250,8 +2271,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { // screenshots of specific subtrees are reasonable. await expectLater( find.byKey(mainStackKey), - matchesGoldenFile('inspector.composited_transform.with_rotations.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.composited_transform.with_rotations.png'), +// matchesGoldenFile('inspector.composited_transform.with_rotations.png'), +// skip: !Platform.isLinux, ); await expectLater( @@ -2260,8 +2282,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { width: 500.0, height: 500.0, ), - matchesGoldenFile('inspector.composited_transform.with_rotations_small.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.composited_transform.with_rotations_small.png'), +// matchesGoldenFile('inspector.composited_transform.with_rotations_small.png'), +// skip: !Platform.isLinux, ); await expectLater( @@ -2270,8 +2293,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { width: 500.0, height: 500.0, ), - matchesGoldenFile('inspector.composited_transform.with_rotations_target.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.composited_transform.with_rotations_target.png'), +// matchesGoldenFile('inspector.composited_transform.with_rotations_target.png'), +// skip: !Platform.isLinux, ); await expectLater( @@ -2280,8 +2304,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { width: 500.0, height: 500.0, ), - matchesGoldenFile('inspector.composited_transform.with_rotations_follower.png'), - skip: !Platform.isLinux, + matchesSkiaGoldFile('inspector.composited_transform.with_rotations_follower.png'), +// matchesGoldenFile('inspector.composited_transform.with_rotations_follower.png'), +// skip: !Platform.isLinux, ); // Make sure taking screenshots hasn't modified the positions of the From 95d74481d0073128bec23467c851abe689b80ff3 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Wed, 24 Apr 2019 10:58:03 -0700 Subject: [PATCH 08/18] Removed unused imports --- packages/flutter/test/widgets/backdrop_filter_test.dart | 1 - packages/flutter/test/widgets/editable_text_cursor_test.dart | 2 -- packages/flutter/test/widgets/invert_colors_test.dart | 2 -- .../flutter/test/widgets/list_wheel_scroll_view_test.dart | 2 -- packages/flutter/test/widgets/opacity_test.dart | 2 -- packages/flutter/test/widgets/physical_model_test.dart | 1 - packages/flutter/test/widgets/shadow_test.dart | 5 ++--- packages/flutter/test/widgets/text_golden_test.dart | 2 -- 8 files changed, 2 insertions(+), 15 deletions(-) diff --git a/packages/flutter/test/widgets/backdrop_filter_test.dart b/packages/flutter/test/widgets/backdrop_filter_test.dart index 11042fddda9..226cdb84417 100644 --- a/packages/flutter/test/widgets/backdrop_filter_test.dart +++ b/packages/flutter/test/widgets/backdrop_filter_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; import 'dart:ui'; import 'package:flutter/widgets.dart'; diff --git a/packages/flutter/test/widgets/editable_text_cursor_test.dart b/packages/flutter/test/widgets/editable_text_cursor_test.dart index 72cfa0ca05a..014ab4c9343 100644 --- a/packages/flutter/test/widgets/editable_text_cursor_test.dart +++ b/packages/flutter/test/widgets/editable_text_cursor_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/material.dart'; diff --git a/packages/flutter/test/widgets/invert_colors_test.dart b/packages/flutter/test/widgets/invert_colors_test.dart index f306d3ce803..19714da0ef8 100644 --- a/packages/flutter/test/widgets/invert_colors_test.dart +++ b/packages/flutter/test/widgets/invert_colors_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart index 80dc7332eda..39340a93f49 100644 --- a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart +++ b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/rendering.dart'; diff --git a/packages/flutter/test/widgets/opacity_test.dart b/packages/flutter/test/widgets/opacity_test.dart index e9c399d3fa1..126237dbd80 100644 --- a/packages/flutter/test/widgets/opacity_test.dart +++ b/packages/flutter/test/widgets/opacity_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/material.dart'; diff --git a/packages/flutter/test/widgets/physical_model_test.dart b/packages/flutter/test/widgets/physical_model_test.dart index f33e4316694..2f54e09a26c 100644 --- a/packages/flutter/test/widgets/physical_model_test.dart +++ b/packages/flutter/test/widgets/physical_model_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; import 'dart:math' as math show pi; import 'package:flutter/material.dart'; diff --git a/packages/flutter/test/widgets/shadow_test.dart b/packages/flutter/test/widgets/shadow_test.dart index 6f54504d0cc..c677110631f 100644 --- a/packages/flutter/test/widgets/shadow_test.dart +++ b/packages/flutter/test/widgets/shadow_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; - import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/material.dart'; @@ -138,4 +136,5 @@ void main() { debugDisableShadows = true; }, // skip: !Platform.isLinux - ); \ No newline at end of file + ); +} \ No newline at end of file diff --git a/packages/flutter/test/widgets/text_golden_test.dart b/packages/flutter/test/widgets/text_golden_test.dart index c79359af147..4af608f5ae9 100644 --- a/packages/flutter/test/widgets/text_golden_test.dart +++ b/packages/flutter/test/widgets/text_golden_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; - import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; From 1fcd1b02de7b09a819d63a4f1acaaa969ba7b0e7 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Wed, 24 Apr 2019 13:38:49 -0700 Subject: [PATCH 09/18] Changes for uploading baseline images. --- .../test/cupertino/date_picker_test.dart | 17 +++++++--------- .../flutter_goldens/lib/flutter_goldens.dart | 11 ++++++---- .../flutter_goldens_client/lib/client.dart | 20 ++++++++++--------- .../lib/src/commands/update_packages.dart | 1 + 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/packages/flutter/test/cupertino/date_picker_test.dart b/packages/flutter/test/cupertino/date_picker_test.dart index 4533c56c1ed..2032924ad16 100644 --- a/packages/flutter/test/cupertino/date_picker_test.dart +++ b/packages/flutter/test/cupertino/date_picker_test.dart @@ -852,26 +852,23 @@ void main() { ) ); -// await expectLater( -// find.byType(CupertinoDatePicker), -// matchesGoldenFile('date_picker_test.datetime.initial.png'), -// skip: !Platform.isLinux -// ); - await expectLater( find.byType(CupertinoDatePicker), - matchesSkiaGoldFile('date_picker_test.datetime.initial.png'), + matchesSkiaGoldFile('date_picker_test.datetime.initial.png') +// matchesGoldenFile('date_picker_test.datetime.initial.png'), +// skip: !Platform.isLinux ); // Slightly drag the hour component to make the current hour off-center. await tester.drag(find.text('4'), Offset(0, _kRowOffset.dy / 2)); await tester.pump(); -// await expectLater( -// find.byType(CupertinoDatePicker), + await expectLater( + find.byType(CupertinoDatePicker), + matchesSkiaGoldFile('date_picker_test.datetime.drag.png'), // matchesGoldenFile('date_picker_test.datetime.drag.png'), // skip: !Platform.isLinux -// ); + ); }); } diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index 7aa23e9496c..67795de66bf 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -30,11 +30,9 @@ Future main(FutureOr testMain()) async { /// Within the https://github.com/flutter/flutter repository, it's important /// not to check-in binaries in order to keep the size of the repository to a /// minimum. To satisfy this requirement, this comparator uses the -/// [SkiaGoldClient] to upload widgets for golden tests and process results. +/// [SkiaGoldClient] to upload widgets for framework-related golden tests and +/// process results. /// -/// This comparator will locally clone the `flutter/goldens` repository into -/// the `$FLUTTER_ROOT/bin/cache/pkg/goldens` folder, then perform the comparison against -/// the files therein. /// This comparator will instantiate the [SkiaGoldClient] and process the /// results of the test. class FlutterGoldenFileComparator implements GoldenFileComparator { @@ -71,9 +69,14 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { // Calculate the appropriate basedir for the current test context. const FileSystem fs = LocalFileSystem(); final Directory testDirectory = fs.directory(defaultComparator.basedir); + //print('test: $testDirectory'); final Directory flutterRoot = fs.directory(Platform.environment[_kFlutterRootKey]); + //print('flutter: $flutterRoot'); final Directory goldenRoot = flutterRoot.childDirectory(fs.path.join('bin', 'cache', 'pkg', 'goldens')); + //print('golden: $goldenRoot'); final String testDirectoryRelativePath = fs.path.relative(testDirectory.path, from: flutterRoot.path); + //print('testDRP: $testDirectoryRelativePath'); + //print('FGFC instantiated with:${goldenRoot.childDirectory(testDirectoryRelativePath).uri}'); return FlutterGoldenFileComparator(goldenRoot.childDirectory(testDirectoryRelativePath).uri); } diff --git a/packages/flutter_goldens_client/lib/client.dart b/packages/flutter_goldens_client/lib/client.dart index cb36481db18..9bfaab74861 100644 --- a/packages/flutter_goldens_client/lib/client.dart +++ b/packages/flutter_goldens_client/lib/client.dart @@ -142,20 +142,22 @@ class SkiaGoldClient { ..writeln('stderr: ${imgtestResult.stderr}'); throw NonZeroExitCode(imgtestResult.exitCode, buf.toString()); } + print('PASS'); return true; } Future _getCommitHash() async { - if (!flutterRoot.existsSync()) { - return null; - } else { - final io.ProcessResult revParse = await process.run( - ['git', 'rev-parse', 'HEAD'], - workingDirectory: flutterRoot.path, - ); - return revParse.exitCode == 0 ? revParse.stdout.trim() : null; + // TODO: Remove after baseline is established and pre-commit works + return 'b27b3d744670bb9312824ec94353b93e7d0424ea'; +// if (!flutterRoot.existsSync()) { +// return null; +// } else { +// final io.ProcessResult revParse = await process.run( +// ['git', 'rev-parse', 'HEAD'], +// workingDirectory: flutterRoot.path, +// ); +// return revParse.exitCode == 0 ? revParse.stdout.trim() : null; } - } String _getKeysJSON() { return convert.json.encode( diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart index a7f581b8f42..0010337052c 100644 --- a/packages/flutter_tools/lib/src/commands/update_packages.dart +++ b/packages/flutter_tools/lib/src/commands/update_packages.dart @@ -135,6 +135,7 @@ class UpdatePackagesCommand extends FlutterCommand { // The dev/integration_tests/android_views integration test depends on an assets // package that is in the goldens repository. We need to make sure that the goldens // repository is cloned locally before we verify or update pubspecs. + // TODO(katelovett): Resolve dependency for android_views living in goldens repository // printStatus('Cloning goldens repository...'); // try { // final GoldensClient goldensClient = GoldensClient(); From ba011fd353b5e60f957c64e30c0f02e6de7a878f Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Wed, 24 Apr 2019 15:35:48 -0700 Subject: [PATCH 10/18] nits --- packages/flutter/test/material/floating_action_button_test.dart | 1 - packages/flutter_goldens_client/lib/client.dart | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/flutter/test/material/floating_action_button_test.dart b/packages/flutter/test/material/floating_action_button_test.dart index 9bdd2941088..3753bb2067b 100644 --- a/packages/flutter/test/material/floating_action_button_test.dart +++ b/packages/flutter/test/material/floating_action_button_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; import 'dart:ui'; import 'package:flutter/material.dart'; diff --git a/packages/flutter_goldens_client/lib/client.dart b/packages/flutter_goldens_client/lib/client.dart index 9bfaab74861..50c2c60f53d 100644 --- a/packages/flutter_goldens_client/lib/client.dart +++ b/packages/flutter_goldens_client/lib/client.dart @@ -137,7 +137,7 @@ class SkiaGoldClient { buf ..writeln('Flutter + Skia Gold imgtest failed.') ..writeln('If this is the first execution of this test, it may need to be triaged.') - ..writeln('\tIn this case, re-run the test after triage is completed.') + ..writeln('In this case, re-run the test after triage is completed.\n') ..writeln('stdout: ${imgtestResult.stdout}') ..writeln('stderr: ${imgtestResult.stderr}'); throw NonZeroExitCode(imgtestResult.exitCode, buf.toString()); From a38311e6c80b6c90672f98c76e1328e3f5a0b969 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Thu, 25 Apr 2019 10:05:13 -0700 Subject: [PATCH 11/18] Fixing duplicate test names. --- packages/flutter/test/widgets/shadow_test.dart | 4 ++-- packages/flutter_goldens_client/lib/client.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/flutter/test/widgets/shadow_test.dart b/packages/flutter/test/widgets/shadow_test.dart index c677110631f..fc5f7389261 100644 --- a/packages/flutter/test/widgets/shadow_test.dart +++ b/packages/flutter/test/widgets/shadow_test.dart @@ -89,7 +89,7 @@ void main() { ); await expectLater( find.byType(Container), - matchesSkiaGoldFile('shadow.PhysicalModel.disabled.png'), + matchesSkiaGoldFile('shadow.PhysicalModel.disabled.0.png'), // matchesGoldenFile('shadow.PhysicalModel.disabled.png'), ); debugDisableShadows = false; @@ -129,7 +129,7 @@ void main() { await tester.pumpWidget(build(elevation.toDouble())); await expectLater( find.byType(Container), - matchesSkiaGoldFile('shadow.PhysicalModel.disabled.png'), + matchesSkiaGoldFile('shadow.PhysicalModel.disabled.1.png'), // matchesGoldenFile('shadow.PhysicalModel.disabled.png'), ); } diff --git a/packages/flutter_goldens_client/lib/client.dart b/packages/flutter_goldens_client/lib/client.dart index 50c2c60f53d..5e2060f4b59 100644 --- a/packages/flutter_goldens_client/lib/client.dart +++ b/packages/flutter_goldens_client/lib/client.dart @@ -148,7 +148,7 @@ class SkiaGoldClient { Future _getCommitHash() async { // TODO: Remove after baseline is established and pre-commit works - return 'b27b3d744670bb9312824ec94353b93e7d0424ea'; + return '96f15c74adebb221eb044d3fc71b2d62da0046c0'; // if (!flutterRoot.existsSync()) { // return null; // } else { From e332ab859ac40a3a51f2551f4d7fe64375533bf3 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Thu, 25 Apr 2019 12:18:56 -0700 Subject: [PATCH 12/18] Changed implementation to incorpoarate new init feature for goldctl. Reduces redundant work as well. --- .../flutter/test/widgets/shadow_test.dart | 2 +- .../flutter_goldens/lib/flutter_goldens.dart | 10 +- .../flutter_goldens_client/lib/client.dart | 107 ++++++++++++------ 3 files changed, 77 insertions(+), 42 deletions(-) diff --git a/packages/flutter/test/widgets/shadow_test.dart b/packages/flutter/test/widgets/shadow_test.dart index fc5f7389261..2ca749fb1f9 100644 --- a/packages/flutter/test/widgets/shadow_test.dart +++ b/packages/flutter/test/widgets/shadow_test.dart @@ -129,7 +129,7 @@ void main() { await tester.pumpWidget(build(elevation.toDouble())); await expectLater( find.byType(Container), - matchesSkiaGoldFile('shadow.PhysicalModel.disabled.1.png'), + matchesSkiaGoldFile('shadow.PhysicalModel.disabled.1.$elevation.png'), // matchesGoldenFile('shadow.PhysicalModel.disabled.png'), ); } diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index 67795de66bf..8644c432223 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -69,14 +69,14 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { // Calculate the appropriate basedir for the current test context. const FileSystem fs = LocalFileSystem(); final Directory testDirectory = fs.directory(defaultComparator.basedir); - //print('test: $testDirectory'); + print('test: $testDirectory'); final Directory flutterRoot = fs.directory(Platform.environment[_kFlutterRootKey]); - //print('flutter: $flutterRoot'); + print('flutter: $flutterRoot'); final Directory goldenRoot = flutterRoot.childDirectory(fs.path.join('bin', 'cache', 'pkg', 'goldens')); - //print('golden: $goldenRoot'); + print('golden: $goldenRoot'); final String testDirectoryRelativePath = fs.path.relative(testDirectory.path, from: flutterRoot.path); - //print('testDRP: $testDirectoryRelativePath'); - //print('FGFC instantiated with:${goldenRoot.childDirectory(testDirectoryRelativePath).uri}'); + print('testDRP: $testDirectoryRelativePath'); + print('FGFC instantiated with:${goldenRoot.childDirectory(testDirectoryRelativePath).uri}'); return FlutterGoldenFileComparator(goldenRoot.childDirectory(testDirectoryRelativePath).uri); } diff --git a/packages/flutter_goldens_client/lib/client.dart b/packages/flutter_goldens_client/lib/client.dart index 5e2060f4b59..98c207d31a4 100644 --- a/packages/flutter_goldens_client/lib/client.dart +++ b/packages/flutter_goldens_client/lib/client.dart @@ -8,6 +8,7 @@ import 'dart:io' as io; import 'package:file/file.dart'; import 'package:file/local.dart'; +import 'package:path/path.dart' as path; import 'package:platform/platform.dart'; import 'package:process/process.dart'; @@ -78,55 +79,88 @@ class SkiaGoldClient { /// This ensures that the goldctl tool is authorized and ready for testing. Future auth(Directory workDirectory) async { _workDirectory = workDirectory; - List authArguments = ['auth']; + //TODO(katelovett): Cleanup for final CI implementation if(_serviceAccount == null) - return false; - //throw const NonZeroExitCode(1, 'No Service Account found.'); + return false; // We are not in the proper environment for running these tests. - authArguments += [ - '--service-account', _serviceAccount, - '--work-dir', _workDirectory.childDirectory('temp').path, - ]; + final File authFile = io.File(path.join(_workDirectory.path, 'temp', 'auth_opt.json')); + if(!authFile.existsSync()) { + final List authArguments = [ + 'auth', + '--service-account', _serviceAccount, + '--work-dir', _workDirectory.childDirectory('temp').path, + ]; - final io.ProcessResult authResults = io.Process.runSync(_goldctl, authArguments); - if (authResults.exitCode != 0) { - final StringBuffer buf = StringBuffer(); - buf - ..writeln('Flutter + Skia Gold auth failed.') - ..writeln('stdout: ${authResults.stdout}') - ..writeln('stderr: ${authResults.stderr}'); - throw NonZeroExitCode(authResults.exitCode, buf.toString()); + final io.ProcessResult authResults = io.Process.runSync(_goldctl, authArguments); + if (authResults.exitCode != 0) { + final StringBuffer buf = StringBuffer(); + buf + ..writeln('Flutter + Skia Gold auth failed.') + ..writeln('stdout: ${authResults.stdout}') + ..writeln('stderr: ${authResults.stderr}'); + throw NonZeroExitCode(authResults.exitCode, buf.toString()); + } + } else { + print('The file is already here, skipping auth.'); + } + // Run init + final File keysFile = io.File(path.join(_workDirectory.path, 'keys.json')); + if(!keysFile.existsSync()) { + + final String commitHash = await _getCommitHash(); + final String keys = '${_workDirectory.path}keys.json'; + final String failures = '${_workDirectory.path}failures.json'; + + await io.File(keys).writeAsString(_getKeysJSON()); + await io.File(failures).create(); + + final List imgtestInitArguments = [ + 'imgtest', 'init', + '--instance', _skiaGoldInstance, + '--work-dir', _workDirectory.childDirectory('temp').path, + '--commit', commitHash, + '--keys-file', keys, + '--failure-file', failures, + '--passfail', + ]; + if(imgtestInitArguments.contains(null)) { + final StringBuffer buf = StringBuffer(); + buf.writeln('Null argument for Skia Gold imgtest init:'); + imgtestInitArguments.forEach(buf.writeln); + throw NonZeroExitCode(1, buf.toString()); + } + + final io.ProcessResult imgtestInitResult = io.Process.runSync( + _goldctl, + imgtestInitArguments + ); + if (imgtestInitResult.exitCode != 0) { + final StringBuffer buf = StringBuffer(); + buf + ..writeln('Flutter + Skia Gold imgtest init failed.') + ..writeln('stdout: ${imgtestInitResult.stdout}') + ..writeln('stderr: ${imgtestInitResult.stderr}'); + throw NonZeroExitCode(imgtestInitResult.exitCode, buf.toString()); + } + } else{ + print('Already init, skipping.'); } return true; } Future imgtest(String testName, File goldenFile) async { - List imgtestArguments = [ - 'imgtest', - 'add', - ]; - final String commitHash = await _getCommitHash(); - final String keys = '${_workDirectory.path}keys.json'; - final String failures = '${_workDirectory.path}failures.json'; - await io.File(keys).writeAsString(_getKeysJSON()); - await io.File(failures).create(); - - imgtestArguments += [ - '--instance', _skiaGoldInstance, + final List imgtestArguments = [ + 'imgtest', 'add', '--work-dir', _workDirectory.childDirectory('temp').path, - '--commit', commitHash, '--test-name', testName, '--png-file', goldenFile.path, - '--keys-file', keys, - '--failure-file', failures, - '--passfail', ]; if(imgtestArguments.contains(null)) { final StringBuffer buf = StringBuffer(); - buf.writeln('null argument for Skia Gold imgtest:'); + buf.writeln('Null argument for Skia Gold imgtest add:'); imgtestArguments.forEach(buf.writeln); throw NonZeroExitCode(1, buf.toString()); } @@ -135,20 +169,20 @@ class SkiaGoldClient { if (imgtestResult.exitCode != 0) { final StringBuffer buf = StringBuffer(); buf - ..writeln('Flutter + Skia Gold imgtest failed.') + ..writeln('Flutter + Skia Gold imgtest add failed.') ..writeln('If this is the first execution of this test, it may need to be triaged.') ..writeln('In this case, re-run the test after triage is completed.\n') ..writeln('stdout: ${imgtestResult.stdout}') ..writeln('stderr: ${imgtestResult.stderr}'); throw NonZeroExitCode(imgtestResult.exitCode, buf.toString()); } - print('PASS'); + // print('PASS'); return true; } Future _getCommitHash() async { - // TODO: Remove after baseline is established and pre-commit works - return '96f15c74adebb221eb044d3fc71b2d62da0046c0'; + // TODO(katelovett): Remove after pre-commit tests can be ingested + return '0572f158fb10505b840281124d07f8785d4f13f0'; // if (!flutterRoot.existsSync()) { // return null; // } else { @@ -160,6 +194,7 @@ class SkiaGoldClient { } String _getKeysJSON() { + // TODO(katelovett): Parse out cleaner key information return convert.json.encode( { 'Operating System' : io.Platform.operatingSystem, From 8861e9f3dcf9d547693e5cac72c04400a3ae6ed1 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Thu, 25 Apr 2019 14:51:59 -0700 Subject: [PATCH 13/18] Cleanup --- .../flutter_goldens/lib/flutter_goldens.dart | 23 +++--- .../test/flutter_goldens_test.dart | 7 ++ .../flutter_goldens_client/lib/client.dart | 74 ++++++++++++------- 3 files changed, 68 insertions(+), 36 deletions(-) diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index 8644c432223..2ae622d37f2 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -69,14 +69,17 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { // Calculate the appropriate basedir for the current test context. const FileSystem fs = LocalFileSystem(); final Directory testDirectory = fs.directory(defaultComparator.basedir); - print('test: $testDirectory'); final Directory flutterRoot = fs.directory(Platform.environment[_kFlutterRootKey]); - print('flutter: $flutterRoot'); - final Directory goldenRoot = flutterRoot.childDirectory(fs.path.join('bin', 'cache', 'pkg', 'goldens')); - print('golden: $goldenRoot'); - final String testDirectoryRelativePath = fs.path.relative(testDirectory.path, from: flutterRoot.path); - print('testDRP: $testDirectoryRelativePath'); - print('FGFC instantiated with:${goldenRoot.childDirectory(testDirectoryRelativePath).uri}'); + final Directory goldenRoot = flutterRoot.childDirectory(fs.path.join( + 'bin', + 'cache', + 'pkg', + 'goldens', + )); + final String testDirectoryRelativePath = fs.path.relative( + testDirectory.path, + from: flutterRoot.path, + ); return FlutterGoldenFileComparator(goldenRoot.childDirectory(testDirectoryRelativePath).uri); } @@ -88,11 +91,13 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { } final bool authorized = await _skiaClient.auth(fs.directory(basedir)); if (!authorized) { - //TODO(katelovett): Clean up for final implementation + //TODO(katelovett): Clean up for final implementation on CI return true; //throw test_package.TestFailure('Could not authorize golctl.'); } - return await _skiaClient.imgtest(golden.path, goldenFile); + await _skiaClient.imgtestInit(); + + return await _skiaClient.imgtestAdd(golden.path, goldenFile); } @override diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart index 99e2ddb5398..681a42a4481 100644 --- a/packages/flutter_goldens/test/flutter_goldens_test.dart +++ b/packages/flutter_goldens/test/flutter_goldens_test.dart @@ -52,6 +52,13 @@ void main() { // check for successful auth - return true // check for unsuccessful auth - throw NonZeroExitCode // check for unavailable auth (not on CI) - return false + // check for redundant work + }); + + group('init', () { + // check for successful init - return true + // check for unsuccessful init - throw NonZeroExitCode + // Check for redundant work }); group('imgtest', () { diff --git a/packages/flutter_goldens_client/lib/client.dart b/packages/flutter_goldens_client/lib/client.dart index 98c207d31a4..b0141f9d996 100644 --- a/packages/flutter_goldens_client/lib/client.dart +++ b/packages/flutter_goldens_client/lib/client.dart @@ -51,7 +51,12 @@ class SkiaGoldClient { Directory _workDirectory; - //TODO(katelovett): Environment variables swapped out for CI implementation + //TODO(katelovett): Environment variables are temporary for local testing + /// The local [Directory] where the Flutter repository is hosted. + /// + /// Uses the [fs] file system. + Directory get flutterRoot => fs.directory(platform.environment[_kFlutterRootKey]); + /// The [path] to the local [Directory] where the goldctl tool is hosted. /// /// Uses the [platform] [environment] in this iteration. @@ -68,11 +73,6 @@ class SkiaGoldClient { /// Uses the [platform] [environment] in this iteration. String get _skiaGoldInstance => platform.environment[_kSkiaGoldInstance]; - /// The local [Directory] where the Flutter repository is hosted. - /// - /// Uses the [fs] file system. - Directory get flutterRoot => fs.directory(platform.environment[_kFlutterRootKey]); - /// Prepares the local work space for golden file testing and initializes the /// goldctl authorization for executing tests. /// @@ -81,18 +81,24 @@ class SkiaGoldClient { _workDirectory = workDirectory; //TODO(katelovett): Cleanup for final CI implementation - if(_serviceAccount == null) - return false; // We are not in the proper environment for running these tests. + if (_serviceAccount == null) + return false; // Not in the proper environment for golden file testing. - final File authFile = io.File(path.join(_workDirectory.path, 'temp', 'auth_opt.json')); - if(!authFile.existsSync()) { + final File authFile = _workDirectory.childFile(fs.path.join( + 'temp', + 'auth_opt.json' + )); + if (!authFile.existsSync()) { final List authArguments = [ 'auth', '--service-account', _serviceAccount, '--work-dir', _workDirectory.childDirectory('temp').path, ]; - final io.ProcessResult authResults = io.Process.runSync(_goldctl, authArguments); + final io.ProcessResult authResults = io.Process.runSync( + _goldctl, + authArguments + ); if (authResults.exitCode != 0) { final StringBuffer buf = StringBuffer(); buf @@ -101,13 +107,14 @@ class SkiaGoldClient { ..writeln('stderr: ${authResults.stderr}'); throw NonZeroExitCode(authResults.exitCode, buf.toString()); } - } else { - print('The file is already here, skipping auth.'); } - // Run init - final File keysFile = io.File(path.join(_workDirectory.path, 'keys.json')); - if(!keysFile.existsSync()) { + return true; + } + Future imgtestInit() async { + final File keysFile = _workDirectory.childFile('keys.json'); + + if(!keysFile.existsSync() || await _isNewCommit()) { final String commitHash = await _getCommitHash(); final String keys = '${_workDirectory.path}keys.json'; final String failures = '${_workDirectory.path}failures.json'; @@ -124,6 +131,7 @@ class SkiaGoldClient { '--failure-file', failures, '--passfail', ]; + if(imgtestInitArguments.contains(null)) { final StringBuffer buf = StringBuffer(); buf.writeln('Null argument for Skia Gold imgtest init:'); @@ -133,8 +141,9 @@ class SkiaGoldClient { final io.ProcessResult imgtestInitResult = io.Process.runSync( _goldctl, - imgtestInitArguments + imgtestInitArguments, ); + if (imgtestInitResult.exitCode != 0) { final StringBuffer buf = StringBuffer(); buf @@ -143,14 +152,10 @@ class SkiaGoldClient { ..writeln('stderr: ${imgtestInitResult.stderr}'); throw NonZeroExitCode(imgtestInitResult.exitCode, buf.toString()); } - } else{ - print('Already init, skipping.'); } - return true; } - Future imgtest(String testName, File goldenFile) async { - + Future imgtestAdd(String testName, File goldenFile) async { final List imgtestArguments = [ 'imgtest', 'add', '--work-dir', _workDirectory.childDirectory('temp').path, @@ -165,7 +170,10 @@ class SkiaGoldClient { throw NonZeroExitCode(1, buf.toString()); } - final io.ProcessResult imgtestResult = io.Process.runSync(_goldctl, imgtestArguments); + final io.ProcessResult imgtestResult = io.Process.runSync( + _goldctl, + imgtestArguments, + ); if (imgtestResult.exitCode != 0) { final StringBuffer buf = StringBuffer(); buf @@ -176,13 +184,12 @@ class SkiaGoldClient { ..writeln('stderr: ${imgtestResult.stderr}'); throw NonZeroExitCode(imgtestResult.exitCode, buf.toString()); } - // print('PASS'); return true; } Future _getCommitHash() async { - // TODO(katelovett): Remove after pre-commit tests can be ingested - return '0572f158fb10505b840281124d07f8785d4f13f0'; + // TODO(katelovett): Remove after pre-commit tests can be ingested by Skia Gold + return 'd4e4726ac262b9f78b002b696f915f552fed3fc8'; // if (!flutterRoot.existsSync()) { // return null; // } else { @@ -191,7 +198,20 @@ class SkiaGoldClient { // workingDirectory: flutterRoot.path, // ); // return revParse.exitCode == 0 ? revParse.stdout.trim() : null; - } + } + + Future _isNewCommit() async { + // auth file is there, need to check if we are on a new commit + final File resultFile = _workDirectory.childFile(fs.path.join( + 'temp', + 'result-state.json' + )); + final String contents = await resultFile.readAsString(); + final Map resultJSON = convert.json.decode(contents); + final String lastTestedCommit = resultJSON['SharedConfig']['gitHash']; + final String currentCommit = await _getCommitHash(); + return lastTestedCommit == currentCommit ? false : true; + } String _getKeysJSON() { // TODO(katelovett): Parse out cleaner key information From 328647aa6e4168362c47570d77920a09d903eb83 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Thu, 25 Apr 2019 15:16:57 -0700 Subject: [PATCH 14/18] Removed matchesGoldenFile and skips --- .../test/cupertino/date_picker_test.dart | 4 -- .../flutter/test/cupertino/nav_bar_test.dart | 12 +--- .../cupertino/segmented_control_test.dart | 11 +-- .../test/material/bottom_app_bar_test.dart | 8 +-- .../material/bottom_app_bar_theme_test.dart | 4 -- .../material/bottom_navigation_bar_test.dart | 3 - .../test/material/card_theme_test.dart | 4 -- .../test/material/dialog_theme_test.dart | 4 -- .../flutter/test/material/dropdown_test.dart | 5 -- .../material/floating_action_button_test.dart | 2 - .../test/material/input_decorator_test.dart | 6 -- .../flutter/test/material/material_test.dart | 6 -- .../flutter/test/material/radio_test.dart | 3 - .../test/material/tab_bar_theme_test.dart | 10 --- .../continous_rectangle_border_test.dart | 7 -- .../test/rendering/localized_fonts_test.dart | 8 --- .../test/widgets/backdrop_filter_test.dart | 4 +- packages/flutter/test/widgets/clip_test.dart | 13 ---- .../widgets/editable_text_cursor_test.dart | 9 +-- .../test/widgets/invert_colors_test.dart | 6 +- .../widgets/list_wheel_scroll_view_test.dart | 4 -- .../flutter/test/widgets/opacity_test.dart | 2 - .../test/widgets/physical_model_test.dart | 2 - .../flutter/test/widgets/shadow_test.dart | 16 +---- .../test/widgets/text_golden_test.dart | 68 ++++--------------- .../test/widgets/widget_inspector_test.dart | 50 -------------- 26 files changed, 24 insertions(+), 247 deletions(-) diff --git a/packages/flutter/test/cupertino/date_picker_test.dart b/packages/flutter/test/cupertino/date_picker_test.dart index 2032924ad16..01613c459cb 100644 --- a/packages/flutter/test/cupertino/date_picker_test.dart +++ b/packages/flutter/test/cupertino/date_picker_test.dart @@ -855,8 +855,6 @@ void main() { await expectLater( find.byType(CupertinoDatePicker), matchesSkiaGoldFile('date_picker_test.datetime.initial.png') -// matchesGoldenFile('date_picker_test.datetime.initial.png'), -// skip: !Platform.isLinux ); // Slightly drag the hour component to make the current hour off-center. @@ -866,8 +864,6 @@ void main() { await expectLater( find.byType(CupertinoDatePicker), matchesSkiaGoldFile('date_picker_test.datetime.drag.png'), -// matchesGoldenFile('date_picker_test.datetime.drag.png'), -// skip: !Platform.isLinux ); }); } diff --git a/packages/flutter/test/cupertino/nav_bar_test.dart b/packages/flutter/test/cupertino/nav_bar_test.dart index 981abbd880d..c1e683b2225 100644 --- a/packages/flutter/test/cupertino/nav_bar_test.dart +++ b/packages/flutter/test/cupertino/nav_bar_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - import 'package:flutter/cupertino.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; @@ -801,13 +799,9 @@ void main() { await expectLater( find.byType(RepaintBoundary).last, - //matchesGoldenFile('nav_bar_test.standard_title.1.png'), matchesSkiaGoldFile('nav_bar_test.standard_title.png'), ); }, - // TODO(xster): remove once https://github.com/flutter/flutter/issues/17483 - // is fixed. - // skip: !Platform.isLinux, ); testWidgets( @@ -836,14 +830,10 @@ void main() { await expectLater( find.byType(RepaintBoundary).last, - // matchesGoldenFile('nav_bar_test.large_title.1.png'), matchesSkiaGoldFile('nav_bar_test.large_title.png'), ); }, - // TODO(xster): remove once https://github.com/flutter/flutter/issues/17483 - // is fixed. - // skip: !Platform.isLinux, - ); + ); testWidgets('NavBar draws a light system bar for a dark background', (WidgetTester tester) async { diff --git a/packages/flutter/test/cupertino/segmented_control_test.dart b/packages/flutter/test/cupertino/segmented_control_test.dart index 479d7d1b7e2..170d1f0da78 100644 --- a/packages/flutter/test/cupertino/segmented_control_test.dart +++ b/packages/flutter/test/cupertino/segmented_control_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - import 'package:flutter/widgets.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -1327,11 +1325,9 @@ void main() { await expectLater( find.byType(RepaintBoundary), - // matchesGoldenFile('segmented_control_test.0.0.png'), matchesSkiaGoldFile('segmented_control_test.0.png'), ); - }, //skip: !Platform.isLinux - ); + },); testWidgets('Golden Test Pressed State', (WidgetTester tester) async { final Map children = {}; @@ -1367,10 +1363,7 @@ void main() { await expectLater( find.byType(RepaintBoundary), - // matchesGoldenFile('segmented_control_test.1.0.png'), matchesSkiaGoldFile('segmented_control_test.1.png'), ); - }, - // skip: !Platform.isLinux - ); + },); } diff --git a/packages/flutter/test/material/bottom_app_bar_test.dart b/packages/flutter/test/material/bottom_app_bar_test.dart index 6f9ace8c55c..e8512c570d2 100644 --- a/packages/flutter/test/material/bottom_app_bar_test.dart +++ b/packages/flutter/test/material/bottom_app_bar_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; - import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; @@ -73,19 +71,15 @@ void main() { await pump(FloatingActionButtonLocation.endDocked); await expectLater( find.byKey(key), - // matchesGoldenFile('bottom_app_bar.custom_shape.1.png'), matchesSkiaGoldFile('bottom_app_bar.custom_shape.1.png'), ); await pump(FloatingActionButtonLocation.centerDocked); await tester.pumpAndSettle(); await expectLater( find.byKey(key), - // matchesGoldenFile('bottom_app_bar.custom_shape.2.png'), matchesSkiaGoldFile('bottom_app_bar.custom_shape.2.png'), ); - }, - // skip: !Platform.isLinux - ); + },); testWidgets('color defaults to Theme.bottomAppBarColor', (WidgetTester tester) async { await tester.pumpWidget( diff --git a/packages/flutter/test/material/bottom_app_bar_theme_test.dart b/packages/flutter/test/material/bottom_app_bar_theme_test.dart index ff456aba12d..80486c02261 100644 --- a/packages/flutter/test/material/bottom_app_bar_theme_test.dart +++ b/packages/flutter/test/material/bottom_app_bar_theme_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; - import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -83,8 +81,6 @@ void main() { await expectLater( find.byKey(_painterKey), matchesSkiaGoldFile('bottom_app_bar_theme.custom_shape.png'), - //matchesGoldenFile('bottom_app_bar_theme.custom_shape.png'), - //skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index 2d205ffdd6d..ad80d3f221f 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; import 'dart:ui'; import 'package:flutter/material.dart'; @@ -1149,8 +1148,6 @@ void main() { await expectLater( find.byType(BottomNavigationBar), matchesSkiaGoldFile('bottom_navigation_bar.shifting_transition.$pump.png'), - // matchesGoldenFile('bottom_navigation_bar.shifting_transition.2.$pump.png'), - // skip: !Platform.isLinux, ); } }); diff --git a/packages/flutter/test/material/card_theme_test.dart b/packages/flutter/test/material/card_theme_test.dart index 10904f4c85c..4ced6250d8c 100644 --- a/packages/flutter/test/material/card_theme_test.dart +++ b/packages/flutter/test/material/card_theme_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; - import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -140,8 +138,6 @@ void main() { await expectLater( find.byKey(painterKey), matchesSkiaGoldFile('card_theme.custom_shape.png'), - // matchesGoldenFile('card_theme.custom_shape.png'), - // skip: !Platform.isLinux, ); }); } diff --git a/packages/flutter/test/material/dialog_theme_test.dart b/packages/flutter/test/material/dialog_theme_test.dart index 99794526186..87c655241dc 100644 --- a/packages/flutter/test/material/dialog_theme_test.dart +++ b/packages/flutter/test/material/dialog_theme_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; - import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -133,8 +131,6 @@ void main() { await expectLater( find.byKey(_painterKey), matchesSkiaGoldFile('dialog_theme.dialog_with_custom_border.png'), - // matchesGoldenFile('dialog_theme.dialog_with_custom_border.png'), - // skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart index a6eaf3912a2..4144fd57e96 100644 --- a/packages/flutter/test/material/dropdown_test.dart +++ b/packages/flutter/test/material/dropdown_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; import 'dart:math' as math; import 'dart:ui' show window; @@ -142,8 +141,6 @@ void main() { await expectLater( find.ancestor(of: buttonFinder, matching: find.byType(RepaintBoundary)).first, matchesSkiaGoldFile('dropdown_test.default.png'), - // matchesGoldenFile('dropdown_test.default.0.png'), - // skip: !Platform.isLinux, ); }); @@ -156,8 +153,6 @@ void main() { await expectLater( find.ancestor(of: buttonFinder, matching: find.byType(RepaintBoundary)).first, matchesSkiaGoldFile('dropdown_test.expanded.png'), - // matchesGoldenFile('dropdown_test.expanded.0.png'), - // skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/material/floating_action_button_test.dart b/packages/flutter/test/material/floating_action_button_test.dart index 3753bb2067b..4949f46f7f8 100644 --- a/packages/flutter/test/material/floating_action_button_test.dart +++ b/packages/flutter/test/material/floating_action_button_test.dart @@ -681,8 +681,6 @@ void main() { await expectLater( find.byKey(key), matchesSkiaGoldFile('floating_action_button_test.clip.png'), - // matchesGoldenFile('floating_action_button_test.clip.2.png'), // .clip.1.png is obsolete and can be removed - // skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 315c28be4e8..364d863d464 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:io' show Platform; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; @@ -2021,19 +2020,14 @@ void main() { await expectLater( find.byType(InputDecorator), matchesSkiaGoldFile('input_decorator.outline_icon_label.ltr.png'), - // matchesGoldenFile('input_decorator.outline_icon_label.ltr.png'), - // skip: !Platform.isLinux, ); await tester.pumpWidget(buildFrame(TextDirection.rtl)); await expectLater( find.byType(InputDecorator), matchesSkiaGoldFile('input_decorator.outline_icon_label.rtl.png'), - // matchesGoldenFile('input_decorator.outline_icon_label.rtl.png'), - // skip: !Platform.isLinux, ); }, -// skip: !Platform.isLinux, ); testWidgets('InputDecorationTheme.toString()', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/material_test.dart b/packages/flutter/test/material/material_test.dart index 6b2db358157..ff22c6cb084 100644 --- a/packages/flutter/test/material/material_test.dart +++ b/packages/flutter/test/material/material_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; - import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; @@ -619,8 +617,6 @@ void main() { await expectLater( find.byKey(painterKey), matchesSkiaGoldFile('material.border_paint_above.png'), - // matchesGoldenFile('material.border_paint_above.png'), - // skip: !Platform.isLinux, ); }); @@ -661,8 +657,6 @@ void main() { await expectLater( find.byKey(painterKey), matchesSkiaGoldFile('material.border_paint_below.png'), - // matchesGoldenFile('material.border_paint_below.png'), - // skip: !Platform.isLinux, ); }); }); diff --git a/packages/flutter/test/material/radio_test.dart b/packages/flutter/test/material/radio_test.dart index 0c7d88119aa..4a4d55c3b72 100644 --- a/packages/flutter/test/material/radio_test.dart +++ b/packages/flutter/test/material/radio_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; import 'dart:ui'; import 'package:flutter/rendering.dart'; @@ -278,8 +277,6 @@ void main() { await expectLater( find.byKey(painterKey), matchesSkiaGoldFile('radio.ink_ripple.png'), - // matchesGoldenFile('radio.ink_ripple.png'), - // skip: !Platform.isLinux, ); }); } diff --git a/packages/flutter/test/material/tab_bar_theme_test.dart b/packages/flutter/test/material/tab_bar_theme_test.dart index 83aacd1474e..a6f6864ad73 100644 --- a/packages/flutter/test/material/tab_bar_theme_test.dart +++ b/packages/flutter/test/material/tab_bar_theme_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; - import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -270,8 +268,6 @@ void main() { await expectLater( find.byKey(_painterKey), matchesSkiaGoldFile('tab_bar_theme.tab_indicator_size_tab.png'), - // matchesGoldenFile('tab_bar_theme.tab_indicator_size_tab.png'), - // skip: !Platform.isLinux, ); }); @@ -283,8 +279,6 @@ void main() { await expectLater( find.byKey(_painterKey), matchesSkiaGoldFile('tab_bar_theme.tab_indicator_size_label.png'), - // matchesGoldenFile('tab_bar_theme.tab_indicator_size_label.png'), - // skip: !Platform.isLinux, ); }); @@ -301,8 +295,6 @@ void main() { await expectLater( find.byKey(_painterKey), matchesSkiaGoldFile('tab_bar_theme.custom_tab_indicator.png'), - // matchesGoldenFile('tab_bar_theme.custom_tab_indicator.png'), - // skip: !Platform.isLinux, ); }); @@ -319,8 +311,6 @@ void main() { await expectLater( find.byKey(_painterKey), matchesSkiaGoldFile('tab_bar_theme.beveled_rect_indicator.png'), - // matchesGoldenFile('tab_bar_theme.beveled_rect_indicator.png'), - // skip: !Platform.isLinux, ); }); } diff --git a/packages/flutter/test/painting/continous_rectangle_border_test.dart b/packages/flutter/test/painting/continous_rectangle_border_test.dart index 765c4174414..479031deb93 100644 --- a/packages/flutter/test/painting/continous_rectangle_border_test.dart +++ b/packages/flutter/test/painting/continous_rectangle_border_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -73,8 +72,6 @@ void main() { await expectLater( find.byType(RepaintBoundary), matchesSkiaGoldFile('continuous_rectangle_border.golden_test_even_radii.png'), -// matchesGoldenFile('continuous_rectangle_border.golden_test_even_radii.png'), -// skip: !Platform.isLinux, ); }); @@ -96,8 +93,6 @@ void main() { await expectLater( find.byType(RepaintBoundary), matchesSkiaGoldFile('continuous_rectangle_border.golden_test_varying_radii.png'), -// matchesGoldenFile('continuous_rectangle_border.golden_test_varying_radii.png'), -// skip: !Platform.isLinux, ); }); @@ -116,8 +111,6 @@ void main() { await expectLater( find.byType(RepaintBoundary), matchesSkiaGoldFile('continuous_rectangle_border.golden_test_large_radii.png'), -// matchesGoldenFile('continuous_rectangle_border.golden_test_large_radii.png'), -// skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/rendering/localized_fonts_test.dart b/packages/flutter/test/rendering/localized_fonts_test.dart index 6cbc28577da..e56fe718751 100644 --- a/packages/flutter/test/rendering/localized_fonts_test.dart +++ b/packages/flutter/test/rendering/localized_fonts_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' show Platform; - import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -52,10 +50,8 @@ void main() { await expectLater( find.byType(RichText), matchesSkiaGoldFile('localized_fonts.rich_text.styled_text_span.png'), - // matchesGoldenFile('localized_fonts.rich_text.styled_text_span.png'), ); }, - //skip: !Platform.isLinux, ); testWidgets( @@ -105,10 +101,8 @@ void main() { await expectLater( find.byType(Row), matchesSkiaGoldFile('localized_fonts.text_ambient_locale.chars.png'), -// matchesGoldenFile('localized_fonts.text_ambient_locale.chars.png'), ); }, -// skip: !Platform.isLinux, ); testWidgets( @@ -150,10 +144,8 @@ void main() { await expectLater( find.byType(Row), matchesSkiaGoldFile('localized_fonts.text_explicit_locale.chars.png'), -// matchesGoldenFile('localized_fonts.text_explicit_locale.chars.png'), ); }, -// skip: !Platform.isLinux, ); } diff --git a/packages/flutter/test/widgets/backdrop_filter_test.dart b/packages/flutter/test/widgets/backdrop_filter_test.dart index 226cdb84417..9ef0b4cd377 100644 --- a/packages/flutter/test/widgets/backdrop_filter_test.dart +++ b/packages/flutter/test/widgets/backdrop_filter_test.dart @@ -42,9 +42,7 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesSkiaGoldFile('backdrop_filter_test.cull_rect.png') -// matchesGoldenFile('backdrop_filter_test.cull_rect.1.png'), -// skip: !Platform.isLinux, + matchesSkiaGoldFile('backdrop_filter_test.cull_rect.png'), ); }); } diff --git a/packages/flutter/test/widgets/clip_test.dart b/packages/flutter/test/widgets/clip_test.dart index 8d3aecc1c02..538bdb07468 100644 --- a/packages/flutter/test/widgets/clip_test.dart +++ b/packages/flutter/test/widgets/clip_test.dart @@ -289,7 +289,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.ClipRect.png'), -// matchesGoldenFile('clip.ClipRect.1.png'), ); }); @@ -330,7 +329,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.ClipRectOverlay.png') -// matchesGoldenFile('clip.ClipRectOverlay.1.png'), ); }); @@ -380,7 +378,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.ClipRRect.png'), -// matchesGoldenFile('clip.ClipRRect.1.png'), ); }); @@ -424,7 +421,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.ClipOval.png'), -// matchesGoldenFile('clip.ClipOval.1.png'), ); }); @@ -473,7 +469,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.ClipPath.png'), -// matchesGoldenFile('clip.ClipPath.1.png'), ); }); @@ -519,7 +514,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.PhysicalModel.antiAlias.png'), -// matchesGoldenFile('clip.PhysicalModel.antiAlias.1.png'), ); }); @@ -528,7 +522,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.PhysicalModel.hardEdge.png'), -// matchesGoldenFile('clip.PhysicalModel.hardEdge.1.png'), ); }); @@ -539,7 +532,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.PhysicalModel.antiAliasWithSaveLayer.png'), -// matchesGoldenFile('clip.PhysicalModel.antiAliasWithSaveLayer.png'), ); }); @@ -582,7 +574,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.PhysicalModel.default.png'), -// matchesGoldenFile('clip.PhysicalModel.default.1.png'), ); }); @@ -632,7 +623,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.PhysicalShape.antiAlias.png'), -// matchesGoldenFile('clip.PhysicalShape.antiAlias.1.png'), ); }); @@ -641,7 +631,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.PhysicalShape.hardEdge.png'), -// matchesGoldenFile('clip.PhysicalShape.hardEdge.1.png'), ); }); @@ -650,7 +639,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.PhysicalShape.antiAliasWithSaveLayer.png'), -// matchesGoldenFile('clip.PhysicalShape.antiAliasWithSaveLayer.png'), ); }); @@ -697,7 +685,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('clip.PhysicalShape.default.png'), -// matchesGoldenFile('clip.PhysicalShape.default.1.png'), ); }); diff --git a/packages/flutter/test/widgets/editable_text_cursor_test.dart b/packages/flutter/test/widgets/editable_text_cursor_test.dart index 014ab4c9343..5ee49cb8dba 100644 --- a/packages/flutter/test/widgets/editable_text_cursor_test.dart +++ b/packages/flutter/test/widgets/editable_text_cursor_test.dart @@ -90,11 +90,8 @@ void main() { await expectLater( find.byKey(const ValueKey(1)), matchesSkiaGoldFile('editable_text_test.0.png'), -// matchesGoldenFile('editable_text_test.0.0.png'), ); - }, - //skip: !Platform.isLinux - ); + },); testWidgets('cursor layout has correct radius', (WidgetTester tester) async { final GlobalKey editableTextKey = GlobalKey(); @@ -144,10 +141,8 @@ void main() { await expectLater( find.byKey(const ValueKey(1)), matchesSkiaGoldFile('editable_text_test.1.png'), -// matchesGoldenFile('editable_text_test.1.0.png'), ); - }, //skip: !Platform.isLinux - ); + },); testWidgets('Cursor animates on iOS', (WidgetTester tester) async { final Widget widget = MaterialApp( diff --git a/packages/flutter/test/widgets/invert_colors_test.dart b/packages/flutter/test/widgets/invert_colors_test.dart index 19714da0ef8..7ad2de07cdf 100644 --- a/packages/flutter/test/widgets/invert_colors_test.dart +++ b/packages/flutter/test/widgets/invert_colors_test.dart @@ -20,9 +20,7 @@ void main() { await expectLater( find.byType(RepaintBoundary), - matchesSkiaGoldFile('invert_colors_test.0.png') -// matchesGoldenFile('invert_colors_test.0.png'), -// skip: !Platform.isLinux, + matchesSkiaGoldFile('invert_colors_test.0.png'), ); }); @@ -41,8 +39,6 @@ void main() { await expectLater( find.byType(RepaintBoundary), matchesSkiaGoldFile('invert_colors_test.1.png'), -// matchesGoldenFile('invert_colors_test.1.png'), -// skip: !Platform.isLinux, ); }); } diff --git a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart index 39340a93f49..b534e92c38e 100644 --- a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart +++ b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart @@ -491,8 +491,6 @@ void main() { await expectLater( find.byKey(const Key('list_wheel_scroll_view')), matchesSkiaGoldFile('list_wheel_scroll_view.center_child.magnified.png'), -// matchesGoldenFile('list_wheel_scroll_view.center_child.magnified.png'), -// skip: !Platform.isLinux, ); }); @@ -547,8 +545,6 @@ void main() { await expectLater( find.byKey(const Key('list_wheel_scroll_view')), matchesSkiaGoldFile('list_wheel_scroll_view.curved_wheel.left.png'), -// matchesGoldenFile('list_wheel_scroll_view.curved_wheel.left.png'), -// skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/widgets/opacity_test.dart b/packages/flutter/test/widgets/opacity_test.dart index 126237dbd80..b8ff2189a73 100644 --- a/packages/flutter/test/widgets/opacity_test.dart +++ b/packages/flutter/test/widgets/opacity_test.dart @@ -178,8 +178,6 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('opacity_test.offset.png'), -// matchesGoldenFile('opacity_test.offset.1.png'), -// skip: !Platform.isLinux, ); }); } diff --git a/packages/flutter/test/widgets/physical_model_test.dart b/packages/flutter/test/widgets/physical_model_test.dart index 2f54e09a26c..0a3ec018c9e 100644 --- a/packages/flutter/test/widgets/physical_model_test.dart +++ b/packages/flutter/test/widgets/physical_model_test.dart @@ -66,8 +66,6 @@ void main() { await expectLater( find.byKey(key), matchesSkiaGoldFile('physical_model_overflow.png'), -// matchesGoldenFile('physical_model_overflow.png'), -// skip: !Platform.isLinux, ); }); diff --git a/packages/flutter/test/widgets/shadow_test.dart b/packages/flutter/test/widgets/shadow_test.dart index 2ca749fb1f9..1db53f0dac1 100644 --- a/packages/flutter/test/widgets/shadow_test.dart +++ b/packages/flutter/test/widgets/shadow_test.dart @@ -24,16 +24,13 @@ void main() { await expectLater( find.byType(Container), matchesSkiaGoldFile('shadow.BoxDecoration.disabled.png'), -// matchesGoldenFile('shadow.BoxDecoration.disabled.png'), ); debugDisableShadows = false; tester.binding.reassembleApplication(); await tester.pump(); - // TODO(ianh): [May no longer apply] use the skip argument instead once that doesn't hang, https://github.com/dart-lang/test/issues/830 await expectLater( find.byType(Container), matchesSkiaGoldFile('shadow.BoxDecoration.enabled.png'), -// matchesGoldenFile('shadow.BoxDecoration.enabled.png'), ); debugDisableShadows = true; }); @@ -60,13 +57,10 @@ void main() { await expectLater( find.byType(Container), matchesSkiaGoldFile('shadow.ShapeDecoration.$elevation.png'), -// matchesGoldenFile('shadow.ShapeDecoration.$elevation.png'), ); } debugDisableShadows = true; - }, -// skip: !Platform.isLinux - ); // shadows render differently on different platforms + },); testWidgets('Shadows with PhysicalLayer', (WidgetTester tester) async { await tester.pumpWidget( @@ -90,16 +84,13 @@ void main() { await expectLater( find.byType(Container), matchesSkiaGoldFile('shadow.PhysicalModel.disabled.0.png'), -// matchesGoldenFile('shadow.PhysicalModel.disabled.png'), ); debugDisableShadows = false; tester.binding.reassembleApplication(); await tester.pump(); - // TODO(ianh): [May no longer apply] use the skip argument instead once that doesn't hang, https://github.com/dart-lang/test/issues/830 await expectLater( find.byType(Container), matchesSkiaGoldFile('shadow.PhysicalModel.enabled.png'), -// matchesGoldenFile('shadow.PhysicalModel.enabled.png'), ); debugDisableShadows = true; }); @@ -130,11 +121,8 @@ void main() { await expectLater( find.byType(Container), matchesSkiaGoldFile('shadow.PhysicalModel.disabled.1.$elevation.png'), -// matchesGoldenFile('shadow.PhysicalModel.disabled.png'), ); } debugDisableShadows = true; - }, -// skip: !Platform.isLinux - ); + },); } \ No newline at end of file diff --git a/packages/flutter/test/widgets/text_golden_test.dart b/packages/flutter/test/widgets/text_golden_test.dart index 4af608f5ae9..c3a376d4c57 100644 --- a/packages/flutter/test/widgets/text_golden_test.dart +++ b/packages/flutter/test/widgets/text_golden_test.dart @@ -30,7 +30,6 @@ void main() { await expectLater( find.byType(Container), matchesSkiaGoldFile('text_golden.Centered.png'), -// matchesGoldenFile('text_golden.Centered.png'), ); await tester.pumpWidget( @@ -55,11 +54,8 @@ void main() { await expectLater( find.byType(Container), matchesSkiaGoldFile('text_golden.Centered.wrap.png'), -// matchesGoldenFile('text_golden.Centered.wrap.png'), ); - }, -// skip: !Platform.isLinux - ); + },); testWidgets('Text Foreground', (WidgetTester tester) async { @@ -89,7 +85,6 @@ void main() { await expectLater( find.byType(RepaintBoundary), matchesSkiaGoldFile('text_golden.Foreground.gradient.png'), -// matchesGoldenFile('text_golden.Foreground.gradient.png'), ); await tester.pumpWidget( @@ -112,7 +107,6 @@ void main() { await expectLater( find.byType(RepaintBoundary), matchesSkiaGoldFile('text_golden.Foreground.stroke.png'), -// matchesGoldenFile('text_golden.Foreground.stroke.png'), ); await tester.pumpWidget( @@ -136,11 +130,8 @@ void main() { await expectLater( find.byType(RepaintBoundary), matchesSkiaGoldFile('text_golden.Foreground.stroke_and_gradient.png'), -// matchesGoldenFile('text_golden.Foreground.stroke_and_gradient.png'), ); - }, -// skip: !Platform.isLinux - ); + },); // TODO(garyq): This test requires an update when the background // drawing from the beginning of the line bug is fixed. The current @@ -189,11 +180,8 @@ void main() { await expectLater( find.byType(RepaintBoundary), matchesSkiaGoldFile('text_golden.Background.png'), -// matchesGoldenFile('text_golden.Background.png'), ); - }, -// skip: !Platform.isLinux - ); + },); testWidgets('Text Fade', (WidgetTester tester) async { await tester.pumpWidget( @@ -228,11 +216,8 @@ void main() { await expectLater( find.byType(RepaintBoundary).first, matchesSkiaGoldFile('text_golden.Fade.1.png'), -// matchesGoldenFile('text_golden.Fade.1.png'), ); - }, -// skip: !Platform.isLinux - ); + },); testWidgets('Default Strut text', (WidgetTester tester) async { await tester.pumpWidget( @@ -256,12 +241,8 @@ void main() { await expectLater( find.byType(Container), matchesSkiaGoldFile('text_golden.StrutDefault.png'), -// matchesGoldenFile('text_golden.StrutDefault.png'), ); - }, -// skip: true // Should only be on linux (skip: !Platform.isLinux). - // Disabled for now until font inconsistency is resolved. - ); + },); testWidgets('Strut text 1', (WidgetTester tester) async { await tester.pumpWidget( @@ -287,11 +268,8 @@ void main() { await expectLater( find.byType(Container), matchesSkiaGoldFile('text_golden.Strut.1.png') -// matchesGoldenFile('text_golden.Strut.1.1.png'), ); - }, - // skip: true // Should only be on linux (skip: !Platform.isLinux). - ); // Disabled for now until font inconsistency is resolved. + },); testWidgets('Strut text 2', (WidgetTester tester) async { await tester.pumpWidget( @@ -318,11 +296,8 @@ void main() { await expectLater( find.byType(Container), matchesSkiaGoldFile('text_golden.Strut.2.png') -// matchesGoldenFile('text_golden.Strut.2.1.png'), ); - }, - // skip: true // Should only be on linux (skip: !Platform.isLinux). - ); // Disabled for now until font inconsistency is resolved. + },); testWidgets('Strut text rich', (WidgetTester tester) async { await tester.pumpWidget( @@ -372,11 +347,8 @@ void main() { await expectLater( find.byType(Container), matchesSkiaGoldFile('text_golden.Strut.3.png') -// matchesGoldenFile('text_golden.Strut.3.1.png'), ); - }, - // skip: true // Should only be on linux (skip: !Platform.isLinux). - ); // Disabled for now until font inconsistency is resolved. + },); testWidgets('Strut text font fallback', (WidgetTester tester) async { // Font Fallback @@ -409,12 +381,9 @@ void main() { ); await expectLater( find.byType(Container), - matchesSkiaGoldFile('text_golden.Strut.4.png') -// matchesGoldenFile('text_golden.Strut.4.1.png'), + matchesSkiaGoldFile('text_golden.Strut.4.png'), ); - }, - // skip: true // Should only be on linux (skip: !Platform.isLinux). - ); // Disabled for now until font inconsistency is resolved. + },); testWidgets('Strut text rich forceStrutHeight', (WidgetTester tester) async { await tester.pumpWidget( @@ -463,12 +432,9 @@ void main() { ); await expectLater( find.byType(Container), - matchesSkiaGoldFile('text_golden.StrutForce.1.png') -// matchesGoldenFile('text_golden.StrutForce.1.1.png'), + matchesSkiaGoldFile('text_golden.StrutForce.1.png'), ); - }, - // skip: true // Should only be on linux (skip: !Platform.isLinux). - ); // Disabled for now until font inconsistency is resolved. + },); testWidgets('Decoration thickness', (WidgetTester tester) async { final TextDecoration allDecorations = TextDecoration.combine( @@ -505,11 +471,8 @@ void main() { await expectLater( find.byType(Container), matchesSkiaGoldFile('text_golden.Decoration.1.png'), -// matchesGoldenFile('text_golden.Decoration.1.0.png'), ); - }, -// skip: !Platform.isLinux - ); // Coretext uses different thicknesses for decoration + },); testWidgets('Decoration thickness', (WidgetTester tester) async { final TextDecoration allDecorations = TextDecoration.combine( @@ -547,9 +510,6 @@ void main() { await expectLater( find.byType(Container), matchesSkiaGoldFile('text_golden.DecorationThickness.1.png'), -// matchesGoldenFile('text_golden.DecorationThickness.1.0.png'), ); - }, -// skip: !Platform.isLinux - ); // Coretext uses different thicknesses for decoration + },); } diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index dcb430cde02..eb31409f946 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -1829,8 +1829,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { await expectLater( layer.toImage(renderObject.semanticBounds.inflate(50.0)), matchesSkiaGoldFile('inspector.repaint_boundary_margin.png'), -// matchesGoldenFile('inspector.repaint_boundary_margin.png'), -// skip: !Platform.isLinux, ); // Regression test for how rendering with a pixel scale other than 1.0 @@ -1841,8 +1839,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { pixelRatio: 0.5, ), matchesSkiaGoldFile('inspector.repaint_boundary_margin_small.png'), -// matchesGoldenFile('inspector.repaint_boundary_margin_small.png'), -// skip: !Platform.isLinux, ); await expectLater( @@ -1851,8 +1847,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { pixelRatio: 2.0, ), matchesSkiaGoldFile('inspector.repaint_boundary_margin_large.png'), -// matchesGoldenFile('inspector.repaint_boundary_margin_large.png'), -// skip: !Platform.isLinux, ); final Layer layerParent = layer.parent; @@ -1868,8 +1862,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 300.0, ), matchesSkiaGoldFile('inspector.repaint_boundary.png'), -// matchesGoldenFile('inspector.repaint_boundary.png'), -// skip: !Platform.isLinux, ); // Verify that taking a screenshot didn't change the layers associated with @@ -1887,8 +1879,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { margin: 50.0, ), matchesSkiaGoldFile('inspector.repaint_boundary_margin.png'), -// matchesGoldenFile('inspector.repaint_boundary_margin.png'), -// skip: !Platform.isLinux, ); // Verify that taking a screenshot didn't change the layers associated with @@ -1909,8 +1899,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { debugPaint: true, ), matchesSkiaGoldFile('inspector.repaint_boundary_debugPaint.png'), -// matchesGoldenFile('inspector.repaint_boundary_debugPaint.png'), -// skip: !Platform.isLinux, ); // Verify that taking a screenshot with debug paint on did not change // the number of children the layer has. @@ -1921,8 +1909,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { await expectLater( find.byType(RepaintBoundaryWithDebugPaint), matchesSkiaGoldFile('inspector.repaint_boundary.png'), -// matchesGoldenFile('inspector.repaint_boundary.png'), -// skip: !Platform.isLinux, ); expect(renderObject.debugLayer, equals(layer)); @@ -1936,8 +1922,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 100.0, ), matchesSkiaGoldFile('inspector.container.png'), -// matchesGoldenFile('inspector.container.png'), -// skip: !Platform.isLinux, ); await expectLater( @@ -1948,8 +1932,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { debugPaint: true, ), matchesSkiaGoldFile('inspector.container_debugPaint.png'), -// matchesGoldenFile('inspector.container_debugPaint.png'), -// skip: !Platform.isLinux, ); { @@ -1970,8 +1952,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { debugPaint: true, ), matchesSkiaGoldFile('inspector.container_debugPaint.png'), -// matchesGoldenFile('inspector.container_debugPaint.png'), -// skip: !Platform.isLinux, ); expect(container.debugNeedsLayout, isFalse); } @@ -1984,8 +1964,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 100.0, ), matchesSkiaGoldFile('inspector.container_small.png'), -// matchesGoldenFile('inspector.container_small.png'), -// skip: !Platform.isLinux, ); await expectLater( @@ -1996,8 +1974,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { maxPixelRatio: 3.0, ), matchesSkiaGoldFile('inspector.container_large.png'), -// matchesGoldenFile('inspector.container_large.png'), -// skip: !Platform.isLinux, ); // This screenshot will show the clip rect debug paint but no other @@ -2010,8 +1986,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { debugPaint: true, ), matchesSkiaGoldFile('inspector.clipRect_debugPaint.png'), -// matchesGoldenFile('inspector.clipRect_debugPaint.png'), -// skip: !Platform.isLinux, ); final Element clipRect = find.byType(ClipRRect).evaluate().single; @@ -2028,8 +2002,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { await expectLater( clipRectScreenshot, matchesSkiaGoldFile('inspector.clipRect_debugPaint_margin.png'), -// matchesGoldenFile('inspector.clipRect_debugPaint_margin.png'), -// skip: !Platform.isLinux, ); // Verify we get the same image if we go through the service extension @@ -2069,8 +2041,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { debugPaint: true, ), matchesSkiaGoldFile('inspector.padding_debugPaint.png'), -// matchesGoldenFile('inspector.padding_debugPaint.png'), -// skip: !Platform.isLinux, ); // The bounds for this box crop its rendered content. @@ -2082,8 +2052,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { debugPaint: true, ), matchesSkiaGoldFile('inspector.sizedBox_debugPaint.png'), -// matchesGoldenFile('inspector.sizedBox_debugPaint.png'), -// skip: !Platform.isLinux, ); // Verify that setting a margin includes the previously cropped content. @@ -2096,8 +2064,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { debugPaint: true, ), matchesSkiaGoldFile('inspector.sizedBox_debugPaint_margin.png'), -// matchesGoldenFile('inspector.sizedBox_debugPaint_margin.png'), -// skip: !Platform.isLinux, ); }); @@ -2169,8 +2135,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { await expectLater( find.byKey(mainStackKey), matchesSkiaGoldFile('inspector.composited_transform.only_offsets.png'), -// matchesGoldenFile('inspector.composited_transform.only_offsets.png'), -// skip: !Platform.isLinux, ); await expectLater( @@ -2180,15 +2144,11 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 500.0, ), matchesSkiaGoldFile('inspector.composited_transform.only_offsets_follower.png'), -// matchesGoldenFile('inspector.composited_transform.only_offsets_follower.png'), -// skip: !Platform.isLinux, ); await expectLater( WidgetInspectorService.instance.screenshot(find.byType(Stack).evaluate().first, width: 300.0, height: 300.0), matchesSkiaGoldFile('inspector.composited_transform.only_offsets_small.png'), -// matchesGoldenFile('inspector.composited_transform.only_offsets_small.1.png'), -// skip: !Platform.isLinux, ); await expectLater( @@ -2198,8 +2158,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 500.0, ), matchesSkiaGoldFile('inspector.composited_transform.only_offsets_target.png'), -// matchesGoldenFile('inspector.composited_transform.only_offsets_target.png'), -// skip: !Platform.isLinux, ); }); @@ -2272,8 +2230,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { await expectLater( find.byKey(mainStackKey), matchesSkiaGoldFile('inspector.composited_transform.with_rotations.png'), -// matchesGoldenFile('inspector.composited_transform.with_rotations.png'), -// skip: !Platform.isLinux, ); await expectLater( @@ -2283,8 +2239,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 500.0, ), matchesSkiaGoldFile('inspector.composited_transform.with_rotations_small.png'), -// matchesGoldenFile('inspector.composited_transform.with_rotations_small.png'), -// skip: !Platform.isLinux, ); await expectLater( @@ -2294,8 +2248,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 500.0, ), matchesSkiaGoldFile('inspector.composited_transform.with_rotations_target.png'), -// matchesGoldenFile('inspector.composited_transform.with_rotations_target.png'), -// skip: !Platform.isLinux, ); await expectLater( @@ -2305,8 +2257,6 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { height: 500.0, ), matchesSkiaGoldFile('inspector.composited_transform.with_rotations_follower.png'), -// matchesGoldenFile('inspector.composited_transform.with_rotations_follower.png'), -// skip: !Platform.isLinux, ); // Make sure taking screenshots hasn't modified the positions of the From 04ad0ffa1e1744dc5e07b179d3b3ec2c1ff14ffe Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Thu, 25 Apr 2019 15:30:58 -0700 Subject: [PATCH 15/18] Style nits --- packages/flutter/test/cupertino/date_picker_test.dart | 2 +- packages/flutter/test/rendering/localized_fonts_test.dart | 2 +- packages/flutter/test/widgets/clip_test.dart | 2 +- packages/flutter/test/widgets/text_golden_test.dart | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/flutter/test/cupertino/date_picker_test.dart b/packages/flutter/test/cupertino/date_picker_test.dart index 01613c459cb..aff149c1acf 100644 --- a/packages/flutter/test/cupertino/date_picker_test.dart +++ b/packages/flutter/test/cupertino/date_picker_test.dart @@ -854,7 +854,7 @@ void main() { await expectLater( find.byType(CupertinoDatePicker), - matchesSkiaGoldFile('date_picker_test.datetime.initial.png') + matchesSkiaGoldFile('date_picker_test.datetime.initial.png'), ); // Slightly drag the hour component to make the current hour off-center. diff --git a/packages/flutter/test/rendering/localized_fonts_test.dart b/packages/flutter/test/rendering/localized_fonts_test.dart index e56fe718751..0e09ff2e3c7 100644 --- a/packages/flutter/test/rendering/localized_fonts_test.dart +++ b/packages/flutter/test/rendering/localized_fonts_test.dart @@ -49,7 +49,7 @@ void main() { await expectLater( find.byType(RichText), - matchesSkiaGoldFile('localized_fonts.rich_text.styled_text_span.png'), + matchesSkiaGoldFile('localized_fonts.rich_text.styled_text_span.png'), ); }, ); diff --git a/packages/flutter/test/widgets/clip_test.dart b/packages/flutter/test/widgets/clip_test.dart index 538bdb07468..03e08e19010 100644 --- a/packages/flutter/test/widgets/clip_test.dart +++ b/packages/flutter/test/widgets/clip_test.dart @@ -328,7 +328,7 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesSkiaGoldFile('clip.ClipRectOverlay.png') + matchesSkiaGoldFile('clip.ClipRectOverlay.png'), ); }); diff --git a/packages/flutter/test/widgets/text_golden_test.dart b/packages/flutter/test/widgets/text_golden_test.dart index c3a376d4c57..897d45d5aa8 100644 --- a/packages/flutter/test/widgets/text_golden_test.dart +++ b/packages/flutter/test/widgets/text_golden_test.dart @@ -267,7 +267,7 @@ void main() { ); await expectLater( find.byType(Container), - matchesSkiaGoldFile('text_golden.Strut.1.png') + matchesSkiaGoldFile('text_golden.Strut.1.png'), ); },); @@ -295,7 +295,7 @@ void main() { ); await expectLater( find.byType(Container), - matchesSkiaGoldFile('text_golden.Strut.2.png') + matchesSkiaGoldFile('text_golden.Strut.2.png'), ); },); @@ -346,7 +346,7 @@ void main() { ); await expectLater( find.byType(Container), - matchesSkiaGoldFile('text_golden.Strut.3.png') + matchesSkiaGoldFile('text_golden.Strut.3.png'), ); },); From abb555fe94307d360ab9cdf8808af37fbb058067 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Thu, 25 Apr 2019 15:50:53 -0700 Subject: [PATCH 16/18] Modified platform specific golden file test. --- packages/flutter/test/widgets/widget_inspector_test.dart | 3 ++- packages/flutter_goldens_client/lib/client.dart | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index eb31409f946..439d8a51cf5 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -1999,9 +1999,10 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { ); // Add a margin so that the clip icon shows up in the screenshot. // This golden image is platform dependent due to the clip icon. + final String platform = Platform.operatingSystem; await expectLater( clipRectScreenshot, - matchesSkiaGoldFile('inspector.clipRect_debugPaint_margin.png'), + matchesSkiaGoldFile('inspector.clipRect_debugPaint_margin.$platform.png'), ); // Verify we get the same image if we go through the service extension diff --git a/packages/flutter_goldens_client/lib/client.dart b/packages/flutter_goldens_client/lib/client.dart index b0141f9d996..3dc8a5769f2 100644 --- a/packages/flutter_goldens_client/lib/client.dart +++ b/packages/flutter_goldens_client/lib/client.dart @@ -189,7 +189,7 @@ class SkiaGoldClient { Future _getCommitHash() async { // TODO(katelovett): Remove after pre-commit tests can be ingested by Skia Gold - return 'd4e4726ac262b9f78b002b696f915f552fed3fc8'; + return 'e51947241b37790a9e4e33bfdef59aaa9b930851'; // if (!flutterRoot.existsSync()) { // return null; // } else { From fdd554fb46e885292fb9c82e91969e21b603a1c3 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Thu, 25 Apr 2019 15:59:48 -0700 Subject: [PATCH 17/18] Anaalyzer fixes. --- .../flutter_goldens/lib/flutter_goldens.dart | 2 +- .../test/flutter_goldens_test.dart | 24 +++++++++---------- .../flutter_goldens_client/lib/client.dart | 8 +++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index 2ae622d37f2..decc5d65935 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -91,7 +91,7 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { } final bool authorized = await _skiaClient.auth(fs.directory(basedir)); if (!authorized) { - //TODO(katelovett): Clean up for final implementation on CI + // TODO(Piinks): Clean up for final implementation on CI, https://github.com/flutter/flutter/pull/31630 return true; //throw test_package.TestFailure('Could not authorize golctl.'); } diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart index 681a42a4481..a1a46968947 100644 --- a/packages/flutter_goldens/test/flutter_goldens_test.dart +++ b/packages/flutter_goldens/test/flutter_goldens_test.dart @@ -13,35 +13,36 @@ import 'package:platform/platform.dart'; import 'package:process/process.dart'; const String _kFlutterRoot = '/flutter'; -const String _kGoldenRoot = '$_kFlutterRoot/bin/cache/pkg/goldens'; +//const String _kGoldenRoot = '$_kFlutterRoot/bin/cache/pkg/goldens'; //const String _kVersionFile = '$_kFlutterRoot/bin/internal/goldens.version'; //const String _kGoldensVersion = '123456abcdef'; -//TODO(katelovett): Finish testing +// TODO(Piinks): Finish testing, https://github.com/flutter/flutter/pull/31630 void main() { MemoryFileSystem fs; FakePlatform platform; MockProcessManager process; - Directory flutter; - Directory golden; + //Directory flutter; + //Directory golden; setUp(() async { fs = MemoryFileSystem(); platform = FakePlatform(environment: { 'FLUTTER_ROOT': _kFlutterRoot, - //TODO(katelovett): Add other env vars for testing + // TODO(Piinks): Add other env vars for testing, https://github.com/flutter/flutter/pull/31630 }); process = MockProcessManager(); - flutter = await fs.directory(_kFlutterRoot).create(recursive: true); - golden = await fs.directory(_kGoldenRoot).create(recursive: true); + //flutter = await fs.directory(_kFlutterRoot).create(recursive: true); + //golden = await fs.directory(_kGoldenRoot).create(recursive: true); //fs.file(_kVersionFile).createSync(recursive: true); //fs.file(_kVersionFile).writeAsStringSync(_kGoldensVersion); }); group('SkiaGoldClient', () { - SkiaGoldClient skiaGold; + //SkiaGoldClient skiaGold; setUp(() { - skiaGold = SkiaGoldClient( + //skiaGold = + SkiaGoldClient( fs: fs, platform: platform, process: process, @@ -105,7 +106,7 @@ void main() { } }); - // TODO(katelovett): This is currently disabled in flutter_goldens.dart + // TODO(Piinks): This is currently disabled in flutter_goldens.dart, https://github.com/flutter/flutter/pull/31630 // test('throws if goldctl has not been authorized', () async { // // See that preceding test does not leave auth behind [52] // try { @@ -115,8 +116,7 @@ void main() { // expect(error.message, contains('Could not authorize goldctl.')); // } // }); - // TODO(katelovett): Add methods to Mock SkiaGoldClient to inform the comparator - // TODO... and test for proper behavior. See matcher_test.dart for model + // TODO(Piinks): Add methods to Mock SkiaGoldClient to inform the comparator and test for proper behavior. See matcher_test.dart for model, https://github.com/flutter/flutter/pull/31630 // test('returns false if skia gold test fails', () async { // final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') // ..createSync(recursive: true); diff --git a/packages/flutter_goldens_client/lib/client.dart b/packages/flutter_goldens_client/lib/client.dart index 3dc8a5769f2..27e3b2ab16a 100644 --- a/packages/flutter_goldens_client/lib/client.dart +++ b/packages/flutter_goldens_client/lib/client.dart @@ -51,7 +51,7 @@ class SkiaGoldClient { Directory _workDirectory; - //TODO(katelovett): Environment variables are temporary for local testing + // TODO(Piinks): Environment variables are temporary for local testing, https://github.com/flutter/flutter/pull/31630 /// The local [Directory] where the Flutter repository is hosted. /// /// Uses the [fs] file system. @@ -80,7 +80,7 @@ class SkiaGoldClient { Future auth(Directory workDirectory) async { _workDirectory = workDirectory; - //TODO(katelovett): Cleanup for final CI implementation + // TODO(Piinks): Cleanup for final CI implementation, https://github.com/flutter/flutter/pull/31630 if (_serviceAccount == null) return false; // Not in the proper environment for golden file testing. @@ -188,7 +188,7 @@ class SkiaGoldClient { } Future _getCommitHash() async { - // TODO(katelovett): Remove after pre-commit tests can be ingested by Skia Gold + // TODO(Piinks): Remove after pre-commit tests can be ingested by Skia Gold, https://github.com/flutter/flutter/pull/31630 return 'e51947241b37790a9e4e33bfdef59aaa9b930851'; // if (!flutterRoot.existsSync()) { // return null; @@ -214,7 +214,7 @@ class SkiaGoldClient { } String _getKeysJSON() { - // TODO(katelovett): Parse out cleaner key information + // TODO(Piinks): Parse out cleaner key information, https://github.com/flutter/flutter/pull/31630 return convert.json.encode( { 'Operating System' : io.Platform.operatingSystem, From 80344acaaad3351f5f1505828046b7905fba49eb Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Thu, 2 May 2019 12:56:31 -0700 Subject: [PATCH 18/18] Comma Comma Nit Nit --- .../cupertino/segmented_control_test.dart | 4 ++-- .../test/material/bottom_app_bar_test.dart | 2 +- .../test/material/input_decorator_test.dart | 3 +-- .../test/rendering/localized_fonts_test.dart | 9 +++---- .../widgets/editable_text_cursor_test.dart | 4 ++-- .../flutter/test/widgets/shadow_test.dart | 6 ++--- .../test/widgets/text_golden_test.dart | 24 +++++++++---------- 7 files changed, 24 insertions(+), 28 deletions(-) diff --git a/packages/flutter/test/cupertino/segmented_control_test.dart b/packages/flutter/test/cupertino/segmented_control_test.dart index 170d1f0da78..31568c93a6c 100644 --- a/packages/flutter/test/cupertino/segmented_control_test.dart +++ b/packages/flutter/test/cupertino/segmented_control_test.dart @@ -1327,7 +1327,7 @@ void main() { find.byType(RepaintBoundary), matchesSkiaGoldFile('segmented_control_test.0.png'), ); - },); + }); testWidgets('Golden Test Pressed State', (WidgetTester tester) async { final Map children = {}; @@ -1365,5 +1365,5 @@ void main() { find.byType(RepaintBoundary), matchesSkiaGoldFile('segmented_control_test.1.png'), ); - },); + }); } diff --git a/packages/flutter/test/material/bottom_app_bar_test.dart b/packages/flutter/test/material/bottom_app_bar_test.dart index e8512c570d2..8003d533d66 100644 --- a/packages/flutter/test/material/bottom_app_bar_test.dart +++ b/packages/flutter/test/material/bottom_app_bar_test.dart @@ -79,7 +79,7 @@ void main() { find.byKey(key), matchesSkiaGoldFile('bottom_app_bar.custom_shape.2.png'), ); - },); + }); testWidgets('color defaults to Theme.bottomAppBarColor', (WidgetTester tester) async { await tester.pumpWidget( diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 364d863d464..da1acfa1221 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -2027,8 +2027,7 @@ void main() { find.byType(InputDecorator), matchesSkiaGoldFile('input_decorator.outline_icon_label.rtl.png'), ); - }, - ); + }); testWidgets('InputDecorationTheme.toString()', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/19305 diff --git a/packages/flutter/test/rendering/localized_fonts_test.dart b/packages/flutter/test/rendering/localized_fonts_test.dart index 0e09ff2e3c7..6d0cae3531c 100644 --- a/packages/flutter/test/rendering/localized_fonts_test.dart +++ b/packages/flutter/test/rendering/localized_fonts_test.dart @@ -51,8 +51,7 @@ void main() { find.byType(RichText), matchesSkiaGoldFile('localized_fonts.rich_text.styled_text_span.png'), ); - }, - ); + }); testWidgets( 'Text with locale-specific glyphs, ambient locale', @@ -102,8 +101,7 @@ void main() { find.byType(Row), matchesSkiaGoldFile('localized_fonts.text_ambient_locale.chars.png'), ); - }, - ); + }); testWidgets( 'Text with locale-specific glyphs, explicit locale', @@ -145,7 +143,6 @@ void main() { find.byType(Row), matchesSkiaGoldFile('localized_fonts.text_explicit_locale.chars.png'), ); - }, - ); + }); } diff --git a/packages/flutter/test/widgets/editable_text_cursor_test.dart b/packages/flutter/test/widgets/editable_text_cursor_test.dart index 5ee49cb8dba..21d9f1f17fb 100644 --- a/packages/flutter/test/widgets/editable_text_cursor_test.dart +++ b/packages/flutter/test/widgets/editable_text_cursor_test.dart @@ -91,7 +91,7 @@ void main() { find.byKey(const ValueKey(1)), matchesSkiaGoldFile('editable_text_test.0.png'), ); - },); + }); testWidgets('cursor layout has correct radius', (WidgetTester tester) async { final GlobalKey editableTextKey = GlobalKey(); @@ -142,7 +142,7 @@ void main() { find.byKey(const ValueKey(1)), matchesSkiaGoldFile('editable_text_test.1.png'), ); - },); + }); testWidgets('Cursor animates on iOS', (WidgetTester tester) async { final Widget widget = MaterialApp( diff --git a/packages/flutter/test/widgets/shadow_test.dart b/packages/flutter/test/widgets/shadow_test.dart index 1db53f0dac1..4f78351784d 100644 --- a/packages/flutter/test/widgets/shadow_test.dart +++ b/packages/flutter/test/widgets/shadow_test.dart @@ -60,7 +60,7 @@ void main() { ); } debugDisableShadows = true; - },); + }); testWidgets('Shadows with PhysicalLayer', (WidgetTester tester) async { await tester.pumpWidget( @@ -124,5 +124,5 @@ void main() { ); } debugDisableShadows = true; - },); -} \ No newline at end of file + }); +} diff --git a/packages/flutter/test/widgets/text_golden_test.dart b/packages/flutter/test/widgets/text_golden_test.dart index 897d45d5aa8..5a90334e16d 100644 --- a/packages/flutter/test/widgets/text_golden_test.dart +++ b/packages/flutter/test/widgets/text_golden_test.dart @@ -55,7 +55,7 @@ void main() { find.byType(Container), matchesSkiaGoldFile('text_golden.Centered.wrap.png'), ); - },); + }); testWidgets('Text Foreground', (WidgetTester tester) async { @@ -131,7 +131,7 @@ void main() { find.byType(RepaintBoundary), matchesSkiaGoldFile('text_golden.Foreground.stroke_and_gradient.png'), ); - },); + }); // TODO(garyq): This test requires an update when the background // drawing from the beginning of the line bug is fixed. The current @@ -181,7 +181,7 @@ void main() { find.byType(RepaintBoundary), matchesSkiaGoldFile('text_golden.Background.png'), ); - },); + }); testWidgets('Text Fade', (WidgetTester tester) async { await tester.pumpWidget( @@ -217,7 +217,7 @@ void main() { find.byType(RepaintBoundary).first, matchesSkiaGoldFile('text_golden.Fade.1.png'), ); - },); + }); testWidgets('Default Strut text', (WidgetTester tester) async { await tester.pumpWidget( @@ -242,7 +242,7 @@ void main() { find.byType(Container), matchesSkiaGoldFile('text_golden.StrutDefault.png'), ); - },); + }); testWidgets('Strut text 1', (WidgetTester tester) async { await tester.pumpWidget( @@ -269,7 +269,7 @@ void main() { find.byType(Container), matchesSkiaGoldFile('text_golden.Strut.1.png'), ); - },); + }); testWidgets('Strut text 2', (WidgetTester tester) async { await tester.pumpWidget( @@ -297,7 +297,7 @@ void main() { find.byType(Container), matchesSkiaGoldFile('text_golden.Strut.2.png'), ); - },); + }); testWidgets('Strut text rich', (WidgetTester tester) async { await tester.pumpWidget( @@ -348,7 +348,7 @@ void main() { find.byType(Container), matchesSkiaGoldFile('text_golden.Strut.3.png'), ); - },); + }); testWidgets('Strut text font fallback', (WidgetTester tester) async { // Font Fallback @@ -383,7 +383,7 @@ void main() { find.byType(Container), matchesSkiaGoldFile('text_golden.Strut.4.png'), ); - },); + }); testWidgets('Strut text rich forceStrutHeight', (WidgetTester tester) async { await tester.pumpWidget( @@ -434,7 +434,7 @@ void main() { find.byType(Container), matchesSkiaGoldFile('text_golden.StrutForce.1.png'), ); - },); + }); testWidgets('Decoration thickness', (WidgetTester tester) async { final TextDecoration allDecorations = TextDecoration.combine( @@ -472,7 +472,7 @@ void main() { find.byType(Container), matchesSkiaGoldFile('text_golden.Decoration.1.png'), ); - },); + }); testWidgets('Decoration thickness', (WidgetTester tester) async { final TextDecoration allDecorations = TextDecoration.combine( @@ -511,5 +511,5 @@ void main() { find.byType(Container), matchesSkiaGoldFile('text_golden.DecorationThickness.1.png'), ); - },); + }); }