Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7e542fc3
Commit
7e542fc3
authored
Apr 19, 2019
by
Kate Lovett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Committing progress.
parent
9e3e44ee
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
16 deletions
+51
-16
flutter_goldens.dart
packages/flutter_goldens/lib/flutter_goldens.dart
+5
-1
flutter_goldens_test.dart
packages/flutter_goldens/test/flutter_goldens_test.dart
+7
-4
client.dart
packages/flutter_goldens_client/lib/client.dart
+4
-3
matchers.dart
packages/flutter_test/lib/src/matchers.dart
+28
-1
update_packages.dart
packages/flutter_tools/lib/src/commands/update_packages.dart
+7
-7
No files found.
packages/flutter_goldens/lib/flutter_goldens.dart
View file @
7e542fc3
...
...
@@ -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
<
bool
>
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
"'
);
...
...
packages/flutter_goldens/test/flutter_goldens_test.dart
View file @
7e542fc3
...
...
@@ -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:
<
String
,
String
>{
'FLUTTER_ROOT'
:
_kFlutterRoot
});
platform
=
FakePlatform
(
environment:
<
String
,
String
>{
'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
(<
int
>[
1
,
2
,
3
]),
Uri
.
parse
(
'test.png'
));
fail
(
'TestFailure expected but not thrown'
);
...
...
packages/flutter_goldens_client/lib/client.dart
View file @
7e542fc3
...
...
@@ -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
<
bool
>
auth
(
Directory
workDirectory
)
async
{
_workDirectory
=
workDirectory
;
List
<
String
>
authArguments
=
<
String
>[
'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
+=
<
String
>[
'--service-account'
,
_serviceAccount
,
...
...
@@ -99,7 +101,6 @@ class SkiaGoldClient {
return
true
;
}
Future
<
bool
>
imgtest
(
String
testName
,
File
goldenFile
)
async
{
List
<
String
>
imgtestArguments
=
<
String
>[
'imgtest'
,
...
...
packages/flutter_test/lib/src/matchers.dart
View file @
7e542fc3
...
...
@@ -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<ui.Image>], 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
);
...
...
packages/flutter_tools/lib/src/commands/update_packages.dart
View file @
7e542fc3
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment