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
4f29c310
Commit
4f29c310
authored
Apr 19, 2019
by
Kate Lovett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating inline documentation
parent
b6a2efb7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
174 deletions
+58
-174
date_picker_test.dart
packages/flutter/test/cupertino/date_picker_test.dart
+12
-7
flutter_goldens.dart
packages/flutter_goldens/lib/flutter_goldens.dart
+5
-4
client.dart
packages/flutter_goldens_client/lib/client.dart
+41
-163
No files found.
packages/flutter/test/cupertino/date_picker_test.dart
View file @
4f29c310
...
...
@@ -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
//
);
});
}
...
...
packages/flutter_goldens/lib/flutter_goldens.dart
View file @
4f29c310
...
...
@@ -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
<
bool
>
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
...
...
packages/flutter_goldens_client/lib/client.dart
View file @
4f29c310
...
...
@@ -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
<
bool
>
auth
(
Directory
workDirectory
)
async
{
_workDirectory
=
workDirectory
;
List
<
String
>
authArguments
=
<
String
>[
'auth'
];
...
...
@@ -61,6 +99,7 @@ class SkiaGoldClient {
return
true
;
}
Future
<
bool
>
imgtest
(
String
testName
,
File
goldenFile
)
async
{
List
<
String
>
imgtestArguments
=
<
String
>[
'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<void> 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<String> _getGoldensCommit() async {
// final File versionFile = flutterRoot.childFile(fs.path.join('bin', 'internal', 'goldens.version'));
// return (await versionFile.readAsString()).trim();
// }
//
// Future<String> _getCurrentCommit() async {
// if (!repositoryRoot.existsSync()) {
// return null;
// } else {
// final io.ProcessResult revParse = await process.run(
// <String>['git', 'rev-parse', 'HEAD'],
// workingDirectory: repositoryRoot.path,
// );
// return revParse.exitCode == 0 ? revParse.stdout.trim() : null;
// }
// }
//
// Future<void> _initRepository() async {
// await repositoryRoot.create(recursive: true);
// await _runCommands(
// <String>[
// '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<void> _checkCanSync() async {
// final io.ProcessResult result = await process.run(
// <String>['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<void> _syncTo(String commit) async {
// await _runCommands(
// <String>[
// 'git pull upstream master',
// 'git fetch upstream $commit',
// 'git reset --hard FETCH_HEAD',
// ],
// workingDirectory: repositoryRoot,
// );
// }
//
// Future<void> _runCommands(
// List<String> commands, {
// Directory workingDirectory,
// }) async {
// for (String command in commands) {
// final List<String> 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<void> _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<void> _releaseLock() async {
// await _lock.close();
// _lock = null;
// }
//}
\ No newline at end of file
}
\ No newline at end of file
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