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
cb232dda
Unverified
Commit
cb232dda
authored
Sep 21, 2020
by
Ian Hickson
Committed by
GitHub
Sep 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent a potential infinite loop. (#66073)
parent
a029e172
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
binding.dart
packages/flutter/lib/src/services/binding.dart
+6
-5
platform_channel_test.dart
packages/flutter/test/services/platform_channel_test.dart
+16
-1
No files found.
packages/flutter/lib/src/services/binding.dart
View file @
cb232dda
...
...
@@ -309,14 +309,15 @@ class _DefaultBinaryMessenger extends BinaryMessenger {
@override
void
setMessageHandler
(
String
channel
,
MessageHandler
?
handler
)
{
if
(
handler
==
null
)
if
(
handler
==
null
)
{
_handlers
.
remove
(
channel
);
else
}
else
{
_handlers
[
channel
]
=
handler
;
ui
.
channelBuffers
.
drain
(
channel
,
(
ByteData
?
data
,
ui
.
PlatformMessageResponseCallback
callback
)
async
{
await
handlePlatformMessage
(
channel
,
data
,
callback
);
});
}
}
@override
bool
checkMessageHandler
(
String
channel
,
MessageHandler
?
handler
)
=>
_handlers
[
channel
]
==
handler
;
...
...
packages/flutter/test/services/platform_channel_test.dart
View file @
cb232dda
...
...
@@ -25,6 +25,7 @@ void main() {
final
String
reply
=
await
channel
.
send
(
'hello'
);
expect
(
reply
,
equals
(
'hello world'
));
});
test
(
'can receive string message and send reply'
,
()
async
{
channel
.
setMessageHandler
((
String
message
)
async
=>
message
+
' world'
);
String
reply
;
...
...
@@ -170,13 +171,25 @@ void main() {
expect
(
result
,
isNull
);
});
test
(
'can handle method call with no registered plugin'
,
()
async
{
test
(
'can handle method call with no registered plugin
(setting before)
'
,
()
async
{
channel
.
setMethodCallHandler
(
null
);
final
ByteData
call
=
jsonMethod
.
encodeMethodCall
(
const
MethodCall
(
'sayHello'
,
'hello'
));
ByteData
envelope
;
await
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'ch7'
,
call
,
(
ByteData
result
)
{
envelope
=
result
;
});
await
null
;
// just in case there's something async happening
expect
(
envelope
,
isNull
);
});
test
(
'can handle method call with no registered plugin (setting after)'
,
()
async
{
final
ByteData
call
=
jsonMethod
.
encodeMethodCall
(
const
MethodCall
(
'sayHello'
,
'hello'
));
ByteData
envelope
;
await
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'ch7'
,
call
,
(
ByteData
result
)
{
envelope
=
result
;
});
channel
.
setMethodCallHandler
(
null
);
await
null
;
// just in case there's something async happening
expect
(
envelope
,
isNull
);
});
...
...
@@ -262,6 +275,7 @@ void main() {
expect
(
channel
.
checkMockMethodCallHandler
(
handler
),
true
);
});
});
group
(
'EventChannel'
,
()
{
const
MessageCodec
<
dynamic
>
jsonMessage
=
JSONMessageCodec
();
const
MethodCodec
jsonMethod
=
JSONMethodCodec
();
...
...
@@ -298,6 +312,7 @@ void main() {
await
Future
<
void
>.
delayed
(
Duration
.
zero
);
expect
(
canceled
,
isTrue
);
});
test
(
'can receive error event'
,
()
async
{
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
setMockMessageHandler
(
'ch'
,
...
...
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