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
f7d62aaa
Commit
f7d62aaa
authored
May 10, 2017
by
Yegor
Committed by
GitHub
May 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix driver connection flakiness (#9968)
parent
abaf2901
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
driver.dart
packages/flutter_driver/lib/src/driver.dart
+15
-1
flutter_driver_test.dart
packages/flutter_driver/test/flutter_driver_test.dart
+17
-3
No files found.
packages/flutter_driver/lib/src/driver.dart
View file @
f7d62aaa
...
...
@@ -212,11 +212,25 @@ class FlutterDriver {
});
}
/// Tells the Dart VM Service to notify us about "Isolate" events.
///
/// This is a workaround for an issue in package:vm_service_client, which
/// subscribes to the "Isolate" stream lazily upon subscription, which
/// results in lost events.
///
/// Details: https://github.com/dart-lang/vm_service_client/issues/17
Future
<
Null
>
enableIsolateStreams
()
async
{
await
connection
.
peer
.
sendRequest
(
'streamListen'
,
<
String
,
String
>{
'streamId'
:
'Isolate'
,
});
}
// If the isolate is paused at the start, e.g. via the --start-paused
// option, then the VM service extension is not registered yet. Wait for
// it to be registered.
final
Future
<
dynamic
>
whenResumed
=
resumeLeniently
();
await
enableIsolateStreams
();
final
Future
<
dynamic
>
whenServiceExtensionReady
=
waitForServiceExtension
();
final
Future
<
dynamic
>
whenResumed
=
resumeLeniently
();
await
whenResumed
;
try
{
...
...
packages/flutter_driver/test/flutter_driver_test.dart
View file @
f7d62aaa
...
...
@@ -24,6 +24,7 @@ void main() {
MockVMServiceClient
mockClient
;
MockVM
mockVM
;
MockIsolate
mockIsolate
;
MockPeer
mockPeer
;
void
expectLogContains
(
String
message
)
{
expect
(
log
.
map
((
LogRecord
r
)
=>
'
$r
'
),
anyElement
(
contains
(
message
)));
...
...
@@ -35,6 +36,7 @@ void main() {
mockClient
=
new
MockVMServiceClient
();
mockVM
=
new
MockVM
();
mockIsolate
=
new
MockIsolate
();
mockPeer
=
new
MockPeer
();
when
(
mockClient
.
getVM
()).
thenReturn
(
mockVM
);
when
(
mockVM
.
isolates
).
thenReturn
(<
VMRunnableIsolate
>[
mockIsolate
]);
when
(
mockIsolate
.
loadRunnable
()).
thenReturn
(
mockIsolate
);
...
...
@@ -42,7 +44,7 @@ void main() {
.
thenReturn
(
makeMockResponse
(<
String
,
dynamic
>{
'status'
:
'ok'
}));
vmServiceConnectFunction
=
(
String
url
)
{
return
new
Future
<
VMServiceClientConnection
>.
value
(
new
VMServiceClientConnection
(
mockClient
,
null
)
new
VMServiceClientConnection
(
mockClient
,
mockPeer
)
);
};
});
...
...
@@ -53,13 +55,25 @@ void main() {
});
test
(
'connects to isolate paused at start'
,
()
async
{
final
List
<
String
>
connectionLog
=
<
String
>[];
when
(
mockPeer
.
sendRequest
(
'streamListen'
,
any
)).
thenAnswer
((
_
)
{
connectionLog
.
add
(
'streamListen'
);
return
null
;
});
when
(
mockIsolate
.
pauseEvent
).
thenReturn
(
new
MockVMPauseStartEvent
());
when
(
mockIsolate
.
resume
()).
thenReturn
(
new
Future
<
Null
>.
value
());
when
(
mockIsolate
.
onExtensionAdded
).
thenReturn
(
new
Stream
<
String
>.
fromIterable
(<
String
>[
'ext.flutter.driver'
]));
when
(
mockIsolate
.
resume
()).
thenAnswer
((
_
)
{
connectionLog
.
add
(
'resume'
);
return
new
Future
<
Null
>.
value
();
});
when
(
mockIsolate
.
onExtensionAdded
).
thenAnswer
((
_
)
{
connectionLog
.
add
(
'onExtensionAdded'
);
return
new
Stream
<
String
>.
fromIterable
(<
String
>[
'ext.flutter.driver'
]);
});
final
FlutterDriver
driver
=
await
FlutterDriver
.
connect
(
dartVmServiceUrl:
''
);
expect
(
driver
,
isNotNull
);
expectLogContains
(
'Isolate is paused at start'
);
expect
(
connectionLog
,
<
String
>[
'streamListen'
,
'onExtensionAdded'
,
'resume'
]);
});
test
(
'connects to isolate paused mid-flight'
,
()
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