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
2f0b4158
Unverified
Commit
2f0b4158
authored
Jul 14, 2018
by
Jonah Williams
Committed by
GitHub
Jul 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to silence driver extension errors (#19247)
parent
e32e4479
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
extension.dart
packages/flutter_driver/lib/src/extension/extension.dart
+14
-6
extension_test.dart
packages/flutter_driver/test/src/extension_test.dart
+2
-2
No files found.
packages/flutter_driver/lib/src/extension/extension.dart
View file @
2f0b4158
...
...
@@ -37,14 +37,15 @@ const String _extensionMethod = 'ext.flutter.$_extensionMethodName';
typedef
Future
<
String
>
DataHandler
(
String
message
);
class
_DriverBinding
extends
BindingBase
with
ServicesBinding
,
SchedulerBinding
,
GestureBinding
,
PaintingBinding
,
RendererBinding
,
WidgetsBinding
{
_DriverBinding
(
this
.
_handler
);
_DriverBinding
(
this
.
_handler
,
this
.
_silenceErrors
);
final
DataHandler
_handler
;
final
bool
_silenceErrors
;
@override
void
initServiceExtensions
()
{
super
.
initServiceExtensions
();
final
FlutterDriverExtension
extension
=
new
FlutterDriverExtension
(
_handler
);
final
FlutterDriverExtension
extension
=
new
FlutterDriverExtension
(
_handler
,
_silenceErrors
);
registerServiceExtension
(
name:
_extensionMethodName
,
callback:
extension
.
call
,
...
...
@@ -62,9 +63,14 @@ class _DriverBinding extends BindingBase with ServicesBinding, SchedulerBinding,
///
/// Optionally you can pass a [DataHandler] callback. It will be called if the
/// test calls [FlutterDriver.requestData].
void
enableFlutterDriverExtension
(
{
DataHandler
handler
})
{
///
/// `slienceErrors` will prevent exceptions from being logged. This is useful
/// for tests where exceptions are expected. Defaults to false. Any errors
/// will still be returned in the `response` field of the result json along
/// with an `isError` boolean.
void
enableFlutterDriverExtension
(
{
DataHandler
handler
,
bool
silenceErrors
=
false
})
{
assert
(
WidgetsBinding
.
instance
==
null
);
new
_DriverBinding
(
handler
);
new
_DriverBinding
(
handler
,
silenceErrors
);
assert
(
WidgetsBinding
.
instance
is
_DriverBinding
);
}
...
...
@@ -88,7 +94,7 @@ class FlutterDriverExtension {
final
TestTextInput
_testTextInput
=
new
TestTextInput
();
/// Creates an object to manage a Flutter Driver connection.
FlutterDriverExtension
(
this
.
_requestDataHandler
)
{
FlutterDriverExtension
(
this
.
_requestDataHandler
,
this
.
_silenceErrors
)
{
_testTextInput
.
register
();
_commandHandlers
.
addAll
(<
String
,
CommandHandlerCallback
>{
...
...
@@ -136,6 +142,7 @@ class FlutterDriverExtension {
}
final
DataHandler
_requestDataHandler
;
final
bool
_silenceErrors
;
static
final
Logger
_log
=
new
Logger
(
'FlutterDriverExtension'
);
...
...
@@ -176,7 +183,8 @@ class FlutterDriverExtension {
return
_makeResponse
(
msg
,
isError:
true
);
}
catch
(
error
,
stackTrace
)
{
final
String
msg
=
'Uncaught extension error while executing
$commandKind
:
$error
\n
$stackTrace
'
;
_log
.
error
(
msg
);
if
(!
_silenceErrors
)
_log
.
error
(
msg
);
return
_makeResponse
(
msg
,
isError:
true
);
}
}
...
...
packages/flutter_driver/test/src/extension_test.dart
View file @
2f0b4158
...
...
@@ -19,7 +19,7 @@ void main() {
setUp
(()
{
result
=
null
;
extension
=
new
FlutterDriverExtension
((
String
message
)
async
{
log
.
add
(
message
);
return
(
messageId
+=
1
).
toString
();
});
extension
=
new
FlutterDriverExtension
((
String
message
)
async
{
log
.
add
(
message
);
return
(
messageId
+=
1
).
toString
();
}
,
false
);
});
testWidgets
(
'returns immediately when transient callback queue is empty'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -74,7 +74,7 @@ void main() {
group
(
'getSemanticsId'
,
()
{
FlutterDriverExtension
extension
;
setUp
(()
{
extension
=
new
FlutterDriverExtension
((
String
arg
)
async
{}
);
extension
=
new
FlutterDriverExtension
((
String
arg
)
async
{},
true
);
});
testWidgets
(
'works when semantics are enabled'
,
(
WidgetTester
tester
)
async
{
...
...
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