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
9a76b420
Unverified
Commit
9a76b420
authored
Dec 16, 2019
by
George Wright
Committed by
GitHub
Dec 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for getting a string representation of the LayerTree (#47014)
parent
467f3d49
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
0 deletions
+70
-0
layer_tree.dart
packages/flutter_driver/lib/src/common/layer_tree.dart
+37
-0
driver.dart
packages/flutter_driver/lib/src/driver/driver.dart
+6
-0
extension.dart
packages/flutter_driver/lib/src/extension/extension.dart
+7
-0
flutter_driver_test.dart
packages/flutter_driver/test/flutter_driver_test.dart
+20
-0
No files found.
packages/flutter_driver/lib/src/common/layer_tree.dart
0 → 100644
View file @
9a76b420
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'message.dart'
;
/// A Flutter Driver command that requests a string representation of the layer tree.
class
GetLayerTree
extends
Command
{
/// Create a command to request a string representation of the layer tree.
const
GetLayerTree
({
Duration
timeout
})
:
super
(
timeout:
timeout
);
/// Deserializes this command from the value generated by [serialize].
GetLayerTree
.
deserialize
(
Map
<
String
,
String
>
json
)
:
super
.
deserialize
(
json
);
@override
String
get
kind
=>
'get_layer_tree'
;
}
/// A string representation of the layer tree, the result of a
/// [FlutterDriver.getLayerTree] method.
class
LayerTree
extends
Result
{
/// Creates a [LayerTree] object with the given string representation.
const
LayerTree
(
this
.
tree
);
/// String representation of the layer tree.
final
String
tree
;
/// Deserializes the result from JSON.
static
LayerTree
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
LayerTree
(
json
[
'tree'
]
as
String
);
}
@override
Map
<
String
,
dynamic
>
toJson
()
=>
<
String
,
dynamic
>{
'tree'
:
tree
,
};
}
packages/flutter_driver/lib/src/driver/driver.dart
View file @
9a76b420
...
@@ -23,6 +23,7 @@ import '../common/fuchsia_compat.dart';
...
@@ -23,6 +23,7 @@ import '../common/fuchsia_compat.dart';
import
'../common/geometry.dart'
;
import
'../common/geometry.dart'
;
import
'../common/gesture.dart'
;
import
'../common/gesture.dart'
;
import
'../common/health.dart'
;
import
'../common/health.dart'
;
import
'../common/layer_tree.dart'
;
import
'../common/message.dart'
;
import
'../common/message.dart'
;
import
'../common/render_tree.dart'
;
import
'../common/render_tree.dart'
;
import
'../common/request_data.dart'
;
import
'../common/request_data.dart'
;
...
@@ -475,6 +476,11 @@ class FlutterDriver {
...
@@ -475,6 +476,11 @@ class FlutterDriver {
return
RenderTree
.
fromJson
(
await
_sendCommand
(
GetRenderTree
(
timeout:
timeout
)));
return
RenderTree
.
fromJson
(
await
_sendCommand
(
GetRenderTree
(
timeout:
timeout
)));
}
}
/// Returns a dump of the layer tree.
Future
<
LayerTree
>
getLayerTree
({
Duration
timeout
})
async
{
return
LayerTree
.
fromJson
(
await
_sendCommand
(
GetLayerTree
(
timeout:
timeout
)));
}
/// Taps at the center of the widget located by [finder].
/// Taps at the center of the widget located by [finder].
Future
<
void
>
tap
(
SerializableFinder
finder
,
{
Duration
timeout
})
async
{
Future
<
void
>
tap
(
SerializableFinder
finder
,
{
Duration
timeout
})
async
{
await
_sendCommand
(
Tap
(
finder
,
timeout:
timeout
));
await
_sendCommand
(
Tap
(
finder
,
timeout:
timeout
));
...
...
packages/flutter_driver/lib/src/extension/extension.dart
View file @
9a76b420
...
@@ -24,6 +24,7 @@ import '../common/frame_sync.dart';
...
@@ -24,6 +24,7 @@ import '../common/frame_sync.dart';
import
'../common/geometry.dart'
;
import
'../common/geometry.dart'
;
import
'../common/gesture.dart'
;
import
'../common/gesture.dart'
;
import
'../common/health.dart'
;
import
'../common/health.dart'
;
import
'../common/layer_tree.dart'
;
import
'../common/message.dart'
;
import
'../common/message.dart'
;
import
'../common/render_tree.dart'
;
import
'../common/render_tree.dart'
;
import
'../common/request_data.dart'
;
import
'../common/request_data.dart'
;
...
@@ -107,6 +108,7 @@ class FlutterDriverExtension {
...
@@ -107,6 +108,7 @@ class FlutterDriverExtension {
_commandHandlers
.
addAll
(<
String
,
CommandHandlerCallback
>{
_commandHandlers
.
addAll
(<
String
,
CommandHandlerCallback
>{
'get_health'
:
_getHealth
,
'get_health'
:
_getHealth
,
'get_layer_tree'
:
_getLayerTree
,
'get_render_tree'
:
_getRenderTree
,
'get_render_tree'
:
_getRenderTree
,
'enter_text'
:
_enterText
,
'enter_text'
:
_enterText
,
'get_text'
:
_getText
,
'get_text'
:
_getText
,
...
@@ -130,6 +132,7 @@ class FlutterDriverExtension {
...
@@ -130,6 +132,7 @@ class FlutterDriverExtension {
_commandDeserializers
.
addAll
(<
String
,
CommandDeserializerCallback
>{
_commandDeserializers
.
addAll
(<
String
,
CommandDeserializerCallback
>{
'get_health'
:
(
Map
<
String
,
String
>
params
)
=>
GetHealth
.
deserialize
(
params
),
'get_health'
:
(
Map
<
String
,
String
>
params
)
=>
GetHealth
.
deserialize
(
params
),
'get_layer_tree'
:
(
Map
<
String
,
String
>
params
)
=>
GetLayerTree
.
deserialize
(
params
),
'get_render_tree'
:
(
Map
<
String
,
String
>
params
)
=>
GetRenderTree
.
deserialize
(
params
),
'get_render_tree'
:
(
Map
<
String
,
String
>
params
)
=>
GetRenderTree
.
deserialize
(
params
),
'enter_text'
:
(
Map
<
String
,
String
>
params
)
=>
EnterText
.
deserialize
(
params
),
'enter_text'
:
(
Map
<
String
,
String
>
params
)
=>
EnterText
.
deserialize
(
params
),
'get_text'
:
(
Map
<
String
,
String
>
params
)
=>
GetText
.
deserialize
(
params
),
'get_text'
:
(
Map
<
String
,
String
>
params
)
=>
GetText
.
deserialize
(
params
),
...
@@ -229,6 +232,10 @@ class FlutterDriverExtension {
...
@@ -229,6 +232,10 @@ class FlutterDriverExtension {
Future
<
Health
>
_getHealth
(
Command
command
)
async
=>
const
Health
(
HealthStatus
.
ok
);
Future
<
Health
>
_getHealth
(
Command
command
)
async
=>
const
Health
(
HealthStatus
.
ok
);
Future
<
LayerTree
>
_getLayerTree
(
Command
command
)
async
{
return
LayerTree
(
RendererBinding
.
instance
?.
renderView
?.
debugLayer
?.
toStringDeep
());
}
Future
<
RenderTree
>
_getRenderTree
(
Command
command
)
async
{
Future
<
RenderTree
>
_getRenderTree
(
Command
command
)
async
{
return
RenderTree
(
RendererBinding
.
instance
?.
renderView
?.
toStringDeep
());
return
RenderTree
(
RendererBinding
.
instance
?.
renderView
?.
toStringDeep
());
}
}
...
...
packages/flutter_driver/test/flutter_driver_test.dart
View file @
9a76b420
...
@@ -6,6 +6,7 @@ import 'dart:async';
...
@@ -6,6 +6,7 @@ import 'dart:async';
import
'package:flutter_driver/src/common/error.dart'
;
import
'package:flutter_driver/src/common/error.dart'
;
import
'package:flutter_driver/src/common/health.dart'
;
import
'package:flutter_driver/src/common/health.dart'
;
import
'package:flutter_driver/src/common/layer_tree.dart'
;
import
'package:flutter_driver/src/common/wait.dart'
;
import
'package:flutter_driver/src/common/wait.dart'
;
import
'package:flutter_driver/src/driver/driver.dart'
;
import
'package:flutter_driver/src/driver/driver.dart'
;
import
'package:flutter_driver/src/driver/timeline.dart'
;
import
'package:flutter_driver/src/driver/timeline.dart'
;
...
@@ -231,6 +232,25 @@ void main() {
...
@@ -231,6 +232,25 @@ void main() {
});
});
});
});
group
(
'getLayerTree'
,
()
{
test
(
'sends the getLayerTree command'
,
()
async
{
when
(
mockIsolate
.
invokeExtension
(
any
,
any
)).
thenAnswer
((
Invocation
i
)
{
expect
(
i
.
positionalArguments
[
1
],
<
String
,
dynamic
>{
'command'
:
'get_layer_tree'
,
'timeout'
:
_kSerializedTestTimeout
,
});
return
makeMockResponse
(<
String
,
String
>{
'tree'
:
'hello'
,
});
});
final
LayerTree
result
=
await
driver
.
getLayerTree
(
timeout:
_kTestTimeout
);
final
LayerTree
referenceTree
=
LayerTree
.
fromJson
(<
String
,
String
>{
'tree'
:
'hello'
,
});
expect
(
result
.
tree
,
referenceTree
.
tree
);
});
});
group
(
'waitFor'
,
()
{
group
(
'waitFor'
,
()
{
test
(
'requires a target reference'
,
()
async
{
test
(
'requires a target reference'
,
()
async
{
expect
(
driver
.
waitFor
(
null
),
throwsA
(
isInstanceOf
<
DriverError
>()));
expect
(
driver
.
waitFor
(
null
),
throwsA
(
isInstanceOf
<
DriverError
>()));
...
...
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