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
68b131f3
Unverified
Commit
68b131f3
authored
May 29, 2020
by
Dan Field
Committed by
GitHub
May 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[e2e] make test bindings friendlier to integration tests (#58210)
parent
42c4c30a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
4 deletions
+64
-4
_binding_web.dart
packages/flutter_test/lib/src/_binding_web.dart
+2
-2
binding.dart
packages/flutter_test/lib/src/binding.dart
+28
-2
bindings_test.dart
packages/flutter_test/test/bindings_test.dart
+8
-0
integration_bindings_test.dart
packages/flutter_test/test/integration_bindings_test.dart
+26
-0
No files found.
packages/flutter_test/lib/src/_binding_web.dart
View file @
68b131f3
...
...
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'binding.dart'
;
import
'binding.dart'
;
/// Ensure the [WidgetsBinding] is initialized.
WidgetsBinding
ensureInitialized
(
[
@visibleForTesting
Map
<
String
,
String
>
environment
])
{
...
...
packages/flutter_test/lib/src/binding.dart
View file @
68b131f3
...
...
@@ -205,6 +205,27 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
@protected
bool
get
disableShadows
=>
false
;
/// Determines whether the Dart [HttpClient] class should be overriden to
/// always return a failure response.
///
/// By default, this value is true, so that unit tests will not become flaky
/// due to intermitten network errors. The value may be overriden by a binding
/// intended for use in integration tests that do end to end application
/// testing, including working with real network responses.
@protected
bool
get
overrideHttpClient
=>
true
;
/// Determines whether the binding automatically registers [testTextInput].
///
/// Unit tests make use of this to mock out text input communication for
/// widgets. An integration test would set this to false, to test real IME
/// or keyboard input.
///
/// [TestTextInput.isRegistered] reports whether the text input mock is
/// registered or not.
@protected
bool
get
registerTestTextInput
=>
true
;
/// Increase the timeout for the current test by the given duration.
///
/// This only matters if the test has an `initialTimeout` set on
...
...
@@ -269,8 +290,13 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
void
initInstances
()
{
super
.
initInstances
();
timeDilation
=
1.0
;
// just in case the developer has artificially changed it for development
binding
.
setupHttpOverrides
();
_testTextInput
=
TestTextInput
(
onCleared:
_resetFocusedEditable
)..
register
();
if
(
overrideHttpClient
)
{
binding
.
setupHttpOverrides
();
}
_testTextInput
=
TestTextInput
(
onCleared:
_resetFocusedEditable
);
if
(
registerTestTextInput
)
{
_testTextInput
.
register
();
}
}
@override
...
...
packages/flutter_test/test/bindings_test.dart
View file @
68b131f3
...
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:io'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -24,4 +26,10 @@ void main() {
expect
(
binding
.
defaultTestTimeout
.
duration
,
const
Duration
(
minutes:
5
));
});
});
test
(
'Initializes httpOverrides and testTextInput'
,
()
async
{
final
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
()
as
TestWidgetsFlutterBinding
;
expect
(
binding
.
testTextInput
.
isRegistered
,
true
);
expect
(
HttpOverrides
.
current
,
isNotNull
);
});
}
packages/flutter_test/test/integration_bindings_test.dart
0 → 100644
View file @
68b131f3
// 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
'dart:io'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'Initializes httpOverrides and testTextInput'
,
()
async
{
expect
(
HttpOverrides
.
current
,
null
);
final
TestWidgetsFlutterBinding
binding
=
CustomBindings
();
expect
(
WidgetsBinding
.
instance
,
isA
<
CustomBindings
>());
expect
(
binding
.
testTextInput
.
isRegistered
,
false
);
expect
(
HttpOverrides
.
current
,
null
);
});
}
class
CustomBindings
extends
AutomatedTestWidgetsFlutterBinding
{
@override
bool
get
overrideHttpClient
=>
false
;
@override
bool
get
registerTestTextInput
=>
false
;
}
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