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
22f593e5
Unverified
Commit
22f593e5
authored
Oct 17, 2023
by
Kostia Sokolovskyi
Committed by
GitHub
Oct 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GoldenFileComparators should dispose created Image objects. (#136716)
parent
3d1d4532
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
6 deletions
+53
-6
live_binding_test.dart
packages/flutter/test/animation/live_binding_test.dart
+0
-2
flutter_goldens.dart
packages/flutter_goldens/lib/flutter_goldens.dart
+2
-0
_goldens_io.dart
packages/flutter_test/lib/src/_goldens_io.dart
+7
-4
goldens.dart
packages/flutter_test/lib/src/goldens.dart
+13
-0
goldens_test.dart
packages/flutter_test/test/goldens_test.dart
+31
-0
No files found.
packages/flutter/test/animation/live_binding_test.dart
View file @
22f593e5
...
...
@@ -137,7 +137,5 @@ void main() {
);
},
skip:
isBrowser
,
// [intended] https://github.com/flutter/flutter/issues/56001
// TODO(polina-c): remove after fixing https://github.com/flutter/flutter/issues/136513
leakTrackingTestConfig:
const
LeakTrackingTestConfig
(
notDisposedAllowList:
<
String
,
int
?>{
'Image'
:
4
}),
);
}
packages/flutter_goldens/lib/flutter_goldens.dart
View file @
22f593e5
...
...
@@ -534,10 +534,12 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
);
if
(
result
.
passed
)
{
result
.
dispose
();
return
true
;
}
final
String
error
=
await
generateFailureOutput
(
result
,
golden
,
basedir
);
result
.
dispose
();
throw
FlutterError
(
error
);
}
}
packages/flutter_test/lib/src/_goldens_io.dart
View file @
22f593e5
...
...
@@ -96,11 +96,14 @@ class LocalFileComparator extends GoldenFileComparator with LocalComparisonOutpu
await
getGoldenBytes
(
golden
),
);
if
(
!
result
.
passed
)
{
final
String
error
=
await
generateFailureOutput
(
result
,
golden
,
basedir
);
throw
FlutterError
(
error
)
;
if
(
result
.
passed
)
{
result
.
dispose
(
);
return
true
;
}
return
result
.
passed
;
final
String
error
=
await
generateFailureOutput
(
result
,
golden
,
basedir
);
result
.
dispose
();
throw
FlutterError
(
error
);
}
@override
...
...
packages/flutter_test/lib/src/goldens.dart
View file @
22f593e5
...
...
@@ -5,6 +5,7 @@
import
'dart:typed_data'
;
import
'dart:ui'
;
import
'package:meta/meta.dart'
;
import
'package:path/path.dart'
as
path
;
import
'_goldens_io.dart'
if
(
dart
.
library
.
html
)
'_goldens_web.dart'
as
goldens
;
...
...
@@ -342,4 +343,16 @@ class ComparisonResult {
/// The calculated percentage of pixel difference between two images.
final
double
diffPercent
;
/// Disposes the images held by this [ComparisonResult].
@mustCallSuper
void
dispose
()
{
if
(
diffs
==
null
)
{
return
;
}
for
(
final
MapEntry
<
String
,
Image
>
entry
in
diffs
!.
entries
)
{
entry
.
value
.
dispose
();
}
}
}
packages/flutter_test/test/goldens_test.dart
View file @
22f593e5
...
...
@@ -5,6 +5,7 @@
import
'dart:async'
;
import
'dart:io'
as
io
;
import
'dart:typed_data'
;
import
'dart:ui'
as
ui
;
import
'package:file/memory.dart'
;
import
'package:flutter/foundation.dart'
show
DiagnosticLevel
,
DiagnosticPropertiesBuilder
,
DiagnosticsNode
,
FlutterError
;
...
...
@@ -322,4 +323,34 @@ void main() {
});
});
});
group
(
'ComparisonResult'
,
()
{
group
(
'dispose'
,
()
{
test
(
'disposes diffs images'
,
()
async
{
final
ui
.
Image
image1
=
await
createTestImage
(
width:
10
,
height:
10
,
cache:
false
);
final
ui
.
Image
image2
=
await
createTestImage
(
width:
15
,
height:
5
,
cache:
false
);
final
ui
.
Image
image3
=
await
createTestImage
(
width:
5
,
height:
10
,
cache:
false
);
final
ComparisonResult
result
=
ComparisonResult
(
passed:
false
,
diffPercent:
1.0
,
diffs:
<
String
,
ui
.
Image
>{
'image1'
:
image1
,
'image2'
:
image2
,
'image3'
:
image3
,
}
);
expect
(
image1
.
debugDisposed
,
isFalse
);
expect
(
image2
.
debugDisposed
,
isFalse
);
expect
(
image3
.
debugDisposed
,
isFalse
);
result
.
dispose
();
expect
(
image1
.
debugDisposed
,
isTrue
);
expect
(
image2
.
debugDisposed
,
isTrue
);
expect
(
image3
.
debugDisposed
,
isTrue
);
});
});
});
}
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