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
793678d5
Unverified
Commit
793678d5
authored
Oct 09, 2020
by
Michael Goderbauer
Committed by
GitHub
Oct 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate tests to null-safety (#67692)
parent
9360bbbb
Changes
19
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
418 additions
and
505 deletions
+418
-505
text_theme_test.dart
packages/flutter/test/material/text_theme_test.dart
+43
-45
theme_data_test.dart
packages/flutter/test/material/theme_data_test.dart
+20
-22
theme_defaults_test.dart
packages/flutter/test/material/theme_defaults_test.dart
+9
-11
theme_test.dart
packages/flutter/test/material/theme_test.dart
+114
-116
time_picker_test.dart
packages/flutter/test/material/time_picker_test.dart
+44
-46
time_picker_theme_test.dart
packages/flutter/test/material/time_picker_theme_test.dart
+35
-37
time_test.dart
packages/flutter/test/material/time_test.dart
+1
-3
toggle_buttons_test.dart
packages/flutter/test/material/toggle_buttons_test.dart
+8
-54
toggle_buttons_theme_test.dart
...ages/flutter/test/material/toggle_buttons_theme_test.dart
+1
-3
tooltip_test.dart
packages/flutter/test/material/tooltip_test.dart
+8
-10
tooltip_theme_test.dart
packages/flutter/test/material/tooltip_theme_test.dart
+14
-16
typography_test.dart
packages/flutter/test/material/typography_test.dart
+63
-65
user_accounts_drawer_header_test.dart
...utter/test/material/user_accounts_drawer_header_test.dart
+13
-15
will_pop_test.dart
packages/flutter/test/material/will_pop_test.dart
+13
-21
app_overrides_test.dart
packages/flutter/test/widgets/app_overrides_test.dart
+3
-5
app_test.dart
packages/flutter/test/widgets/app_test.dart
+26
-27
app_title_test.dart
packages/flutter/test/widgets/app_title_test.dart
+1
-3
aspect_ratio_test.dart
packages/flutter/test/widgets/aspect_ratio_test.dart
+0
-2
async_lifecycle_test.dart
packages/flutter/test/widgets/async_lifecycle_test.dart
+2
-4
No files found.
packages/flutter/test/material/text_theme_test.dart
View file @
793678d5
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -52,7 +50,7 @@ void main() {
test
(
'TextTheme merges properly in the presence of null fields.'
,
()
{
const
TextTheme
partialTheme
=
TextTheme
(
headline6:
TextStyle
(
color:
Color
(
0xcafefeed
)));
final
TextTheme
fullTheme
=
ThemeData
.
fallback
().
textTheme
.
merge
(
partialTheme
);
expect
(
fullTheme
.
headline6
.
color
,
equals
(
partialTheme
.
headline6
.
color
));
expect
(
fullTheme
.
headline6
!.
color
,
equals
(
partialTheme
.
headline6
!
.
color
));
const
TextTheme
onlyHeadlineAndTitle
=
TextTheme
(
headline5:
TextStyle
(
color:
Color
(
0xcafefeed
)),
...
...
@@ -64,9 +62,9 @@ void main() {
);
TextTheme
merged
=
onlyHeadlineAndTitle
.
merge
(
onlyBody1AndTitle
);
expect
(
merged
.
bodyText1
,
isNull
);
expect
(
merged
.
bodyText2
.
color
,
equals
(
onlyBody1AndTitle
.
bodyText2
.
color
));
expect
(
merged
.
headline5
.
color
,
equals
(
onlyHeadlineAndTitle
.
headline5
.
color
));
expect
(
merged
.
headline6
.
color
,
equals
(
onlyBody1AndTitle
.
headline6
.
color
));
expect
(
merged
.
bodyText2
!.
color
,
equals
(
onlyBody1AndTitle
.
bodyText2
!
.
color
));
expect
(
merged
.
headline5
!.
color
,
equals
(
onlyHeadlineAndTitle
.
headline5
!
.
color
));
expect
(
merged
.
headline6
!.
color
,
equals
(
onlyBody1AndTitle
.
headline6
!
.
color
));
merged
=
onlyHeadlineAndTitle
.
merge
(
null
);
expect
(
merged
,
equals
(
onlyHeadlineAndTitle
));
...
...
@@ -96,34 +94,34 @@ void main() {
decorationStyle:
decorationStyle
,
);
expect
(
theme
.
headline1
.
color
,
displayColor
);
expect
(
theme
.
headline2
.
color
,
displayColor
);
expect
(
theme
.
headline3
.
color
,
displayColor
);
expect
(
theme
.
headline4
.
color
,
displayColor
);
expect
(
theme
.
caption
.
color
,
displayColor
);
expect
(
theme
.
headline5
.
color
,
bodyColor
);
expect
(
theme
.
headline6
.
color
,
bodyColor
);
expect
(
theme
.
subtitle1
.
color
,
bodyColor
);
expect
(
theme
.
bodyText1
.
color
,
bodyColor
);
expect
(
theme
.
bodyText2
.
color
,
bodyColor
);
expect
(
theme
.
button
.
color
,
bodyColor
);
expect
(
theme
.
subtitle2
.
color
,
bodyColor
);
expect
(
theme
.
overline
.
color
,
bodyColor
);
expect
(
theme
.
headline1
!
.
color
,
displayColor
);
expect
(
theme
.
headline2
!
.
color
,
displayColor
);
expect
(
theme
.
headline3
!
.
color
,
displayColor
);
expect
(
theme
.
headline4
!
.
color
,
displayColor
);
expect
(
theme
.
caption
!
.
color
,
displayColor
);
expect
(
theme
.
headline5
!
.
color
,
bodyColor
);
expect
(
theme
.
headline6
!
.
color
,
bodyColor
);
expect
(
theme
.
subtitle1
!
.
color
,
bodyColor
);
expect
(
theme
.
bodyText1
!
.
color
,
bodyColor
);
expect
(
theme
.
bodyText2
!
.
color
,
bodyColor
);
expect
(
theme
.
button
!
.
color
,
bodyColor
);
expect
(
theme
.
subtitle2
!
.
color
,
bodyColor
);
expect
(
theme
.
overline
!
.
color
,
bodyColor
);
final
List
<
TextStyle
>
themeStyles
=
<
TextStyle
>[
theme
.
headline1
,
theme
.
headline2
,
theme
.
headline3
,
theme
.
headline4
,
theme
.
caption
,
theme
.
headline5
,
theme
.
headline6
,
theme
.
subtitle1
,
theme
.
bodyText1
,
theme
.
bodyText2
,
theme
.
button
,
theme
.
subtitle2
,
theme
.
overline
,
theme
.
headline1
!
,
theme
.
headline2
!
,
theme
.
headline3
!
,
theme
.
headline4
!
,
theme
.
caption
!
,
theme
.
headline5
!
,
theme
.
headline6
!
,
theme
.
subtitle1
!
,
theme
.
bodyText1
!
,
theme
.
bodyText2
!
,
theme
.
button
!
,
theme
.
subtitle2
!
,
theme
.
overline
!
,
];
expect
(
themeStyles
.
every
((
TextStyle
style
)
=>
style
.
fontFamily
==
fontFamily
),
true
);
expect
(
themeStyles
.
every
((
TextStyle
style
)
=>
style
.
decorationColor
==
decorationColor
),
true
);
...
...
@@ -139,19 +137,19 @@ void main() {
fontSizeDelta:
5.0
,
);
expect
(
sizeTheme
.
headline1
.
fontSize
,
baseTheme
.
headline1
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
headline2
.
fontSize
,
baseTheme
.
headline2
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
headline3
.
fontSize
,
baseTheme
.
headline3
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
headline4
.
fontSize
,
baseTheme
.
headline4
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
caption
.
fontSize
,
baseTheme
.
caption
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
headline5
.
fontSize
,
baseTheme
.
headline5
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
headline6
.
fontSize
,
baseTheme
.
headline6
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
subtitle1
.
fontSize
,
baseTheme
.
subtitle1
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
bodyText1
.
fontSize
,
baseTheme
.
bodyText1
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
bodyText2
.
fontSize
,
baseTheme
.
bodyText2
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
button
.
fontSize
,
baseTheme
.
button
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
subtitle2
.
fontSize
,
baseTheme
.
subtitle2
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
overline
.
fontSize
,
baseTheme
.
overline
.
fontSize
*
2.0
+
5.0
);
expect
(
sizeTheme
.
headline1
!.
fontSize
,
baseTheme
.
headline1
!.
fontSize
!
*
2.0
+
5.0
);
expect
(
sizeTheme
.
headline2
!.
fontSize
,
baseTheme
.
headline2
!.
fontSize
!
*
2.0
+
5.0
);
expect
(
sizeTheme
.
headline3
!.
fontSize
,
baseTheme
.
headline3
!.
fontSize
!
*
2.0
+
5.0
);
expect
(
sizeTheme
.
headline4
!.
fontSize
,
baseTheme
.
headline4
!.
fontSize
!
*
2.0
+
5.0
);
expect
(
sizeTheme
.
caption
!.
fontSize
,
baseTheme
.
caption
!.
fontSize
!
*
2.0
+
5.0
);
expect
(
sizeTheme
.
headline5
!.
fontSize
,
baseTheme
.
headline5
!.
fontSize
!
*
2.0
+
5.0
);
expect
(
sizeTheme
.
headline6
!.
fontSize
,
baseTheme
.
headline6
!.
fontSize
!
*
2.0
+
5.0
);
expect
(
sizeTheme
.
subtitle1
!.
fontSize
,
baseTheme
.
subtitle1
!.
fontSize
!
*
2.0
+
5.0
);
expect
(
sizeTheme
.
bodyText1
!.
fontSize
,
baseTheme
.
bodyText1
!.
fontSize
!
*
2.0
+
5.0
);
expect
(
sizeTheme
.
bodyText2
!.
fontSize
,
baseTheme
.
bodyText2
!.
fontSize
!
*
2.0
+
5.0
);
expect
(
sizeTheme
.
button
!.
fontSize
,
baseTheme
.
button
!.
fontSize
!
*
2.0
+
5.0
);
expect
(
sizeTheme
.
subtitle2
!.
fontSize
,
baseTheme
.
subtitle2
!.
fontSize
!
*
2.0
+
5.0
);
expect
(
sizeTheme
.
overline
!.
fontSize
,
baseTheme
.
overline
!.
fontSize
!
*
2.0
+
5.0
);
});
test
(
'TextTheme lerp with second parameter null'
,
()
{
...
...
packages/flutter/test/material/theme_data_test.dart
View file @
793678d5
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -37,8 +35,8 @@ void main() {
final
ThemeData
darkTheme
=
ThemeData
(
brightness:
Brightness
.
dark
);
final
Typography
typography
=
Typography
.
material2018
(
platform:
lightTheme
.
platform
);
expect
(
lightTheme
.
textTheme
.
headline6
.
color
,
typography
.
black
.
headline6
.
color
);
expect
(
darkTheme
.
textTheme
.
headline6
.
color
,
typography
.
white
.
headline6
.
color
);
expect
(
lightTheme
.
textTheme
.
headline6
!.
color
,
typography
.
black
.
headline6
!
.
color
);
expect
(
darkTheme
.
textTheme
.
headline6
!.
color
,
typography
.
white
.
headline6
!
.
color
);
});
test
(
'Default primary text theme contrasts with primary brightness'
,
()
{
...
...
@@ -46,8 +44,8 @@ void main() {
final
ThemeData
darkTheme
=
ThemeData
(
primaryColorBrightness:
Brightness
.
dark
);
final
Typography
typography
=
Typography
.
material2018
(
platform:
lightTheme
.
platform
);
expect
(
lightTheme
.
primaryTextTheme
.
headline6
.
color
,
typography
.
black
.
headline6
.
color
);
expect
(
darkTheme
.
primaryTextTheme
.
headline6
.
color
,
typography
.
white
.
headline6
.
color
);
expect
(
lightTheme
.
primaryTextTheme
.
headline6
!.
color
,
typography
.
black
.
headline6
!
.
color
);
expect
(
darkTheme
.
primaryTextTheme
.
headline6
!.
color
,
typography
.
white
.
headline6
!
.
color
);
});
test
(
'Default accent text theme contrasts with accent brightness'
,
()
{
...
...
@@ -55,8 +53,8 @@ void main() {
final
ThemeData
darkTheme
=
ThemeData
(
accentColorBrightness:
Brightness
.
dark
);
final
Typography
typography
=
Typography
.
material2018
(
platform:
lightTheme
.
platform
);
expect
(
lightTheme
.
accentTextTheme
.
headline6
.
color
,
typography
.
black
.
headline6
.
color
);
expect
(
darkTheme
.
accentTextTheme
.
headline6
.
color
,
typography
.
white
.
headline6
.
color
);
expect
(
lightTheme
.
accentTextTheme
.
headline6
!.
color
,
typography
.
black
.
headline6
!
.
color
);
expect
(
darkTheme
.
accentTextTheme
.
headline6
!.
color
,
typography
.
white
.
headline6
!
.
color
);
});
test
(
'Default chip label style gets a default bodyText1 if textTheme.bodyText1 is null'
,
()
{
...
...
@@ -65,8 +63,8 @@ void main() {
final
ThemeData
darkTheme
=
ThemeData
(
brightness:
Brightness
.
dark
,
textTheme:
noBodyText1TextTheme
);
final
Typography
typography
=
Typography
.
material2018
(
platform:
lightTheme
.
platform
);
expect
(
lightTheme
.
chipTheme
.
labelStyle
.
color
,
equals
(
typography
.
black
.
bodyText1
.
color
.
withAlpha
(
0xde
)));
expect
(
darkTheme
.
chipTheme
.
labelStyle
.
color
,
equals
(
typography
.
white
.
bodyText1
.
color
.
withAlpha
(
0xde
)));
expect
(
lightTheme
.
chipTheme
.
labelStyle
.
color
,
equals
(
typography
.
black
.
bodyText1
!.
color
!
.
withAlpha
(
0xde
)));
expect
(
darkTheme
.
chipTheme
.
labelStyle
.
color
,
equals
(
typography
.
white
.
bodyText1
!.
color
!
.
withAlpha
(
0xde
)));
});
test
(
'Default icon theme contrasts with brightness'
,
()
{
...
...
@@ -74,8 +72,8 @@ void main() {
final
ThemeData
darkTheme
=
ThemeData
(
brightness:
Brightness
.
dark
);
final
Typography
typography
=
Typography
.
material2018
(
platform:
lightTheme
.
platform
);
expect
(
lightTheme
.
textTheme
.
headline6
.
color
,
typography
.
black
.
headline6
.
color
);
expect
(
darkTheme
.
textTheme
.
headline6
.
color
,
typography
.
white
.
headline6
.
color
);
expect
(
lightTheme
.
textTheme
.
headline6
!.
color
,
typography
.
black
.
headline6
!
.
color
);
expect
(
darkTheme
.
textTheme
.
headline6
!.
color
,
typography
.
white
.
headline6
!
.
color
);
});
test
(
'Default primary icon theme contrasts with primary brightness'
,
()
{
...
...
@@ -83,8 +81,8 @@ void main() {
final
ThemeData
darkTheme
=
ThemeData
(
primaryColorBrightness:
Brightness
.
dark
);
final
Typography
typography
=
Typography
.
material2018
(
platform:
lightTheme
.
platform
);
expect
(
lightTheme
.
primaryTextTheme
.
headline6
.
color
,
typography
.
black
.
headline6
.
color
);
expect
(
darkTheme
.
primaryTextTheme
.
headline6
.
color
,
typography
.
white
.
headline6
.
color
);
expect
(
lightTheme
.
primaryTextTheme
.
headline6
!.
color
,
typography
.
black
.
headline6
!
.
color
);
expect
(
darkTheme
.
primaryTextTheme
.
headline6
!.
color
,
typography
.
white
.
headline6
!
.
color
);
});
test
(
'Default accent icon theme contrasts with accent brightness'
,
()
{
...
...
@@ -92,8 +90,8 @@ void main() {
final
ThemeData
darkTheme
=
ThemeData
(
accentColorBrightness:
Brightness
.
dark
);
final
Typography
typography
=
Typography
.
material2018
(
platform:
lightTheme
.
platform
);
expect
(
lightTheme
.
accentTextTheme
.
headline6
.
color
,
typography
.
black
.
headline6
.
color
);
expect
(
darkTheme
.
accentTextTheme
.
headline6
.
color
,
typography
.
white
.
headline6
.
color
);
expect
(
lightTheme
.
accentTextTheme
.
headline6
!.
color
,
typography
.
black
.
headline6
!
.
color
);
expect
(
darkTheme
.
accentTextTheme
.
headline6
!.
color
,
typography
.
white
.
headline6
!
.
color
);
});
testWidgets
(
'Defaults to MaterialTapTargetBehavior.padded on mobile platforms and MaterialTapTargetBehavior.shrinkWrap on desktop'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -120,12 +118,12 @@ void main() {
),
);
expect
(
themeData
.
textTheme
.
bodyText1
.
fontFamily
,
equals
(
'Ahem'
));
expect
(
themeData
.
primaryTextTheme
.
headline3
.
fontFamily
,
equals
(
'Ahem'
));
expect
(
themeData
.
accentTextTheme
.
headline1
.
fontFamily
,
equals
(
'Ahem'
));
expect
(
themeData
.
textTheme
.
bodyText1
!
.
fontFamily
,
equals
(
'Ahem'
));
expect
(
themeData
.
primaryTextTheme
.
headline3
!
.
fontFamily
,
equals
(
'Ahem'
));
expect
(
themeData
.
accentTextTheme
.
headline1
!
.
fontFamily
,
equals
(
'Ahem'
));
// Shouldn't override the specified style's family
expect
(
themeData
.
textTheme
.
headline6
.
fontFamily
,
equals
(
'Roboto'
));
expect
(
themeData
.
textTheme
.
headline6
!
.
fontFamily
,
equals
(
'Roboto'
));
});
test
(
'Can estimate brightness - directly'
,
()
{
...
...
@@ -192,7 +190,7 @@ void main() {
});
testWidgets
(
'VisualDensity.adaptivePlatformDensity returns adaptive values'
,
(
WidgetTester
tester
)
async
{
switch
(
debugDefaultTargetPlatformOverride
)
{
switch
(
debugDefaultTargetPlatformOverride
!
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
fuchsia
:
...
...
@@ -207,7 +205,7 @@ void main() {
testWidgets
(
'VisualDensity in ThemeData defaults to "compact" on desktop and "standard" on mobile'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
themeData
=
ThemeData
();
switch
(
debugDefaultTargetPlatformOverride
)
{
switch
(
debugDefaultTargetPlatformOverride
!
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
fuchsia
:
...
...
packages/flutter/test/material/theme_defaults_test.dart
View file @
793678d5
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -28,7 +26,7 @@ void main() {
);
final
RawMaterialButton
raw
=
tester
.
widget
<
RawMaterialButton
>(
find
.
byType
(
RawMaterialButton
));
expect
(
raw
.
textStyle
.
color
,
const
Color
(
0xdd000000
));
expect
(
raw
.
textStyle
!
.
color
,
const
Color
(
0xdd000000
));
expect
(
raw
.
fillColor
,
const
Color
(
0xffe0e0e0
));
expect
(
raw
.
highlightColor
,
const
Color
(
0x29000000
));
// Was Color(0x66bcbcbc)
expect
(
raw
.
splashColor
,
const
Color
(
0x1f000000
));
// Was Color(0x66c8c8c8)
...
...
@@ -56,7 +54,7 @@ void main() {
);
final
RawMaterialButton
raw
=
tester
.
widget
<
RawMaterialButton
>(
find
.
byType
(
RawMaterialButton
));
expect
(
raw
.
textStyle
.
color
,
const
Color
(
0x61000000
));
expect
(
raw
.
textStyle
!
.
color
,
const
Color
(
0x61000000
));
expect
(
raw
.
fillColor
,
const
Color
(
0x61000000
));
// highlightColor, disabled button can't be pressed
// splashColor, disabled button doesn't splash
...
...
@@ -86,7 +84,7 @@ void main() {
);
final
RawMaterialButton
raw
=
tester
.
widget
<
RawMaterialButton
>(
find
.
byType
(
RawMaterialButton
));
expect
(
raw
.
textStyle
.
color
,
const
Color
(
0xdd000000
));
expect
(
raw
.
textStyle
!
.
color
,
const
Color
(
0xdd000000
));
expect
(
raw
.
fillColor
,
null
);
expect
(
raw
.
highlightColor
,
const
Color
(
0x29000000
));
// Was Color(0x66bcbcbc)
expect
(
raw
.
splashColor
,
const
Color
(
0x1f000000
));
// Was Color(0x66c8c8c8)
...
...
@@ -114,7 +112,7 @@ void main() {
);
final
RawMaterialButton
raw
=
tester
.
widget
<
RawMaterialButton
>(
find
.
byType
(
RawMaterialButton
));
expect
(
raw
.
textStyle
.
color
,
const
Color
(
0x61000000
));
expect
(
raw
.
textStyle
!
.
color
,
const
Color
(
0x61000000
));
expect
(
raw
.
fillColor
,
null
);
// highlightColor, disabled button can't be pressed
// splashColor, disabled button doesn't splash
...
...
@@ -148,7 +146,7 @@ void main() {
);
final
RawMaterialButton
raw
=
tester
.
widget
<
RawMaterialButton
>(
find
.
byType
(
RawMaterialButton
));
expect
(
raw
.
textStyle
.
color
,
const
Color
(
0xdd000000
));
expect
(
raw
.
textStyle
!
.
color
,
const
Color
(
0xdd000000
));
expect
(
raw
.
fillColor
,
const
Color
(
0x00fafafa
));
expect
(
raw
.
highlightColor
,
const
Color
(
0x29000000
));
// Was Color(0x66bcbcbc)
expect
(
raw
.
splashColor
,
const
Color
(
0x1f000000
));
// Was Color(0x66c8c8c8)
...
...
@@ -175,7 +173,7 @@ void main() {
);
final
RawMaterialButton
raw
=
tester
.
widget
<
RawMaterialButton
>(
find
.
byType
(
RawMaterialButton
));
expect
(
raw
.
textStyle
.
color
,
const
Color
(
0xdd000000
));
expect
(
raw
.
textStyle
!
.
color
,
const
Color
(
0xdd000000
));
expect
(
raw
.
fillColor
,
Colors
.
transparent
);
expect
(
raw
.
highlightColor
,
const
Color
(
0x29000000
));
// Was Color(0x66bcbcbc)
expect
(
raw
.
splashColor
,
const
Color
(
0x1f000000
));
// Was Color(0x66c8c8c8)
...
...
@@ -202,7 +200,7 @@ void main() {
);
final
RawMaterialButton
raw
=
tester
.
widget
<
RawMaterialButton
>(
find
.
byType
(
RawMaterialButton
));
expect
(
raw
.
textStyle
.
color
,
const
Color
(
0x61000000
));
expect
(
raw
.
textStyle
!
.
color
,
const
Color
(
0x61000000
));
expect
(
raw
.
fillColor
,
const
Color
(
0x00000000
));
// highlightColor, disabled button can't be pressed
// splashColor, disabled button doesn't splash
...
...
@@ -236,7 +234,7 @@ void main() {
final
RawMaterialButton
raw
=
tester
.
widget
<
RawMaterialButton
>(
find
.
byType
(
RawMaterialButton
));
expect
(
raw
.
enabled
,
true
);
expect
(
raw
.
textStyle
.
color
,
const
Color
(
0xffffffff
));
expect
(
raw
.
textStyle
!
.
color
,
const
Color
(
0xffffffff
));
expect
(
raw
.
fillColor
,
const
Color
(
0xff2196f3
));
expect
(
raw
.
elevation
,
6.0
);
expect
(
raw
.
highlightElevation
,
12.0
);
...
...
@@ -263,7 +261,7 @@ void main() {
final
RawMaterialButton
raw
=
tester
.
widget
<
RawMaterialButton
>(
find
.
byType
(
RawMaterialButton
));
expect
(
raw
.
enabled
,
false
);
expect
(
raw
.
textStyle
.
color
,
const
Color
(
0xffffffff
));
expect
(
raw
.
textStyle
!
.
color
,
const
Color
(
0xffffffff
));
expect
(
raw
.
fillColor
,
const
Color
(
0xff2196f3
));
// highlightColor, disabled button can't be pressed
// splashColor, disabled button doesn't splash
...
...
packages/flutter/test/material/theme_test.dart
View file @
793678d5
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/time_picker_test.dart
View file @
793678d5
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/time_picker_theme_test.dart
View file @
793678d5
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/time_test.dart
View file @
793678d5
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -11,7 +9,7 @@ void main() {
group
(
'TimeOfDay.format'
,
()
{
testWidgets
(
'respects alwaysUse24HourFormat option'
,
(
WidgetTester
tester
)
async
{
Future
<
String
>
pumpTest
(
bool
alwaysUse24HourFormat
)
async
{
String
formattedValue
;
late
String
formattedValue
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
data:
MediaQueryData
(
alwaysUse24HourFormat:
alwaysUse24HourFormat
),
...
...
packages/flutter/test/material/toggle_buttons_test.dart
View file @
793678d5
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -13,7 +11,7 @@ import '../rendering/mock_canvas.dart';
const
double
_defaultBorderWidth
=
1.0
;
Widget
boilerplate
(
{
Widget
child
})
{
Widget
boilerplate
(
{
required
Widget
child
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
child
),
...
...
@@ -170,50 +168,6 @@ void main() {
},
);
testWidgets
(
'children property cannot be null'
,
(
WidgetTester
tester
)
async
{
try
{
await
tester
.
pumpWidget
(
Material
(
child:
boilerplate
(
child:
ToggleButtons
(
isSelected:
const
<
bool
>[
false
,
true
],
onPressed:
(
int
index
)
{},
children:
null
,
),
),
),
);
fail
(
'Should not be possible to create a toggle button with no children.'
);
}
on
AssertionError
catch
(
e
)
{
expect
(
e
.
toString
(),
contains
(
'children != null'
));
}
});
testWidgets
(
'isSelected property cannot be null'
,
(
WidgetTester
tester
)
async
{
try
{
await
tester
.
pumpWidget
(
Material
(
child:
boilerplate
(
child:
ToggleButtons
(
isSelected:
null
,
onPressed:
(
int
index
)
{},
children:
const
<
Widget
>[
Text
(
'First child'
),
Text
(
'Second child'
),
],
),
),
),
);
fail
(
'Should not be possible to create a toggle button with no isSelected.'
);
}
on
AssertionError
catch
(
e
)
{
expect
(
e
.
toString
(),
contains
(
'isSelected != null'
));
}
},
);
testWidgets
(
'children and isSelected properties have to be the same length'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -262,15 +216,15 @@ void main() {
of:
find
.
widgetWithText
(
RawMaterialButton
,
'First child'
),
matching:
find
.
byType
(
DefaultTextStyle
),
)).
style
;
expect
(
textStyle
.
fontFamily
,
theme
.
textTheme
.
bodyText2
.
fontFamily
);
expect
(
textStyle
.
decoration
,
theme
.
textTheme
.
bodyText2
.
decoration
);
expect
(
textStyle
.
fontFamily
,
theme
.
textTheme
.
bodyText2
!
.
fontFamily
);
expect
(
textStyle
.
decoration
,
theme
.
textTheme
.
bodyText2
!
.
decoration
);
textStyle
=
tester
.
widget
<
DefaultTextStyle
>(
find
.
descendant
(
of:
find
.
widgetWithText
(
RawMaterialButton
,
'Second child'
),
matching:
find
.
byType
(
DefaultTextStyle
),
)).
style
;
expect
(
textStyle
.
fontFamily
,
theme
.
textTheme
.
bodyText2
.
fontFamily
);
expect
(
textStyle
.
decoration
,
theme
.
textTheme
.
bodyText2
.
decoration
);
expect
(
textStyle
.
fontFamily
,
theme
.
textTheme
.
bodyText2
!
.
fontFamily
);
expect
(
textStyle
.
decoration
,
theme
.
textTheme
.
bodyText2
!
.
decoration
);
});
testWidgets
(
'Custom text style except color is applied'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -1470,7 +1424,7 @@ void main() {
await
tester
.
pump
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
// Test default cursor
await
tester
.
pumpWidget
(
...
...
@@ -1491,7 +1445,7 @@ void main() {
),
);
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
// Test default cursor when disabled
await
tester
.
pumpWidget
(
...
...
@@ -1511,6 +1465,6 @@ void main() {
),
);
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
});
}
packages/flutter/test/material/toggle_buttons_theme_test.dart
View file @
793678d5
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -11,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
import
'../rendering/mock_canvas.dart'
;
Widget
boilerplate
(
{
Widget
child
})
{
Widget
boilerplate
(
{
required
Widget
child
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
child
),
...
...
packages/flutter/test/material/tooltip_test.dart
View file @
793678d5
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:ui'
;
import
'package:flutter/services.dart'
;
...
...
@@ -581,7 +579,7 @@ void main() {
(
key
.
currentState
as
dynamic
).
ensureTooltipVisible
();
// Before using "as dynamic" in your code, see note at the top of the file.
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
// faded in, show timer started (and at 0.0)
final
TextStyle
textStyle
=
tester
.
widget
<
Text
>(
find
.
text
(
tooltipText
)).
style
;
final
TextStyle
textStyle
=
tester
.
widget
<
Text
>(
find
.
text
(
tooltipText
)).
style
!
;
expect
(
textStyle
.
color
,
Colors
.
white
);
expect
(
textStyle
.
fontFamily
,
'Roboto'
);
expect
(
textStyle
.
decoration
,
TextDecoration
.
none
);
...
...
@@ -607,7 +605,7 @@ void main() {
(
key
.
currentState
as
dynamic
).
ensureTooltipVisible
();
// Before using "as dynamic" in your code, see note at the top of the file.
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
// faded in, show timer started (and at 0.0)
final
TextStyle
textStyle
=
tester
.
widget
<
Text
>(
find
.
text
(
tooltipText
)).
style
;
final
TextStyle
textStyle
=
tester
.
widget
<
Text
>(
find
.
text
(
tooltipText
)).
style
!
;
expect
(
textStyle
.
color
,
Colors
.
black
);
expect
(
textStyle
.
fontFamily
,
'Roboto'
);
expect
(
textStyle
.
decoration
,
TextDecoration
.
none
);
...
...
@@ -634,7 +632,7 @@ void main() {
(
key
.
currentState
as
dynamic
).
ensureTooltipVisible
();
// Before using "as dynamic" in your code, see note at the top of the file.
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
// faded in, show timer started (and at 0.0)
final
TextStyle
textStyle
=
tester
.
widget
<
Text
>(
find
.
text
(
tooltipText
)).
style
;
final
TextStyle
textStyle
=
tester
.
widget
<
Text
>(
find
.
text
(
tooltipText
)).
style
!
;
expect
(
textStyle
.
color
,
Colors
.
orange
);
expect
(
textStyle
.
fontFamily
,
null
);
expect
(
textStyle
.
decoration
,
TextDecoration
.
underline
);
...
...
@@ -833,12 +831,12 @@ void main() {
testWidgets
(
'Tooltip shows/hides when hovered'
,
(
WidgetTester
tester
)
async
{
const
Duration
waitDuration
=
Duration
(
milliseconds:
0
);
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
);
TestGesture
?
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
);
addTearDown
(()
async
{
if
(
gesture
!=
null
)
return
gesture
.
removePointer
();
});
await
gesture
.
addPointer
();
await
gesture
!
.
addPointer
();
await
gesture
.
moveTo
(
const
Offset
(
1.0
,
1.0
));
await
tester
.
pump
();
await
gesture
.
moveTo
(
Offset
.
zero
);
...
...
@@ -1013,7 +1011,7 @@ void main() {
});
testWidgets
(
'Tooltip text scales with textScaleFactor'
,
(
WidgetTester
tester
)
async
{
Widget
buildApp
(
String
text
,
{
double
textScaleFactor
})
{
Widget
buildApp
(
String
text
,
{
required
double
textScaleFactor
})
{
return
MediaQuery
(
data:
MediaQueryData
(
textScaleFactor:
textScaleFactor
),
child:
Directionality
(
...
...
@@ -1254,6 +1252,6 @@ void main() {
SemanticsNode
findDebugSemantics
(
RenderObject
object
)
{
if
(
object
.
debugSemantics
!=
null
)
return
object
.
debugSemantics
;
return
findDebugSemantics
(
object
.
parent
as
RenderObject
);
return
object
.
debugSemantics
!
;
return
findDebugSemantics
(
object
.
parent
!
as
RenderObject
);
}
packages/flutter/test/material/tooltip_theme_test.dart
View file @
793678d5
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/services.dart'
;
import
'package:flutter/src/material/tooltip_theme.dart'
;
import
'package:flutter/gestures.dart'
;
...
...
@@ -151,7 +149,7 @@ void main() {
* *
*********************/
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
as
RenderBox
;
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
!
as
RenderBox
;
expect
(
tip
.
size
.
height
,
equals
(
100.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
topLeft
(
Offset
.
zero
)).
dy
,
equals
(
100.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
bottomRight
(
Offset
.
zero
)).
dy
,
equals
(
200.0
));
...
...
@@ -209,7 +207,7 @@ void main() {
* *
*********************/
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
as
RenderBox
;
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
!
as
RenderBox
;
expect
(
tip
.
size
.
height
,
equals
(
100.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
topLeft
(
Offset
.
zero
)).
dy
,
equals
(
100.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
bottomRight
(
Offset
.
zero
)).
dy
,
equals
(
200.0
));
...
...
@@ -280,7 +278,7 @@ void main() {
* * }- 10.0 margin
*********************/
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
as
RenderBox
;
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
!
as
RenderBox
;
expect
(
tip
.
size
.
height
,
equals
(
190.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
topLeft
(
Offset
.
zero
)).
dy
,
equals
(
399.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
bottomRight
(
Offset
.
zero
)).
dy
,
equals
(
589.0
));
...
...
@@ -349,7 +347,7 @@ void main() {
* * }- 10.0 margin
*********************/
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
as
RenderBox
;
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
!
as
RenderBox
;
expect
(
tip
.
size
.
height
,
equals
(
190.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
topLeft
(
Offset
.
zero
)).
dy
,
equals
(
399.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
bottomRight
(
Offset
.
zero
)).
dy
,
equals
(
589.0
));
...
...
@@ -408,7 +406,7 @@ void main() {
* * }- 10.0 margin
*********************/
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
as
RenderBox
;
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
!
as
RenderBox
;
expect
(
tip
.
size
.
height
,
equals
(
190.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
topLeft
(
Offset
.
zero
)).
dy
,
equals
(
400.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
bottomRight
(
Offset
.
zero
)).
dy
,
equals
(
590.0
));
...
...
@@ -465,7 +463,7 @@ void main() {
* * }- 10.0 margin
*********************/
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
as
RenderBox
;
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
!
as
RenderBox
;
expect
(
tip
.
size
.
height
,
equals
(
190.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
topLeft
(
Offset
.
zero
)).
dy
,
equals
(
400.0
));
expect
(
tip
.
localToGlobal
(
tip
.
size
.
bottomRight
(
Offset
.
zero
)).
dy
,
equals
(
590.0
));
...
...
@@ -505,7 +503,7 @@ void main() {
(
key
.
currentState
as
dynamic
).
ensureTooltipVisible
();
// Before using "as dynamic" in your code, see note at the top of the file.
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
// faded in, show timer started (and at 0.0)
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
.
parent
.
parent
.
parent
.
parent
as
RenderBox
;
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
!.
parent
!.
parent
!.
parent
!.
parent
!
as
RenderBox
;
final
RenderBox
tooltipContent
=
tester
.
renderObject
(
find
.
text
(
tooltipText
));
final
Offset
topLeftTipInGlobal
=
tip
.
localToGlobal
(
tip
.
size
.
topLeft
(
Offset
.
zero
));
...
...
@@ -561,7 +559,7 @@ void main() {
(
key
.
currentState
as
dynamic
).
ensureTooltipVisible
();
// Before using "as dynamic" in your code, see note at the top of the file.
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
// faded in, show timer started (and at 0.0)
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
.
parent
.
parent
.
parent
.
parent
as
RenderBox
;
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
!.
parent
!.
parent
!.
parent
!.
parent
!
as
RenderBox
;
final
RenderBox
tooltipContent
=
tester
.
renderObject
(
find
.
text
(
tooltipText
));
final
Offset
topLeftTipInGlobal
=
tip
.
localToGlobal
(
tip
.
size
.
topLeft
(
Offset
.
zero
));
...
...
@@ -609,7 +607,7 @@ void main() {
(
key
.
currentState
as
dynamic
).
ensureTooltipVisible
();
// Before using "as dynamic" in your code, see note at the top of the file.
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
// faded in, show timer started (and at 0.0)
final
TextStyle
textStyle
=
tester
.
widget
<
Text
>(
find
.
text
(
tooltipText
)).
style
;
final
TextStyle
textStyle
=
tester
.
widget
<
Text
>(
find
.
text
(
tooltipText
)).
style
!
;
expect
(
textStyle
.
color
,
Colors
.
orange
);
expect
(
textStyle
.
fontFamily
,
null
);
expect
(
textStyle
.
decoration
,
TextDecoration
.
underline
);
...
...
@@ -638,7 +636,7 @@ void main() {
(
key
.
currentState
as
dynamic
).
ensureTooltipVisible
();
// Before using "as dynamic" in your code, see note at the top of the file.
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
// faded in, show timer started (and at 0.0)
final
TextStyle
textStyle
=
tester
.
widget
<
Text
>(
find
.
text
(
tooltipText
)).
style
;
final
TextStyle
textStyle
=
tester
.
widget
<
Text
>(
find
.
text
(
tooltipText
)).
style
!
;
expect
(
textStyle
.
color
,
Colors
.
orange
);
expect
(
textStyle
.
fontFamily
,
null
);
expect
(
textStyle
.
decoration
,
TextDecoration
.
underline
);
...
...
@@ -681,7 +679,7 @@ void main() {
(
key
.
currentState
as
dynamic
).
ensureTooltipVisible
();
// Before using "as dynamic" in your code, see note at the top of the file.
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
// faded in, show timer started (and at 0.0)
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
.
parent
.
parent
.
parent
as
RenderBox
;
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
!.
parent
!.
parent
!.
parent
!
as
RenderBox
;
expect
(
tip
.
size
.
height
,
equals
(
32.0
));
expect
(
tip
.
size
.
width
,
equals
(
74.0
));
...
...
@@ -723,7 +721,7 @@ void main() {
(
key
.
currentState
as
dynamic
).
ensureTooltipVisible
();
// Before using "as dynamic" in your code, see note at the top of the file.
await
tester
.
pump
(
const
Duration
(
seconds:
2
));
// faded in, show timer started (and at 0.0)
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
.
parent
.
parent
.
parent
as
RenderBox
;
final
RenderBox
tip
=
tester
.
renderObject
(
find
.
text
(
tooltipText
)).
parent
!.
parent
!.
parent
!.
parent
!
as
RenderBox
;
expect
(
tip
.
size
.
height
,
equals
(
32.0
));
expect
(
tip
.
size
.
width
,
equals
(
74.0
));
...
...
@@ -1259,6 +1257,6 @@ void main() {
SemanticsNode
findDebugSemantics
(
RenderObject
object
)
{
if
(
object
.
debugSemantics
!=
null
)
return
object
.
debugSemantics
;
return
findDebugSemantics
(
object
.
parent
as
RenderObject
);
return
object
.
debugSemantics
!
;
return
findDebugSemantics
(
object
.
parent
!
as
RenderObject
);
}
packages/flutter/test/material/typography_test.dart
View file @
793678d5
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -19,16 +17,16 @@ void main() {
});
test
(
'Typography on non-Apple platforms defaults to the correct font'
,
()
{
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
headline6
.
fontFamily
,
'Roboto'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
fuchsia
).
black
.
headline6
.
fontFamily
,
'Roboto'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
linux
).
black
.
headline6
.
fontFamily
,
'Roboto'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
linux
).
black
.
headline6
.
fontFamilyFallback
,
<
String
>[
'Ubuntu'
,
'Cantarell'
,
'DejaVu Sans'
,
'Liberation Sans'
,
'Arial'
]);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
windows
).
black
.
headline6
.
fontFamily
,
'Segoe UI'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
white
.
headline6
.
fontFamily
,
'Roboto'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
fuchsia
).
white
.
headline6
.
fontFamily
,
'Roboto'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
linux
).
white
.
headline6
.
fontFamily
,
'Roboto'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
linux
).
white
.
headline6
.
fontFamilyFallback
,
<
String
>[
'Ubuntu'
,
'Cantarell'
,
'DejaVu Sans'
,
'Liberation Sans'
,
'Arial'
]);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
windows
).
white
.
headline6
.
fontFamily
,
'Segoe UI'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
black
.
headline6
!
.
fontFamily
,
'Roboto'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
fuchsia
).
black
.
headline6
!
.
fontFamily
,
'Roboto'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
linux
).
black
.
headline6
!
.
fontFamily
,
'Roboto'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
linux
).
black
.
headline6
!
.
fontFamilyFallback
,
<
String
>[
'Ubuntu'
,
'Cantarell'
,
'DejaVu Sans'
,
'Liberation Sans'
,
'Arial'
]);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
windows
).
black
.
headline6
!
.
fontFamily
,
'Segoe UI'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
android
).
white
.
headline6
!
.
fontFamily
,
'Roboto'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
fuchsia
).
white
.
headline6
!
.
fontFamily
,
'Roboto'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
linux
).
white
.
headline6
!
.
fontFamily
,
'Roboto'
);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
linux
).
white
.
headline6
!
.
fontFamilyFallback
,
<
String
>[
'Ubuntu'
,
'Cantarell'
,
'DejaVu Sans'
,
'Liberation Sans'
,
'Arial'
]);
expect
(
Typography
.
material2018
(
platform:
TargetPlatform
.
windows
).
white
.
headline6
!
.
fontFamily
,
'Segoe UI'
);
});
// Ref: https://developer.apple.com/ios/human-interface-guidelines/visual-design/typography/
...
...
@@ -91,7 +89,7 @@ void main() {
final
List
<
String
>
nonDefaultPropertyNames
=
builder
.
properties
.
where
((
DiagnosticsNode
node
)
=>
!
node
.
isFiltered
(
DiagnosticLevel
.
info
))
.
map
((
DiagnosticsNode
node
)
=>
node
.
name
).
toList
();
.
map
((
DiagnosticsNode
node
)
=>
node
.
name
!
).
toList
();
expect
(
nonDefaultPropertyNames
,
<
String
>[
'black'
,
'white'
,
'englishLike'
,
'dense'
,
'tall'
]);
});
...
...
@@ -106,81 +104,81 @@ void main() {
const
FontWeight
medium
=
FontWeight
.
w500
;
// H1 Roboto light 96 -1.5
expect
(
theme
.
headline1
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
headline1
.
fontWeight
,
light
);
expect
(
theme
.
headline1
.
fontSize
,
96
);
expect
(
theme
.
headline1
.
letterSpacing
,
-
1.5
);
expect
(
theme
.
headline1
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
headline1
!
.
fontWeight
,
light
);
expect
(
theme
.
headline1
!
.
fontSize
,
96
);
expect
(
theme
.
headline1
!
.
letterSpacing
,
-
1.5
);
// H2 Roboto light 60 -0.5
expect
(
theme
.
headline2
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
headline2
.
fontWeight
,
light
);
expect
(
theme
.
headline2
.
fontSize
,
60
);
expect
(
theme
.
headline2
.
letterSpacing
,
-
0.5
);
expect
(
theme
.
headline2
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
headline2
!
.
fontWeight
,
light
);
expect
(
theme
.
headline2
!
.
fontSize
,
60
);
expect
(
theme
.
headline2
!
.
letterSpacing
,
-
0.5
);
// H3 Roboto regular 48 0
expect
(
theme
.
headline3
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
headline3
.
fontWeight
,
regular
);
expect
(
theme
.
headline3
.
fontSize
,
48
);
expect
(
theme
.
headline3
.
letterSpacing
,
0
);
expect
(
theme
.
headline3
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
headline3
!
.
fontWeight
,
regular
);
expect
(
theme
.
headline3
!
.
fontSize
,
48
);
expect
(
theme
.
headline3
!
.
letterSpacing
,
0
);
// H4 Roboto regular 34 0.25
expect
(
theme
.
headline4
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
headline4
.
fontWeight
,
regular
);
expect
(
theme
.
headline4
.
fontSize
,
34
);
expect
(
theme
.
headline4
.
letterSpacing
,
0.25
);
expect
(
theme
.
headline4
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
headline4
!
.
fontWeight
,
regular
);
expect
(
theme
.
headline4
!
.
fontSize
,
34
);
expect
(
theme
.
headline4
!
.
letterSpacing
,
0.25
);
// H5 Roboto regular 24 0
expect
(
theme
.
headline5
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
headline5
.
fontWeight
,
regular
);
expect
(
theme
.
headline5
.
fontSize
,
24
);
expect
(
theme
.
headline5
.
letterSpacing
,
0
);
expect
(
theme
.
headline5
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
headline5
!
.
fontWeight
,
regular
);
expect
(
theme
.
headline5
!
.
fontSize
,
24
);
expect
(
theme
.
headline5
!
.
letterSpacing
,
0
);
// H6 Roboto medium 20 0.15
expect
(
theme
.
headline6
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
headline6
.
fontWeight
,
medium
);
expect
(
theme
.
headline6
.
fontSize
,
20
);
expect
(
theme
.
headline6
.
letterSpacing
,
0.15
);
expect
(
theme
.
headline6
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
headline6
!
.
fontWeight
,
medium
);
expect
(
theme
.
headline6
!
.
fontSize
,
20
);
expect
(
theme
.
headline6
!
.
letterSpacing
,
0.15
);
// Subtitle1 Roboto regular 16 0.15
expect
(
theme
.
subtitle1
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
subtitle1
.
fontWeight
,
regular
);
expect
(
theme
.
subtitle1
.
fontSize
,
16
);
expect
(
theme
.
subtitle1
.
letterSpacing
,
0.15
);
expect
(
theme
.
subtitle1
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
subtitle1
!
.
fontWeight
,
regular
);
expect
(
theme
.
subtitle1
!
.
fontSize
,
16
);
expect
(
theme
.
subtitle1
!
.
letterSpacing
,
0.15
);
// Subtitle2 Roboto medium 14 0.1
expect
(
theme
.
subtitle2
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
subtitle2
.
fontWeight
,
medium
);
expect
(
theme
.
subtitle2
.
fontSize
,
14
);
expect
(
theme
.
subtitle2
.
letterSpacing
,
0.1
);
expect
(
theme
.
subtitle2
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
subtitle2
!
.
fontWeight
,
medium
);
expect
(
theme
.
subtitle2
!
.
fontSize
,
14
);
expect
(
theme
.
subtitle2
!
.
letterSpacing
,
0.1
);
// Body1 Roboto regular 16 0.5
expect
(
theme
.
bodyText1
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
bodyText1
.
fontWeight
,
regular
);
expect
(
theme
.
bodyText1
.
fontSize
,
16
);
expect
(
theme
.
bodyText1
.
letterSpacing
,
0.5
);
expect
(
theme
.
bodyText1
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
bodyText1
!
.
fontWeight
,
regular
);
expect
(
theme
.
bodyText1
!
.
fontSize
,
16
);
expect
(
theme
.
bodyText1
!
.
letterSpacing
,
0.5
);
// Body2 Roboto regular 14 0.25
expect
(
theme
.
bodyText2
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
bodyText2
.
fontWeight
,
regular
);
expect
(
theme
.
bodyText2
.
fontSize
,
14
);
expect
(
theme
.
bodyText2
.
letterSpacing
,
0.25
);
expect
(
theme
.
bodyText2
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
bodyText2
!
.
fontWeight
,
regular
);
expect
(
theme
.
bodyText2
!
.
fontSize
,
14
);
expect
(
theme
.
bodyText2
!
.
letterSpacing
,
0.25
);
// BUTTON Roboto medium 14 1.25
expect
(
theme
.
button
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
button
.
fontWeight
,
medium
);
expect
(
theme
.
button
.
fontSize
,
14
);
expect
(
theme
.
button
.
letterSpacing
,
1.25
);
expect
(
theme
.
button
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
button
!
.
fontWeight
,
medium
);
expect
(
theme
.
button
!
.
fontSize
,
14
);
expect
(
theme
.
button
!
.
letterSpacing
,
1.25
);
// Caption Roboto regular 12 0.4
expect
(
theme
.
caption
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
caption
.
fontWeight
,
regular
);
expect
(
theme
.
caption
.
fontSize
,
12
);
expect
(
theme
.
caption
.
letterSpacing
,
0.4
);
expect
(
theme
.
caption
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
caption
!
.
fontWeight
,
regular
);
expect
(
theme
.
caption
!
.
fontSize
,
12
);
expect
(
theme
.
caption
!
.
letterSpacing
,
0.4
);
// OVERLINE Roboto regular 10 1.5
expect
(
theme
.
overline
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
overline
.
fontWeight
,
regular
);
expect
(
theme
.
overline
.
fontSize
,
10
);
expect
(
theme
.
overline
.
letterSpacing
,
1.5
);
expect
(
theme
.
overline
!
.
fontFamily
,
'Roboto'
);
expect
(
theme
.
overline
!
.
fontWeight
,
regular
);
expect
(
theme
.
overline
!
.
fontSize
,
10
);
expect
(
theme
.
overline
!
.
letterSpacing
,
1.5
);
});
}
packages/flutter/test/material/user_accounts_drawer_header_test.dart
View file @
793678d5
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -143,7 +141,7 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/25801.
testWidgets
(
'UserAccountsDrawerHeader icon does not rotate after setState'
,
(
WidgetTester
tester
)
async
{
StateSetter
testSetState
;
late
StateSetter
testSetState
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
StatefulBuilder
(
...
...
@@ -251,12 +249,12 @@ void main() {
testWidgets
(
'UserAccountsDrawerHeader null parameters LTR'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
Widget
currentAccountPicture
,
List
<
Widget
>
otherAccountsPictures
,
Widget
accountName
,
Widget
accountEmail
,
VoidCallback
onDetailsPressed
,
EdgeInsets
margin
,
Widget
?
currentAccountPicture
,
List
<
Widget
>
?
otherAccountsPictures
,
Widget
?
accountName
,
Widget
?
accountEmail
,
VoidCallback
?
onDetailsPressed
,
EdgeInsets
?
margin
,
})
{
return
MaterialApp
(
home:
Material
(
...
...
@@ -359,12 +357,12 @@ void main() {
testWidgets
(
'UserAccountsDrawerHeader null parameters RTL'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
Widget
currentAccountPicture
,
List
<
Widget
>
otherAccountsPictures
,
Widget
accountName
,
Widget
accountEmail
,
VoidCallback
onDetailsPressed
,
EdgeInsets
margin
,
Widget
?
currentAccountPicture
,
List
<
Widget
>
?
otherAccountsPictures
,
Widget
?
accountName
,
Widget
?
accountEmail
,
VoidCallback
?
onDetailsPressed
,
EdgeInsets
?
margin
,
})
{
return
MaterialApp
(
home:
Directionality
(
...
...
packages/flutter/test/material/will_pop_test.dart
View file @
793678d5
...
...
@@ -2,21 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
bool
willPopValue
=
false
;
class
SamplePage
extends
StatefulWidget
{
const
SamplePage
({
Key
key
})
:
super
(
key:
key
);
const
SamplePage
({
Key
?
key
})
:
super
(
key:
key
);
@override
SamplePageState
createState
()
=>
SamplePageState
();
}
class
SamplePageState
extends
State
<
SamplePage
>
{
ModalRoute
<
void
>
_route
;
ModalRoute
<
void
>
?
_route
;
Future
<
bool
>
_callback
()
async
=>
willPopValue
;
...
...
@@ -45,7 +43,7 @@ class SamplePageState extends State<SamplePage> {
int
willPopCount
=
0
;
class
SampleForm
extends
StatelessWidget
{
const
SampleForm
({
Key
key
,
this
.
callback
})
:
super
(
key:
key
);
const
SampleForm
({
Key
?
key
,
required
this
.
callback
})
:
super
(
key:
key
);
final
WillPopCallback
callback
;
...
...
@@ -68,7 +66,7 @@ class SampleForm extends StatelessWidget {
// Expose the protected hasScopedWillPopCallback getter
class
TestPageRoute
<
T
>
extends
MaterialPageRoute
<
T
>
{
TestPageRoute
({
WidgetBuilder
builder
})
TestPageRoute
({
required
WidgetBuilder
builder
})
:
super
(
builder:
builder
,
maintainState:
true
);
bool
get
hasCallback
=>
super
.
hasScopedWillPopCallback
;
...
...
@@ -118,7 +116,7 @@ void main() {
// Use didPopRoute() to simulate the system back button. Check that
// didPopRoute() indicates that the notification was handled.
final
dynamic
widgetsAppState
=
tester
.
state
(
find
.
byType
(
WidgetsApp
));
final
dynamic
widgetsAppState
=
tester
.
state
(
find
.
byType
(
WidgetsApp
));
// ignore: unnecessary_nullable_for_final_variable_declarations
expect
(
await
widgetsAppState
.
didPopRoute
(),
isTrue
);
expect
(
find
.
text
(
'Sample Page'
),
findsOneWidget
);
...
...
@@ -141,7 +139,7 @@ void main() {
child:
TextButton
(
child:
const
Text
(
'X'
),
onPressed:
()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
<
void
>(
Navigator
.
of
(
context
)
!
.
push
(
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
SampleForm
(
callback:
()
=>
Future
<
bool
>.
value
(
willPopValue
),
...
...
@@ -162,12 +160,6 @@ void main() {
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Sample Form'
),
findsOneWidget
);
// Should not pop if callback returns null
willPopValue
=
null
;
await
tester
.
tap
(
find
.
byTooltip
(
'Back'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Sample Form'
),
findsOneWidget
);
// Should pop if callback returns true
willPopValue
=
true
;
await
tester
.
tap
(
find
.
byTooltip
(
'Back'
));
...
...
@@ -186,7 +178,7 @@ void main() {
child:
TextButton
(
child:
const
Text
(
'X'
),
onPressed:
()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
<
void
>(
Navigator
.
of
(
context
)
!
.
push
(
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
SampleForm
(
callback:
()
=>
Future
<
bool
>.
value
(
willPopValue
),
...
...
@@ -238,11 +230,11 @@ void main() {
actions:
<
Widget
>
[
TextButton
(
child:
const
Text
(
'YES'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
true
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pop
(
true
);
},
),
TextButton
(
child:
const
Text
(
'NO'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
false
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pop
(
false
);
},
),
],
);
...
...
@@ -260,7 +252,7 @@ void main() {
child:
TextButton
(
child:
const
Text
(
'X'
),
onPressed:
()
{
Navigator
.
of
(
context
).
push
(
MaterialPageRoute
<
void
>(
Navigator
.
of
(
context
)
!
.
push
(
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
SampleForm
(
callback:
()
=>
showYesNoAlert
(
context
),
...
...
@@ -322,7 +314,7 @@ void main() {
});
testWidgets
(
'Route.scopedWillPop callbacks do not accumulate'
,
(
WidgetTester
tester
)
async
{
StateSetter
contentsSetState
;
// call this to rebuild the route's SampleForm contents
late
StateSetter
contentsSetState
;
// call this to rebuild the route's SampleForm contents
bool
contentsEmpty
=
false
;
// when true, don't include the SampleForm in the route
final
TestPageRoute
<
void
>
route
=
TestPageRoute
<
void
>(
...
...
@@ -330,7 +322,7 @@ void main() {
return
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
contentsSetState
=
setState
;
return
contentsEmpty
?
Container
()
:
SampleForm
(
key:
UniqueKey
());
return
contentsEmpty
?
Container
()
:
SampleForm
(
key:
UniqueKey
()
,
callback:
()
async
=>
false
);
}
);
},
...
...
@@ -346,7 +338,7 @@ void main() {
child:
TextButton
(
child:
const
Text
(
'X'
),
onPressed:
()
{
Navigator
.
of
(
context
).
push
(
route
);
Navigator
.
of
(
context
)
!
.
push
(
route
);
},
),
);
...
...
packages/flutter/test/widgets/app_overrides_test.dart
View file @
793678d5
...
...
@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
class
TestRoute
<
T
>
extends
PageRoute
<
T
>
{
TestRoute
({
this
.
child
,
RouteSettings
settings
})
:
super
(
settings:
settings
);
TestRoute
({
required
this
.
child
,
RouteSettings
?
settings
})
:
super
(
settings:
settings
);
final
Widget
child
;
...
...
@@ -16,10 +14,10 @@ class TestRoute<T> extends PageRoute<T> {
Duration
get
transitionDuration
=>
const
Duration
(
milliseconds:
150
);
@override
Color
get
barrierColor
=>
null
;
Color
?
get
barrierColor
=>
null
;
@override
String
get
barrierLabel
=>
null
;
String
?
get
barrierLabel
=>
null
;
@override
bool
get
maintainState
=>
false
;
...
...
packages/flutter/test/widgets/app_test.dart
View file @
793678d5
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
...
...
@@ -33,7 +31,7 @@ void main() {
await
tester
.
pumpWidget
(
WidgetsApp
(
key:
key
,
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
const
Placeholder
();
},
color:
const
Color
(
0xFF123456
),
...
...
@@ -43,17 +41,17 @@ void main() {
});
testWidgets
(
'WidgetsApp can override default key bindings'
,
(
WidgetTester
tester
)
async
{
bool
checked
=
false
;
bool
?
checked
=
false
;
final
GlobalKey
key
=
GlobalKey
();
await
tester
.
pumpWidget
(
WidgetsApp
(
key:
key
,
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Material
(
child:
Checkbox
(
value:
checked
,
autofocus:
true
,
onChanged:
(
bool
value
)
{
onChanged:
(
bool
?
value
)
{
checked
=
value
;
},
),
...
...
@@ -79,12 +77,12 @@ void main() {
shortcuts:
<
LogicalKeySet
,
Intent
>
{
LogicalKeySet
(
LogicalKeyboardKey
.
space
):
const
TestIntent
(),
},
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Material
(
child:
Checkbox
(
value:
checked
,
autofocus:
true
,
onChanged:
(
bool
value
)
{
onChanged:
(
bool
?
value
)
{
checked
=
value
;
},
),
...
...
@@ -104,16 +102,16 @@ void main() {
});
testWidgets
(
'WidgetsApp default activation key mappings work'
,
(
WidgetTester
tester
)
async
{
bool
checked
=
false
;
bool
?
checked
=
false
;
await
tester
.
pumpWidget
(
WidgetsApp
(
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Material
(
child:
Checkbox
(
value:
checked
,
autofocus:
true
,
onChanged:
(
bool
value
)
{
onChanged:
(
bool
?
value
)
{
checked
=
value
;
},
),
...
...
@@ -147,15 +145,15 @@ void main() {
group
(
'error control test'
,
()
{
Future
<
void
>
expectFlutterError
({
GlobalKey
<
NavigatorState
>
key
,
Widget
widget
,
WidgetTester
tester
,
String
errorMessage
,
required
GlobalKey
<
NavigatorState
>
key
,
required
Widget
widget
,
required
WidgetTester
tester
,
required
String
errorMessage
,
})
async
{
await
tester
.
pumpWidget
(
widget
);
FlutterError
error
;
late
FlutterError
error
;
try
{
key
.
currentState
.
pushNamed
(
'/path'
);
key
.
currentState
!
.
pushNamed
(
'/path'
);
}
on
FlutterError
catch
(
e
)
{
error
=
e
;
}
finally
{
...
...
@@ -258,7 +256,7 @@ void main() {
expect
(
find
.
text
(
'non-regular page two'
),
findsOneWidget
);
expect
(
find
.
text
(
'non-regular page one'
),
findsNothing
);
expect
(
find
.
text
(
'regular page'
),
findsNothing
);
navigatorKey
.
currentState
.
pop
();
navigatorKey
.
currentState
!
.
pop
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'non-regular page two'
),
findsNothing
);
expect
(
find
.
text
(
'non-regular page one'
),
findsOneWidget
);
...
...
@@ -273,7 +271,7 @@ void main() {
);
final
SimpleNavigatorRouterDelegate
delegate
=
SimpleNavigatorRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
return
Text
(
information
.
location
);
return
Text
(
information
.
location
!
);
},
onPopPage:
(
Route
<
void
>
route
,
void
result
,
SimpleNavigatorRouterDelegate
delegate
)
{
delegate
.
routeInformation
=
const
RouteInformation
(
...
...
@@ -292,7 +290,7 @@ void main() {
// Simulate android back button intent.
final
ByteData
message
=
const
JSONMethodCodec
().
encodeMethodCall
(
const
MethodCall
(
'popRoute'
));
await
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
ServicesBinding
.
instance
!
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
});
...
...
@@ -300,8 +298,9 @@ void main() {
testWidgets
(
'WidgetsApp.router has correct default'
,
(
WidgetTester
tester
)
async
{
final
SimpleNavigatorRouterDelegate
delegate
=
SimpleNavigatorRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
return
Text
(
information
.
location
);
return
Text
(
information
.
location
!
);
},
onPopPage:
(
Route
<
Object
?>
route
,
Object
?
result
,
SimpleNavigatorRouterDelegate
delegate
)
=>
true
,
);
await
tester
.
pumpWidget
(
WidgetsApp
.
router
(
routeInformationParser:
SimpleRouteInformationParser
(),
...
...
@@ -331,22 +330,22 @@ class SimpleRouteInformationParser extends RouteInformationParser<RouteInformati
class
SimpleNavigatorRouterDelegate
extends
RouterDelegate
<
RouteInformation
>
with
PopNavigatorRouterDelegateMixin
<
RouteInformation
>,
ChangeNotifier
{
SimpleNavigatorRouterDelegate
({
@
required
this
.
builder
,
this
.
onPopPage
,
required
this
.
builder
,
required
this
.
onPopPage
,
});
@override
GlobalKey
<
NavigatorState
>
navigatorKey
=
GlobalKey
<
NavigatorState
>();
RouteInformation
get
routeInformation
=>
_routeInformation
;
RouteInformation
_routeInformation
;
late
RouteInformation
_routeInformation
;
set
routeInformation
(
RouteInformation
newValue
)
{
_routeInformation
=
newValue
;
notifyListeners
();
}
SimpleRouterDelegateBuilder
builder
;
SimpleNavigatorRouterDelegatePopPage
<
void
>
onPopPage
;
final
SimpleRouterDelegateBuilder
builder
;
final
SimpleNavigatorRouterDelegatePopPage
<
void
>
onPopPage
;
@override
Future
<
void
>
setNewRoutePath
(
RouteInformation
configuration
)
{
...
...
@@ -370,7 +369,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
child:
Text
(
'base'
),
),
MaterialPage
<
void
>(
key:
ValueKey
<
String
>(
routeInformation
?.
location
),
key:
ValueKey
<
String
>(
routeInformation
.
location
!
),
child:
builder
(
context
,
routeInformation
),
)
],
...
...
packages/flutter/test/widgets/app_title_test.dart
View file @
793678d5
...
...
@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
const
Color
kTitleColor
=
Color
(
0xFF333333
);
const
String
kTitleString
=
'Hello World'
;
Future
<
void
>
pumpApp
(
WidgetTester
tester
,
{
GenerateAppTitle
onGenerateTitle
})
async
{
Future
<
void
>
pumpApp
(
WidgetTester
tester
,
{
GenerateAppTitle
?
onGenerateTitle
})
async
{
await
tester
.
pumpWidget
(
WidgetsApp
(
supportedLocales:
const
<
Locale
>[
...
...
packages/flutter/test/widgets/aspect_ratio_test.dart
View file @
793678d5
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter/test/widgets/async_lifecycle_test.dart
View file @
793678d5
...
...
@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
class
InvalidOnInitLifecycleWidget
extends
StatefulWidget
{
const
InvalidOnInitLifecycleWidget
({
Key
key
})
:
super
(
key:
key
);
const
InvalidOnInitLifecycleWidget
({
Key
?
key
})
:
super
(
key:
key
);
@override
InvalidOnInitLifecycleWidgetState
createState
()
=>
InvalidOnInitLifecycleWidgetState
();
...
...
@@ -27,7 +25,7 @@ class InvalidOnInitLifecycleWidgetState extends State<InvalidOnInitLifecycleWidg
}
class
InvalidDidUpdateWidgetLifecycleWidget
extends
StatefulWidget
{
const
InvalidDidUpdateWidgetLifecycleWidget
({
Key
key
,
this
.
id
})
:
super
(
key:
key
);
const
InvalidDidUpdateWidgetLifecycleWidget
({
Key
?
key
,
required
this
.
id
})
:
super
(
key:
key
);
final
int
id
;
...
...
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