From beebd5c4a7c0c95381d88f96fc092811084af842 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Fri, 19 Apr 2019 15:00:13 -0700 Subject: [PATCH] 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 eff723fa28..4533c56c1e 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 b56b91aceb..7aa23e9496 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 6cebb3ab8c..99e2ddb539 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 1293ef6e6a..a7f581b8f4 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';