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
9840d659
Unverified
Commit
9840d659
authored
Mar 10, 2021
by
Kate Lovett
Committed by
GitHub
Mar 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make LocalFileComparator.compare easier to override (#77825)
parent
0cc087c2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
_goldens_io.dart
packages/flutter_test/lib/src/_goldens_io.dart
+16
-10
No files found.
packages/flutter_test/lib/src/_goldens_io.dart
View file @
9840d659
...
...
@@ -91,16 +91,9 @@ class LocalFileComparator extends GoldenFileComparator with LocalComparisonOutpu
@override
Future
<
bool
>
compare
(
Uint8List
imageBytes
,
Uri
golden
)
async
{
final
File
goldenFile
=
_getGoldenFile
(
golden
);
if
(!
goldenFile
.
existsSync
())
{
throw
test_package
.
TestFailure
(
'Could not be compared against non-existent file: "
$golden
"'
);
}
final
List
<
int
>
goldenBytes
=
await
goldenFile
.
readAsBytes
();
final
ComparisonResult
result
=
await
GoldenFileComparator
.
compareLists
(
imageBytes
,
goldenBytes
,
await
getGoldenBytes
(
golden
)
,
);
if
(!
result
.
passed
)
{
...
...
@@ -117,9 +110,22 @@ class LocalFileComparator extends GoldenFileComparator with LocalComparisonOutpu
await
goldenFile
.
writeAsBytes
(
imageBytes
,
flush:
true
);
}
File
_getGoldenFile
(
Uri
golden
)
{
return
File
(
_path
.
join
(
_path
.
fromUri
(
basedir
),
_path
.
fromUri
(
golden
.
path
)));
/// Returns the bytes of the given [golden] file.
///
/// If the file cannot be found, an error will be thrown.
@protected
Future
<
List
<
int
>>
getGoldenBytes
(
Uri
golden
)
async
{
final
File
goldenFile
=
_getGoldenFile
(
golden
);
if
(!
goldenFile
.
existsSync
())
{
throw
test_package
.
TestFailure
(
'Could not be compared against non-existent file: "
$golden
"'
);
}
final
List
<
int
>
goldenBytes
=
await
goldenFile
.
readAsBytes
();
return
goldenBytes
;
}
File
_getGoldenFile
(
Uri
golden
)
=>
File
(
_path
.
join
(
_path
.
fromUri
(
basedir
),
_path
.
fromUri
(
golden
.
path
)));
}
/// A class for use in golden file comparators that run locally and provide
...
...
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