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
a813dc55
Unverified
Commit
a813dc55
authored
Mar 28, 2019
by
Jonah Williams
Committed by
GitHub
Mar 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more test coverage to image handling (#30078)
parent
ec93c87c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
image_provider_test.dart
packages/flutter/test/painting/image_provider_test.dart
+28
-0
mocks_for_image_cache.dart
packages/flutter/test/painting/mocks_for_image_cache.dart
+24
-0
No files found.
packages/flutter/test/painting/image_provider_test.dart
View file @
a813dc55
...
...
@@ -86,4 +86,32 @@ void main() {
});
expect
(
await
caughtError
.
future
,
true
);
});
test
(
'ImageProvider.resolve sync errors will be caught'
,
()
async
{
final
ImageProvider
imageProvider
=
LoadErrorImageProvider
();
final
Completer
<
bool
>
caughtError
=
Completer
<
bool
>();
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
caughtError
.
complete
(
false
);
};
final
ImageStream
result
=
imageProvider
.
resolve
(
ImageConfiguration
.
empty
);
result
.
addListener
((
ImageInfo
info
,
bool
syncCall
)
{
},
onError:
(
dynamic
error
,
StackTrace
stackTrace
)
{
caughtError
.
complete
(
true
);
});
expect
(
await
caughtError
.
future
,
true
);
});
test
(
'ImageProvider.resolve errors in the completer will be caught'
,
()
async
{
final
ImageProvider
imageProvider
=
LoadErrorCompleterImageProvider
();
final
Completer
<
bool
>
caughtError
=
Completer
<
bool
>();
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
caughtError
.
complete
(
false
);
};
final
ImageStream
result
=
imageProvider
.
resolve
(
ImageConfiguration
.
empty
);
result
.
addListener
((
ImageInfo
info
,
bool
syncCall
)
{
},
onError:
(
dynamic
error
,
StackTrace
stackTrace
)
{
caughtError
.
complete
(
true
);
});
expect
(
await
caughtError
.
future
,
true
);
});
}
packages/flutter/test/painting/mocks_for_image_cache.dart
View file @
a813dc55
...
...
@@ -106,4 +106,28 @@ class ObtainKeyErrorImageProvider extends ImageProvider<ObtainKeyErrorImageProvi
}
}
class
LoadErrorImageProvider
extends
ImageProvider
<
LoadErrorImageProvider
>
{
@override
ImageStreamCompleter
load
(
LoadErrorImageProvider
key
)
{
throw
Error
();
}
@override
Future
<
LoadErrorImageProvider
>
obtainKey
(
ImageConfiguration
configuration
)
{
return
SynchronousFuture
<
LoadErrorImageProvider
>(
this
);
}
}
class
LoadErrorCompleterImageProvider
extends
ImageProvider
<
LoadErrorCompleterImageProvider
>
{
@override
ImageStreamCompleter
load
(
LoadErrorCompleterImageProvider
key
)
{
return
OneFrameImageStreamCompleter
(
SynchronousFuture
<
ImageInfo
>(
null
).
then
((
_
)
=>
throw
Error
()));
}
@override
Future
<
LoadErrorCompleterImageProvider
>
obtainKey
(
ImageConfiguration
configuration
)
{
return
SynchronousFuture
<
LoadErrorCompleterImageProvider
>(
this
);
}
}
class
TestImageStreamCompleter
extends
ImageStreamCompleter
{}
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