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
f52fe4f7
Unverified
Commit
f52fe4f7
authored
Oct 09, 2023
by
droidbg
Committed by
GitHub
Oct 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[leak-tracking] Add leak tracking in test/painting #2 (#136169)
parent
6dce1425
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
29 deletions
+31
-29
continuous_rectangle_border_test.dart
...utter/test/painting/continuous_rectangle_border_test.dart
+8
-7
image_stream_test.dart
packages/flutter/test/painting/image_stream_test.dart
+23
-22
No files found.
packages/flutter/test/painting/continuous_rectangle_border_test.dart
View file @
f52fe4f7
...
...
@@ -9,6 +9,7 @@ library;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
void
main
(
)
{
test
(
'ContinuousRectangleBorder defaults'
,
()
{
...
...
@@ -108,7 +109,7 @@ void main() {
expect
(
border
.
getInnerPath
(
rect
,
textDirection:
TextDirection
.
rtl
),
looksLikeRectRtl
);
});
testWidgets
(
'Golden test even radii'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Golden test even radii'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Material
(
color:
Colors
.
blueAccent
[
400
],
...
...
@@ -126,7 +127,7 @@ void main() {
);
});
testWidgets
(
'Golden test varying radii'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Golden test varying radii'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Material
(
color:
Colors
.
green
[
100
],
...
...
@@ -149,7 +150,7 @@ void main() {
);
});
testWidgets
(
'Golden test topLeft radii'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Golden test topLeft radii'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Material
(
color:
Colors
.
green
[
200
],
...
...
@@ -169,7 +170,7 @@ void main() {
);
});
testWidgets
(
'Golden test topRight radii'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Golden test topRight radii'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Material
(
color:
Colors
.
green
[
300
],
...
...
@@ -189,7 +190,7 @@ void main() {
);
});
testWidgets
(
'Golden test bottomLeft radii'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Golden test bottomLeft radii'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Material
(
color:
Colors
.
green
[
400
],
...
...
@@ -209,7 +210,7 @@ void main() {
);
});
testWidgets
(
'Golden test bottomRight radii'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Golden test bottomRight radii'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Material
(
color:
Colors
.
green
[
500
],
...
...
@@ -229,7 +230,7 @@ void main() {
);
});
testWidgets
(
'Golden test large radii'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Golden test large radii'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
RepaintBoundary
(
child:
Material
(
color:
Colors
.
redAccent
[
400
],
...
...
packages/flutter/test/painting/image_stream_test.dart
View file @
f52fe4f7
...
...
@@ -9,6 +9,7 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/painting.dart'
;
import
'package:flutter/scheduler.dart'
show
SchedulerBinding
,
timeDilation
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'
;
import
'../image_data.dart'
;
import
'fake_codec.dart'
;
...
...
@@ -84,7 +85,7 @@ void main() {
image200x100
=
await
createTestImage
(
width:
200
,
height:
100
);
});
testWidgets
(
'Codec future fails'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Codec future fails'
,
(
WidgetTester
tester
)
async
{
final
Completer
<
Codec
>
completer
=
Completer
<
Codec
>();
MultiFrameImageStreamCompleter
(
codec:
completer
.
future
,
...
...
@@ -95,7 +96,7 @@ void main() {
expect
(
tester
.
takeException
(),
'failure message'
);
});
testWidgets
(
'Decoding starts when a listener is added after codec is ready'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Decoding starts when a listener is added after codec is ready'
,
(
WidgetTester
tester
)
async
{
final
Completer
<
Codec
>
completer
=
Completer
<
Codec
>();
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
1
;
...
...
@@ -114,7 +115,7 @@ void main() {
expect
(
mockCodec
.
numFramesAsked
,
1
);
});
testWidgets
(
'Decoding starts when a codec is ready after a listener is added'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Decoding starts when a codec is ready after a listener is added'
,
(
WidgetTester
tester
)
async
{
final
Completer
<
Codec
>
completer
=
Completer
<
Codec
>();
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
1
;
...
...
@@ -133,7 +134,7 @@ void main() {
expect
(
mockCodec
.
numFramesAsked
,
1
);
});
testWidgets
(
'Decoding does not crash when disposed'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Decoding does not crash when disposed'
,
(
WidgetTester
tester
)
async
{
final
Completer
<
Codec
>
completer
=
Completer
<
Codec
>();
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
1
;
...
...
@@ -158,7 +159,7 @@ void main() {
await
tester
.
idle
();
});
testWidgets
(
'Chunk events of base ImageStreamCompleter are delivered'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Chunk events of base ImageStreamCompleter are delivered'
,
(
WidgetTester
tester
)
async
{
final
List
<
ImageChunkEvent
>
chunkEvents
=
<
ImageChunkEvent
>[];
final
StreamController
<
ImageChunkEvent
>
streamController
=
StreamController
<
ImageChunkEvent
>();
final
ImageStreamCompleter
imageStream
=
FakeEventReportingImageStreamCompleter
(
...
...
@@ -182,7 +183,7 @@ void main() {
expect
(
chunkEvents
[
1
].
expectedTotalBytes
,
3
);
});
testWidgets
(
'Chunk events of base ImageStreamCompleter are not buffered before listener registration'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Chunk events of base ImageStreamCompleter are not buffered before listener registration'
,
(
WidgetTester
tester
)
async
{
final
List
<
ImageChunkEvent
>
chunkEvents
=
<
ImageChunkEvent
>[];
final
StreamController
<
ImageChunkEvent
>
streamController
=
StreamController
<
ImageChunkEvent
>();
final
ImageStreamCompleter
imageStream
=
FakeEventReportingImageStreamCompleter
(
...
...
@@ -205,7 +206,7 @@ void main() {
expect
(
chunkEvents
[
0
].
expectedTotalBytes
,
3
);
});
testWidgets
(
'Chunk events of MultiFrameImageStreamCompleter are delivered'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Chunk events of MultiFrameImageStreamCompleter are delivered'
,
(
WidgetTester
tester
)
async
{
final
List
<
ImageChunkEvent
>
chunkEvents
=
<
ImageChunkEvent
>[];
final
Completer
<
Codec
>
completer
=
Completer
<
Codec
>();
final
StreamController
<
ImageChunkEvent
>
streamController
=
StreamController
<
ImageChunkEvent
>();
...
...
@@ -232,7 +233,7 @@ void main() {
expect
(
chunkEvents
[
1
].
expectedTotalBytes
,
3
);
});
testWidgets
(
'Chunk events of MultiFrameImageStreamCompleter are not buffered before listener registration'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Chunk events of MultiFrameImageStreamCompleter are not buffered before listener registration'
,
(
WidgetTester
tester
)
async
{
final
List
<
ImageChunkEvent
>
chunkEvents
=
<
ImageChunkEvent
>[];
final
Completer
<
Codec
>
completer
=
Completer
<
Codec
>();
final
StreamController
<
ImageChunkEvent
>
streamController
=
StreamController
<
ImageChunkEvent
>();
...
...
@@ -258,7 +259,7 @@ void main() {
expect
(
chunkEvents
[
0
].
expectedTotalBytes
,
3
);
});
testWidgets
(
'Chunk errors are reported'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Chunk errors are reported'
,
(
WidgetTester
tester
)
async
{
final
List
<
ImageChunkEvent
>
chunkEvents
=
<
ImageChunkEvent
>[];
final
Completer
<
Codec
>
completer
=
Completer
<
Codec
>();
final
StreamController
<
ImageChunkEvent
>
streamController
=
StreamController
<
ImageChunkEvent
>();
...
...
@@ -284,7 +285,7 @@ void main() {
expect
(
chunkEvents
[
0
].
expectedTotalBytes
,
3
);
});
testWidgets
(
'getNextFrame future fails'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'getNextFrame future fails'
,
(
WidgetTester
tester
)
async
{
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
1
;
final
Completer
<
Codec
>
codecCompleter
=
Completer
<
Codec
>();
...
...
@@ -309,7 +310,7 @@ void main() {
expect
(
tester
.
takeException
(),
'frame completion error'
);
});
testWidgets
(
'ImageStream emits frame (static image)'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'ImageStream emits frame (static image)'
,
(
WidgetTester
tester
)
async
{
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
1
;
final
Completer
<
Codec
>
codecCompleter
=
Completer
<
Codec
>();
...
...
@@ -334,7 +335,7 @@ void main() {
expect
(
emittedImages
.
every
((
ImageInfo
info
)
=>
info
.
image
.
isCloneOf
(
frame
.
image
)),
true
);
});
testWidgets
(
'ImageStream emits frames (animated images)'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'ImageStream emits frames (animated images)'
,
(
WidgetTester
tester
)
async
{
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
2
;
mockCodec
.
repetitionCount
=
-
1
;
...
...
@@ -380,7 +381,7 @@ void main() {
await
tester
.
pump
(
const
Duration
(
milliseconds:
400
));
});
testWidgets
(
'animation wraps back'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'animation wraps back'
,
(
WidgetTester
tester
)
async
{
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
2
;
mockCodec
.
repetitionCount
=
-
1
;
...
...
@@ -421,7 +422,7 @@ void main() {
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
});
testWidgets
(
"animation doesn't repeat more than specified"
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
"animation doesn't repeat more than specified"
,
(
WidgetTester
tester
)
async
{
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
2
;
mockCodec
.
repetitionCount
=
0
;
...
...
@@ -459,7 +460,7 @@ void main() {
expect
(
emittedImages
[
1
].
image
.
isCloneOf
(
frame2
.
image
),
true
);
});
testWidgets
(
'frames are only decoded when there are listeners'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'frames are only decoded when there are listeners'
,
(
WidgetTester
tester
)
async
{
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
2
;
mockCodec
.
repetitionCount
=
-
1
;
...
...
@@ -499,7 +500,7 @@ void main() {
handle
.
dispose
();
});
testWidgets
(
'multiple stream listeners'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'multiple stream listeners'
,
(
WidgetTester
tester
)
async
{
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
2
;
mockCodec
.
repetitionCount
=
-
1
;
...
...
@@ -546,7 +547,7 @@ void main() {
});
testWidgets
(
'timer is canceled when listeners are removed'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'timer is canceled when listeners are removed'
,
(
WidgetTester
tester
)
async
{
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
2
;
mockCodec
.
repetitionCount
=
-
1
;
...
...
@@ -579,7 +580,7 @@ void main() {
// point.
});
testWidgets
(
'timeDilation affects animation frame timers'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'timeDilation affects animation frame timers'
,
(
WidgetTester
tester
)
async
{
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
2
;
mockCodec
.
repetitionCount
=
-
1
;
...
...
@@ -616,7 +617,7 @@ void main() {
timeDilation
=
1.0
;
// restore time dilation, or it will affect other tests
});
testWidgets
(
'error handlers can intercept errors'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'error handlers can intercept errors'
,
(
WidgetTester
tester
)
async
{
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
1
;
final
Completer
<
Codec
>
codecCompleter
=
Completer
<
Codec
>();
...
...
@@ -651,7 +652,7 @@ void main() {
expect
(
capturedException
,
'frame completion error'
);
});
testWidgets
(
'remove and add listener '
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'remove and add listener '
,
(
WidgetTester
tester
)
async
{
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
3
;
mockCodec
.
repetitionCount
=
0
;
...
...
@@ -682,7 +683,7 @@ void main() {
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
// emit 2nd frame.
});
testWidgets
(
'ImageStreamListener hashCode and equals'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'ImageStreamListener hashCode and equals'
,
(
WidgetTester
tester
)
async
{
void
handleImage
(
ImageInfo
image
,
bool
synchronousCall
)
{
}
void
handleImageDifferently
(
ImageInfo
image
,
bool
synchronousCall
)
{
}
void
handleError
(
dynamic
error
,
StackTrace
?
stackTrace
)
{
}
...
...
@@ -714,7 +715,7 @@ void main() {
compare
(
onImage1:
handleImage
,
onChunk1:
handleChunk
,
onError1:
handleError
,
onImage2:
handleImage
,
onError2:
handleError
,
areEqual:
false
);
});
testWidgets
(
'Keep alive handles do not drive frames or prevent last listener callbacks'
,
(
WidgetTester
tester
)
async
{
testWidgets
WithLeakTracking
(
'Keep alive handles do not drive frames or prevent last listener callbacks'
,
(
WidgetTester
tester
)
async
{
final
Image
image10x10
=
(
await
tester
.
runAsync
(()
=>
createTestImage
(
width:
10
,
height:
10
)))!;
final
MockCodec
mockCodec
=
MockCodec
();
mockCodec
.
frameCount
=
2
;
...
...
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