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
1d08642a
Commit
1d08642a
authored
Jan 10, 2020
by
Angjie Li
Committed by
Flutter GitHub Bot
Jan 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create helper functions to handle WebDriver actions. Some actions on base … (#48538)
parent
6397c022
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
37 deletions
+41
-37
driver.dart
packages/flutter_driver/lib/src/driver/driver.dart
+11
-11
web_driver.dart
packages/flutter_driver/lib/src/driver/web_driver.dart
+30
-26
No files found.
packages/flutter_driver/lib/src/driver/driver.dart
View file @
1d08642a
...
@@ -157,10 +157,10 @@ abstract class FlutterDriver {
...
@@ -157,10 +157,10 @@ abstract class FlutterDriver {
}
}
/// Getter of appIsolate
/// Getter of appIsolate
VMIsolate
get
appIsolate
;
VMIsolate
get
appIsolate
=>
throw
UnimplementedError
()
;
/// Getter of serviceClient
/// Getter of serviceClient
VMServiceClient
get
serviceClient
;
VMServiceClient
get
serviceClient
=>
throw
UnimplementedError
()
;
/// Sends [command] to the Flutter Driver extensions.
/// Sends [command] to the Flutter Driver extensions.
/// This must be implemented by subclass.
/// This must be implemented by subclass.
...
@@ -169,7 +169,7 @@ abstract class FlutterDriver {
...
@@ -169,7 +169,7 @@ abstract class FlutterDriver {
///
///
/// * [VMServiceFlutterDriver], which uses vmservice to implement.
/// * [VMServiceFlutterDriver], which uses vmservice to implement.
/// * [WebFlutterDriver], which uses webdriver to implement.
/// * [WebFlutterDriver], which uses webdriver to implement.
Future
<
Map
<
String
,
dynamic
>>
sendCommand
(
Command
command
);
Future
<
Map
<
String
,
dynamic
>>
sendCommand
(
Command
command
)
=>
throw
UnimplementedError
()
;
/// Checks the status of the Flutter Driver extension.
/// Checks the status of the Flutter Driver extension.
Future
<
Health
>
checkHealth
({
Duration
timeout
})
async
{
Future
<
Health
>
checkHealth
({
Duration
timeout
})
async
{
...
@@ -561,7 +561,7 @@ abstract class FlutterDriver {
...
@@ -561,7 +561,7 @@ abstract class FlutterDriver {
/// In practice, sometimes the device gets really busy for a while and
/// In practice, sometimes the device gets really busy for a while and
/// even two seconds isn't enough, which means that this is still racy
/// even two seconds isn't enough, which means that this is still racy
/// and a source of flakes.
/// and a source of flakes.
Future
<
List
<
int
>>
screenshot
();
Future
<
List
<
int
>>
screenshot
()
=>
throw
UnimplementedError
()
;
/// Returns the Flags set in the Dart VM as JSON.
/// Returns the Flags set in the Dart VM as JSON.
///
///
...
@@ -584,7 +584,7 @@ abstract class FlutterDriver {
...
@@ -584,7 +584,7 @@ abstract class FlutterDriver {
/// [getFlagList]: https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#getflaglist
/// [getFlagList]: https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#getflaglist
///
///
/// Throws [UnimplementedError] on [WebFlutterDriver] instances.
/// Throws [UnimplementedError] on [WebFlutterDriver] instances.
Future
<
List
<
Map
<
String
,
dynamic
>>>
getVmFlags
();
Future
<
List
<
Map
<
String
,
dynamic
>>>
getVmFlags
()
=>
throw
UnimplementedError
()
;
/// Starts recording performance traces.
/// Starts recording performance traces.
///
///
...
@@ -596,7 +596,7 @@ abstract class FlutterDriver {
...
@@ -596,7 +596,7 @@ abstract class FlutterDriver {
Future
<
void
>
startTracing
({
Future
<
void
>
startTracing
({
List
<
TimelineStream
>
streams
=
const
<
TimelineStream
>[
TimelineStream
.
all
],
List
<
TimelineStream
>
streams
=
const
<
TimelineStream
>[
TimelineStream
.
all
],
Duration
timeout
=
kUnusuallyLongTimeout
,
Duration
timeout
=
kUnusuallyLongTimeout
,
});
})
=>
throw
UnimplementedError
()
;
/// Stops recording performance traces and downloads the timeline.
/// Stops recording performance traces and downloads the timeline.
///
///
...
@@ -607,7 +607,7 @@ abstract class FlutterDriver {
...
@@ -607,7 +607,7 @@ abstract class FlutterDriver {
/// For [WebFlutterDriver], this is only supported for Chrome.
/// For [WebFlutterDriver], this is only supported for Chrome.
Future
<
Timeline
>
stopTracingAndDownloadTimeline
({
Future
<
Timeline
>
stopTracingAndDownloadTimeline
({
Duration
timeout
=
kUnusuallyLongTimeout
,
Duration
timeout
=
kUnusuallyLongTimeout
,
});
})
=>
throw
UnimplementedError
()
;
/// Runs [action] and outputs a performance trace for it.
/// Runs [action] and outputs a performance trace for it.
///
///
...
@@ -632,7 +632,7 @@ abstract class FlutterDriver {
...
@@ -632,7 +632,7 @@ abstract class FlutterDriver {
Future
<
dynamic
>
action
(),
{
Future
<
dynamic
>
action
(),
{
List
<
TimelineStream
>
streams
=
const
<
TimelineStream
>[
TimelineStream
.
all
],
List
<
TimelineStream
>
streams
=
const
<
TimelineStream
>[
TimelineStream
.
all
],
bool
retainPriorEvents
=
false
,
bool
retainPriorEvents
=
false
,
});
})
=>
throw
UnimplementedError
()
;
/// Clears all timeline events recorded up until now.
/// Clears all timeline events recorded up until now.
///
///
...
@@ -643,7 +643,7 @@ abstract class FlutterDriver {
...
@@ -643,7 +643,7 @@ abstract class FlutterDriver {
/// For [WebFlutterDriver], this is only supported for Chrome.
/// For [WebFlutterDriver], this is only supported for Chrome.
Future
<
void
>
clearTimeline
({
Future
<
void
>
clearTimeline
({
Duration
timeout
=
kUnusuallyLongTimeout
,
Duration
timeout
=
kUnusuallyLongTimeout
,
});
})
=>
throw
UnimplementedError
()
;
/// [action] will be executed with the frame sync mechanism disabled.
/// [action] will be executed with the frame sync mechanism disabled.
///
///
...
@@ -675,12 +675,12 @@ abstract class FlutterDriver {
...
@@ -675,12 +675,12 @@ abstract class FlutterDriver {
/// Force a garbage collection run in the VM.
/// Force a garbage collection run in the VM.
///
///
/// Throws [UnimplementedError] on [WebFlutterDriver] instances.
/// Throws [UnimplementedError] on [WebFlutterDriver] instances.
Future
<
void
>
forceGC
();
Future
<
void
>
forceGC
()
=>
throw
UnimplementedError
()
;
/// Closes the underlying connection to the VM service.
/// Closes the underlying connection to the VM service.
///
///
/// Returns a [Future] that fires once the connection has been closed.
/// Returns a [Future] that fires once the connection has been closed.
Future
<
void
>
close
();
Future
<
void
>
close
()
=>
throw
UnimplementedError
()
;
}
}
/// Provides convenient accessors to frequently used finders.
/// Provides convenient accessors to frequently used finders.
...
...
packages/flutter_driver/lib/src/driver/web_driver.dart
View file @
1d08642a
...
@@ -88,16 +88,6 @@ class WebFlutterDriver extends FlutterDriver {
...
@@ -88,16 +88,6 @@ class WebFlutterDriver extends FlutterDriver {
@override
@override
Future
<
void
>
close
()
=>
_connection
.
close
();
Future
<
void
>
close
()
=>
_connection
.
close
();
@override
Future
<
void
>
forceGC
()
async
{
throw
UnimplementedError
();
}
@override
Future
<
List
<
Map
<
String
,
Object
>>>
getVmFlags
()
async
{
throw
UnimplementedError
();
}
@override
@override
Future
<
void
>
waitUntilFirstFrameRasterized
()
async
{
Future
<
void
>
waitUntilFirstFrameRasterized
()
async
{
throw
UnimplementedError
();
throw
UnimplementedError
();
...
@@ -178,7 +168,8 @@ class WebFlutterDriver extends FlutterDriver {
...
@@ -178,7 +168,8 @@ class WebFlutterDriver extends FlutterDriver {
/// Encapsulates connection information to an instance of a Flutter Web application.
/// Encapsulates connection information to an instance of a Flutter Web application.
class
FlutterWebConnection
{
class
FlutterWebConnection
{
FlutterWebConnection
.
_
(
this
.
_driver
);
/// Creates a FlutterWebConnection with WebDriver
FlutterWebConnection
(
this
.
_driver
);
final
sync_io
.
WebDriver
_driver
;
final
sync_io
.
WebDriver
_driver
;
...
@@ -193,22 +184,10 @@ class FlutterWebConnection {
...
@@ -193,22 +184,10 @@ class FlutterWebConnection {
final
sync_io
.
WebDriver
driver
=
createDriver
(
settings
);
final
sync_io
.
WebDriver
driver
=
createDriver
(
settings
);
driver
.
get
(
url
);
driver
.
get
(
url
);
// Configure WebDriver browser by setting its location and dimension.
setDriverLocationAndDimension
(
driver
,
settings
);
final
List
<
String
>
dimensions
=
settings
[
'browser-dimension'
].
split
(
','
)
as
List
<
String
>;
if
(
dimensions
.
length
!=
2
)
{
throw
DriverError
(
'Invalid browser window size.'
);
}
final
int
x
=
int
.
parse
(
dimensions
[
0
]);
final
int
y
=
int
.
parse
(
dimensions
[
1
]);
final
sync_io
.
Window
window
=
driver
.
window
;
window
.
setLocation
(
const
math
.
Point
<
int
>(
0
,
0
));
window
.
setSize
(
math
.
Rectangle
<
int
>(
0
,
0
,
x
,
y
));
// Wait until extension is installed.
await
waitUntilExtensionInstalled
(
driver
,
timeout
);
await
waitFor
<
void
>(()
=>
driver
.
execute
(
'return typeof(window.
\
$flutterDriver
)'
,
<
String
>[]),
return
FlutterWebConnection
(
driver
);
matcher:
'function'
,
timeout:
timeout
??
const
Duration
(
days:
365
));
return
FlutterWebConnection
.
_
(
driver
);
}
}
/// Sends command via WebDriver to Flutter web application
/// Sends command via WebDriver to Flutter web application
...
@@ -248,3 +227,28 @@ class FlutterWebConnection {
...
@@ -248,3 +227,28 @@ class FlutterWebConnection {
_driver
.
quit
();
_driver
.
quit
();
}
}
}
}
/// Configures the location and dimension of WebDriver.
void
setDriverLocationAndDimension
(
sync_io
.
WebDriver
driver
,
Map
<
String
,
dynamic
>
settings
)
{
final
List
<
String
>
dimensions
=
settings
[
'browser-dimension'
].
split
(
','
)
as
List
<
String
>;
if
(
dimensions
.
length
!=
2
)
{
throw
DriverError
(
'Invalid browser window size.'
);
}
final
int
x
=
int
.
parse
(
dimensions
[
0
]);
final
int
y
=
int
.
parse
(
dimensions
[
1
]);
final
sync_io
.
Window
window
=
driver
.
window
;
try
{
window
.
setLocation
(
const
math
.
Point
<
int
>(
0
,
0
));
window
.
setSize
(
math
.
Rectangle
<
int
>(
0
,
0
,
x
,
y
));
}
catch
(
_
)
{
// Error might be thrown in some browsers.
}
}
/// Waits until extension is installed.
Future
<
void
>
waitUntilExtensionInstalled
(
sync_io
.
WebDriver
driver
,
Duration
timeout
)
async
{
await
waitFor
<
void
>(()
=>
driver
.
execute
(
'return typeof(window.
\
$flutterDriver
)'
,
<
String
>[]),
matcher:
'function'
,
timeout:
timeout
??
const
Duration
(
days:
365
));
}
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