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
6ec90142
Unverified
Commit
6ec90142
authored
Mar 02, 2021
by
Kate Lovett
Committed by
GitHub
Mar 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose the diff from ComparisonResult (#77014)
parent
347e77d9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
4 deletions
+15
-4
_goldens_io.dart
packages/flutter_test/lib/src/_goldens_io.dart
+10
-3
goldens.dart
packages/flutter_test/lib/src/goldens.dart
+4
-0
goldens_test.dart
packages/flutter_test/test/goldens_test.dart
+1
-1
No files found.
packages/flutter_test/lib/src/_goldens_io.dart
View file @
6ec90142
...
...
@@ -170,11 +170,15 @@ class LocalComparisonOutput {
/// [test] and [master] image bytes provided.
Future
<
ComparisonResult
>
compareLists
(
List
<
int
>?
test
,
List
<
int
>?
master
)
async
{
if
(
identical
(
test
,
master
))
return
ComparisonResult
(
passed:
true
);
return
ComparisonResult
(
passed:
true
,
diffPercent:
0.0
,
);
if
(
test
==
null
||
master
==
null
||
test
.
isEmpty
||
master
.
isEmpty
)
{
return
ComparisonResult
(
passed:
false
,
diffPercent:
1.0
,
error:
'Pixel test failed, null image provided.'
,
);
}
...
...
@@ -195,6 +199,7 @@ Future<ComparisonResult> compareLists(List<int>? test, List<int>? master) async
if
(
width
!=
masterImage
.
width
||
height
!=
masterImage
.
height
)
{
return
ComparisonResult
(
passed:
false
,
diffPercent:
1.0
,
error:
'Pixel test failed, image sizes do not match.
\n
'
'Master Image:
${masterImage.width}
X
${masterImage.height}
\n
'
'Test Image:
${testImage.width}
X
${testImage.height}
'
,
...
...
@@ -240,10 +245,12 @@ Future<ComparisonResult> compareLists(List<int>? test, List<int>? master) async
}
if
(
pixelDiffCount
>
0
)
{
final
double
diffPercent
=
pixelDiffCount
/
totalPixels
;
return
ComparisonResult
(
passed:
false
,
diffPercent:
diffPercent
,
error:
'Pixel test failed, '
'
${(
(pixelDiffCount/totalPixels)
* 100).toStringAsFixed(2)}
% '
'
${(
diffPercent
* 100).toStringAsFixed(2)}
% '
'diff detected.'
,
diffs:
<
String
,
Image
>{
'masterImage'
:
masterImage
,
...
...
@@ -253,7 +260,7 @@ Future<ComparisonResult> compareLists(List<int>? test, List<int>? master) async
},
);
}
return
ComparisonResult
(
passed:
true
);
return
ComparisonResult
(
passed:
true
,
diffPercent:
0.0
);
}
/// Inverts [imageBytes], returning a new [ByteData] object.
...
...
packages/flutter_test/lib/src/goldens.dart
View file @
6ec90142
...
...
@@ -319,6 +319,7 @@ class ComparisonResult {
/// Creates a new [ComparisonResult] for the current test.
ComparisonResult
({
required
this
.
passed
,
required
this
.
diffPercent
,
this
.
error
,
this
.
diffs
,
});
...
...
@@ -335,4 +336,7 @@ class ComparisonResult {
/// values in the execution of the pixel test.
// TODO(jonahwilliams): fix type signature when image is updated to support web.
final
Map
<
String
,
Object
>?
diffs
;
/// The calculated percentage of pixel difference between two images.
final
double
diffPercent
;
}
packages/flutter_test/test/goldens_test.dart
View file @
6ec90142
...
...
@@ -104,7 +104,7 @@ void main() {
test
(
'throws if local output is not awaited'
,
()
{
try
{
comparator
.
generateFailureOutput
(
ComparisonResult
(
passed:
false
),
ComparisonResult
(
passed:
false
,
diffPercent:
1.0
),
Uri
.
parse
(
'foo_test.dart'
),
Uri
.
parse
(
'/foo/bar/'
),
);
...
...
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