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
625dc8a9
Commit
625dc8a9
authored
Mar 03, 2016
by
Yegor
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2364 from yjbanov/driver-command-type-hierarchy
[driver] serialize commands to plain strings
parents
017b4230
008785be
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
49 deletions
+49
-49
driver.dart
packages/flutter_driver/lib/src/driver.dart
+3
-3
extension.dart
packages/flutter_driver/lib/src/extension.dart
+5
-5
find.dart
packages/flutter_driver/lib/src/find.dart
+17
-17
gesture.dart
packages/flutter_driver/lib/src/gesture.dart
+8
-8
health.dart
packages/flutter_driver/lib/src/health.dart
+2
-2
message.dart
packages/flutter_driver/lib/src/message.dart
+14
-14
No files found.
packages/flutter_driver/lib/src/driver.dart
View file @
625dc8a9
...
...
@@ -148,9 +148,9 @@ class FlutterDriver {
final
VMIsolateRef
_appIsolate
;
Future
<
Map
<
String
,
dynamic
>>
_sendCommand
(
Command
command
)
async
{
Map
<
String
,
dynamic
>
json
=
<
String
,
dynamic
>{
'command'
:
command
.
kind
}
..
addAll
(
command
.
toJson
());
return
_appIsolate
.
invokeExtension
(
_kFlutterExtensionMethod
,
json
)
Map
<
String
,
String
>
parameters
=
<
String
,
String
>{
'command'
:
command
.
kind
}
..
addAll
(
command
.
serialize
());
return
_appIsolate
.
invokeExtension
(
_kFlutterExtensionMethod
,
parameters
)
.
then
((
Map
<
String
,
dynamic
>
result
)
=>
result
,
onError:
(
error
,
stackTrace
)
{
throw
new
DriverError
(
'Failed to fulfill
${command.runtimeType}
due to remote error'
,
...
...
packages/flutter_driver/lib/src/extension.dart
View file @
625dc8a9
...
...
@@ -60,11 +60,11 @@ class FlutterDriverExtension {
};
_commandDeserializers
=
{
'get_health'
:
GetHealth
.
fromJson
,
'find'
:
Find
.
fromJson
,
'tap'
:
Tap
.
fromJson
,
'get_text'
:
GetText
.
fromJson
,
'scroll'
:
Scroll
.
fromJson
,
'get_health'
:
GetHealth
.
deserialize
,
'find'
:
Find
.
deserialize
,
'tap'
:
Tap
.
deserialize
,
'get_text'
:
GetText
.
deserialize
,
'scroll'
:
Scroll
.
deserialize
,
};
}
...
...
packages/flutter_driver/lib/src/find.dart
View file @
625dc8a9
...
...
@@ -15,10 +15,10 @@ class Find extends Command {
final
SearchSpecification
searchSpec
;
Map
<
String
,
dynamic
>
toJson
()
=>
searchSpec
.
toJson
();
Map
<
String
,
String
>
serialize
()
=>
searchSpec
.
serialize
();
static
Find
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
new
Find
(
SearchSpecification
.
fromJson
(
json
));
static
Find
deserialize
(
Map
<
String
,
String
>
json
)
{
return
new
Find
(
SearchSpecification
.
deserialize
(
json
));
}
static
_throwInvalidKeyValueType
(
String
invalidType
)
{
...
...
@@ -27,20 +27,20 @@ class Find extends Command {
}
/// Describes how to the driver should search for elements.
abstract
class
SearchSpecification
extends
Message
{
abstract
class
SearchSpecification
{
String
get
searchSpecType
;
static
SearchSpecification
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
static
SearchSpecification
deserialize
(
Map
<
String
,
String
>
json
)
{
String
searchSpecType
=
json
[
'searchSpecType'
];
switch
(
searchSpecType
)
{
case
'ByValueKey'
:
return
ByValueKey
.
fromJson
(
json
);
case
'ByTooltipMessage'
:
return
ByTooltipMessage
.
fromJson
(
json
);
case
'ByText'
:
return
ByText
.
fromJson
(
json
);
case
'ByValueKey'
:
return
ByValueKey
.
deserialize
(
json
);
case
'ByTooltipMessage'
:
return
ByTooltipMessage
.
deserialize
(
json
);
case
'ByText'
:
return
ByText
.
deserialize
(
json
);
}
throw
new
DriverError
(
'Unsupported search specification type
$searchSpecType
'
);
}
Map
<
String
,
dynamic
>
toJson
()
=>
{
Map
<
String
,
String
>
serialize
()
=>
{
'searchSpecType'
:
searchSpecType
,
};
}
...
...
@@ -54,11 +54,11 @@ class ByTooltipMessage extends SearchSpecification {
/// Tooltip message text.
final
String
text
;
Map
<
String
,
dynamic
>
toJson
()
=>
super
.
toJson
()..
addAll
({
Map
<
String
,
String
>
serialize
()
=>
super
.
serialize
()..
addAll
({
'text'
:
text
,
});
static
ByTooltipMessage
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
static
ByTooltipMessage
deserialize
(
Map
<
String
,
String
>
json
)
{
return
new
ByTooltipMessage
(
json
[
'text'
]);
}
}
...
...
@@ -71,11 +71,11 @@ class ByText extends SearchSpecification {
final
String
text
;
Map
<
String
,
dynamic
>
toJson
()
=>
super
.
toJson
()..
addAll
({
Map
<
String
,
String
>
serialize
()
=>
super
.
serialize
()..
addAll
({
'text'
:
text
,
});
static
ByText
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
static
ByText
deserialize
(
Map
<
String
,
String
>
json
)
{
return
new
ByText
(
json
[
'text'
]);
}
}
...
...
@@ -103,12 +103,12 @@ class ByValueKey extends SearchSpecification {
/// May be one of "String", "int". The list of supported types may change.
final
String
keyValueType
;
Map
<
String
,
dynamic
>
toJson
()
=>
super
.
toJson
()..
addAll
({
Map
<
String
,
String
>
serialize
()
=>
super
.
serialize
()..
addAll
({
'keyValueString'
:
keyValueString
,
'keyValueType'
:
keyValueType
,
});
static
ByValueKey
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
static
ByValueKey
deserialize
(
Map
<
String
,
String
>
json
)
{
String
keyValueString
=
json
[
'keyValueString'
];
String
keyValueType
=
json
[
'keyValueType'
];
switch
(
keyValueType
)
{
...
...
@@ -130,14 +130,14 @@ class ByValueKey extends SearchSpecification {
class
GetText
extends
CommandWithTarget
{
final
String
kind
=
'get_text'
;
static
GetText
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
static
GetText
deserialize
(
Map
<
String
,
String
>
json
)
{
return
new
GetText
(
new
ObjectRef
(
json
[
'targetRef'
]));
}
/// [targetRef] identifies an element that contains a piece of text.
GetText
(
ObjectRef
targetRef
)
:
super
(
targetRef
);
Map
<
String
,
dynamic
>
toJson
()
=>
super
.
toJson
();
Map
<
String
,
String
>
serialize
()
=>
super
.
serialize
();
}
class
GetTextResult
extends
Result
{
...
...
packages/flutter_driver/lib/src/gesture.dart
View file @
625dc8a9
...
...
@@ -9,11 +9,11 @@ class Tap extends CommandWithTarget {
Tap
(
ObjectRef
targetRef
)
:
super
(
targetRef
);
static
Tap
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
static
Tap
deserialize
(
Map
<
String
,
String
>
json
)
{
return
new
Tap
(
new
ObjectRef
(
json
[
'targetRef'
]));
}
Map
<
String
,
dynamic
>
toJson
()
=>
super
.
toJson
();
Map
<
String
,
String
>
serialize
()
=>
super
.
serialize
();
}
class
TapResult
extends
Result
{
...
...
@@ -37,7 +37,7 @@ class Scroll extends CommandWithTarget {
this
.
frequency
)
:
super
(
targetRef
);
static
Scroll
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
static
Scroll
deserialize
(
Map
<
String
,
dynamic
>
json
)
{
return
new
Scroll
(
new
ObjectRef
(
json
[
'targetRef'
]),
double
.
parse
(
json
[
'dx'
]),
...
...
@@ -59,11 +59,11 @@ class Scroll extends CommandWithTarget {
/// The frequency in Hz of the generated move events.
final
int
frequency
;
Map
<
String
,
dynamic
>
toJson
()
=>
super
.
toJson
()..
addAll
({
'dx'
:
dx
,
'dy'
:
dy
,
'duration'
:
duration
.
inMicroseconds
,
'frequency'
:
frequency
,
Map
<
String
,
String
>
serialize
()
=>
super
.
serialize
()..
addAll
({
'dx'
:
'
$dx
'
,
'dy'
:
'
$dy
'
,
'duration'
:
'
${duration.inMicroseconds}
'
,
'frequency'
:
'
$frequency
'
,
});
}
...
...
packages/flutter_driver/lib/src/health.dart
View file @
625dc8a9
...
...
@@ -9,9 +9,9 @@ import 'message.dart';
class
GetHealth
implements
Command
{
final
String
kind
=
'get_health'
;
static
fromJson
(
Map
<
String
,
dynamic
>
json
)
=>
new
GetHealth
();
static
deserialize
(
Map
<
String
,
String
>
json
)
=>
new
GetHealth
();
Map
<
String
,
dynamic
>
toJson
()
=>
const
{};
Map
<
String
,
String
>
serialize
()
=>
const
{};
}
/// Application health status.
...
...
packages/flutter_driver/lib/src/message.dart
View file @
625dc8a9
...
...
@@ -4,22 +4,22 @@
import
'error.dart'
;
/// A piece of data travelling between Flutter Driver and a Flutter application.
abstract
class
Message
{
/// Serializes this message to a JSON map.
Map
<
String
,
dynamic
>
toJson
();
}
/// A message that travels from the Flutter Driver to a Flutter application to
/// instruct the application to perform a task.
abstract
class
Command
extends
Message
{
/// An object sent from the Flutter Driver to a Flutter application to instruct
/// the application to perform a task.
abstract
class
Command
{
/// Identifies the type of the command object and of the handler.
String
get
kind
;
/// Serializes this command to parameter name/value pairs.
Map
<
String
,
String
>
serialize
();
}
/// A
message
sent from a Flutter application back to the Flutter Driver in
/// A
n object
sent from a Flutter application back to the Flutter Driver in
/// response to a command.
abstract
class
Result
extends
Message
{
}
abstract
class
Result
{
/// Serializes this message to a JSON map.
Map
<
String
,
dynamic
>
toJson
();
}
/// A serializable reference to an object that lives in the application isolate.
class
ObjectRef
extends
Result
{
...
...
@@ -47,7 +47,7 @@ class ObjectRef extends Result {
/// A command aimed at an object represented by [targetRef].
///
/// Implementations must provide a concrete [kind]. If additional data is
/// required beyond the [targetRef] the implementation may override [
toJson
]
/// required beyond the [targetRef] the implementation may override [
serialize
]
/// and add more keys to the returned map.
abstract
class
CommandWithTarget
extends
Command
{
CommandWithTarget
(
ObjectRef
ref
)
:
this
.
targetRef
=
ref
?.
objectReferenceKey
{
...
...
@@ -66,10 +66,10 @@ abstract class CommandWithTarget extends Command {
///
/// Example:
///
/// Map<String,
dynamic
> toJson() => super.toJson()..addAll({
/// Map<String,
String
> toJson() => super.toJson()..addAll({
/// 'foo': this.foo,
/// });
Map
<
String
,
dynamic
>
toJson
()
=>
{
Map
<
String
,
String
>
serialize
()
=>
<
String
,
String
>
{
'targetRef'
:
targetRef
,
};
}
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