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
586ab30c
Commit
586ab30c
authored
Feb 24, 2016
by
Yegor
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2126 from yjbanov/sample-driver-test-waits
wait for text to change in the sample driver test
parents
ccc9a25a
d2c94990
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
27 deletions
+64
-27
retry.dart
packages/flutter_driver/lib/src/retry.dart
+12
-1
retry_test.dart
packages/flutter_driver/test/retry_test.dart
+43
-22
e2e_test.dart.tmpl
packages/flutter_tools/templates/driver/e2e_test.dart.tmpl
+9
-4
No files found.
packages/flutter_driver/lib/src/retry.dart
View file @
586ab30c
...
...
@@ -19,7 +19,7 @@ Future<dynamic> retry(Action action, Duration timeout,
assert
(
timeout
!=
null
);
assert
(
pauseBetweenRetries
!=
null
);
Stopwatch
sw
=
new
Stopwatch
()..
start
();
Stopwatch
sw
=
stopwatchFactory
()..
start
();
dynamic
result
=
null
;
dynamic
lastError
=
null
;
dynamic
lastStackTrace
=
null
;
...
...
@@ -43,3 +43,14 @@ Future<dynamic> retry(Action action, Duration timeout,
else
return
new
Future
.
error
(
lastError
,
lastStackTrace
);
}
/// A function that produces a [Stopwatch].
typedef
Stopwatch
StopwatchFactory
(
);
/// Restores [stopwatchFactory] to the default implementation.
void
restoreStopwatchFactory
(
)
{
stopwatchFactory
=
()
=>
new
Stopwatch
();
}
/// Used by [retry] as a source of [Stopwatch] implementation.
StopwatchFactory
stopwatchFactory
=
()
=>
new
Stopwatch
();
packages/flutter_driver/test/retry_test.dart
View file @
586ab30c
...
...
@@ -3,14 +3,29 @@
// found in the LICENSE file.
import
'package:test/test.dart'
;
import
'package:quiver/time.dart'
;
import
'package:quiver/testing/async.dart'
;
import
'package:quiver/testing/time.dart'
;
import
'package:flutter_driver/src/retry.dart'
;
main
()
{
group
(
'retry'
,
()
{
FakeAsync
fakeAsync
;
setUp
(()
{
fakeAsync
=
new
FakeAsync
();
Clock
fakeClock
=
fakeAsync
.
getClock
(
new
DateTime
.
now
());
stopwatchFactory
=
()
{
return
new
FakeStopwatch
(
()
=>
fakeClock
.
now
().
millisecondsSinceEpoch
,
1000
);
};
});
test
(
'retries until succeeds'
,
()
{
new
FakeAsync
().
run
((
FakeAsync
fakeAsync
)
{
fakeAsync
.
run
((
_
)
{
int
retryCount
=
0
;
expect
(
...
...
@@ -37,17 +52,18 @@ main() {
});
test
(
'times out returning last error'
,
()
async
{
fakeAsync
.
run
((
_
)
{
bool
timedOut
=
false
;
int
retryCount
=
0
;
dynamic
lastError
;
dynamic
lastStackTrace
;
await
retry
(
retry
(
()
{
retryCount
++;
throw
'error'
;
},
new
Duration
(
milliseconds:
9
),
new
Duration
(
milliseconds:
7
),
new
Duration
(
milliseconds:
2
)
).
catchError
((
error
,
stackTrace
)
{
timedOut
=
true
;
...
...
@@ -55,10 +71,15 @@ main() {
lastStackTrace
=
stackTrace
;
});
print
(
'before elapse'
);
fakeAsync
.
elapse
(
new
Duration
(
milliseconds:
10
));
print
(
'after elapse'
);
expect
(
timedOut
,
isTrue
);
expect
(
lastError
,
'error'
);
expect
(
lastStackTrace
,
isNotNull
);
expect
(
retryCount
,
4
);
},
skip:
"Flaky. See https://github.com/flutter/flutter/issues/2133"
);
});
});
});
}
packages/flutter_tools/templates/driver/e2e_test.dart.tmpl
View file @
586ab30c
...
...
@@ -32,13 +32,18 @@ main() {
});
test('tap on the floating action button; verify counter', () async {
// Find floating action button (fab) to tap on
ObjectRef fab = await driver.findByValueKey('fab');
expect(fab, isNotNull);
// Tap on the fab
await driver.tap(fab);
// Wait for text to change to the desired value
await driver.waitFor(() async {
ObjectRef counter = await driver.findByValueKey('counter');
expect(counter, isNotNull);
String text = await driver.getText(counter);
expect(text, contains("Button tapped 1 times."));
return await driver.getText(counter);
}, contains("Button tapped 1 times."));
});
});
}
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