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
be2918ff
Unverified
Commit
be2918ff
authored
May 23, 2019
by
Todd Volkert
Committed by
GitHub
May 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ImageStreamListener's hashCode & operator== (#33217)
I forgot to add `onChunk` to them in #33092
parent
ef9866bf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletion
+35
-1
image_stream.dart
packages/flutter/lib/src/painting/image_stream.dart
+2
-1
image_stream_test.dart
packages/flutter/test/painting/image_stream_test.dart
+33
-0
No files found.
packages/flutter/lib/src/painting/image_stream.dart
View file @
be2918ff
...
...
@@ -113,7 +113,7 @@ class ImageStreamListener {
final
ImageErrorListener
onError
;
@override
int
get
hashCode
=>
hashValues
(
onImage
,
onError
);
int
get
hashCode
=>
hashValues
(
onImage
,
on
Chunk
,
on
Error
);
@override
bool
operator
==(
dynamic
other
)
{
...
...
@@ -121,6 +121,7 @@ class ImageStreamListener {
return
false
;
final
ImageStreamListener
typedOther
=
other
;
return
onImage
==
typedOther
.
onImage
&&
onChunk
==
typedOther
.
onChunk
&&
onError
==
typedOther
.
onError
;
}
}
...
...
packages/flutter/test/painting/image_stream_test.dart
View file @
be2918ff
...
...
@@ -9,6 +9,7 @@ import 'dart:ui';
import
'package:flutter/painting.dart'
;
import
'package:flutter/scheduler.dart'
show
timeDilation
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:meta/meta.dart'
;
class
FakeFrameInfo
implements
FrameInfo
{
FakeFrameInfo
(
int
width
,
int
height
,
this
.
_duration
)
...
...
@@ -606,6 +607,38 @@ void main() {
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
// emit 2nd frame.
});
testWidgets
(
'ImageStreamListener hashCode and equals'
,
(
WidgetTester
tester
)
{
void
handleImage
(
ImageInfo
image
,
bool
synchronousCall
)
{
}
void
handleImageDifferently
(
ImageInfo
image
,
bool
synchronousCall
)
{
}
void
handleError
(
dynamic
error
,
StackTrace
stackTrace
)
{
}
void
handleChunk
(
ImageChunkEvent
event
)
{
}
void
compare
({
@required
ImageListener
onImage1
,
@required
ImageListener
onImage2
,
ImageChunkListener
onChunk1
,
ImageChunkListener
onChunk2
,
ImageErrorListener
onError1
,
ImageErrorListener
onError2
,
bool
areEqual
=
true
,
})
{
final
ImageStreamListener
l1
=
ImageStreamListener
(
onImage1
,
onChunk:
onChunk1
,
onError:
onError1
);
final
ImageStreamListener
l2
=
ImageStreamListener
(
onImage2
,
onChunk:
onChunk2
,
onError:
onError2
);
Matcher
comparison
(
dynamic
expected
)
=>
areEqual
?
equals
(
expected
)
:
isNot
(
equals
(
expected
));
expect
(
l1
,
comparison
(
l2
));
expect
(
l1
.
hashCode
,
comparison
(
l2
.
hashCode
));
}
compare
(
onImage1:
handleImage
,
onImage2:
handleImage
);
compare
(
onImage1:
handleImage
,
onImage2:
handleImageDifferently
,
areEqual:
false
);
compare
(
onImage1:
handleImage
,
onChunk1:
handleChunk
,
onImage2:
handleImage
,
onChunk2:
handleChunk
);
compare
(
onImage1:
handleImage
,
onChunk1:
handleChunk
,
onError1:
handleError
,
onImage2:
handleImage
,
onChunk2:
handleChunk
,
onError2:
handleError
);
compare
(
onImage1:
handleImage
,
onChunk1:
handleChunk
,
onImage2:
handleImage
,
areEqual:
false
);
compare
(
onImage1:
handleImage
,
onChunk1:
handleChunk
,
onError1:
handleError
,
onImage2:
handleImage
,
areEqual:
false
);
compare
(
onImage1:
handleImage
,
onChunk1:
handleChunk
,
onError1:
handleError
,
onImage2:
handleImage
,
onChunk2:
handleChunk
,
areEqual:
false
);
compare
(
onImage1:
handleImage
,
onChunk1:
handleChunk
,
onError1:
handleError
,
onImage2:
handleImage
,
onError2:
handleError
,
areEqual:
false
);
});
// TODO(amirh): enable this once WidgetTester supports flushTimers.
// https://github.com/flutter/flutter/issues/30344
// testWidgets('remove and add listener before a delayed frame is scheduled', (WidgetTester tester) async {
...
...
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