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
d53115ab
Commit
d53115ab
authored
May 04, 2019
by
done
Committed by
Dan Field
May 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix FlutterDriver timeout (#31824)
parent
c731e3e6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
18 deletions
+26
-18
driver.dart
packages/flutter_driver/lib/src/driver/driver.dart
+7
-16
flutter_driver_test.dart
packages/flutter_driver/test/flutter_driver_test.dart
+19
-2
No files found.
packages/flutter_driver/lib/src/driver/driver.dart
View file @
d53115ab
...
...
@@ -63,7 +63,8 @@ const List<TimelineStream> _defaultStreams = <TimelineStream>[TimelineStream.all
/// How long to wait before showing a message saying that
/// things seem to be taking a long time.
const
Duration
_kUnusuallyLongTimeout
=
Duration
(
seconds:
5
);
@visibleForTesting
const
Duration
kUnusuallyLongTimeout
=
Duration
(
seconds:
5
);
/// The amount of time we wait prior to making the next attempt to connect to
/// the VM service.
...
...
@@ -102,16 +103,6 @@ Future<T> _warnIfSlow<T>({
return
future
..
timeout
(
timeout
,
onTimeout:
()
{
_log
.
warning
(
message
);
});
}
Duration
_maxDuration
(
Duration
a
,
Duration
b
)
{
if
(
a
==
null
)
return
b
;
if
(
b
==
null
)
return
a
;
if
(
a
>
b
)
return
a
;
return
b
;
}
/// A convenient accessor to frequently used finders.
///
/// Examples:
...
...
@@ -334,7 +325,7 @@ class FlutterDriver {
// register it. If that happens, show a message but continue waiting.
await
_warnIfSlow
<
String
>(
future:
whenServiceExtensionReady
,
timeout:
_
kUnusuallyLongTimeout
,
timeout:
kUnusuallyLongTimeout
,
message:
'Flutter Driver extension is taking a long time to become available. '
'Ensure your test app (often "lib/main.dart") imports '
'"package:flutter_driver/driver_extension.dart" and '
...
...
@@ -416,7 +407,7 @@ class FlutterDriver {
).
then
<
Map
<
String
,
dynamic
>>((
Object
value
)
=>
value
);
response
=
await
_warnIfSlow
<
Map
<
String
,
dynamic
>>(
future:
future
,
timeout:
_maxDuration
(
command
.
timeout
,
_kUnusuallyLongTimeout
)
,
timeout:
command
.
timeout
??
kUnusuallyLongTimeout
,
message:
'
${command.kind}
message is taking a long time to complete...'
,
);
_logCommunication
(
'<<<
$response
'
);
...
...
@@ -736,7 +727,7 @@ class FlutterDriver {
/// operation.
Future
<
void
>
startTracing
({
List
<
TimelineStream
>
streams
=
_defaultStreams
,
Duration
timeout
=
_
kUnusuallyLongTimeout
,
Duration
timeout
=
kUnusuallyLongTimeout
,
})
async
{
assert
(
streams
!=
null
&&
streams
.
isNotEmpty
);
assert
(
timeout
!=
null
);
...
...
@@ -763,7 +754,7 @@ class FlutterDriver {
/// operation exceeds the specified timeout; it does not actually cancel the
/// operation.
Future
<
Timeline
>
stopTracingAndDownloadTimeline
({
Duration
timeout
=
_
kUnusuallyLongTimeout
,
Duration
timeout
=
kUnusuallyLongTimeout
,
})
async
{
assert
(
timeout
!=
null
);
try
{
...
...
@@ -832,7 +823,7 @@ class FlutterDriver {
/// operation exceeds the specified timeout; it does not actually cancel the
/// operation.
Future
<
void
>
clearTimeline
({
Duration
timeout
=
_
kUnusuallyLongTimeout
,
Duration
timeout
=
kUnusuallyLongTimeout
,
})
async
{
assert
(
timeout
!=
null
);
try
{
...
...
packages/flutter_driver/test/flutter_driver_test.dart
View file @
d53115ab
...
...
@@ -386,7 +386,7 @@ void main() {
});
group
(
'sendCommand error conditions'
,
()
{
test
(
'local timeout'
,
()
async
{
test
(
'local
default
timeout'
,
()
async
{
final
List
<
String
>
log
=
<
String
>[];
final
StreamSubscription
<
LogRecord
>
logSub
=
flutterDriverLog
.
listen
((
LogRecord
s
)
=>
log
.
add
(
s
.
toString
()));
when
(
mockIsolate
.
invokeExtension
(
any
,
any
)).
thenAnswer
((
Invocation
i
)
{
...
...
@@ -396,7 +396,24 @@ void main() {
FakeAsync
().
run
((
FakeAsync
time
)
{
driver
.
waitFor
(
find
.
byTooltip
(
'foo'
));
expect
(
log
,
<
String
>[]);
time
.
elapse
(
const
Duration
(
hours:
1
));
time
.
elapse
(
kUnusuallyLongTimeout
);
});
expect
(
log
,
<
String
>[
'[warning] FlutterDriver: waitFor message is taking a long time to complete...'
]);
await
logSub
.
cancel
();
});
test
(
'local custom timeout'
,
()
async
{
final
List
<
String
>
log
=
<
String
>[];
final
StreamSubscription
<
LogRecord
>
logSub
=
flutterDriverLog
.
listen
((
LogRecord
s
)
=>
log
.
add
(
s
.
toString
()));
when
(
mockIsolate
.
invokeExtension
(
any
,
any
)).
thenAnswer
((
Invocation
i
)
{
// completer never completed to trigger timeout
return
Completer
<
Map
<
String
,
dynamic
>>().
future
;
});
FakeAsync
().
run
((
FakeAsync
time
)
{
final
Duration
customTimeout
=
kUnusuallyLongTimeout
-
const
Duration
(
seconds:
1
);
driver
.
waitFor
(
find
.
byTooltip
(
'foo'
),
timeout:
customTimeout
);
expect
(
log
,
<
String
>[]);
time
.
elapse
(
customTimeout
);
});
expect
(
log
,
<
String
>[
'[warning] FlutterDriver: waitFor message is taking a long time to complete...'
]);
await
logSub
.
cancel
();
...
...
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