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
890085e9
Unverified
Commit
890085e9
authored
Jan 22, 2019
by
xster
Committed by
GitHub
Jan 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add another test to ImageStream (#26693)
parent
8098b5e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
image_test.dart
packages/flutter/test/widgets/image_test.dart
+52
-0
No files found.
packages/flutter/test/widgets/image_test.dart
View file @
890085e9
...
...
@@ -581,6 +581,58 @@ void main() {
expect
(
capturedImage
,
isNull
);
// The image stream listeners should never be called.
});
testWidgets
(
'Removing listener FIFO removes exactly one listener and error listener'
,
(
WidgetTester
tester
)
async
{
// To make sure that a single listener removal doesn't only happen
// accidentally as described in https://github.com/flutter/flutter/pull/25865#discussion_r244851565.
int
errorListener1Called
=
0
;
int
errorListener2Called
=
0
;
int
errorListener3Called
=
0
;
ImageInfo
capturedImage
;
final
ImageErrorListener
errorListener1
=
(
dynamic
exception
,
StackTrace
stackTrace
)
{
errorListener1Called
++;
};
final
ImageErrorListener
errorListener2
=
(
dynamic
exception
,
StackTrace
stackTrace
)
{
errorListener2Called
++;
};
final
ImageErrorListener
errorListener3
=
(
dynamic
exception
,
StackTrace
stackTrace
)
{
errorListener3Called
++;
};
final
ImageListener
listener
=
(
ImageInfo
info
,
bool
synchronous
)
{
capturedImage
=
info
;
};
final
Exception
testException
=
Exception
(
'cannot resolve host'
);
final
StackTrace
testStack
=
StackTrace
.
current
;
final
TestImageProvider
imageProvider
=
TestImageProvider
();
imageProvider
.
_streamCompleter
.
addListener
(
listener
,
onError:
errorListener1
);
imageProvider
.
_streamCompleter
.
addListener
(
listener
,
onError:
errorListener2
);
imageProvider
.
_streamCompleter
.
addListener
(
listener
,
onError:
errorListener3
);
// Remove listener. It should remove exactly the first one and the associated
// errorListener1.
imageProvider
.
_streamCompleter
.
removeListener
(
listener
);
ImageConfiguration
configuration
;
await
tester
.
pumpWidget
(
Builder
(
builder:
(
BuildContext
context
)
{
configuration
=
createLocalImageConfiguration
(
context
);
return
Container
();
},
),
);
imageProvider
.
resolve
(
configuration
);
imageProvider
.
fail
(
testException
,
testStack
);
expect
(
tester
.
binding
.
microtaskCount
,
1
);
await
tester
.
idle
();
// Let the failed completer's future hit the stream completer.
expect
(
tester
.
binding
.
microtaskCount
,
0
);
expect
(
errorListener1Called
,
0
);
expect
(
errorListener2Called
,
1
);
expect
(
errorListener3Called
,
1
);
expect
(
capturedImage
,
isNull
);
// The image stream listeners should never be called.
});
testWidgets
(
'Image.memory control test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Image
.
memory
(
Uint8List
.
fromList
(
kTransparentImage
),
excludeFromSemantics:
true
,));
});
...
...
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