diff --git a/packages/flutter/lib/src/animation/animation_controller.dart b/packages/flutter/lib/src/animation/animation_controller.dart index 7f16caa75d..764514ef23 100644 --- a/packages/flutter/lib/src/animation/animation_controller.dart +++ b/packages/flutter/lib/src/animation/animation_controller.dart @@ -341,7 +341,8 @@ class AnimationController extends Animation /// Stops the animation controller and sets the current value of the /// animation. /// - /// The new value is clamped to the range set by [lowerBound] and [upperBound]. + /// The new value is clamped to the range set by [lowerBound] and + /// [upperBound]. /// /// Value listeners are notified even if this does not change the value. /// Status listeners are notified if the animation was previously playing. diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index 085256405c..ddee374eee 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -136,17 +136,31 @@ abstract class FlutterGoldenFileComparator extends GoldenFileComparator { /// maintain thread safety while using the `goldctl` tool. @protected @visibleForTesting - static Directory getBaseDirectory(LocalFileComparator defaultComparator, Platform platform, {String suffix = ''}) { + static Directory getBaseDirectory( + LocalFileComparator defaultComparator, + Platform platform, { + String suffix = '', + bool local = false, + }) { const FileSystem fs = LocalFileSystem(); final Directory flutterRoot = fs.directory(platform.environment[_kFlutterRootKey]); - final Directory comparisonRoot = flutterRoot.childDirectory( - fs.path.join( - 'bin', - 'cache', - 'pkg', - 'skia_goldens$suffix', - ) - ); + Directory comparisonRoot; + + if (!local) { + comparisonRoot = fs.systemTempDirectory.childDirectory( + 'skia_goldens$suffix' + ); + } else { + comparisonRoot = flutterRoot.childDirectory( + fs.path.join( + 'bin', + 'cache', + 'pkg', + 'skia_goldens', + ) + ); + } + final Directory testDirectory = fs.directory(defaultComparator.basedir); final String testDirectoryRelativePath = fs.path.relative( testDirectory.path, @@ -550,6 +564,7 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC baseDirectory ??= FlutterGoldenFileComparator.getBaseDirectory( defaultComparator, platform, + local: true, ); if(!baseDirectory.existsSync()) { diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart index 96fb28192d..97be7b1e75 100644 --- a/packages/flutter_goldens/test/flutter_goldens_test.dart +++ b/packages/flutter_goldens/test/flutter_goldens_test.dart @@ -68,8 +68,9 @@ void main() { }); test('auth performs minimal work if already authorized', () async { - fs.file('/workDirectory/temp/auth_opt.json') + final File authFile = fs.file('/workDirectory/temp/auth_opt.json') ..createSync(recursive: true); + authFile.writeAsStringSync(authTemplate()); when(process.run(any)) .thenAnswer((_) => Future .value(ProcessResult(123, 0, '', ''))); @@ -81,6 +82,16 @@ void main() { )); }); + test('gsutil is checked when authorization file is present', () async { + final File authFile = fs.file('/workDirectory/temp/auth_opt.json') + ..createSync(recursive: true); + authFile.writeAsStringSync(authTemplate(gsutil: true)); + expect( + await skiaClient.clientIsAuthorized(), + isFalse, + ); + }); + test('throws for error state from auth', () async { platform = FakePlatform( environment: { @@ -110,7 +121,7 @@ void main() { ); }); - test(' throws for error state from init', () { + test('throws for error state from init', () { platform = FakePlatform( environment: { 'FLUTTER_ROOT': _kFlutterRoot, @@ -458,7 +469,7 @@ void main() { ); }); - test('calculates the basedir correctly from defaultComparator', () async { + test('calculates the basedir correctly from defaultComparator for local testing', () async { final MockLocalFileComparator defaultComparator = MockLocalFileComparator(); final Directory flutterRoot = fs.directory(platform.environment['FLUTTER_ROOT']) ..createSync(recursive: true); @@ -467,6 +478,7 @@ void main() { final Directory basedir = FlutterGoldenFileComparator.getBaseDirectory( defaultComparator, platform, + local: true, ); expect( basedir.uri, diff --git a/packages/flutter_goldens/test/json_templates.dart b/packages/flutter_goldens/test/json_templates.dart index 427bb4e4bd..f5f96ad71a 100644 --- a/packages/flutter_goldens/test/json_templates.dart +++ b/packages/flutter_goldens/test/json_templates.dart @@ -2,6 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +/// JSON template for the contents of the auth_opt.json file created by goldctl. +String authTemplate({ + bool gsutil = false, +}) { + return ''' + { + "Luci":false, + "ServiceAccount":"${gsutil ? '' : '/packages/flutter/test/widgets/serviceAccount.json'}", + "GSUtil":$gsutil + } + '''; +} + /// JSON response template for Skia Gold expectations request: /// https://flutter-gold.skia.org/json/expectations/commit/HEAD String rawExpectationsTemplate() { diff --git a/packages/flutter_goldens_client/lib/skia_client.dart b/packages/flutter_goldens_client/lib/skia_client.dart index 3920af95dd..a41dc31b21 100644 --- a/packages/flutter_goldens_client/lib/skia_client.dart +++ b/packages/flutter_goldens_client/lib/skia_client.dart @@ -98,7 +98,7 @@ class SkiaGoldClient { /// will only be called once for each instance of /// [FlutterSkiaGoldFileComparator]. Future auth() async { - if (_clientIsAuthorized()) + if (await clientIsAuthorized()) return; if (_serviceAccount.isEmpty) { @@ -604,12 +604,18 @@ class SkiaGoldClient { /// Returns a boolean value to prevent the client from re-authorizing itself /// for multiple tests. - bool _clientIsAuthorized() { + Future clientIsAuthorized() async { final File authFile = workDirectory?.childFile(fs.path.join( 'temp', 'auth_opt.json', )); - return authFile.existsSync(); + + if(await authFile.exists()) { + final String contents = await authFile.readAsString(); + final Map decoded = json.decode(contents) as Map; + return !(decoded['GSUtil'] as bool); + } + return false; } }