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
147bb4db
Unverified
Commit
147bb4db
authored
Feb 03, 2021
by
Michael Goderbauer
Committed by
GitHub
Feb 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More null-safety fixes for flutter_driver (#75343)
parent
3c9ae131
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
56 additions
and
143 deletions
+56
-143
find.dart
packages/flutter_driver/lib/src/common/find.dart
+0
-28
frame_sync.dart
packages/flutter_driver/lib/src/common/frame_sync.dart
+0
-14
gesture.dart
packages/flutter_driver/lib/src/common/gesture.dart
+0
-30
handler_factory.dart
packages/flutter_driver/lib/src/common/handler_factory.dart
+25
-25
message.dart
packages/flutter_driver/lib/src/common/message.dart
+13
-0
text.dart
packages/flutter_driver/lib/src/common/text.dart
+0
-28
extension.dart
packages/flutter_driver/lib/src/extension/extension.dart
+1
-1
extension_test.dart
...es/flutter_driver/test/src/real_tests/extension_test.dart
+17
-17
No files found.
packages/flutter_driver/lib/src/common/find.dart
View file @
147bb4db
...
...
@@ -64,20 +64,6 @@ class WaitFor extends CommandWithTarget {
String
get
kind
=>
'waitFor'
;
}
/// The result of a [WaitFor] command.
class
WaitForResult
extends
Result
{
/// Creates a [WaitForResult].
const
WaitForResult
();
/// Deserializes the result from JSON.
static
WaitForResult
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
const
WaitForResult
();
}
@override
Map
<
String
,
dynamic
>
toJson
()
=>
<
String
,
dynamic
>{};
}
/// A Flutter Driver command that waits until [finder] can no longer locate the target.
class
WaitForAbsent
extends
CommandWithTarget
{
/// Creates a command that waits for the widget identified by [finder] to
...
...
@@ -94,20 +80,6 @@ class WaitForAbsent extends CommandWithTarget {
String
get
kind
=>
'waitForAbsent'
;
}
/// The result of a [WaitForAbsent] command.
class
WaitForAbsentResult
extends
Result
{
/// Creates a [WaitForAbsentResult].
const
WaitForAbsentResult
();
/// Deserializes the result from JSON.
static
WaitForAbsentResult
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
const
WaitForAbsentResult
();
}
@override
Map
<
String
,
dynamic
>
toJson
()
=>
<
String
,
dynamic
>{};
}
/// Base class for Flutter Driver finders, objects that describe how the driver
/// should search for elements.
abstract
class
SerializableFinder
{
...
...
packages/flutter_driver/lib/src/common/frame_sync.dart
View file @
147bb4db
...
...
@@ -25,17 +25,3 @@ class SetFrameSync extends Command {
'enabled'
:
'
$enabled
'
,
});
}
/// The result of a [SetFrameSync] command.
class
SetFrameSyncResult
extends
Result
{
/// Creates a [SetFrameSyncResult].
const
SetFrameSyncResult
();
/// Deserializes this result from JSON.
static
SetFrameSyncResult
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
const
SetFrameSyncResult
();
}
@override
Map
<
String
,
dynamic
>
toJson
()
=>
<
String
,
dynamic
>{};
}
packages/flutter_driver/lib/src/common/gesture.dart
View file @
147bb4db
...
...
@@ -4,7 +4,6 @@
import
'deserialization_factory.dart'
;
import
'find.dart'
;
import
'message.dart'
;
/// A Flutter Driver command that taps on a target widget located by [finder].
class
Tap
extends
CommandWithTarget
{
...
...
@@ -18,21 +17,6 @@ class Tap extends CommandWithTarget {
String
get
kind
=>
'tap'
;
}
/// The result of a [Tap] command.
class
TapResult
extends
Result
{
/// Creates a [TapResult].
const
TapResult
();
/// Deserializes this result from JSON.
static
TapResult
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
const
TapResult
();
}
@override
Map
<
String
,
dynamic
>
toJson
()
=>
<
String
,
dynamic
>{};
}
/// A Flutter Driver command that commands the driver to perform a scrolling action.
class
Scroll
extends
CommandWithTarget
{
/// Creates a scroll command that will attempt to scroll a scrollable view by
...
...
@@ -78,20 +62,6 @@ class Scroll extends CommandWithTarget {
});
}
/// The result of a [Scroll] command.
class
ScrollResult
extends
Result
{
/// Creates a [ScrollResult].
const
ScrollResult
();
/// Deserializes this result from JSON.
static
ScrollResult
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
const
ScrollResult
();
}
@override
Map
<
String
,
dynamic
>
toJson
()
=>
<
String
,
dynamic
>{};
}
/// A Flutter Driver command that commands the driver to ensure that the element
/// represented by [finder] has been scrolled completely into view.
class
ScrollIntoView
extends
CommandWithTarget
{
...
...
packages/flutter_driver/lib/src/common/handler_factory.dart
View file @
147bb4db
...
...
@@ -154,7 +154,7 @@ mixin CommandHandlerFactory {
final
TestTextInput
_testTextInput
=
TestTextInput
();
/// Deserializes the finder from JSON generated by [Command.serialize] or [CommandWithTarget.serialize].
Future
<
Result
?
>
handleCommand
(
Command
command
,
WidgetController
prober
,
CreateFinderFactory
finderFactory
)
{
Future
<
Result
>
handleCommand
(
Command
command
,
WidgetController
prober
,
CreateFinderFactory
finderFactory
)
{
switch
(
command
.
kind
)
{
case
'get_health'
:
return
_getHealth
(
command
);
case
'get_layer_tree'
:
return
_getLayerTree
(
command
);
...
...
@@ -192,14 +192,14 @@ mixin CommandHandlerFactory {
return
RenderTree
(
RendererBinding
.
instance
?.
renderView
.
toStringDeep
());
}
Future
<
EnterText
Result
>
_enterText
(
Command
command
)
async
{
Future
<
Result
>
_enterText
(
Command
command
)
async
{
if
(!
_testTextInput
.
isRegistered
)
{
throw
'Unable to fulfill `FlutterDriver.enterText`. Text emulation is '
'disabled. You can enable it using `FlutterDriver.setTextEntryEmulation`.'
;
}
final
EnterText
enterTextCommand
=
command
as
EnterText
;
_testTextInput
.
enterText
(
enterTextCommand
.
text
);
return
const
EnterTextResult
()
;
return
Result
.
empty
;
}
Future
<
RequestDataResult
>
_requestData
(
Command
command
)
async
{
...
...
@@ -210,49 +210,49 @@ mixin CommandHandlerFactory {
:
await
dataHandler
(
requestDataCommand
.
message
));
}
Future
<
SetFrameSync
Result
>
_setFrameSync
(
Command
command
)
async
{
Future
<
Result
>
_setFrameSync
(
Command
command
)
async
{
final
SetFrameSync
setFrameSyncCommand
=
command
as
SetFrameSync
;
_frameSync
=
setFrameSyncCommand
.
enabled
;
return
const
SetFrameSyncResult
()
;
return
Result
.
empty
;
}
Future
<
Tap
Result
>
_tap
(
Command
command
,
WidgetController
prober
,
CreateFinderFactory
finderFactory
)
async
{
Future
<
Result
>
_tap
(
Command
command
,
WidgetController
prober
,
CreateFinderFactory
finderFactory
)
async
{
final
Tap
tapCommand
=
command
as
Tap
;
final
Finder
computedFinder
=
await
waitForElement
(
finderFactory
.
createFinder
(
tapCommand
.
finder
).
hitTestable
(),
);
await
prober
.
tap
(
computedFinder
);
return
const
TapResult
()
;
return
Result
.
empty
;
}
Future
<
WaitFor
Result
>
_waitFor
(
Command
command
,
CreateFinderFactory
finderFactory
)
async
{
Future
<
Result
>
_waitFor
(
Command
command
,
CreateFinderFactory
finderFactory
)
async
{
final
WaitFor
waitForCommand
=
command
as
WaitFor
;
await
waitForElement
(
finderFactory
.
createFinder
(
waitForCommand
.
finder
));
return
const
WaitForResult
()
;
return
Result
.
empty
;
}
Future
<
WaitForAbsent
Result
>
_waitForAbsent
(
Command
command
,
CreateFinderFactory
finderFactory
)
async
{
Future
<
Result
>
_waitForAbsent
(
Command
command
,
CreateFinderFactory
finderFactory
)
async
{
final
WaitForAbsent
waitForAbsentCommand
=
command
as
WaitForAbsent
;
await
waitForAbsentElement
(
finderFactory
.
createFinder
(
waitForAbsentCommand
.
finder
));
return
const
WaitForAbsentResult
()
;
return
Result
.
empty
;
}
Future
<
Result
?
>
_waitForCondition
(
Command
command
)
async
{
Future
<
Result
>
_waitForCondition
(
Command
command
)
async
{
assert
(
command
!=
null
);
final
WaitForCondition
waitForConditionCommand
=
command
as
WaitForCondition
;
final
WaitCondition
condition
=
deserializeCondition
(
waitForConditionCommand
.
condition
);
await
condition
.
wait
();
return
null
;
return
Result
.
empty
;
}
@Deprecated
(
'This method has been deprecated in favor of _waitForCondition. '
'This feature was deprecated after v1.9.3.'
)
Future
<
Result
?
>
_waitUntilNoTransientCallbacks
(
Command
command
)
async
{
Future
<
Result
>
_waitUntilNoTransientCallbacks
(
Command
command
)
async
{
if
(
SchedulerBinding
.
instance
!.
transientCallbackCount
!=
0
)
await
_waitUntilFrame
(()
=>
SchedulerBinding
.
instance
!.
transientCallbackCount
==
0
);
return
null
;
return
Result
.
empty
;
}
/// Returns a future that waits until no pending frame is scheduled (frame is synced).
...
...
@@ -278,12 +278,12 @@ mixin CommandHandlerFactory {
'This method has been deprecated in favor of _waitForCondition. '
'This feature was deprecated after v1.9.3.'
)
Future
<
Result
?
>
_waitUntilNoPendingFrame
(
Command
command
)
async
{
Future
<
Result
>
_waitUntilNoPendingFrame
(
Command
command
)
async
{
await
_waitUntilFrame
(()
{
return
SchedulerBinding
.
instance
!.
transientCallbackCount
==
0
&&
!
SchedulerBinding
.
instance
!.
hasScheduledFrame
;
});
return
null
;
return
Result
.
empty
;
}
Future
<
GetSemanticsIdResult
>
_getSemanticsId
(
Command
command
,
CreateFinderFactory
finderFactory
)
async
{
...
...
@@ -351,7 +351,7 @@ mixin CommandHandlerFactory {
)));
}
Future
<
Scroll
Result
>
_scroll
(
Command
command
,
WidgetController
_prober
,
CreateFinderFactory
finderFactory
)
async
{
Future
<
Result
>
_scroll
(
Command
command
,
WidgetController
_prober
,
CreateFinderFactory
finderFactory
)
async
{
final
Scroll
scrollCommand
=
command
as
Scroll
;
final
Finder
target
=
await
waitForElement
(
finderFactory
.
createFinder
(
scrollCommand
.
finder
));
final
int
totalMoves
=
scrollCommand
.
duration
.
inMicroseconds
*
scrollCommand
.
frequency
~/
Duration
.
microsecondsPerSecond
;
...
...
@@ -369,14 +369,14 @@ mixin CommandHandlerFactory {
}
_prober
.
binding
.
handlePointerEvent
(
pointer
.
up
());
return
const
ScrollResult
()
;
return
Result
.
empty
;
}
Future
<
Scroll
Result
>
_scrollIntoView
(
Command
command
,
CreateFinderFactory
finderFactory
)
async
{
Future
<
Result
>
_scrollIntoView
(
Command
command
,
CreateFinderFactory
finderFactory
)
async
{
final
ScrollIntoView
scrollIntoViewCommand
=
command
as
ScrollIntoView
;
final
Finder
target
=
await
waitForElement
(
finderFactory
.
createFinder
(
scrollIntoViewCommand
.
finder
));
await
Scrollable
.
ensureVisible
(
target
.
evaluate
().
single
,
duration:
const
Duration
(
milliseconds:
100
),
alignment:
scrollIntoViewCommand
.
alignment
);
return
const
ScrollResult
()
;
return
Result
.
empty
;
}
Future
<
GetTextResult
>
_getText
(
Command
command
,
CreateFinderFactory
finderFactory
)
async
{
...
...
@@ -408,14 +408,14 @@ mixin CommandHandlerFactory {
return
GetTextResult
(
text
);
}
Future
<
SetTextEntryEmulation
Result
>
_setTextEntryEmulation
(
Command
command
)
async
{
Future
<
Result
>
_setTextEntryEmulation
(
Command
command
)
async
{
final
SetTextEntryEmulation
setTextEntryEmulationCommand
=
command
as
SetTextEntryEmulation
;
if
(
setTextEntryEmulationCommand
.
enabled
)
{
_testTextInput
.
register
();
}
else
{
_testTextInput
.
unregister
();
}
return
const
SetTextEntryEmulationResult
()
;
return
Result
.
empty
;
}
SemanticsHandle
?
_semantics
;
...
...
@@ -446,9 +446,9 @@ mixin CommandHandlerFactory {
'This method has been deprecated in favor of _waitForCondition. '
'This feature was deprecated after v1.9.3.'
)
Future
<
Result
?
>
_waitUntilFirstFrameRasterized
(
Command
command
)
async
{
Future
<
Result
>
_waitUntilFirstFrameRasterized
(
Command
command
)
async
{
await
WidgetsBinding
.
instance
!.
waitUntilFirstFrameRasterized
;
return
null
;
return
Result
.
empty
;
}
/// Runs `finder` repeatedly until it finds one or more [Element]s.
...
...
packages/flutter_driver/lib/src/common/message.dart
View file @
147bb4db
...
...
@@ -64,6 +64,19 @@ abstract class Result {
/// A const constructor to allow subclasses to be const.
const
Result
();
/// An empty responds that does not include any result data.
///
/// Consider using this object as a result for [Command]s that do not return
/// any data.
static
const
Result
empty
=
_EmptyResult
();
/// Serializes this message to a JSON map.
Map
<
String
,
dynamic
>
toJson
();
}
class
_EmptyResult
extends
Result
{
const
_EmptyResult
();
@override
Map
<
String
,
dynamic
>
toJson
()
=>
<
String
,
dynamic
>{};
}
packages/flutter_driver/lib/src/common/text.dart
View file @
147bb4db
...
...
@@ -59,20 +59,6 @@ class EnterText extends Command {
});
}
/// The result of the [EnterText] command.
class
EnterTextResult
extends
Result
{
/// Creates a successful result of entering the text.
const
EnterTextResult
();
/// Deserializes the result from JSON.
static
EnterTextResult
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
const
EnterTextResult
();
}
@override
Map
<
String
,
dynamic
>
toJson
()
=>
const
<
String
,
String
>{};
}
/// A Flutter Driver command that enables and disables text entry emulation.
class
SetTextEntryEmulation
extends
Command
{
/// Creates a command that enables and disables text entry emulation.
...
...
@@ -94,17 +80,3 @@ class SetTextEntryEmulation extends Command {
'enabled'
:
'
$enabled
'
,
});
}
/// The result of the [SetTextEntryEmulation] command.
class
SetTextEntryEmulationResult
extends
Result
{
/// Creates a successful result.
const
SetTextEntryEmulationResult
();
/// Deserializes the result from JSON.
static
SetTextEntryEmulationResult
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
return
const
SetTextEntryEmulationResult
();
}
@override
Map
<
String
,
dynamic
>
toJson
()
=>
const
<
String
,
String
>{};
}
packages/flutter_driver/lib/src/extension/extension.dart
View file @
147bb4db
...
...
@@ -433,7 +433,7 @@ class FlutterDriverExtension with DeserializeFinderFactory, CreateFinderFactory,
}
@override
Future
<
Result
?
>
handleCommand
(
Command
command
,
WidgetController
prober
,
CreateFinderFactory
finderFactory
)
{
Future
<
Result
>
handleCommand
(
Command
command
,
WidgetController
prober
,
CreateFinderFactory
finderFactory
)
{
final
String
kind
=
command
.
kind
;
if
(
_commandExtensions
.
containsKey
(
kind
))
{
return
_commandExtensions
[
kind
]!.
call
(
command
,
prober
,
finderFactory
,
this
);
...
...
packages/flutter_driver/test/src/real_tests/extension_test.dart
View file @
147bb4db
...
...
@@ -56,7 +56,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -81,7 +81,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -117,7 +117,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -142,7 +142,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -159,7 +159,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -182,7 +182,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -201,7 +201,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -230,7 +230,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -259,7 +259,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -277,7 +277,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -310,7 +310,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -359,7 +359,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -410,7 +410,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -460,7 +460,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -1145,7 +1145,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -1171,7 +1171,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
@@ -1195,7 +1195,7 @@ void main() {
result
,
<
String
,
dynamic
>{
'isError'
:
false
,
'response'
:
null
,
'response'
:
<
String
,
dynamic
>{}
,
},
);
});
...
...
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