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
cdeb83cf
Commit
cdeb83cf
authored
Mar 04, 2017
by
Chris Bracken
Committed by
GitHub
Mar 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Declare locals as final where not reassigned (flutter_driver) (#8567)
parent
e0c51480
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
81 additions
and
81 deletions
+81
-81
driver.dart
packages/flutter_driver/lib/src/driver.dart
+14
-14
error.dart
packages/flutter_driver/lib/src/error.dart
+1
-1
extension.dart
packages/flutter_driver/lib/src/extension.dart
+31
-31
find.dart
packages/flutter_driver/lib/src/find.dart
+3
-3
input.dart
packages/flutter_driver/lib/src/input.dart
+1
-1
matcher_util.dart
packages/flutter_driver/lib/src/matcher_util.dart
+2
-2
retry.dart
packages/flutter_driver/lib/src/retry.dart
+1
-1
timeline.dart
packages/flutter_driver/lib/src/timeline.dart
+1
-1
timeline_summary.dart
packages/flutter_driver/lib/src/timeline_summary.dart
+7
-7
flutter_driver_test.dart
packages/flutter_driver/test/flutter_driver_test.dart
+8
-8
matcher_util_test.dart
packages/flutter_driver/test/src/matcher_util_test.dart
+4
-4
retry_test.dart
packages/flutter_driver/test/src/retry_test.dart
+1
-1
timeline_summary_test.dart
packages/flutter_driver/test/src/timeline_summary_test.dart
+4
-4
timeline_test.dart
packages/flutter_driver/test/src/timeline_test.dart
+3
-3
No files found.
packages/flutter_driver/lib/src/driver.dart
View file @
cdeb83cf
...
...
@@ -139,9 +139,9 @@ class FlutterDriver {
// Connect to Dart VM servcies
_log
.
info
(
'Connecting to Flutter application at
$dartVmServiceUrl
'
);
VMServiceClientConnection
connection
=
await
vmServiceConnectFunction
(
dartVmServiceUrl
);
VMServiceClient
client
=
connection
.
client
;
VM
vm
=
await
client
.
getVM
();
final
VMServiceClientConnection
connection
=
await
vmServiceConnectFunction
(
dartVmServiceUrl
);
final
VMServiceClient
client
=
connection
.
client
;
final
VM
vm
=
await
client
.
getVM
();
_log
.
trace
(
'Looking for the isolate'
);
VMIsolate
isolate
=
await
vm
.
isolates
.
first
.
loadRunnable
();
...
...
@@ -162,7 +162,7 @@ class FlutterDriver {
isolate
=
await
vm
.
isolates
.
first
.
loadRunnable
();
}
FlutterDriver
driver
=
new
FlutterDriver
.
connectedTo
(
final
FlutterDriver
driver
=
new
FlutterDriver
.
connectedTo
(
client
,
connection
.
peer
,
isolate
,
printCommunication:
printCommunication
,
logCommunicationToFile:
logCommunicationToFile
...
...
@@ -203,8 +203,8 @@ class FlutterDriver {
// 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.
Future
<
dynamic
>
whenResumed
=
resumeLeniently
();
Future
<
dynamic
>
whenServiceExtensionReady
=
Future
.
any
<
dynamic
>(<
Future
<
dynamic
>>[
final
Future
<
dynamic
>
whenResumed
=
resumeLeniently
();
final
Future
<
dynamic
>
whenServiceExtensionReady
=
Future
.
any
<
dynamic
>(<
Future
<
dynamic
>>[
waitForServiceExtension
(),
// We will never receive the extension event if the user does not
// register it. If that happens time out.
...
...
@@ -212,7 +212,7 @@ class FlutterDriver {
]);
await
whenResumed
;
_log
.
trace
(
'Waiting for service extension'
);
dynamic
signal
=
await
whenServiceExtensionReady
;
final
dynamic
signal
=
await
whenServiceExtensionReady
;
if
(
signal
==
'timeout'
)
{
throw
new
DriverError
(
'Timed out waiting for Flutter Driver extension to become available. '
...
...
@@ -239,7 +239,7 @@ class FlutterDriver {
}
// At this point the service extension must be installed. Verify it.
Health
health
=
await
driver
.
checkHealth
();
final
Health
health
=
await
driver
.
checkHealth
();
if
(
health
.
status
!=
HealthStatus
.
ok
)
{
await
client
.
close
();
throw
new
DriverError
(
'Flutter application health check failed.'
);
...
...
@@ -265,7 +265,7 @@ class FlutterDriver {
Future
<
Map
<
String
,
dynamic
>>
_sendCommand
(
Command
command
)
async
{
Map
<
String
,
dynamic
>
response
;
try
{
Map
<
String
,
String
>
serialized
=
command
.
serialize
();
final
Map
<
String
,
String
>
serialized
=
command
.
serialize
();
_logCommunication
(
'>>>
$serialized
'
);
response
=
await
_appIsolate
.
invokeExtension
(
_kFlutterExtensionMethod
,
serialized
)
...
...
@@ -293,7 +293,7 @@ class FlutterDriver {
if
(
_printCommunication
)
_log
.
info
(
message
);
if
(
_logCommunicationToFile
)
{
f
.
File
file
=
fs
.
file
(
p
.
join
(
testOutputsDirectory
,
'flutter_driver_commands_
$_driverId
.log'
));
f
inal
f
.
File
file
=
fs
.
file
(
p
.
join
(
testOutputsDirectory
,
'flutter_driver_commands_
$_driverId
.log'
));
file
.
createSync
(
recursive:
true
);
// no-op if file exists
file
.
writeAsStringSync
(
'
${new DateTime.now()}
$message
\n
'
,
mode:
f
.
FileMode
.
APPEND
,
flush:
true
);
}
...
...
@@ -329,7 +329,7 @@ class FlutterDriver {
/// This command invokes the `onSubmitted` handler of the `Input` widget and
/// the returns the submitted text value.
Future
<
String
>
submitInputText
(
SerializableFinder
finder
)
async
{
Map
<
String
,
dynamic
>
json
=
await
_sendCommand
(
new
SubmitInputText
(
finder
));
final
Map
<
String
,
dynamic
>
json
=
await
_sendCommand
(
new
SubmitInputText
(
finder
));
return
json
[
'text'
];
}
...
...
@@ -378,7 +378,7 @@ class FlutterDriver {
/// Take a screenshot. The image will be returned as a PNG.
Future
<
List
<
int
>>
screenshot
()
async
{
Map
<
String
,
dynamic
>
result
=
await
_peer
.
sendRequest
(
'_flutter.screenshot'
);
final
Map
<
String
,
dynamic
>
result
=
await
_peer
.
sendRequest
(
'_flutter.screenshot'
);
return
BASE64
.
decode
(
result
[
'screenshot'
]);
}
...
...
@@ -402,7 +402,7 @@ class FlutterDriver {
///
/// [getFlagList]: https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#getflaglist
Future
<
List
<
Map
<
String
,
dynamic
>>>
getVmFlags
()
async
{
Map
<
String
,
dynamic
>
result
=
await
_peer
.
sendRequest
(
'getFlagList'
);
final
Map
<
String
,
dynamic
>
result
=
await
_peer
.
sendRequest
(
'getFlagList'
);
return
result
[
'flags'
];
}
...
...
@@ -525,7 +525,7 @@ void restoreVmServiceConnectFunction() {
///
/// Times out after 30 seconds.
Future
<
VMServiceClientConnection
>
_waitAndConnect
(
String
url
)
async
{
Stopwatch
timer
=
new
Stopwatch
()..
start
();
final
Stopwatch
timer
=
new
Stopwatch
()..
start
();
Future
<
VMServiceClientConnection
>
attemptConnection
()
async
{
Uri
uri
=
Uri
.
parse
(
url
);
...
...
packages/flutter_driver/lib/src/error.dart
View file @
cdeb83cf
...
...
@@ -39,7 +39,7 @@ final StreamController<LogRecord> _logger =
});
void
_log
(
LogLevel
level
,
String
loggerName
,
Object
message
)
{
LogRecord
record
=
new
LogRecord
.
_
(
level
,
loggerName
,
'
$message
'
);
final
LogRecord
record
=
new
LogRecord
.
_
(
level
,
loggerName
,
'
$message
'
);
// If nobody expressed interest in rerouting log messages somewhere specific,
// print them to stderr.
if
(
_noLogSubscribers
)
...
...
packages/flutter_driver/lib/src/extension.dart
View file @
cdeb83cf
...
...
@@ -29,7 +29,7 @@ class _DriverBinding extends WidgetsFlutterBinding { // TODO(ianh): refactor so
@override
void
initServiceExtensions
()
{
super
.
initServiceExtensions
();
FlutterDriverExtension
extension
=
new
FlutterDriverExtension
();
final
FlutterDriverExtension
extension
=
new
FlutterDriverExtension
();
registerServiceExtension
(
name:
_extensionMethodName
,
callback:
extension
.
call
...
...
@@ -119,22 +119,22 @@ class FlutterDriverExtension {
/// The returned JSON is command specific. Generally the caller deserializes
/// the result into a subclass of [Result], but that's not strictly required.
Future
<
Map
<
String
,
dynamic
>>
call
(
Map
<
String
,
String
>
params
)
async
{
String
commandKind
=
params
[
'command'
];
final
String
commandKind
=
params
[
'command'
];
try
{
CommandHandlerCallback
commandHandler
=
_commandHandlers
[
commandKind
];
CommandDeserializerCallback
commandDeserializer
=
final
CommandHandlerCallback
commandHandler
=
_commandHandlers
[
commandKind
];
final
CommandDeserializerCallback
commandDeserializer
=
_commandDeserializers
[
commandKind
];
if
(
commandHandler
==
null
||
commandDeserializer
==
null
)
throw
'Extension
$_extensionMethod
does not support command
$commandKind
'
;
Command
command
=
commandDeserializer
(
params
);
Result
response
=
await
commandHandler
(
command
).
timeout
(
command
.
timeout
);
final
Command
command
=
commandDeserializer
(
params
);
final
Result
response
=
await
commandHandler
(
command
).
timeout
(
command
.
timeout
);
return
_makeResponse
(
response
?.
toJson
());
}
on
TimeoutException
catch
(
error
,
stackTrace
)
{
String
msg
=
'Timeout while executing
$commandKind
:
$error
\n
$stackTrace
'
;
final
String
msg
=
'Timeout while executing
$commandKind
:
$error
\n
$stackTrace
'
;
_log
.
error
(
msg
);
return
_makeResponse
(
msg
,
isError:
true
);
}
catch
(
error
,
stackTrace
)
{
String
msg
=
'Uncaught extension error while executing
$commandKind
:
$error
\n
$stackTrace
'
;
final
String
msg
=
'Uncaught extension error while executing
$commandKind
:
$error
\n
$stackTrace
'
;
_log
.
error
(
msg
);
return
_makeResponse
(
msg
,
isError:
true
);
}
...
...
@@ -185,7 +185,7 @@ class FlutterDriverExtension {
Finder
_createByTooltipMessageFinder
(
ByTooltipMessage
arguments
)
{
return
find
.
byElementPredicate
((
Element
element
)
{
Widget
widget
=
element
.
widget
;
final
Widget
widget
=
element
.
widget
;
if
(
widget
is
Tooltip
)
return
widget
.
message
==
arguments
.
text
;
return
false
;
...
...
@@ -204,7 +204,7 @@ class FlutterDriverExtension {
}
Finder
_createFinder
(
SerializableFinder
finder
)
{
FinderConstructor
constructor
=
_finders
[
finder
.
finderType
];
final
FinderConstructor
constructor
=
_finders
[
finder
.
finderType
];
if
(
constructor
==
null
)
throw
'Unsupported finder type:
${finder.finderType}
'
;
...
...
@@ -213,13 +213,13 @@ class FlutterDriverExtension {
}
Future
<
TapResult
>
_tap
(
Command
command
)
async
{
Tap
tapCommand
=
command
;
final
Tap
tapCommand
=
command
;
await
_prober
.
tap
(
await
_waitForElement
(
_createFinder
(
tapCommand
.
finder
)));
return
new
TapResult
();
}
Future
<
WaitForResult
>
_waitFor
(
Command
command
)
async
{
WaitFor
waitForCommand
=
command
;
final
WaitFor
waitForCommand
=
command
;
if
((
await
_waitForElement
(
_createFinder
(
waitForCommand
.
finder
))).
evaluate
().
isNotEmpty
)
return
new
WaitForResult
();
else
...
...
@@ -232,15 +232,15 @@ class FlutterDriverExtension {
}
Future
<
ScrollResult
>
_scroll
(
Command
command
)
async
{
Scroll
scrollCommand
=
command
;
Finder
target
=
await
_waitForElement
(
_createFinder
(
scrollCommand
.
finder
));
final
Scroll
scrollCommand
=
command
;
final
Finder
target
=
await
_waitForElement
(
_createFinder
(
scrollCommand
.
finder
));
final
int
totalMoves
=
scrollCommand
.
duration
.
inMicroseconds
*
scrollCommand
.
frequency
~/
Duration
.
MICROSECONDS_PER_SECOND
;
Offset
delta
=
new
Offset
(
scrollCommand
.
dx
,
scrollCommand
.
dy
)
/
totalMoves
.
toDouble
();
Duration
pause
=
scrollCommand
.
duration
~/
totalMoves
;
Point
startLocation
=
_prober
.
getCenter
(
target
);
final
Offset
delta
=
new
Offset
(
scrollCommand
.
dx
,
scrollCommand
.
dy
)
/
totalMoves
.
toDouble
();
final
Duration
pause
=
scrollCommand
.
duration
~/
totalMoves
;
final
Point
startLocation
=
_prober
.
getCenter
(
target
);
Point
currentLocation
=
startLocation
;
TestPointer
pointer
=
new
TestPointer
(
1
);
HitTestResult
hitTest
=
new
HitTestResult
();
final
TestPointer
pointer
=
new
TestPointer
(
1
);
final
HitTestResult
hitTest
=
new
HitTestResult
();
_prober
.
binding
.
hitTest
(
hitTest
,
startLocation
);
_prober
.
binding
.
dispatchEvent
(
pointer
.
down
(
startLocation
),
hitTest
);
...
...
@@ -256,38 +256,38 @@ class FlutterDriverExtension {
}
Future
<
ScrollResult
>
_scrollIntoView
(
Command
command
)
async
{
ScrollIntoView
scrollIntoViewCommand
=
command
;
Finder
target
=
await
_waitForElement
(
_createFinder
(
scrollIntoViewCommand
.
finder
));
final
ScrollIntoView
scrollIntoViewCommand
=
command
;
final
Finder
target
=
await
_waitForElement
(
_createFinder
(
scrollIntoViewCommand
.
finder
));
await
Scrollable
.
ensureVisible
(
target
.
evaluate
().
single
,
duration:
const
Duration
(
milliseconds:
100
),
alignment:
scrollIntoViewCommand
.
alignment
??
0.0
);
return
new
ScrollResult
();
}
Future
<
SetInputTextResult
>
_setInputText
(
Command
command
)
async
{
SetInputText
setInputTextCommand
=
command
;
Finder
target
=
await
_waitForElement
(
_createFinder
(
setInputTextCommand
.
finder
));
Input
input
=
target
.
evaluate
().
single
.
widget
;
final
SetInputText
setInputTextCommand
=
command
;
final
Finder
target
=
await
_waitForElement
(
_createFinder
(
setInputTextCommand
.
finder
));
final
Input
input
=
target
.
evaluate
().
single
.
widget
;
input
.
onChanged
(
new
InputValue
(
text:
setInputTextCommand
.
text
));
return
new
SetInputTextResult
();
}
Future
<
SubmitInputTextResult
>
_submitInputText
(
Command
command
)
async
{
SubmitInputText
submitInputTextCommand
=
command
;
Finder
target
=
await
_waitForElement
(
_createFinder
(
submitInputTextCommand
.
finder
));
Input
input
=
target
.
evaluate
().
single
.
widget
;
final
SubmitInputText
submitInputTextCommand
=
command
;
final
Finder
target
=
await
_waitForElement
(
_createFinder
(
submitInputTextCommand
.
finder
));
final
Input
input
=
target
.
evaluate
().
single
.
widget
;
input
.
onSubmitted
(
input
.
value
);
return
new
SubmitInputTextResult
(
input
.
value
.
text
);
}
Future
<
GetTextResult
>
_getText
(
Command
command
)
async
{
GetText
getTextCommand
=
command
;
Finder
target
=
await
_waitForElement
(
_createFinder
(
getTextCommand
.
finder
));
final
GetText
getTextCommand
=
command
;
final
Finder
target
=
await
_waitForElement
(
_createFinder
(
getTextCommand
.
finder
));
// TODO(yjbanov): support more ways to read text
Text
text
=
target
.
evaluate
().
single
.
widget
;
final
Text
text
=
target
.
evaluate
().
single
.
widget
;
return
new
GetTextResult
(
text
.
data
);
}
Future
<
SetFrameSyncResult
>
_setFrameSync
(
Command
command
)
async
{
SetFrameSync
setFrameSyncCommand
=
command
;
final
SetFrameSync
setFrameSyncCommand
=
command
;
_frameSync
=
setFrameSyncCommand
.
enabled
;
return
new
SetFrameSyncResult
();
}
...
...
packages/flutter_driver/lib/src/find.dart
View file @
cdeb83cf
...
...
@@ -92,7 +92,7 @@ abstract class SerializableFinder {
/// Deserializes a finder from JSON generated by [serialize].
static
SerializableFinder
deserialize
(
Map
<
String
,
String
>
json
)
{
String
finderType
=
json
[
'finderType'
];
final
String
finderType
=
json
[
'finderType'
];
switch
(
finderType
)
{
case
'ByValueKey'
:
return
ByValueKey
.
deserialize
(
json
);
case
'ByTooltipMessage'
:
return
ByTooltipMessage
.
deserialize
(
json
);
...
...
@@ -188,8 +188,8 @@ class ByValueKey extends SerializableFinder {
/// Deserializes the finder from JSON generated by [serialize].
static
ByValueKey
deserialize
(
Map
<
String
,
String
>
json
)
{
String
keyValueString
=
json
[
'keyValueString'
];
String
keyValueType
=
json
[
'keyValueType'
];
final
String
keyValueString
=
json
[
'keyValueString'
];
final
String
keyValueType
=
json
[
'keyValueType'
];
switch
(
keyValueType
)
{
case
'int'
:
return
new
ByValueKey
(
int
.
parse
(
keyValueString
));
...
...
packages/flutter_driver/lib/src/input.dart
View file @
cdeb83cf
...
...
@@ -26,7 +26,7 @@ class SetInputText extends CommandWithTarget {
@override
Map
<
String
,
String
>
serialize
()
{
Map
<
String
,
String
>
json
=
super
.
serialize
();
final
Map
<
String
,
String
>
json
=
super
.
serialize
();
json
[
'text'
]
=
text
;
return
json
;
}
...
...
packages/flutter_driver/lib/src/matcher_util.dart
View file @
cdeb83cf
...
...
@@ -6,11 +6,11 @@ import 'package:matcher/matcher.dart';
/// Matches [value] against the [matcher].
MatchResult
match
(
dynamic
value
,
Matcher
matcher
)
{
Map
<
dynamic
,
dynamic
>
matchState
=
<
dynamic
,
dynamic
>{};
final
Map
<
dynamic
,
dynamic
>
matchState
=
<
dynamic
,
dynamic
>{};
if
(
matcher
.
matches
(
value
,
matchState
))
{
return
new
MatchResult
.
_matched
();
}
else
{
Description
description
=
final
Description
description
=
matcher
.
describeMismatch
(
value
,
new
_TextDescription
(),
matchState
,
false
);
return
new
MatchResult
.
_mismatched
(
description
.
toString
());
}
...
...
packages/flutter_driver/lib/src/retry.dart
View file @
cdeb83cf
...
...
@@ -23,7 +23,7 @@ Future<dynamic> retry(Action action, Duration timeout,
assert
(
timeout
!=
null
);
assert
(
pauseBetweenRetries
!=
null
);
Stopwatch
sw
=
stopwatchFactory
()..
start
();
final
Stopwatch
sw
=
stopwatchFactory
()..
start
();
dynamic
result
;
dynamic
lastError
;
dynamic
lastStackTrace
;
...
...
packages/flutter_driver/lib/src/timeline.dart
View file @
cdeb83cf
...
...
@@ -122,7 +122,7 @@ class TimelineEvent {
}
List
<
TimelineEvent
>
_parseEvents
(
Map
<
String
,
dynamic
>
json
)
{
List
<
Map
<
String
,
dynamic
>>
jsonEvents
=
json
[
'traceEvents'
];
final
List
<
Map
<
String
,
dynamic
>>
jsonEvents
=
json
[
'traceEvents'
];
if
(
jsonEvents
==
null
)
return
null
;
...
...
packages/flutter_driver/lib/src/timeline_summary.dart
View file @
cdeb83cf
...
...
@@ -93,7 +93,7 @@ class TimelineSummary {
{
String
destinationDirectory
,
bool
pretty:
false
})
async
{
destinationDirectory
??=
testOutputsDirectory
;
await
fs
.
directory
(
destinationDirectory
).
create
(
recursive:
true
);
File
file
=
fs
.
file
(
path
.
join
(
destinationDirectory
,
'
$traceName
.timeline.json'
));
final
File
file
=
fs
.
file
(
path
.
join
(
destinationDirectory
,
'
$traceName
.timeline.json'
));
await
file
.
writeAsString
(
_encodeJson
(
_timeline
.
json
,
pretty
));
}
...
...
@@ -102,7 +102,7 @@ class TimelineSummary {
{
String
destinationDirectory
,
bool
pretty:
false
})
async
{
destinationDirectory
??=
testOutputsDirectory
;
await
fs
.
directory
(
destinationDirectory
).
create
(
recursive:
true
);
File
file
=
fs
.
file
(
path
.
join
(
destinationDirectory
,
'
$traceName
.timeline_summary.json'
));
final
File
file
=
fs
.
file
(
path
.
join
(
destinationDirectory
,
'
$traceName
.timeline_summary.json'
));
await
file
.
writeAsString
(
_encodeJson
(
summaryJson
,
pretty
));
}
...
...
@@ -127,15 +127,15 @@ class TimelineSummary {
///
/// See: https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU
List
<
TimedEvent
>
_extractBeginEndEvents
(
String
name
)
{
List
<
TimedEvent
>
result
=
<
TimedEvent
>[];
final
List
<
TimedEvent
>
result
=
<
TimedEvent
>[];
// Timeline does not guarantee that the first event is the "begin" event.
Iterator
<
TimelineEvent
>
events
=
_extractNamedEvents
(
name
)
final
Iterator
<
TimelineEvent
>
events
=
_extractNamedEvents
(
name
)
.
skipWhile
((
TimelineEvent
evt
)
=>
evt
.
phase
!=
'B'
).
iterator
;
while
(
events
.
moveNext
())
{
TimelineEvent
beginEvent
=
events
.
current
;
final
TimelineEvent
beginEvent
=
events
.
current
;
if
(
events
.
moveNext
())
{
TimelineEvent
endEvent
=
events
.
current
;
final
TimelineEvent
endEvent
=
events
.
current
;
result
.
add
(
new
TimedEvent
(
beginEvent
.
timestampMicros
,
endEvent
.
timestampMicros
...
...
@@ -150,7 +150,7 @@ class TimelineSummary {
if
(
durations
.
isEmpty
)
return
null
;
int
total
=
durations
.
fold
<
int
>(
0
,
(
int
t
,
Duration
duration
)
=>
t
+
duration
.
inMilliseconds
);
final
int
total
=
durations
.
fold
<
int
>(
0
,
(
int
t
,
Duration
duration
)
=>
t
+
duration
.
inMilliseconds
);
return
total
/
durations
.
length
;
}
...
...
packages/flutter_driver/test/flutter_driver_test.dart
View file @
cdeb83cf
...
...
@@ -53,7 +53,7 @@ void main() {
when
(
mockIsolate
.
resume
()).
thenReturn
(
new
Future
<
Null
>.
value
());
when
(
mockIsolate
.
onExtensionAdded
).
thenReturn
(
new
Stream
<
String
>.
fromIterable
(<
String
>[
'ext.flutter.driver'
]));
FlutterDriver
driver
=
await
FlutterDriver
.
connect
(
dartVmServiceUrl:
''
);
final
FlutterDriver
driver
=
await
FlutterDriver
.
connect
(
dartVmServiceUrl:
''
);
expect
(
driver
,
isNotNull
);
expectLogContains
(
'Isolate is paused at start'
);
});
...
...
@@ -62,7 +62,7 @@ void main() {
when
(
mockIsolate
.
pauseEvent
).
thenReturn
(
new
MockVMPauseBreakpointEvent
());
when
(
mockIsolate
.
resume
()).
thenReturn
(
new
Future
<
Null
>.
value
());
FlutterDriver
driver
=
await
FlutterDriver
.
connect
(
dartVmServiceUrl:
''
);
final
FlutterDriver
driver
=
await
FlutterDriver
.
connect
(
dartVmServiceUrl:
''
);
expect
(
driver
,
isNotNull
);
expectLogContains
(
'Isolate is paused mid-flight'
);
});
...
...
@@ -79,14 +79,14 @@ void main() {
return
new
Future
<
Null
>.
error
(
new
rpc
.
RpcException
(
101
,
''
));
});
FlutterDriver
driver
=
await
FlutterDriver
.
connect
(
dartVmServiceUrl:
''
);
final
FlutterDriver
driver
=
await
FlutterDriver
.
connect
(
dartVmServiceUrl:
''
);
expect
(
driver
,
isNotNull
);
expectLogContains
(
'Attempted to resume an already resumed isolate'
);
});
test
(
'connects to unpaused isolate'
,
()
async
{
when
(
mockIsolate
.
pauseEvent
).
thenReturn
(
new
MockVMResumeEvent
());
FlutterDriver
driver
=
await
FlutterDriver
.
connect
(
dartVmServiceUrl:
''
);
final
FlutterDriver
driver
=
await
FlutterDriver
.
connect
(
dartVmServiceUrl:
''
);
expect
(
driver
,
isNotNull
);
expectLogContains
(
'Isolate is not paused. Assuming application is ready.'
);
});
...
...
@@ -108,7 +108,7 @@ void main() {
test
(
'checks the health of the driver extension'
,
()
async
{
when
(
mockIsolate
.
invokeExtension
(
any
,
any
)).
thenReturn
(
makeMockResponse
(<
String
,
dynamic
>{
'status'
:
'ok'
}));
Health
result
=
await
driver
.
checkHealth
();
final
Health
result
=
await
driver
.
checkHealth
();
expect
(
result
.
status
,
HealthStatus
.
ok
);
});
...
...
@@ -175,7 +175,7 @@ void main() {
'text'
:
'hello'
});
});
String
result
=
await
driver
.
getText
(
find
.
byValueKey
(
123
));
final
String
result
=
await
driver
.
getText
(
find
.
byValueKey
(
123
));
expect
(
result
,
'hello'
);
});
});
...
...
@@ -240,7 +240,7 @@ void main() {
};
});
Timeline
timeline
=
await
driver
.
traceAction
(()
{
final
Timeline
timeline
=
await
driver
.
traceAction
(()
{
actionCalled
=
true
;
});
...
...
@@ -279,7 +279,7 @@ void main() {
};
});
Timeline
timeline
=
await
driver
.
traceAction
(()
{
final
Timeline
timeline
=
await
driver
.
traceAction
(()
{
actionCalled
=
true
;
},
streams:
const
<
TimelineStream
>[
...
...
packages/flutter_driver/test/src/matcher_util_test.dart
View file @
cdeb83cf
...
...
@@ -8,8 +8,8 @@ import 'package:flutter_driver/src/matcher_util.dart';
void
main
(
)
{
group
(
'match'
,
()
{
test
(
'matches'
,
()
{
_TestMatcher
matcher
=
new
_TestMatcher
(
1
);
MatchResult
ok
=
match
(
1
,
matcher
);
final
_TestMatcher
matcher
=
new
_TestMatcher
(
1
);
final
MatchResult
ok
=
match
(
1
,
matcher
);
expect
(
ok
.
hasMatched
,
isTrue
);
expect
(
ok
.
mismatchDescription
,
isNull
);
expect
(
matcher
.
matchState1
is
Map
<
dynamic
,
dynamic
>,
isTrue
);
...
...
@@ -17,8 +17,8 @@ void main() {
});
test
(
'mismatches'
,
()
{
_TestMatcher
matcher
=
new
_TestMatcher
(
2
);
MatchResult
fail
=
match
(
1
,
matcher
);
final
_TestMatcher
matcher
=
new
_TestMatcher
(
2
);
final
MatchResult
fail
=
match
(
1
,
matcher
);
expect
(
fail
.
hasMatched
,
isFalse
);
expect
(
fail
.
mismatchDescription
,
'mismatch!'
);
expect
(
matcher
.
matchState1
,
matcher
.
matchState2
);
...
...
packages/flutter_driver/test/src/retry_test.dart
View file @
cdeb83cf
...
...
@@ -15,7 +15,7 @@ void main() {
setUp
(()
{
fakeAsync
=
new
FakeAsync
();
Clock
fakeClock
=
fakeAsync
.
getClock
(
new
DateTime
.
now
());
final
Clock
fakeClock
=
fakeAsync
.
getClock
(
new
DateTime
.
now
());
stopwatchFactory
=
()
{
return
new
FakeStopwatch
(
()
=>
fakeClock
.
now
().
millisecondsSinceEpoch
,
...
...
packages/flutter_driver/test/src/timeline_summary_test.dart
View file @
cdeb83cf
...
...
@@ -84,7 +84,7 @@ void main() {
group
(
'computeMissedFrameBuildBudgetCount'
,
()
{
test
(
'computes the number of missed build budgets'
,
()
{
TimelineSummary
summary
=
summarize
(<
Map
<
String
,
dynamic
>>[
final
TimelineSummary
summary
=
summarize
(<
Map
<
String
,
dynamic
>>[
build
(
1000
,
9000
),
build
(
11000
,
1000
),
build
(
13000
,
10000
),
...
...
@@ -176,7 +176,7 @@ void main() {
group
(
'computeMissedFrameRasterizerBudgetCount'
,
()
{
test
(
'computes the number of missed rasterizer budgets'
,
()
{
TimelineSummary
summary
=
summarize
(<
Map
<
String
,
dynamic
>>[
final
TimelineSummary
summary
=
summarize
(<
Map
<
String
,
dynamic
>>[
begin
(
1000
),
end
(
10000
),
begin
(
11000
),
end
(
12000
),
begin
(
13000
),
end
(
23000
),
...
...
@@ -229,7 +229,7 @@ void main() {
test
(
'writes timeline to JSON file'
,
()
async
{
await
summarize
(<
Map
<
String
,
String
>>[<
String
,
String
>{
'foo'
:
'bar'
}])
.
writeTimelineToFile
(
'test'
,
destinationDirectory:
tempDir
.
path
);
String
written
=
final
String
written
=
await
fs
.
file
(
path
.
join
(
tempDir
.
path
,
'test.timeline.json'
)).
readAsString
();
expect
(
written
,
'{"traceEvents":[{"foo":"bar"}]}'
);
});
...
...
@@ -243,7 +243,7 @@ void main() {
build
(
11000
,
1000
),
build
(
13000
,
11000
),
]).
writeSummaryToFile
(
'test'
,
destinationDirectory:
tempDir
.
path
);
String
written
=
final
String
written
=
await
fs
.
file
(
path
.
join
(
tempDir
.
path
,
'test.timeline_summary.json'
)).
readAsString
();
expect
(
JSON
.
decode
(
written
),
<
String
,
dynamic
>{
'average_frame_build_time_millis'
:
7.0
,
...
...
packages/flutter_driver/test/src/timeline_test.dart
View file @
cdeb83cf
...
...
@@ -8,7 +8,7 @@ import 'package:flutter_driver/src/timeline.dart';
void
main
(
)
{
group
(
'Timeline'
,
()
{
test
(
'parses JSON'
,
()
{
Timeline
timeline
=
new
Timeline
.
fromJson
(<
String
,
dynamic
>{
final
Timeline
timeline
=
new
Timeline
.
fromJson
(<
String
,
dynamic
>{
'traceEvents'
:
<
Map
<
String
,
dynamic
>>[
<
String
,
dynamic
>{
'name'
:
'test event'
,
...
...
@@ -31,7 +31,7 @@ void main() {
expect
(
timeline
.
events
,
hasLength
(
2
));
TimelineEvent
e1
=
timeline
.
events
[
0
];
final
TimelineEvent
e1
=
timeline
.
events
[
0
];
expect
(
e1
.
name
,
'test event'
);
expect
(
e1
.
category
,
'test category'
);
expect
(
e1
.
phase
,
'B'
);
...
...
@@ -43,7 +43,7 @@ void main() {
expect
(
e1
.
threadTimestampMicros
,
567
);
expect
(
e1
.
arguments
,
<
String
,
dynamic
>{
'arg1'
:
true
});
TimelineEvent
e2
=
timeline
.
events
[
1
];
final
TimelineEvent
e2
=
timeline
.
events
[
1
];
expect
(
e2
.
name
,
isNull
);
expect
(
e2
.
category
,
isNull
);
expect
(
e2
.
phase
,
isNull
);
...
...
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