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
cba170fb
Unverified
Commit
cba170fb
authored
Oct 01, 2020
by
Michael Goderbauer
Committed by
GitHub
Oct 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate the tests of flutter_test to null-safety (#67058)
parent
b63970c6
Changes
37
Hide whitespace changes
Inline
Side-by-side
Showing
37 changed files
with
128 additions
and
223 deletions
+128
-223
accessibility_test.dart
packages/flutter_test/test/accessibility_test.dart
+37
-39
accessibility_window_test.dart
packages/flutter_test/test/accessibility_window_test.dart
+0
-2
bindings_async_gap_test.dart
packages/flutter_test/test/bindings_async_gap_test.dart
+0
-2
flutter_test_variable_is_false_test.dart
...ings_environment/flutter_test_variable_is_false_test.dart
+0
-3
flutter_test_variable_is_not_true_or_false_test.dart
...ment/flutter_test_variable_is_not_true_or_false_test.dart
+0
-3
flutter_test_variable_is_null_test.dart
...dings_environment/flutter_test_variable_is_null_test.dart
+0
-16
flutter_test_variable_is_true_test.dart
...dings_environment/flutter_test_variable_is_true_test.dart
+0
-3
no_flutter_test_variable_test.dart
...t/bindings_environment/no_flutter_test_variable_test.dart
+0
-3
bindings_test.dart
packages/flutter_test/test/bindings_test.dart
+0
-3
bindings_test_failure.dart
packages/flutter_test/test/bindings_test_failure.dart
+0
-2
controller_test.dart
packages/flutter_test/test/controller_test.dart
+0
-2
flutter_test_config.dart
...t/test/custom_exception_reporter/flutter_test_config.dart
+0
-2
test_exception_reporter_test.dart
...stom_exception_reporter/test_exception_reporter_test.dart
+0
-2
demangle_test.dart
packages/flutter_test/test/demangle_test.dart
+1
-3
event_simulation_test.dart
packages/flutter_test/test/event_simulation_test.dart
+0
-2
finders_test.dart
packages/flutter_test/test/finders_test.dart
+0
-2
frame_timing_summarizer_test.dart
packages/flutter_test/test/frame_timing_summarizer_test.dart
+0
-2
goldens_test.dart
packages/flutter_test/test/goldens_test.dart
+2
-4
integration_bindings_test.dart
packages/flutter_test/test/integration_bindings_test.dart
+0
-2
live_binding_test.dart
packages/flutter_test/test/live_binding_test.dart
+2
-4
live_widget_controller_test.dart
packages/flutter_test/test/live_widget_controller_test.dart
+7
-9
matchers_test.dart
packages/flutter_test/test/matchers_test.dart
+11
-14
reference_image_test.dart
packages/flutter_test/test/reference_image_test.dart
+0
-2
restoration_test.dart
packages/flutter_test/test/restoration_test.dart
+4
-6
stack_manipulation_test.dart
packages/flutter_test/test/stack_manipulation_test.dart
+1
-3
test_async_utils_test.dart
packages/flutter_test/test/test_async_utils_test.dart
+13
-15
config_test.dart
...er_test/test/test_config/child_directory/config_test.dart
+0
-2
config_test.dart
...fig/child_directory/grandchild_directory/config_test.dart
+0
-2
config_test.dart
packages/flutter_test/test/test_config/config_test.dart
+0
-2
config_test_utils.dart
...ages/flutter_test/test/test_config/config_test_utils.dart
+1
-3
flutter_test_config.dart
...es/flutter_test/test/test_config/flutter_test_config.dart
+0
-2
config_test.dart
...tter_test/test/test_config/nested_config/config_test.dart
+0
-2
flutter_test_config.dart
...t/test/test_config/nested_config/flutter_test_config.dart
+0
-2
config_test.dart
...utter_test/test/test_config/project_root/config_test.dart
+0
-2
test_text_input_test.dart
packages/flutter_test/test/test_text_input_test.dart
+0
-2
widget_tester_test.dart
packages/flutter_test/test/widget_tester_test.dart
+28
-30
window_test.dart
packages/flutter_test/test/window_test.dart
+21
-24
No files found.
packages/flutter_test/test/accessibility_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -181,7 +179,7 @@ void main() {
...
@@ -181,7 +179,7 @@ void main() {
});
});
group
(
'custom minimum contrast guideline'
,
()
{
group
(
'custom minimum contrast guideline'
,
()
{
Widget
_icon
({
IconData
icon
=
Icons
.
search
,
Color
color
,
Color
background
})
{
Widget
_icon
({
IconData
icon
=
Icons
.
search
,
required
Color
color
,
required
Color
background
})
{
return
Container
(
return
Container
(
padding:
const
EdgeInsets
.
all
(
8.0
),
padding:
const
EdgeInsets
.
all
(
8.0
),
color:
background
,
color:
background
,
...
@@ -189,7 +187,7 @@ void main() {
...
@@ -189,7 +187,7 @@ void main() {
);
);
}
}
Widget
_text
({
String
text
=
'Text'
,
Color
color
,
Color
background
})
{
Widget
_text
({
String
text
=
'Text'
,
required
Color
color
,
required
Color
background
})
{
return
Container
(
return
Container
(
padding:
const
EdgeInsets
.
all
(
8.0
),
padding:
const
EdgeInsets
.
all
(
8.0
),
color:
background
,
color:
background
,
...
@@ -197,7 +195,7 @@ void main() {
...
@@ -197,7 +195,7 @@ void main() {
);
);
}
}
Widget
_row
(
List
<
Widget
>
widgets
)
=>
_boilerplate
(
Row
(
children:
widgets
));
Widget
_row
(
List
<
Widget
>
widgets
)
=>
_boilerplate
(
Row
(
children:
widgets
));
final
Finder
_findIcons
=
find
.
byWidgetPredicate
((
Widget
widget
)
=>
widget
is
Icon
);
final
Finder
_findIcons
=
find
.
byWidgetPredicate
((
Widget
widget
)
=>
widget
is
Icon
);
final
Finder
_findTexts
=
find
.
byWidgetPredicate
((
Widget
widget
)
=>
widget
is
Text
);
final
Finder
_findTexts
=
find
.
byWidgetPredicate
((
Widget
widget
)
=>
widget
is
Text
);
...
@@ -205,8 +203,8 @@ void main() {
...
@@ -205,8 +203,8 @@ void main() {
testWidgets
(
'Black icons on white background'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Black icons on white background'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
]));
]));
await
expectLater
(
tester
,
meetsGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
await
expectLater
(
tester
,
meetsGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
...
@@ -214,8 +212,8 @@ void main() {
...
@@ -214,8 +212,8 @@ void main() {
testWidgets
(
'Black icons on black background'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Black icons on black background'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
_icon
(
color:
Colors
.
black
,
background:
Colors
.
black
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
black
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
black
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
black
),
]));
]));
await
expectLater
(
tester
,
doesNotMeetGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
await
expectLater
(
tester
,
doesNotMeetGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
...
@@ -223,8 +221,8 @@ void main() {
...
@@ -223,8 +221,8 @@ void main() {
testWidgets
(
'White icons on black background ("dark mode")'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'White icons on black background ("dark mode")'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
_icon
(
color:
Colors
.
white
,
background:
Colors
.
black
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
black
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
black
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
black
),
]));
]));
await
expectLater
(
tester
,
meetsGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
await
expectLater
(
tester
,
meetsGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
...
@@ -232,10 +230,10 @@ void main() {
...
@@ -232,10 +230,10 @@ void main() {
testWidgets
(
'Using different icons'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Using different icons'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
,
icon:
Icons
.
more_horiz
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
,
icon:
Icons
.
more_horiz
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
,
icon:
Icons
.
description
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
,
icon:
Icons
.
description
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
,
icon:
Icons
.
image
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
,
icon:
Icons
.
image
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
,
icon:
Icons
.
beach_access
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
,
icon:
Icons
.
beach_access
),
]));
]));
await
expectLater
(
tester
,
meetsGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
await
expectLater
(
tester
,
meetsGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
...
@@ -243,8 +241,8 @@ void main() {
...
@@ -243,8 +241,8 @@ void main() {
testWidgets
(
'One invalid instance fails entire test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'One invalid instance fails entire test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
black
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
black
),
]));
]));
await
expectLater
(
tester
,
doesNotMeetGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
await
expectLater
(
tester
,
doesNotMeetGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
...
@@ -252,10 +250,10 @@ void main() {
...
@@ -252,10 +250,10 @@ void main() {
testWidgets
(
'White on different colors, passing'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'White on different colors, passing'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
_icon
(
color:
Colors
.
white
,
background:
Colors
.
red
[
800
]
,
icon:
Icons
.
more_horiz
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
red
[
800
]!
,
icon:
Icons
.
more_horiz
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
green
[
800
]
,
icon:
Icons
.
description
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
green
[
800
]!
,
icon:
Icons
.
description
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
blue
[
800
]
,
icon:
Icons
.
image
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
blue
[
800
]!
,
icon:
Icons
.
image
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
purple
[
800
]
,
icon:
Icons
.
beach_access
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
purple
[
800
]!
,
icon:
Icons
.
beach_access
),
]));
]));
await
expectLater
(
tester
,
meetsGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
await
expectLater
(
tester
,
meetsGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
...
@@ -263,10 +261,10 @@ void main() {
...
@@ -263,10 +261,10 @@ void main() {
testWidgets
(
'White on different colors, failing'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'White on different colors, failing'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
_icon
(
color:
Colors
.
white
,
background:
Colors
.
red
[
200
]
,
icon:
Icons
.
more_horiz
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
red
[
200
]!
,
icon:
Icons
.
more_horiz
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
green
[
400
]
,
icon:
Icons
.
description
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
green
[
400
]!
,
icon:
Icons
.
description
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
blue
[
600
]
,
icon:
Icons
.
image
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
blue
[
600
]!
,
icon:
Icons
.
image
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
purple
[
800
]
,
icon:
Icons
.
beach_access
),
_icon
(
color:
Colors
.
white
,
background:
Colors
.
purple
[
800
]!
,
icon:
Icons
.
beach_access
),
]));
]));
await
expectLater
(
tester
,
doesNotMeetGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
await
expectLater
(
tester
,
doesNotMeetGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
...
@@ -280,8 +278,8 @@ void main() {
...
@@ -280,8 +278,8 @@ void main() {
testWidgets
(
'Absence of icons, passing - 2nd test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Absence of icons, passing - 2nd test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
_text
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_text
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_text
(
color:
Colors
.
black
,
background:
Colors
.
black
),
_text
(
color:
Colors
.
black
,
background:
Colors
.
black
),
]));
]));
await
expectLater
(
tester
,
meetsGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
await
expectLater
(
tester
,
meetsGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
...
@@ -289,10 +287,10 @@ void main() {
...
@@ -289,10 +287,10 @@ void main() {
testWidgets
(
'Guideline ignores widgets of other types'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Guideline ignores widgets of other types'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_text
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_text
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_text
(
color:
Colors
.
black
,
background:
Colors
.
black
),
_text
(
color:
Colors
.
black
,
background:
Colors
.
black
),
]));
]));
await
expectLater
(
tester
,
meetsGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
await
expectLater
(
tester
,
meetsGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
...
@@ -302,8 +300,8 @@ void main() {
...
@@ -302,8 +300,8 @@ void main() {
testWidgets
(
'Custom minimum ratio - Icons'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Custom minimum ratio - Icons'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
_icon
(
color:
Colors
.
blue
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
blue
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
]));
]));
await
expectLater
(
tester
,
doesNotMeetGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
await
expectLater
(
tester
,
doesNotMeetGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
...
@@ -312,8 +310,8 @@ void main() {
...
@@ -312,8 +310,8 @@ void main() {
testWidgets
(
'Custom minimum ratio - Texts'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Custom minimum ratio - Texts'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
_text
(
color:
Colors
.
blue
,
background:
Colors
.
white
),
_text
(
color:
Colors
.
blue
,
background:
Colors
.
white
),
_text
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_text
(
color:
Colors
.
black
,
background:
Colors
.
white
),
]));
]));
await
expectLater
(
tester
,
doesNotMeetGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findTexts
)));
await
expectLater
(
tester
,
doesNotMeetGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findTexts
)));
...
@@ -322,10 +320,10 @@ void main() {
...
@@ -322,10 +320,10 @@ void main() {
testWidgets
(
'Custom minimum ratio - Different standards for icons and texts'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Custom minimum ratio - Different standards for icons and texts'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
await
tester
.
pumpWidget
(
_row
(<
Widget
>[
_icon
(
color:
Colors
.
blue
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
blue
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_icon
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_text
(
color:
Colors
.
blue
,
background:
Colors
.
white
),
_text
(
color:
Colors
.
blue
,
background:
Colors
.
white
),
_text
(
color:
Colors
.
black
,
background:
Colors
.
white
),
_text
(
color:
Colors
.
black
,
background:
Colors
.
white
),
]));
]));
await
expectLater
(
tester
,
doesNotMeetGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
await
expectLater
(
tester
,
doesNotMeetGuideline
(
CustomMinimumContrastGuideline
(
finder:
_findIcons
)));
...
...
packages/flutter_test/test/accessibility_window_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter_test/test/bindings_async_gap_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
...
packages/flutter_test/test/bindings_environment/flutter_test_variable_is_false_test.dart
View file @
cba170fb
...
@@ -2,9 +2,6 @@
...
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter_test/test/bindings_environment/flutter_test_variable_is_not_true_or_false_test.dart
View file @
cba170fb
...
@@ -2,9 +2,6 @@
...
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter_test/test/bindings_environment/flutter_test_variable_is_null_test.dart
deleted
100644 → 0
View file @
b63970c6
// 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.
// @dart = 2.9
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'
$WidgetsBinding
initializes with
$AutomatedTestWidgetsFlutterBinding
when FLUTTER_TEST is defined but null'
,
()
{
TestWidgetsFlutterBinding
.
ensureInitialized
(<
String
,
String
>{
'FLUTTER_TEST'
:
null
});
expect
(
WidgetsBinding
.
instance
,
isA
<
AutomatedTestWidgetsFlutterBinding
>());
});
}
packages/flutter_test/test/bindings_environment/flutter_test_variable_is_true_test.dart
View file @
cba170fb
...
@@ -2,9 +2,6 @@
...
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter_test/test/bindings_environment/no_flutter_test_variable_test.dart
View file @
cba170fb
...
@@ -2,9 +2,6 @@
...
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter_test/test/bindings_test.dart
View file @
cba170fb
...
@@ -2,11 +2,8 @@
...
@@ -2,11 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:io'
;
import
'dart:io'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter_test/test/bindings_test_failure.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:io'
;
import
'dart:io'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter_test/test/controller_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:ui'
;
import
'dart:ui'
;
import
'package:flutter/semantics.dart'
;
import
'package:flutter/semantics.dart'
;
...
...
packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
...
packages/flutter_test/test/custom_exception_reporter/test_exception_reporter_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'flutter_test_config.dart'
as
real_test
;
import
'flutter_test_config.dart'
as
real_test
;
void
main
(
)
=>
real_test
.
runTest
();
void
main
(
)
=>
real_test
.
runTest
();
packages/flutter_test/test/demangle_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
@@ -38,7 +36,7 @@ Future<void> main() async {
...
@@ -38,7 +36,7 @@ Future<void> main() async {
await
binding
.
runTest
(()
async
{
await
binding
.
runTest
(()
async
{
final
DebugPrintCallback
oldDebugPrint
=
debugPrint
;
final
DebugPrintCallback
oldDebugPrint
=
debugPrint
;
try
{
try
{
debugPrint
=
(
String
message
,
{
int
wrapWidth
})
{};
debugPrint
=
(
String
?
message
,
{
int
?
wrapWidth
})
{};
debugPrintStack
(
debugPrintStack
(
stackTrace:
await
getMangledStack
(),
stackTrace:
await
getMangledStack
(),
);
);
...
...
packages/flutter_test/test/event_simulation_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter_test/test/finders_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter_test/test/frame_timing_summarizer_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:ui'
;
import
'dart:ui'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter_test/test/goldens_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:async'
;
import
'dart:async'
;
import
'dart:io'
as
io
;
import
'dart:io'
as
io
;
import
'dart:typed_data'
;
import
'dart:typed_data'
;
...
@@ -35,7 +33,7 @@ const List<int> _kSizeFailurePngBytes =
...
@@ -35,7 +33,7 @@ const List<int> _kSizeFailurePngBytes =
0
,
0
,
73
,
69
,
78
,
68
,
174
,
66
,
96
,
130
];
0
,
0
,
73
,
69
,
78
,
68
,
174
,
66
,
96
,
130
];
void
main
(
)
{
void
main
(
)
{
MemoryFileSystem
fs
;
late
MemoryFileSystem
fs
;
setUp
(()
{
setUp
(()
{
final
FileSystemStyle
style
=
io
.
Platform
.
isWindows
final
FileSystemStyle
style
=
io
.
Platform
.
isWindows
...
@@ -86,7 +84,7 @@ void main() {
...
@@ -86,7 +84,7 @@ void main() {
});
});
group
(
'LocalFileComparator'
,
()
{
group
(
'LocalFileComparator'
,
()
{
LocalFileComparator
comparator
;
late
LocalFileComparator
comparator
;
setUp
(()
{
setUp
(()
{
comparator
=
LocalFileComparator
(
fs
.
file
(
fix
(
'/golden_test.dart'
)).
uri
,
pathStyle:
fs
.
path
.
style
);
comparator
=
LocalFileComparator
(
fs
.
file
(
fix
(
'/golden_test.dart'
)).
uri
,
pathStyle:
fs
.
path
.
style
);
...
...
packages/flutter_test/test/integration_bindings_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:io'
;
import
'dart:io'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter_test/test/live_binding_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:ui'
;
import
'dart:ui'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
@@ -24,7 +22,7 @@ void main() {
...
@@ -24,7 +22,7 @@ void main() {
});
});
testWidgets
(
'Input PointerHoverEvent'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Input PointerHoverEvent'
,
(
WidgetTester
tester
)
async
{
PointerHoverEvent
hoverEvent
;
PointerHoverEvent
?
hoverEvent
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MouseRegion
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MouseRegion
(
child:
const
Text
(
'Test'
),
child:
const
Text
(
'Test'
),
onHover:
(
PointerHoverEvent
event
){
onHover:
(
PointerHoverEvent
event
){
...
@@ -37,7 +35,7 @@ void main() {
...
@@ -37,7 +35,7 @@ void main() {
// for mouse input without a down event, moveTo generates a hover event
// for mouse input without a down event, moveTo generates a hover event
await
gesture
.
moveTo
(
location
);
await
gesture
.
moveTo
(
location
);
expect
(
hoverEvent
,
isNotNull
);
expect
(
hoverEvent
,
isNotNull
);
expect
(
hoverEvent
.
position
,
location
);
expect
(
hoverEvent
!
.
position
,
location
);
await
gesture
.
removePointer
();
await
gesture
.
removePointer
();
});
});
}
}
packages/flutter_test/test/live_widget_controller_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:ui'
;
import
'dart:ui'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
@@ -38,7 +36,7 @@ class AnimateSample extends StatefulWidget {
...
@@ -38,7 +36,7 @@ class AnimateSample extends StatefulWidget {
class
_AnimateSampleState
extends
State
<
AnimateSample
>
class
_AnimateSampleState
extends
State
<
AnimateSample
>
with
SingleTickerProviderStateMixin
{
with
SingleTickerProviderStateMixin
{
AnimationController
_controller
;
late
AnimationController
_controller
;
@override
@override
void
initState
()
{
void
initState
()
{
...
@@ -68,9 +66,9 @@ void main() {
...
@@ -68,9 +66,9 @@ void main() {
test
(
'Test pump on LiveWidgetController'
,
()
async
{
test
(
'Test pump on LiveWidgetController'
,
()
async
{
runApp
(
MaterialApp
(
home:
Center
(
child:
CountButton
())));
runApp
(
MaterialApp
(
home:
Center
(
child:
CountButton
())));
await
SchedulerBinding
.
instance
.
endOfFrame
;
await
SchedulerBinding
.
instance
!
.
endOfFrame
;
final
WidgetController
controller
=
final
WidgetController
controller
=
LiveWidgetController
(
WidgetsBinding
.
instance
);
LiveWidgetController
(
WidgetsBinding
.
instance
!
);
await
controller
.
tap
(
find
.
text
(
'Counter 0'
));
await
controller
.
tap
(
find
.
text
(
'Counter 0'
));
expect
(
find
.
text
(
'Counter 0'
),
findsOneWidget
);
expect
(
find
.
text
(
'Counter 0'
),
findsOneWidget
);
expect
(
find
.
text
(
'Counter 1'
),
findsNothing
);
expect
(
find
.
text
(
'Counter 1'
),
findsNothing
);
...
@@ -81,9 +79,9 @@ void main() {
...
@@ -81,9 +79,9 @@ void main() {
test
(
'Test pumpAndSettle on LiveWidgetController'
,
()
async
{
test
(
'Test pumpAndSettle on LiveWidgetController'
,
()
async
{
runApp
(
MaterialApp
(
home:
Center
(
child:
AnimateSample
())));
runApp
(
MaterialApp
(
home:
Center
(
child:
AnimateSample
())));
await
SchedulerBinding
.
instance
.
endOfFrame
;
await
SchedulerBinding
.
instance
!
.
endOfFrame
;
final
WidgetController
controller
=
final
WidgetController
controller
=
LiveWidgetController
(
WidgetsBinding
.
instance
);
LiveWidgetController
(
WidgetsBinding
.
instance
!
);
expect
(
find
.
text
(
'Value: 1.0'
),
findsNothing
);
expect
(
find
.
text
(
'Value: 1.0'
),
findsNothing
);
await
controller
.
pumpAndSettle
();
await
controller
.
pumpAndSettle
();
expect
(
find
.
text
(
'Value: 1.0'
),
findsOneWidget
);
expect
(
find
.
text
(
'Value: 1.0'
),
findsOneWidget
);
...
@@ -101,9 +99,9 @@ void main() {
...
@@ -101,9 +99,9 @@ void main() {
),
),
),
),
);
);
await
SchedulerBinding
.
instance
.
endOfFrame
;
await
SchedulerBinding
.
instance
!
.
endOfFrame
;
final
WidgetController
controller
=
final
WidgetController
controller
=
LiveWidgetController
(
WidgetsBinding
.
instance
);
LiveWidgetController
(
WidgetsBinding
.
instance
!
);
final
Offset
location
=
controller
.
getCenter
(
find
.
text
(
'test'
));
final
Offset
location
=
controller
.
getCenter
(
find
.
text
(
'test'
));
final
List
<
PointerEventRecord
>
records
=
<
PointerEventRecord
>[
final
List
<
PointerEventRecord
>
records
=
<
PointerEventRecord
>[
...
...
packages/flutter_test/test/matchers_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:typed_data'
;
import
'dart:typed_data'
;
import
'dart:ui'
;
import
'dart:ui'
;
...
@@ -13,9 +11,8 @@ import 'package:flutter_test/flutter_test.dart';
...
@@ -13,9 +11,8 @@ import 'package:flutter_test/flutter_test.dart';
/// Class that makes it easy to mock common toStringDeep behavior.
/// Class that makes it easy to mock common toStringDeep behavior.
class
_MockToStringDeep
{
class
_MockToStringDeep
{
_MockToStringDeep
(
String
str
)
{
_MockToStringDeep
(
String
str
)
:
_lines
=
<
String
>[]
{
final
List
<
String
>
lines
=
str
.
split
(
'
\n
'
);
final
List
<
String
>
lines
=
str
.
split
(
'
\n
'
);
_lines
=
<
String
>[];
for
(
int
i
=
0
;
i
<
lines
.
length
-
1
;
++
i
)
for
(
int
i
=
0
;
i
<
lines
.
length
-
1
;
++
i
)
_lines
.
add
(
'
${lines[i]}
\n
'
);
_lines
.
add
(
'
${lines[i]}
\n
'
);
...
@@ -31,7 +28,7 @@ class _MockToStringDeep {
...
@@ -31,7 +28,7 @@ class _MockToStringDeep {
/// Lines in the message to display when [toStringDeep] is called.
/// Lines in the message to display when [toStringDeep] is called.
/// For correct toStringDeep behavior, each line should be terminated with a
/// For correct toStringDeep behavior, each line should be terminated with a
/// line break.
/// line break.
List
<
String
>
_lines
;
final
List
<
String
>
_lines
;
String
toStringDeep
({
String
prefixLineOne
=
''
,
String
prefixOtherLines
=
''
})
{
String
toStringDeep
({
String
prefixLineOne
=
''
,
String
prefixOtherLines
=
''
})
{
final
StringBuffer
sb
=
StringBuffer
();
final
StringBuffer
sb
=
StringBuffer
();
...
@@ -340,7 +337,7 @@ void main() {
...
@@ -340,7 +337,7 @@ void main() {
});
});
group
(
'matchesGoldenFile'
,
()
{
group
(
'matchesGoldenFile'
,
()
{
_FakeComparator
comparator
;
late
_FakeComparator
comparator
;
Widget
boilerplate
(
Widget
child
)
{
Widget
boilerplate
(
Widget
child
)
{
return
Directionality
(
return
Directionality
(
...
@@ -561,8 +558,7 @@ void main() {
...
@@ -561,8 +558,7 @@ void main() {
currentValueLength:
10
,
currentValueLength:
10
,
maxValueLength:
15
,
maxValueLength:
15
,
);
);
final
_FakeSemanticsNode
node
=
_FakeSemanticsNode
();
final
_FakeSemanticsNode
node
=
_FakeSemanticsNode
(
data
);
node
.
data
=
data
;
expect
(
node
,
matchesSemantics
(
expect
(
node
,
matchesSemantics
(
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
10.0
,
10.0
),
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
10.0
,
10.0
),
...
@@ -666,9 +662,9 @@ enum _ComparatorInvocation {
...
@@ -666,9 +662,9 @@ enum _ComparatorInvocation {
class
_FakeComparator
implements
GoldenFileComparator
{
class
_FakeComparator
implements
GoldenFileComparator
{
_ComparatorBehavior
behavior
=
_ComparatorBehavior
.
returnTrue
;
_ComparatorBehavior
behavior
=
_ComparatorBehavior
.
returnTrue
;
_ComparatorInvocation
invocation
;
_ComparatorInvocation
?
invocation
;
Uint8List
imageBytes
;
Uint8List
?
imageBytes
;
Uri
golden
;
Uri
?
golden
;
@override
@override
Future
<
bool
>
compare
(
Uint8List
imageBytes
,
Uri
golden
)
{
Future
<
bool
>
compare
(
Uint8List
imageBytes
,
Uri
golden
)
{
...
@@ -683,7 +679,6 @@ class _FakeComparator implements GoldenFileComparator {
...
@@ -683,7 +679,6 @@ class _FakeComparator implements GoldenFileComparator {
case
_ComparatorBehavior
.
throwTestFailure
:
case
_ComparatorBehavior
.
throwTestFailure
:
throw
TestFailure
(
'fake message'
);
throw
TestFailure
(
'fake message'
);
}
}
return
Future
<
bool
>.
value
(
false
);
}
}
@override
@override
...
@@ -695,12 +690,14 @@ class _FakeComparator implements GoldenFileComparator {
...
@@ -695,12 +690,14 @@ class _FakeComparator implements GoldenFileComparator {
}
}
@override
@override
Uri
getTestUri
(
Uri
key
,
int
version
)
{
Uri
getTestUri
(
Uri
key
,
int
?
version
)
{
return
key
;
return
key
;
}
}
}
}
class
_FakeSemanticsNode
extends
SemanticsNode
{
class
_FakeSemanticsNode
extends
SemanticsNode
{
_FakeSemanticsNode
(
this
.
data
);
SemanticsData
data
;
SemanticsData
data
;
@override
@override
SemanticsData
getSemanticsData
()
=>
data
;
SemanticsData
getSemanticsData
()
=>
data
;
...
@@ -709,7 +706,7 @@ class _FakeSemanticsNode extends SemanticsNode {
...
@@ -709,7 +706,7 @@ class _FakeSemanticsNode extends SemanticsNode {
@immutable
@immutable
class
_CustomColor
extends
Color
{
class
_CustomColor
extends
Color
{
const
_CustomColor
(
int
value
,
{
this
.
isEqual
})
:
super
(
value
);
const
_CustomColor
(
int
value
,
{
this
.
isEqual
})
:
super
(
value
);
final
bool
isEqual
;
final
bool
?
isEqual
;
@override
@override
bool
operator
==(
Object
other
)
=>
isEqual
??
super
==
other
;
bool
operator
==(
Object
other
)
=>
isEqual
??
super
==
other
;
...
...
packages/flutter_test/test/reference_image_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:ui'
as
ui
;
import
'dart:ui'
as
ui
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter_test/test/restoration_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -75,9 +73,9 @@ void main() {
...
@@ -75,9 +73,9 @@ void main() {
}
}
class
_RestorableWidget
extends
StatefulWidget
{
class
_RestorableWidget
extends
StatefulWidget
{
const
_RestorableWidget
({
Key
key
,
this
.
restorationId
})
:
super
(
key:
key
);
const
_RestorableWidget
({
Key
?
key
,
this
.
restorationId
})
:
super
(
key:
key
);
final
String
restorationId
;
final
String
?
restorationId
;
@override
@override
State
<
_RestorableWidget
>
createState
()
=>
_RestorableWidgetState
();
State
<
_RestorableWidget
>
createState
()
=>
_RestorableWidgetState
();
...
@@ -90,7 +88,7 @@ class _RestorableWidgetState extends State<_RestorableWidget> with RestorationMi
...
@@ -90,7 +88,7 @@ class _RestorableWidgetState extends State<_RestorableWidget> with RestorationMi
double
doubleValue
=
1.0
;
// Not restorable.
double
doubleValue
=
1.0
;
// Not restorable.
@override
@override
void
restoreState
(
RestorationBucket
oldBucket
,
bool
initialRestore
)
{
void
restoreState
(
RestorationBucket
?
oldBucket
,
bool
initialRestore
)
{
registerForRestoration
(
stringValue
,
'string'
);
registerForRestoration
(
stringValue
,
'string'
);
registerForRestoration
(
intValue
,
'int'
);
registerForRestoration
(
intValue
,
'int'
);
}
}
...
@@ -109,5 +107,5 @@ class _RestorableWidgetState extends State<_RestorableWidget> with RestorationMi
...
@@ -109,5 +107,5 @@ class _RestorableWidgetState extends State<_RestorableWidget> with RestorationMi
}
}
@override
@override
String
get
restorationId
=>
widget
.
restorationId
;
String
?
get
restorationId
=>
widget
.
restorationId
;
}
}
packages/flutter_test/test/stack_manipulation_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -22,7 +20,7 @@ void main() {
...
@@ -22,7 +20,7 @@ void main() {
}
}
try
{
try
{
throw
null
;
throw
Object
()
;
}
catch
(
e
,
stack
)
{
}
catch
(
e
,
stack
)
{
final
List
<
DiagnosticsNode
>
information
=
<
DiagnosticsNode
>[];
final
List
<
DiagnosticsNode
>
information
=
<
DiagnosticsNode
>[];
expect
(
reportExpectCall
(
stack
,
information
),
0
);
expect
(
reportExpectCall
(
stack
,
information
),
0
);
...
...
packages/flutter_test/test/test_async_utils_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -18,17 +16,17 @@ import 'package:test_api/test_api.dart' as real_test show expect;
...
@@ -18,17 +16,17 @@ import 'package:test_api/test_api.dart' as real_test show expect;
// of this test is to see how we handle leaking APIs.
// of this test is to see how we handle leaking APIs.
class
TestAPI
{
class
TestAPI
{
Future
<
Object
>
testGuard1
()
{
Future
<
Object
?
>
testGuard1
()
{
return
TestAsyncUtils
.
guard
<
Object
>(()
async
{
return
null
;
});
return
TestAsyncUtils
.
guard
<
Object
?
>(()
async
{
return
null
;
});
}
}
Future
<
Object
>
testGuard2
()
{
Future
<
Object
?
>
testGuard2
()
{
return
TestAsyncUtils
.
guard
<
Object
>(()
async
{
return
null
;
});
return
TestAsyncUtils
.
guard
<
Object
?
>(()
async
{
return
null
;
});
}
}
}
}
class
TestAPISubclass
extends
TestAPI
{
class
TestAPISubclass
extends
TestAPI
{
Future
<
Object
>
testGuard3
()
{
Future
<
Object
?
>
testGuard3
()
{
return
TestAsyncUtils
.
guard
<
Object
>(()
async
{
return
null
;
});
return
TestAsyncUtils
.
guard
<
Object
?
>(()
async
{
return
null
;
});
}
}
}
}
...
@@ -41,7 +39,7 @@ Future<Object> _guardedThrower() {
...
@@ -41,7 +39,7 @@ Future<Object> _guardedThrower() {
void
main
(
)
{
void
main
(
)
{
test
(
'TestAsyncUtils - one class'
,
()
async
{
test
(
'TestAsyncUtils - one class'
,
()
async
{
final
TestAPI
testAPI
=
TestAPI
();
final
TestAPI
testAPI
=
TestAPI
();
Future
<
Object
>
f1
,
f2
;
Future
<
Object
?>?
f1
,
f2
;
f1
=
testAPI
.
testGuard1
();
f1
=
testAPI
.
testGuard1
();
try
{
try
{
f2
=
testAPI
.
testGuard2
();
f2
=
testAPI
.
testGuard2
();
...
@@ -63,7 +61,7 @@ void main() {
...
@@ -63,7 +61,7 @@ void main() {
test
(
'TestAsyncUtils - two classes, all callers in superclass'
,
()
async
{
test
(
'TestAsyncUtils - two classes, all callers in superclass'
,
()
async
{
final
TestAPI
testAPI
=
TestAPISubclass
();
final
TestAPI
testAPI
=
TestAPISubclass
();
Future
<
Object
>
f1
,
f2
;
Future
<
Object
?>?
f1
,
f2
;
f1
=
testAPI
.
testGuard1
();
f1
=
testAPI
.
testGuard1
();
try
{
try
{
f2
=
testAPI
.
testGuard2
();
f2
=
testAPI
.
testGuard2
();
...
@@ -85,7 +83,7 @@ void main() {
...
@@ -85,7 +83,7 @@ void main() {
test
(
'TestAsyncUtils - two classes, mixed callers'
,
()
async
{
test
(
'TestAsyncUtils - two classes, mixed callers'
,
()
async
{
final
TestAPISubclass
testAPI
=
TestAPISubclass
();
final
TestAPISubclass
testAPI
=
TestAPISubclass
();
Future
<
Object
>
f1
,
f2
;
Future
<
Object
?>?
f1
,
f2
;
f1
=
testAPI
.
testGuard1
();
f1
=
testAPI
.
testGuard1
();
try
{
try
{
f2
=
testAPI
.
testGuard3
();
f2
=
testAPI
.
testGuard3
();
...
@@ -107,7 +105,7 @@ void main() {
...
@@ -107,7 +105,7 @@ void main() {
test
(
'TestAsyncUtils - expect() catches pending async work'
,
()
async
{
test
(
'TestAsyncUtils - expect() catches pending async work'
,
()
async
{
final
TestAPI
testAPI
=
TestAPISubclass
();
final
TestAPI
testAPI
=
TestAPISubclass
();
Future
<
Object
>
f1
;
Future
<
Object
?>?
f1
;
f1
=
testAPI
.
testGuard1
();
f1
=
testAPI
.
testGuard1
();
try
{
try
{
flutter_test
.
expect
(
0
,
0
);
flutter_test
.
expect
(
0
,
0
);
...
@@ -128,7 +126,7 @@ void main() {
...
@@ -128,7 +126,7 @@ void main() {
});
});
testWidgets
(
'TestAsyncUtils - expect() catches pending async work'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'TestAsyncUtils - expect() catches pending async work'
,
(
WidgetTester
tester
)
async
{
Future
<
Object
>
f1
,
f2
;
Future
<
Object
?>?
f1
,
f2
;
try
{
try
{
f1
=
tester
.
pump
();
f1
=
tester
.
pump
();
f2
=
tester
.
pump
();
f2
=
tester
.
pump
();
...
@@ -170,7 +168,7 @@ void main() {
...
@@ -170,7 +168,7 @@ void main() {
});
});
testWidgets
(
'TestAsyncUtils - expect() catches pending async work'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'TestAsyncUtils - expect() catches pending async work'
,
(
WidgetTester
tester
)
async
{
Future
<
Object
>
f1
;
Future
<
Object
?>?
f1
;
try
{
try
{
f1
=
tester
.
pump
();
f1
=
tester
.
pump
();
TestAsyncUtils
.
verifyAllScopesClosed
();
TestAsyncUtils
.
verifyAllScopesClosed
();
...
@@ -195,7 +193,7 @@ void main() {
...
@@ -195,7 +193,7 @@ void main() {
});
});
testWidgets
(
'TestAsyncUtils - expect() catches pending async work'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'TestAsyncUtils - expect() catches pending async work'
,
(
WidgetTester
tester
)
async
{
Future
<
Object
>
f1
;
Future
<
Object
?>?
f1
;
try
{
try
{
f1
=
tester
.
pump
();
f1
=
tester
.
pump
();
TestAsyncUtils
.
verifyAllScopesClosed
();
TestAsyncUtils
.
verifyAllScopesClosed
();
...
...
packages/flutter_test/test/test_config/child_directory/config_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'../config_test_utils.dart'
;
import
'../config_test_utils.dart'
;
void
main
(
)
{
void
main
(
)
{
...
...
packages/flutter_test/test/test_config/child_directory/grandchild_directory/config_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'../../config_test_utils.dart'
;
import
'../../config_test_utils.dart'
;
void
main
(
)
{
void
main
(
)
{
...
...
packages/flutter_test/test/test_config/config_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'config_test_utils.dart'
;
import
'config_test_utils.dart'
;
void
main
(
)
{
void
main
(
)
{
...
...
packages/flutter_test/test/test_config/config_test_utils.dart
View file @
cba170fb
...
@@ -2,15 +2,13 @@
...
@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
testConfig
(
void
testConfig
(
String
description
,
String
description
,
String
expectedStringValue
,
{
String
?
expectedStringValue
,
{
Map
<
Type
,
dynamic
>
otherExpectedValues
=
const
<
Type
,
dynamic
>{
int
:
isNull
},
Map
<
Type
,
dynamic
>
otherExpectedValues
=
const
<
Type
,
dynamic
>{
int
:
isNull
},
})
{
})
{
final
String
actualStringValue
=
Zone
.
current
[
String
]
as
String
;
final
String
actualStringValue
=
Zone
.
current
[
String
]
as
String
;
...
...
packages/flutter_test/test/test_config/flutter_test_config.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:async'
;
import
'dart:async'
;
Future
<
void
>
main
(
FutureOr
<
void
>
testMain
())
async
{
Future
<
void
>
main
(
FutureOr
<
void
>
testMain
())
async
{
...
...
packages/flutter_test/test/test_config/nested_config/config_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'../config_test_utils.dart'
;
import
'../config_test_utils.dart'
;
void
main
(
)
{
void
main
(
)
{
...
...
packages/flutter_test/test/test_config/nested_config/flutter_test_config.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:async'
;
import
'dart:async'
;
Future
<
void
>
main
(
FutureOr
<
void
>
testMain
())
async
{
Future
<
void
>
main
(
FutureOr
<
void
>
testMain
())
async
{
...
...
packages/flutter_test/test/test_config/project_root/config_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'../config_test_utils.dart'
;
import
'../config_test_utils.dart'
;
void
main
(
)
{
void
main
(
)
{
...
...
packages/flutter_test/test/test_text_input_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter_test/test/widget_tester_test.dart
View file @
cba170fb
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:async'
;
import
'dart:async'
;
import
'dart:io'
;
import
'dart:io'
;
import
'dart:ui'
;
import
'dart:ui'
;
...
@@ -30,7 +28,7 @@ void main() {
...
@@ -30,7 +28,7 @@ void main() {
testWidgets
(
'completes when matcher completes'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'completes when matcher completes'
,
(
WidgetTester
tester
)
async
{
final
Completer
<
void
>
completer
=
Completer
<
void
>();
final
Completer
<
void
>
completer
=
Completer
<
void
>();
final
Future
<
void
>
future
=
expectLater
(
null
,
FakeMatcher
(
completer
));
final
Future
<
void
>
future
=
expectLater
(
null
,
FakeMatcher
(
completer
));
String
result
;
String
?
result
;
future
.
then
<
void
>((
void
value
)
{
future
.
then
<
void
>((
void
value
)
{
result
=
'123'
;
result
=
'123'
;
});
});
...
@@ -62,7 +60,7 @@ void main() {
...
@@ -62,7 +60,7 @@ void main() {
});
});
testWidgets
(
'fails with a descriptive message'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'fails with a descriptive message'
,
(
WidgetTester
tester
)
async
{
TestFailure
failure
;
late
TestFailure
failure
;
try
{
try
{
expect
(
find
.
text
(
'foo'
,
skipOffstage:
false
),
findsOneWidget
);
expect
(
find
.
text
(
'foo'
,
skipOffstage:
false
),
findsOneWidget
);
}
on
TestFailure
catch
(
e
)
{
}
on
TestFailure
catch
(
e
)
{
...
@@ -85,7 +83,7 @@ void main() {
...
@@ -85,7 +83,7 @@ void main() {
testWidgets
(
'fails with a descriptive message'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'fails with a descriptive message'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Text
(
'foo'
,
textDirection:
TextDirection
.
ltr
));
await
tester
.
pumpWidget
(
const
Text
(
'foo'
,
textDirection:
TextDirection
.
ltr
));
TestFailure
failure
;
late
TestFailure
failure
;
try
{
try
{
expect
(
find
.
text
(
'foo'
,
skipOffstage:
false
),
findsNothing
);
expect
(
find
.
text
(
'foo'
,
skipOffstage:
false
),
findsNothing
);
}
on
TestFailure
catch
(
e
)
{
}
on
TestFailure
catch
(
e
)
{
...
@@ -103,7 +101,7 @@ void main() {
...
@@ -103,7 +101,7 @@ void main() {
testWidgets
(
'fails with a descriptive message when skipping'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'fails with a descriptive message when skipping'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Text
(
'foo'
,
textDirection:
TextDirection
.
ltr
));
await
tester
.
pumpWidget
(
const
Text
(
'foo'
,
textDirection:
TextDirection
.
ltr
));
TestFailure
failure
;
late
TestFailure
failure
;
try
{
try
{
expect
(
find
.
text
(
'foo'
),
findsNothing
);
expect
(
find
.
text
(
'foo'
),
findsNothing
);
}
on
TestFailure
catch
(
e
)
{
}
on
TestFailure
catch
(
e
)
{
...
@@ -156,13 +154,13 @@ void main() {
...
@@ -156,13 +154,13 @@ void main() {
testWidgets
(
'pumpFrames'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'pumpFrames'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
logPaints
=
<
int
>[];
final
List
<
int
>
logPaints
=
<
int
>[];
int
initial
;
int
?
initial
;
final
Widget
target
=
_AlwaysAnimating
(
final
Widget
target
=
_AlwaysAnimating
(
onPaint:
()
{
onPaint:
()
{
final
int
current
=
SchedulerBinding
.
instance
.
currentFrameTimeStamp
.
inMicroseconds
;
final
int
current
=
SchedulerBinding
.
instance
!
.
currentFrameTimeStamp
.
inMicroseconds
;
initial
??=
current
;
initial
??=
current
;
logPaints
.
add
(
current
-
initial
);
logPaints
.
add
(
current
-
initial
!
);
},
},
);
);
...
@@ -182,7 +180,7 @@ void main() {
...
@@ -182,7 +180,7 @@ void main() {
await
tester
.
pumpWidget
(
const
Text
(
'foo'
,
textDirection:
TextDirection
.
ltr
));
await
tester
.
pumpWidget
(
const
Text
(
'foo'
,
textDirection:
TextDirection
.
ltr
));
const
String
customDescription
=
'custom description'
;
const
String
customDescription
=
'custom description'
;
TestFailure
failure
;
late
TestFailure
failure
;
try
{
try
{
expect
(
find
.
byElementPredicate
((
_
)
=>
false
,
description:
customDescription
),
findsOneWidget
);
expect
(
find
.
byElementPredicate
((
_
)
=>
false
,
description:
customDescription
),
findsOneWidget
);
}
on
TestFailure
catch
(
e
)
{
}
on
TestFailure
catch
(
e
)
{
...
@@ -199,7 +197,7 @@ void main() {
...
@@ -199,7 +197,7 @@ void main() {
await
tester
.
pumpWidget
(
const
Text
(
'foo'
,
textDirection:
TextDirection
.
ltr
));
await
tester
.
pumpWidget
(
const
Text
(
'foo'
,
textDirection:
TextDirection
.
ltr
));
const
String
customDescription
=
'custom description'
;
const
String
customDescription
=
'custom description'
;
TestFailure
failure
;
late
TestFailure
failure
;
try
{
try
{
expect
(
find
.
byWidgetPredicate
((
_
)
=>
false
,
description:
customDescription
),
findsOneWidget
);
expect
(
find
.
byWidgetPredicate
((
_
)
=>
false
,
description:
customDescription
),
findsOneWidget
);
}
on
TestFailure
catch
(
e
)
{
}
on
TestFailure
catch
(
e
)
{
...
@@ -250,7 +248,7 @@ void main() {
...
@@ -250,7 +248,7 @@ void main() {
],
],
));
));
TestFailure
failure
;
late
TestFailure
failure
;
try
{
try
{
expect
(
find
.
descendant
(
expect
(
find
.
descendant
(
of:
find
.
widgetWithText
(
Column
,
'foo'
),
of:
find
.
widgetWithText
(
Column
,
'foo'
),
...
@@ -312,7 +310,7 @@ void main() {
...
@@ -312,7 +310,7 @@ void main() {
],
],
));
));
TestFailure
failure
;
late
TestFailure
failure
;
try
{
try
{
expect
(
find
.
ancestor
(
expect
(
find
.
ancestor
(
of:
find
.
text
(
'bar'
),
of:
find
.
text
(
'bar'
),
...
@@ -554,7 +552,7 @@ void main() {
...
@@ -554,7 +552,7 @@ void main() {
group
(
'runAsync'
,
()
{
group
(
'runAsync'
,
()
{
testWidgets
(
'works with no async calls'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'works with no async calls'
,
(
WidgetTester
tester
)
async
{
String
value
;
String
?
value
;
await
tester
.
runAsync
(()
async
{
await
tester
.
runAsync
(()
async
{
value
=
'123'
;
value
=
'123'
;
});
});
...
@@ -574,14 +572,14 @@ void main() {
...
@@ -574,14 +572,14 @@ void main() {
});
});
testWidgets
(
'propagates return values'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'propagates return values'
,
(
WidgetTester
tester
)
async
{
final
String
value
=
await
tester
.
runAsync
<
String
>(()
async
{
final
String
?
value
=
await
tester
.
runAsync
<
String
>(()
async
{
return
'123'
;
return
'123'
;
});
});
expect
(
value
,
'123'
);
expect
(
value
,
'123'
);
});
});
testWidgets
(
'reports errors via framework'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'reports errors via framework'
,
(
WidgetTester
tester
)
async
{
final
String
value
=
await
tester
.
runAsync
<
String
>(()
async
{
final
String
?
value
=
await
tester
.
runAsync
<
String
>(()
async
{
throw
ArgumentError
();
throw
ArgumentError
();
});
});
expect
(
value
,
isNull
);
expect
(
value
,
isNull
);
...
@@ -630,7 +628,7 @@ void main() {
...
@@ -630,7 +628,7 @@ void main() {
});
});
testWidgets
(
'verifyTickersWereDisposed control test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'verifyTickersWereDisposed control test'
,
(
WidgetTester
tester
)
async
{
FlutterError
error
;
late
FlutterError
error
;
final
Ticker
ticker
=
tester
.
createTicker
((
Duration
duration
)
{});
final
Ticker
ticker
=
tester
.
createTicker
((
Duration
duration
)
{});
ticker
.
start
();
ticker
.
start
();
try
{
try
{
...
@@ -685,7 +683,7 @@ void main() {
...
@@ -685,7 +683,7 @@ void main() {
group
(
'TargetPlatformVariant'
,
()
{
group
(
'TargetPlatformVariant'
,
()
{
int
numberOfVariationsRun
=
0
;
int
numberOfVariationsRun
=
0
;
TargetPlatform
origTargetPlatform
;
TargetPlatform
?
origTargetPlatform
;
setUpAll
((){
setUpAll
((){
origTargetPlatform
=
debugDefaultTargetPlatformOverride
;
origTargetPlatform
=
debugDefaultTargetPlatformOverride
;
...
@@ -717,7 +715,7 @@ void main() {
...
@@ -717,7 +715,7 @@ void main() {
});
});
group
(
'Pending timer'
,
()
{
group
(
'Pending timer'
,
()
{
TestExceptionReporter
currentExceptionReporter
;
late
TestExceptionReporter
currentExceptionReporter
;
setUp
(()
{
setUp
(()
{
currentExceptionReporter
=
reportTestException
;
currentExceptionReporter
=
reportTestException
;
});
});
...
@@ -727,7 +725,7 @@ void main() {
...
@@ -727,7 +725,7 @@ void main() {
});
});
test
(
'Throws assertion message without code'
,
()
async
{
test
(
'Throws assertion message without code'
,
()
async
{
FlutterErrorDetails
flutterErrorDetails
;
late
FlutterErrorDetails
flutterErrorDetails
;
reportTestException
=
(
FlutterErrorDetails
details
,
String
testDescription
)
{
reportTestException
=
(
FlutterErrorDetails
details
,
String
testDescription
)
{
flutterErrorDetails
=
details
;
flutterErrorDetails
=
details
;
};
};
...
@@ -738,8 +736,8 @@ void main() {
...
@@ -738,8 +736,8 @@ void main() {
expect
(
timer
.
isActive
,
true
);
expect
(
timer
.
isActive
,
true
);
},
()
{});
},
()
{});
expect
(
flutterErrorDetails
?
.
exception
,
isA
<
AssertionError
>());
expect
(
flutterErrorDetails
.
exception
,
isA
<
AssertionError
>());
expect
(
flutterErrorDetails
?.
exception
?
.
message
,
'A Timer is still pending even after the widget tree was disposed.'
);
expect
(
flutterErrorDetails
.
exception
!
.
message
,
'A Timer is still pending even after the widget tree was disposed.'
);
});
});
});
});
}
}
...
@@ -750,8 +748,8 @@ class FakeMatcher extends AsyncMatcher {
...
@@ -750,8 +748,8 @@ class FakeMatcher extends AsyncMatcher {
final
Completer
<
void
>
completer
;
final
Completer
<
void
>
completer
;
@override
@override
Future
<
String
>
matchAsync
(
dynamic
object
)
{
Future
<
String
?
>
matchAsync
(
dynamic
object
)
{
return
completer
.
future
.
then
<
String
>((
void
value
)
{
return
completer
.
future
.
then
<
String
?
>((
void
value
)
{
return
object
?.
toString
();
return
object
?.
toString
();
});
});
}
}
...
@@ -761,14 +759,14 @@ class FakeMatcher extends AsyncMatcher {
...
@@ -761,14 +759,14 @@ class FakeMatcher extends AsyncMatcher {
}
}
class
_SingleTickerTest
extends
StatefulWidget
{
class
_SingleTickerTest
extends
StatefulWidget
{
const
_SingleTickerTest
({
Key
key
})
:
super
(
key:
key
);
const
_SingleTickerTest
({
Key
?
key
})
:
super
(
key:
key
);
@override
@override
_SingleTickerTestState
createState
()
=>
_SingleTickerTestState
();
_SingleTickerTestState
createState
()
=>
_SingleTickerTestState
();
}
}
class
_SingleTickerTestState
extends
State
<
_SingleTickerTest
>
with
SingleTickerProviderStateMixin
{
class
_SingleTickerTestState
extends
State
<
_SingleTickerTest
>
with
SingleTickerProviderStateMixin
{
AnimationController
controller
;
late
AnimationController
controller
;
@override
@override
void
initState
()
{
void
initState
()
{
...
@@ -788,10 +786,10 @@ class _SingleTickerTestState extends State<_SingleTickerTest> with SingleTickerP
...
@@ -788,10 +786,10 @@ class _SingleTickerTestState extends State<_SingleTickerTest> with SingleTickerP
class
_AlwaysAnimating
extends
StatefulWidget
{
class
_AlwaysAnimating
extends
StatefulWidget
{
const
_AlwaysAnimating
({
const
_AlwaysAnimating
({
this
.
child
,
this
.
child
,
this
.
onPaint
,
required
this
.
onPaint
,
});
});
final
Widget
child
;
final
Widget
?
child
;
final
VoidCallback
onPaint
;
final
VoidCallback
onPaint
;
@override
@override
...
@@ -799,7 +797,7 @@ class _AlwaysAnimating extends StatefulWidget {
...
@@ -799,7 +797,7 @@ class _AlwaysAnimating extends StatefulWidget {
}
}
class
_AlwaysAnimatingState
extends
State
<
_AlwaysAnimating
>
with
SingleTickerProviderStateMixin
{
class
_AlwaysAnimatingState
extends
State
<
_AlwaysAnimating
>
with
SingleTickerProviderStateMixin
{
AnimationController
_controller
;
late
AnimationController
_controller
;
@override
@override
void
initState
()
{
void
initState
()
{
...
@@ -821,7 +819,7 @@ class _AlwaysAnimatingState extends State<_AlwaysAnimating> with SingleTickerPro
...
@@ -821,7 +819,7 @@ class _AlwaysAnimatingState extends State<_AlwaysAnimating> with SingleTickerPro
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
AnimatedBuilder
(
return
AnimatedBuilder
(
animation:
_controller
.
view
,
animation:
_controller
.
view
,
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
CustomPaint
(
return
CustomPaint
(
painter:
_AlwaysRepaint
(
widget
.
onPaint
),
painter:
_AlwaysRepaint
(
widget
.
onPaint
),
child:
widget
.
child
,
child:
widget
.
child
,
...
...
packages/flutter_test/test/window_test.dart
View file @
cba170fb
...
@@ -2,18 +2,15 @@
...
@@ -2,18 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.9
import
'dart:ui'
as
ui
show
window
;
import
'dart:ui'
as
ui
show
window
;
import
'dart:ui'
show
Size
,
Locale
,
WindowPadding
,
AccessibilityFeatures
,
Brightness
;
import
'dart:ui'
show
Size
,
Locale
,
WindowPadding
,
AccessibilityFeatures
,
Brightness
;
import
'package:flutter/widgets.dart'
show
WidgetsBinding
;
import
'package:flutter/widgets.dart'
show
WidgetsBinding
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:meta/meta.dart'
;
void
main
(
)
{
void
main
(
)
{
test
(
'TestWindow can handle new methods without breaking'
,
()
{
test
(
'TestWindow can handle new methods without breaking'
,
()
{
final
dynamic
testWindow
=
TestWindow
(
window:
ui
.
window
);
final
dynamic
testWindow
=
TestWindow
(
window:
ui
.
window
);
// ignore: unnecessary_nullable_for_final_variable_declarations
expect
(
testWindow
.
someNewProperty
,
null
);
expect
(
testWindow
.
someNewProperty
,
null
);
});
});
...
@@ -23,7 +20,7 @@ void main() {
...
@@ -23,7 +20,7 @@ void main() {
realValue:
ui
.
window
.
devicePixelRatio
,
realValue:
ui
.
window
.
devicePixelRatio
,
fakeValue:
2.5
,
fakeValue:
2.5
,
propertyRetriever:
()
{
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
window
.
devicePixelRatio
;
return
WidgetsBinding
.
instance
!
.
window
.
devicePixelRatio
;
},
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
double
fakeValue
)
{
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
double
fakeValue
)
{
binding
.
window
.
devicePixelRatioTestValue
=
fakeValue
;
binding
.
window
.
devicePixelRatioTestValue
=
fakeValue
;
...
@@ -37,7 +34,7 @@ void main() {
...
@@ -37,7 +34,7 @@ void main() {
realValue:
ui
.
window
.
physicalSize
,
realValue:
ui
.
window
.
physicalSize
,
fakeValue:
const
Size
(
50
,
50
),
fakeValue:
const
Size
(
50
,
50
),
propertyRetriever:
()
{
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
window
.
physicalSize
;
return
WidgetsBinding
.
instance
!
.
window
.
physicalSize
;
},
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
Size
fakeValue
)
{
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
Size
fakeValue
)
{
binding
.
window
.
physicalSizeTestValue
=
fakeValue
;
binding
.
window
.
physicalSizeTestValue
=
fakeValue
;
...
@@ -51,7 +48,7 @@ void main() {
...
@@ -51,7 +48,7 @@ void main() {
realValue:
ui
.
window
.
viewInsets
,
realValue:
ui
.
window
.
viewInsets
,
fakeValue:
const
FakeWindowPadding
(),
fakeValue:
const
FakeWindowPadding
(),
propertyRetriever:
()
{
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
window
.
viewInsets
;
return
WidgetsBinding
.
instance
!
.
window
.
viewInsets
;
},
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
WindowPadding
fakeValue
)
{
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
WindowPadding
fakeValue
)
{
binding
.
window
.
viewInsetsTestValue
=
fakeValue
;
binding
.
window
.
viewInsetsTestValue
=
fakeValue
;
...
@@ -65,7 +62,7 @@ void main() {
...
@@ -65,7 +62,7 @@ void main() {
realValue:
ui
.
window
.
padding
,
realValue:
ui
.
window
.
padding
,
fakeValue:
const
FakeWindowPadding
(),
fakeValue:
const
FakeWindowPadding
(),
propertyRetriever:
()
{
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
window
.
padding
;
return
WidgetsBinding
.
instance
!
.
window
.
padding
;
},
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
WindowPadding
fakeValue
)
{
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
WindowPadding
fakeValue
)
{
binding
.
window
.
paddingTestValue
=
fakeValue
;
binding
.
window
.
paddingTestValue
=
fakeValue
;
...
@@ -79,7 +76,7 @@ void main() {
...
@@ -79,7 +76,7 @@ void main() {
realValue:
ui
.
window
.
locale
,
realValue:
ui
.
window
.
locale
,
fakeValue:
const
Locale
(
'fake_language_code'
),
fakeValue:
const
Locale
(
'fake_language_code'
),
propertyRetriever:
()
{
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
window
.
locale
;
return
WidgetsBinding
.
instance
!
.
window
.
locale
;
},
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
Locale
fakeValue
)
{
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
Locale
fakeValue
)
{
binding
.
window
.
localeTestValue
=
fakeValue
;
binding
.
window
.
localeTestValue
=
fakeValue
;
...
@@ -93,7 +90,7 @@ void main() {
...
@@ -93,7 +90,7 @@ void main() {
realValue:
ui
.
window
.
locales
,
realValue:
ui
.
window
.
locales
,
fakeValue:
<
Locale
>[
const
Locale
(
'fake_language_code'
)],
fakeValue:
<
Locale
>[
const
Locale
(
'fake_language_code'
)],
propertyRetriever:
()
{
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
window
.
locales
;
return
WidgetsBinding
.
instance
!
.
window
.
locales
;
},
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
List
<
Locale
>
fakeValue
)
{
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
List
<
Locale
>
fakeValue
)
{
binding
.
window
.
localesTestValue
=
fakeValue
;
binding
.
window
.
localesTestValue
=
fakeValue
;
...
@@ -107,7 +104,7 @@ void main() {
...
@@ -107,7 +104,7 @@ void main() {
realValue:
ui
.
window
.
textScaleFactor
,
realValue:
ui
.
window
.
textScaleFactor
,
fakeValue:
2.5
,
fakeValue:
2.5
,
propertyRetriever:
()
{
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
window
.
textScaleFactor
;
return
WidgetsBinding
.
instance
!
.
window
.
textScaleFactor
;
},
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
double
fakeValue
)
{
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
double
fakeValue
)
{
binding
.
window
.
textScaleFactorTestValue
=
fakeValue
;
binding
.
window
.
textScaleFactorTestValue
=
fakeValue
;
...
@@ -121,7 +118,7 @@ void main() {
...
@@ -121,7 +118,7 @@ void main() {
realValue:
ui
.
window
.
alwaysUse24HourFormat
,
realValue:
ui
.
window
.
alwaysUse24HourFormat
,
fakeValue:
!
ui
.
window
.
alwaysUse24HourFormat
,
fakeValue:
!
ui
.
window
.
alwaysUse24HourFormat
,
propertyRetriever:
()
{
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
window
.
alwaysUse24HourFormat
;
return
WidgetsBinding
.
instance
!
.
window
.
alwaysUse24HourFormat
;
},
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
bool
fakeValue
)
{
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
bool
fakeValue
)
{
binding
.
window
.
alwaysUse24HourFormatTestValue
=
fakeValue
;
binding
.
window
.
alwaysUse24HourFormatTestValue
=
fakeValue
;
...
@@ -135,7 +132,7 @@ void main() {
...
@@ -135,7 +132,7 @@ void main() {
realValue:
ui
.
window
.
defaultRouteName
,
realValue:
ui
.
window
.
defaultRouteName
,
fakeValue:
'fake_route'
,
fakeValue:
'fake_route'
,
propertyRetriever:
()
{
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
window
.
defaultRouteName
;
return
WidgetsBinding
.
instance
!
.
window
.
defaultRouteName
;
},
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
String
fakeValue
)
{
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
String
fakeValue
)
{
binding
.
window
.
defaultRouteNameTestValue
=
fakeValue
;
binding
.
window
.
defaultRouteNameTestValue
=
fakeValue
;
...
@@ -149,7 +146,7 @@ void main() {
...
@@ -149,7 +146,7 @@ void main() {
realValue:
ui
.
window
.
accessibilityFeatures
,
realValue:
ui
.
window
.
accessibilityFeatures
,
fakeValue:
const
FakeAccessibilityFeatures
(),
fakeValue:
const
FakeAccessibilityFeatures
(),
propertyRetriever:
()
{
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
window
.
accessibilityFeatures
;
return
WidgetsBinding
.
instance
!
.
window
.
accessibilityFeatures
;
},
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
AccessibilityFeatures
fakeValue
)
{
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
AccessibilityFeatures
fakeValue
)
{
binding
.
window
.
accessibilityFeaturesTestValue
=
fakeValue
;
binding
.
window
.
accessibilityFeaturesTestValue
=
fakeValue
;
...
@@ -163,7 +160,7 @@ void main() {
...
@@ -163,7 +160,7 @@ void main() {
realValue:
Brightness
.
light
,
realValue:
Brightness
.
light
,
fakeValue:
Brightness
.
dark
,
fakeValue:
Brightness
.
dark
,
propertyRetriever:
()
{
propertyRetriever:
()
{
return
WidgetsBinding
.
instance
.
window
.
platformBrightness
;
return
WidgetsBinding
.
instance
!
.
window
.
platformBrightness
;
},
},
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
Brightness
fakeValue
)
{
propertyFaker:
(
TestWidgetsFlutterBinding
binding
,
Brightness
fakeValue
)
{
binding
.
window
.
platformBrightnessTestValue
=
fakeValue
;
binding
.
window
.
platformBrightnessTestValue
=
fakeValue
;
...
@@ -184,20 +181,20 @@ void main() {
...
@@ -184,20 +181,20 @@ void main() {
testWindow
.
clearAllTestValues
();
testWindow
.
clearAllTestValues
();
// Verify that the window once again reports real property values.
// Verify that the window once again reports real property values.
expect
(
WidgetsBinding
.
instance
.
window
.
devicePixelRatio
,
originalDevicePixelRatio
);
expect
(
WidgetsBinding
.
instance
!
.
window
.
devicePixelRatio
,
originalDevicePixelRatio
);
expect
(
WidgetsBinding
.
instance
.
window
.
textScaleFactor
,
originalTextScaleFactor
);
expect
(
WidgetsBinding
.
instance
!
.
window
.
textScaleFactor
,
originalTextScaleFactor
);
});
});
}
}
void
verifyThatTestWindowCanFakeProperty
<
WindowPropertyType
>({
void
verifyThatTestWindowCanFakeProperty
<
WindowPropertyType
>({
@
required
WidgetTester
tester
,
required
WidgetTester
tester
,
@required
WindowPropertyType
realValue
,
required
WindowPropertyType
?
realValue
,
@
required
WindowPropertyType
fakeValue
,
required
WindowPropertyType
fakeValue
,
@required
WindowPropertyType
Function
()
propertyRetriever
,
required
WindowPropertyType
?
Function
()
propertyRetriever
,
@
required
Function
(
TestWidgetsFlutterBinding
,
WindowPropertyType
fakeValue
)
propertyFaker
,
required
Function
(
TestWidgetsFlutterBinding
,
WindowPropertyType
fakeValue
)
propertyFaker
,
})
{
})
{
WindowPropertyType
propertyBeforeFaking
;
WindowPropertyType
?
propertyBeforeFaking
;
WindowPropertyType
propertyAfterFaking
;
WindowPropertyType
?
propertyAfterFaking
;
propertyBeforeFaking
=
propertyRetriever
();
propertyBeforeFaking
=
propertyRetriever
();
...
...
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