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
3961a12a
Unverified
Commit
3961a12a
authored
Oct 07, 2020
by
Michael Goderbauer
Committed by
GitHub
Oct 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate some material tests to nnbd (#67477)
parent
af0c7aed
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
185 additions
and
256 deletions
+185
-256
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+1
-2
navigation_rail_test.dart
packages/flutter/test/material/navigation_rail_test.dart
+16
-18
navigation_rail_theme_test.dart
...ges/flutter/test/material/navigation_rail_theme_test.dart
+2
-4
outlined_button_test.dart
packages/flutter/test/material/outlined_button_test.dart
+46
-48
outlined_button_theme_test.dart
...ges/flutter/test/material/outlined_button_theme_test.dart
+12
-14
page_selector_test.dart
packages/flutter/test/material/page_selector_test.dart
+1
-3
page_test.dart
packages/flutter/test/material/page_test.dart
+40
-54
page_transitions_theme_test.dart
...es/flutter/test/material/page_transitions_theme_test.dart
+10
-12
paginated_data_table_test.dart
...ages/flutter/test/material/paginated_data_table_test.dart
+16
-18
persistent_bottom_sheet_test.dart
...s/flutter/test/material/persistent_bottom_sheet_test.dart
+12
-15
popup_menu_test.dart
packages/flutter/test/material/popup_menu_test.dart
+25
-62
popup_menu_theme_test.dart
packages/flutter/test/material/popup_menu_theme_test.dart
+4
-6
No files found.
packages/flutter/lib/src/material/popup_menu.dart
View file @
3961a12a
...
...
@@ -96,8 +96,7 @@ abstract class PopupMenuEntry<T> extends StatefulWidget {
/// * [showMenu], a method to dynamically show a popup menu at a given location.
/// * [PopupMenuButton], an [IconButton] that automatically shows a menu when
/// it is tapped.
// ignore: prefer_void_to_null, https://github.com/dart-lang/sdk/issues/34416
class
PopupMenuDivider
extends
PopupMenuEntry
<
Null
>
{
class
PopupMenuDivider
extends
PopupMenuEntry
<
Never
>
{
/// Creates a horizontal divider for a popup menu.
///
/// By default, the divider has a height of 16 logical pixels.
...
...
packages/flutter/test/material/navigation_rail_test.dart
View file @
3961a12a
...
...
@@ -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'
;
...
...
@@ -26,8 +24,8 @@ void main() {
),
);
final
TextStyle
actualSelectedTextStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Abc'
)).
text
.
style
;
final
TextStyle
actualUnselectedTextStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Def'
)).
text
.
style
;
final
TextStyle
actualSelectedTextStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Abc'
)).
text
.
style
!
;
final
TextStyle
actualUnselectedTextStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Def'
)).
text
.
style
!
;
expect
(
actualSelectedTextStyle
.
fontSize
,
equals
(
selectedTextStyle
.
fontSize
));
expect
(
actualSelectedTextStyle
.
fontWeight
,
equals
(
selectedTextStyle
.
fontWeight
));
expect
(
actualUnselectedTextStyle
.
fontSize
,
equals
(
actualUnselectedTextStyle
.
fontSize
));
...
...
@@ -1416,7 +1414,7 @@ void main() {
testWidgets
(
'Extended rail animates the width and labels appear - [textDirection]=LTR'
,
(
WidgetTester
tester
)
async
{
bool
extended
=
false
;
StateSetter
stateSetter
;
late
StateSetter
stateSetter
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -1553,7 +1551,7 @@ void main() {
testWidgets
(
'Extended rail animates the width and labels appear - [textDirection]=RTL'
,
(
WidgetTester
tester
)
async
{
bool
extended
=
false
;
StateSetter
stateSetter
;
late
StateSetter
stateSetter
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -1697,7 +1695,7 @@ void main() {
testWidgets
(
'Extended rail gets wider with longer labels are larger text scale'
,
(
WidgetTester
tester
)
async
{
bool
extended
=
false
;
StateSetter
stateSetter
;
late
StateSetter
stateSetter
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -1708,7 +1706,7 @@ void main() {
body:
Row
(
children:
<
Widget
>[
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
3.0
),
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
textScaleFactor:
3.0
),
child:
NavigationRail
(
selectedIndex:
0
,
destinations:
const
<
NavigationRailDestination
>[
...
...
@@ -1755,7 +1753,7 @@ void main() {
testWidgets
(
'Extended rail final width can be changed'
,
(
WidgetTester
tester
)
async
{
bool
extended
=
false
;
StateSetter
stateSetter
;
late
StateSetter
stateSetter
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -1797,7 +1795,7 @@ void main() {
/// Regression test for https://github.com/flutter/flutter/issues/65657
testWidgets
(
'Extended rail transition does not jump from the beginning'
,
(
WidgetTester
tester
)
async
{
bool
extended
=
false
;
StateSetter
stateSetter
;
late
StateSetter
stateSetter
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -1855,8 +1853,8 @@ void main() {
testWidgets
(
'Extended rail animation can be consumed'
,
(
WidgetTester
tester
)
async
{
bool
extended
=
false
;
Animation
<
double
>
animation
;
StateSetter
stateSetter
;
late
Animation
<
double
>
animation
;
late
StateSetter
stateSetter
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -1899,7 +1897,7 @@ void main() {
});
testWidgets
(
'onDestinationSelected is called'
,
(
WidgetTester
tester
)
async
{
int
selectedIndex
;
late
int
selectedIndex
;
await
_pumpNavigationRail
(
tester
,
...
...
@@ -2106,14 +2104,14 @@ List<NavigationRailDestination> _destinations() {
Future
<
void
>
_pumpNavigationRail
(
WidgetTester
tester
,
{
double
textScaleFactor
=
1.0
,
NavigationRail
navigationRail
,
required
NavigationRail
navigationRail
,
})
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
textScaleFactor
),
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
textScaleFactor:
textScaleFactor
),
child:
Scaffold
(
body:
Row
(
children:
<
Widget
>[
...
...
@@ -2131,7 +2129,7 @@ Future<void> _pumpNavigationRail(
);
}
Future
<
void
>
_pumpLocalizedTestRail
(
WidgetTester
tester
,
{
NavigationRailLabelType
labelType
,
bool
extended
=
false
})
async
{
Future
<
void
>
_pumpLocalizedTestRail
(
WidgetTester
tester
,
{
NavigationRailLabelType
?
labelType
,
bool
extended
=
false
})
async
{
await
tester
.
pumpWidget
(
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
...
...
@@ -2184,7 +2182,7 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) {
of:
find
.
byIcon
(
icon
),
matching:
find
.
byType
(
RichText
),
),
).
text
.
style
;
).
text
.
style
!
;
}
Finder
_opacityAboveLabel
(
String
text
)
{
...
...
@@ -2213,4 +2211,4 @@ Material _railMaterial(WidgetTester tester) {
matching:
find
.
byType
(
Material
),
),
);
}
\ No newline at end of file
}
packages/flutter/test/material/navigation_rail_theme_test.dart
View file @
3961a12a
...
...
@@ -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/rendering.dart'
;
...
...
@@ -271,7 +269,7 @@ TextStyle _selectedLabelStyle(WidgetTester tester) {
of:
find
.
text
(
'Abc'
),
matching:
find
.
byType
(
RichText
),
),
).
text
.
style
;
).
text
.
style
!
;
}
TextStyle
_unselectedLabelStyle
(
WidgetTester
tester
)
{
...
...
@@ -280,7 +278,7 @@ TextStyle _unselectedLabelStyle(WidgetTester tester) {
of:
find
.
text
(
'Def'
),
matching:
find
.
byType
(
RichText
),
),
).
text
.
style
;
).
text
.
style
!
;
}
Align
_destinationsAlign
(
WidgetTester
tester
)
{
...
...
packages/flutter/test/material/outlined_button_test.dart
View file @
3961a12a
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/outlined_button_theme_test.dart
View file @
3961a12a
...
...
@@ -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'
;
...
...
@@ -40,10 +38,10 @@ void main() {
side:
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
)),
borderRadius:
BorderRadius
.
circular
(
4.0
),
));
expect
(
material
.
textStyle
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
.
fontSize
,
14
);
expect
(
material
.
textStyle
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
textStyle
!
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!
.
fontSize
,
14
);
expect
(
material
.
textStyle
!
.
fontWeight
,
FontWeight
.
w500
);
});
group
(
'[Theme, TextTheme, OutlinedButton style overrides]'
,
()
{
...
...
@@ -81,7 +79,7 @@ void main() {
enableFeedback:
enableFeedback
,
);
Widget
buildFrame
({
ButtonStyle
buttonStyle
,
ButtonStyle
themeStyle
,
ButtonStyle
overallStyle
})
{
Widget
buildFrame
({
ButtonStyle
?
buttonStyle
,
ButtonStyle
?
themeStyle
,
ButtonStyle
?
overallStyle
})
{
final
Widget
child
=
Builder
(
builder:
(
BuildContext
context
)
{
return
OutlinedButton
(
...
...
@@ -126,15 +124,15 @@ void main() {
void
checkButton
(
WidgetTester
tester
)
{
final
Material
material
=
tester
.
widget
<
Material
>(
findMaterial
);
final
InkWell
inkWell
=
tester
.
widget
<
InkWell
>(
findInkWell
);
expect
(
material
.
textStyle
.
color
,
primaryColor
);
expect
(
material
.
textStyle
.
fontSize
,
12
);
expect
(
material
.
textStyle
!
.
color
,
primaryColor
);
expect
(
material
.
textStyle
!
.
fontSize
,
12
);
expect
(
material
.
color
,
backgroundColor
);
expect
(
material
.
shadowColor
,
shadowColor
);
expect
(
material
.
elevation
,
elevation
);
expect
(
MaterialStateProperty
.
resolveAs
<
MouseCursor
>(
inkWell
.
mouseCursor
,
enabled
),
enabledMouseCursor
);
expect
(
MaterialStateProperty
.
resolveAs
<
MouseCursor
>(
inkWell
.
mouseCursor
,
disabled
),
disabledMouseCursor
);
expect
(
inkWell
.
overlayColor
.
resolve
(
hovered
),
primaryColor
.
withOpacity
(
0.04
));
expect
(
inkWell
.
overlayColor
.
resolve
(
focused
),
primaryColor
.
withOpacity
(
0.12
));
expect
(
MaterialStateProperty
.
resolveAs
<
MouseCursor
?
>(
inkWell
.
mouseCursor
,
enabled
),
enabledMouseCursor
);
expect
(
MaterialStateProperty
.
resolveAs
<
MouseCursor
?
>(
inkWell
.
mouseCursor
,
disabled
),
disabledMouseCursor
);
expect
(
inkWell
.
overlayColor
!
.
resolve
(
hovered
),
primaryColor
.
withOpacity
(
0.04
));
expect
(
inkWell
.
overlayColor
!
.
resolve
(
focused
),
primaryColor
.
withOpacity
(
0.12
));
expect
(
inkWell
.
enableFeedback
,
enableFeedback
);
expect
(
material
.
borderRadius
,
null
);
expect
(
material
.
shape
,
shape
);
...
...
@@ -186,7 +184,7 @@ void main() {
const
Color
shadowColor
=
Color
(
0xff000001
);
const
Color
overiddenColor
=
Color
(
0xff000002
);
Widget
buildFrame
({
Color
overallShadowColor
,
Color
themeShadowColor
,
Color
shadowColor
})
{
Widget
buildFrame
({
Color
?
overallShadowColor
,
Color
?
themeShadowColor
,
Color
?
shadowColor
})
{
return
MaterialApp
(
theme:
ThemeData
.
from
(
colorScheme:
colorScheme
).
copyWith
(
shadowColor:
overallShadowColor
,
...
...
packages/flutter/test/material/page_selector_test.dart
View file @
3961a12a
...
...
@@ -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/material.dart'
;
const
Color
kSelectedColor
=
Color
(
0xFF00FF00
);
const
Color
kUnselectedColor
=
Colors
.
transparent
;
Widget
buildFrame
(
TabController
tabController
,
{
Color
color
,
Color
selectedColor
,
double
indicatorSize
=
12.0
})
{
Widget
buildFrame
(
TabController
tabController
,
{
Color
?
color
,
Color
?
selectedColor
,
double
indicatorSize
=
12.0
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Theme
(
...
...
packages/flutter/test/material/page_test.dart
View file @
3961a12a
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/page_transitions_theme_test.dart
View file @
3961a12a
...
...
@@ -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/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -12,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
void
main
(
)
{
testWidgets
(
'Default PageTransitionsTheme platform'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Text
(
'home'
)));
final
PageTransitionsTheme
theme
=
Theme
.
of
(
tester
.
element
(
find
.
text
(
'home'
))).
pageTransitionsTheme
;
final
PageTransitionsTheme
theme
=
Theme
.
of
(
tester
.
element
(
find
.
text
(
'home'
)))
!
.
pageTransitionsTheme
;
expect
(
theme
.
builders
,
isNotNull
);
for
(
final
TargetPlatform
platform
in
TargetPlatform
.
values
)
{
if
(
platform
==
TargetPlatform
.
fuchsia
)
{
...
...
@@ -28,7 +26,7 @@ void main() {
'/'
:
(
BuildContext
context
)
=>
Material
(
child:
TextButton
(
child:
const
Text
(
'push'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/b'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/b'
);
},
),
),
'/b'
:
(
BuildContext
context
)
=>
const
Text
(
'page b'
),
...
...
@@ -40,7 +38,7 @@ void main() {
),
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
))).
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
)))
!
.
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
find
.
byType
(
CupertinoPageTransition
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'push'
));
...
...
@@ -54,7 +52,7 @@ void main() {
'/'
:
(
BuildContext
context
)
=>
Material
(
child:
TextButton
(
child:
const
Text
(
'push'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/b'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/b'
);
},
),
),
'/b'
:
(
BuildContext
context
)
=>
const
Text
(
'page b'
),
...
...
@@ -73,7 +71,7 @@ void main() {
);
}
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
))).
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
)))
!
.
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
findFadeUpwardsPageTransition
(),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'push'
));
...
...
@@ -87,7 +85,7 @@ void main() {
'/'
:
(
BuildContext
context
)
=>
Material
(
child:
TextButton
(
child:
const
Text
(
'push'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/b'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/b'
);
},
),
),
'/b'
:
(
BuildContext
context
)
=>
const
Text
(
'page b'
),
...
...
@@ -113,7 +111,7 @@ void main() {
);
}
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
))).
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
)))
!
.
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
findOpenUpwardsPageTransition
(),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'push'
));
...
...
@@ -127,7 +125,7 @@ void main() {
'/'
:
(
BuildContext
context
)
=>
Material
(
child:
TextButton
(
child:
const
Text
(
'push'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/b'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/b'
);
},
),
),
'/b'
:
(
BuildContext
context
)
=>
const
Text
(
'page b'
),
...
...
@@ -153,7 +151,7 @@ void main() {
);
}
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
))).
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
)))
!
.
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
findZoomPageTransition
(),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'push'
));
...
...
@@ -171,7 +169,7 @@ void main() {
'/'
:
(
BuildContext
context
)
=>
Material
(
child:
TextButton
(
child:
const
Text
(
'push'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/b'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/b'
);
},
),
),
'/b'
:
(
BuildContext
context
)
=>
StatefulBuilder
(
...
...
packages/flutter/test/material/paginated_data_table_test.dart
View file @
3961a12a
...
...
@@ -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'
;
import
'package:flutter/gestures.dart'
show
DragStartBehavior
;
...
...
@@ -15,7 +13,7 @@ class TestDataSource extends DataTableSource {
this
.
onSelectChanged
,
});
final
void
Function
(
bool
)
onSelectChanged
;
final
void
Function
(
bool
?)?
onSelectChanged
;
int
get
generation
=>
_generation
;
int
_generation
=
0
;
...
...
@@ -68,7 +66,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{
log
.
add
(
'rows-per-page-changed:
$rowsPerPage
'
);
},
onPageChanged:
(
int
rowIndex
)
{
...
...
@@ -218,7 +216,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
8
,
9
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{
},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{
},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'COL1'
)),
DataColumn
(
label:
Text
(
'COL2'
)),
...
...
@@ -243,7 +241,7 @@ void main() {
source
:
source
,
rowsPerPage:
501
,
availableRowsPerPage:
const
<
int
>[
501
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{
},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{
},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'COL1'
)),
DataColumn
(
label:
Text
(
'COL2'
)),
...
...
@@ -280,7 +278,7 @@ void main() {
rowsPerPage:
5
,
dragStartBehavior:
DragStartBehavior
.
down
,
availableRowsPerPage:
const
<
int
>[
5
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{
},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{
},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'COL1'
)),
DataColumn
(
label:
Text
(
'COL2'
)),
...
...
@@ -315,7 +313,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -336,7 +334,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -398,7 +396,7 @@ void main() {
await
binding
.
setSurfaceSize
(
const
Size
(
_width
,
_height
));
final
TestDataSource
source
=
TestDataSource
(
onSelectChanged:
(
bool
value
)
{},
onSelectChanged:
(
bool
?
value
)
{},
);
Finder
cellContent
;
Finder
checkbox
;
...
...
@@ -412,9 +410,9 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
onSelectAll:
(
bool
value
)
{},
onSelectAll:
(
bool
?
value
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
DataColumn
(
label:
Text
(
'Calories'
),
numeric:
true
),
...
...
@@ -481,9 +479,9 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
onSelectAll:
(
bool
value
)
{},
onSelectAll:
(
bool
?
value
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
DataColumn
(
label:
Text
(
'Calories'
),
numeric:
true
),
...
...
@@ -564,7 +562,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -620,7 +618,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -691,7 +689,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -735,7 +733,7 @@ void main() {
Widget
buildTable
(
bool
checkbox
)
=>
MaterialApp
(
home:
PaginatedDataTable
(
header:
const
Text
(
'Test table'
),
source
:
TestDataSource
(
onSelectChanged:
(
bool
value
)
{}),
source
:
TestDataSource
(
onSelectChanged:
(
bool
?
value
)
{}),
showCheckboxColumn:
checkbox
,
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
packages/flutter/test/material/persistent_bottom_sheet_test.dart
View file @
3961a12a
...
...
@@ -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/material.dart'
;
...
...
@@ -25,7 +23,6 @@ void main() {
testWidgets
(
'Verify that a BottomSheet can be rebuilt with ScaffoldFeatureController.setState()'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
PersistentBottomSheetController
<
void
>
bottomSheet
;
int
buildCount
=
0
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -35,7 +32,7 @@ void main() {
),
));
bottomSheet
=
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
_
)
{
final
PersistentBottomSheetController
<
void
>
bottomSheet
=
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
_
)
{
return
Builder
(
builder:
(
BuildContext
context
)
{
buildCount
+=
1
;
...
...
@@ -46,7 +43,7 @@ void main() {
await
tester
.
pump
();
expect
(
buildCount
,
equals
(
1
));
bottomSheet
.
setState
(()
{
});
bottomSheet
.
setState
!
(()
{
});
await
tester
.
pump
();
expect
(
buildCount
,
equals
(
2
));
});
...
...
@@ -92,7 +89,7 @@ void main() {
),
));
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
return
ListView
(
shrinkWrap:
true
,
primary:
false
,
...
...
@@ -124,7 +121,7 @@ void main() {
),
));
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
return
ListView
(
shrinkWrap:
true
,
primary:
false
,
...
...
@@ -159,7 +156,7 @@ void main() {
),
));
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>(
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>(
(
BuildContext
context
)
{
return
DraggableScrollableSheet
(
expand:
false
,
...
...
@@ -313,7 +310,7 @@ void main() {
),
));
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>(
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>(
(
BuildContext
context
)
{
return
DraggableScrollableSheet
(
expand:
false
,
...
...
@@ -363,7 +360,7 @@ void main() {
int
buildCount
=
0
;
showBottomSheet
<
void
>(
context:
key
.
currentContext
,
context:
key
.
currentContext
!
,
builder:
(
BuildContext
context
)
{
return
Builder
(
builder:
(
BuildContext
context
)
{
...
...
@@ -378,8 +375,8 @@ void main() {
});
testWidgets
(
'Scaffold removes top MediaQuery padding'
,
(
WidgetTester
tester
)
async
{
BuildContext
scaffoldContext
;
BuildContext
bottomSheetContext
;
late
BuildContext
scaffoldContext
;
late
BuildContext
bottomSheetContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
...
...
@@ -411,7 +408,7 @@ void main() {
await
tester
.
pump
();
expect
(
MediaQuery
.
of
(
bottomSheetContext
).
padding
,
MediaQuery
.
of
(
bottomSheetContext
)
!
.
padding
,
const
EdgeInsets
.
only
(
bottom:
50.0
,
left:
50.0
,
...
...
@@ -492,7 +489,7 @@ void main() {
),
));
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
return
ListView
(
shrinkWrap:
true
,
primary:
false
,
...
...
@@ -522,7 +519,7 @@ void main() {
),
));
final
PersistentBottomSheetController
<
void
>
bottomSheet
=
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
_
)
{
final
PersistentBottomSheetController
<
void
>
bottomSheet
=
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
_
)
{
return
Builder
(
builder:
(
BuildContext
context
)
{
return
Container
(
height:
200.0
);
...
...
packages/flutter/test/material/popup_menu_test.dart
View file @
3961a12a
...
...
@@ -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'
show
window
,
SemanticsFlag
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -66,7 +64,7 @@ void main() {
testWidgets
(
'PopupMenuButton calls onCanceled callback when an item is not selected'
,
(
WidgetTester
tester
)
async
{
int
cancels
=
0
;
BuildContext
popupContext
;
late
BuildContext
popupContext
;
final
Key
noCallbackKey
=
UniqueKey
();
final
Key
withCallbackKey
=
UniqueKey
();
...
...
@@ -125,7 +123,7 @@ void main() {
await
tester
.
tap
(
find
.
byKey
(
withCallbackKey
));
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
Navigator
.
of
(
popupContext
).
pop
();
Navigator
.
of
(
popupContext
)
!
.
pop
();
await
tester
.
pump
();
expect
(
cancels
,
equals
(
2
));
});
...
...
@@ -140,7 +138,7 @@ void main() {
return
MaterialApp
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
navigationMode:
NavigationMode
.
directional
,
),
child:
Material
(
...
...
@@ -191,7 +189,7 @@ void main() {
await
tester
.
pumpWidget
(
buildApp
(
directional:
true
));
// Try to bring up the popup menu and select the first item from it
Focus
.
of
(
popupButtonKey
.
currentContext
)
.
requestFocus
();
Focus
.
of
(
popupButtonKey
.
currentContext
!)!
.
requestFocus
();
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
byKey
(
popupButtonKey
));
await
tester
.
pumpAndSettle
();
...
...
@@ -240,10 +238,10 @@ void main() {
),
),
);
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
)
.
requestFocus
();
Focus
.
of
(
childKey
.
currentContext
!)!
.
requestFocus
();
await
tester
.
pump
();
expect
(
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
)
.
hasPrimaryFocus
,
isFalse
);
expect
(
Focus
.
of
(
childKey
.
currentContext
!)!
.
hasPrimaryFocus
,
isFalse
);
expect
(
itemBuilderCalled
,
isFalse
);
expect
(
onSelectedCalled
,
isFalse
);
});
...
...
@@ -256,7 +254,7 @@ void main() {
MaterialApp
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
navigationMode:
NavigationMode
.
directional
,
),
child:
Material
(
...
...
@@ -283,10 +281,10 @@ void main() {
}),
),
);
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
)
.
requestFocus
();
Focus
.
of
(
childKey
.
currentContext
!)!
.
requestFocus
();
await
tester
.
pump
();
expect
(
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
)
.
hasPrimaryFocus
,
isTrue
);
expect
(
Focus
.
of
(
childKey
.
currentContext
!)!
.
hasPrimaryFocus
,
isTrue
);
});
testWidgets
(
'PopupMenuItem is only focusable when enabled'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -321,7 +319,7 @@ void main() {
// Open the popup to build and show the menu contents.
await
tester
.
tap
(
find
.
byKey
(
popupButtonKey
));
await
tester
.
pumpAndSettle
();
final
FocusNode
childNode
=
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
)
;
final
FocusNode
childNode
=
Focus
.
of
(
childKey
.
currentContext
!)!
;
// Now that the contents are shown, request focus on the child text.
childNode
.
requestFocus
();
await
tester
.
pumpAndSettle
();
...
...
@@ -364,7 +362,7 @@ void main() {
await
tester
.
pumpAndSettle
();
expect
(
itemBuilderCalled
,
isTrue
);
expect
(
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
)
.
hasPrimaryFocus
,
isFalse
);
expect
(
Focus
.
of
(
childKey
.
currentContext
!)!
.
hasPrimaryFocus
,
isFalse
);
});
testWidgets
(
'PopupMenuButton is horizontal on iOS'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -637,7 +635,7 @@ void main() {
});
testWidgets
(
'PopupMenu removes MediaQuery padding'
,
(
WidgetTester
tester
)
async
{
BuildContext
popupContext
;
late
BuildContext
popupContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
...
...
@@ -674,7 +672,7 @@ void main() {
await
tester
.
pump
();
expect
(
MediaQuery
.
of
(
popupContext
).
padding
,
EdgeInsets
.
zero
);
expect
(
MediaQuery
.
of
(
popupContext
)
!
.
padding
,
EdgeInsets
.
zero
);
});
testWidgets
(
'Popup Menu Offset Test'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -1042,7 +1040,7 @@ void main() {
testWidgets
(
'PopupMenuButton PopupMenuDivider'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/27072
String
selectedValue
;
late
String
selectedValue
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
...
...
@@ -1093,41 +1091,6 @@ void main() {
expect
(
selectedValue
,
'2'
);
});
testWidgets
(
'showMenu position required'
,
(
WidgetTester
tester
)
async
{
// Test for https://github.com/flutter/flutter/issues/22256
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Center
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
ElevatedButton
(
onPressed:
()
{
// Ensure showMenu throws an assertion without a position
expect
(()
{
// ignore: missing_required_param
showMenu
<
int
>(
context:
context
,
items:
<
PopupMenuItem
<
int
>>[
const
PopupMenuItem
<
int
>(
value:
1
,
child:
Text
(
'1'
),
),
],
);
},
throwsAssertionError
);
},
child:
const
Text
(
'Menu Button'
),
);
},
),
),
),
),
);
await
tester
.
tap
(
find
.
text
(
'Menu Button'
));
});
testWidgets
(
'PopupMenuItem child height is a minimum, child is vertically centered'
,
(
WidgetTester
tester
)
async
{
final
Key
popupMenuButtonKey
=
UniqueKey
();
final
Type
menuItemType
=
const
PopupMenuItem
<
String
>(
child:
Text
(
'item'
)).
runtimeType
;
...
...
@@ -1219,14 +1182,14 @@ void main() {
double
fontSize
=
24
,
})
{
return
MaterialApp
(
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Directionality
(
textDirection:
textDirection
,
child:
PopupMenuTheme
(
data:
PopupMenuTheme
.
of
(
context
).
copyWith
(
textStyle:
Theme
.
of
(
context
)
.
textTheme
.
subtitle1
.
copyWith
(
fontSize:
fontSize
),
textStyle:
Theme
.
of
(
context
)
!.
textTheme
.
subtitle1
!
.
copyWith
(
fontSize:
fontSize
),
),
child:
child
,
child:
child
!
,
),
);
},
...
...
@@ -1533,7 +1496,7 @@ void main() {
expect
(
find
.
text
(
'Tap me please!'
),
findsNothing
);
globalKey
.
currentState
.
showButtonMenu
();
globalKey
.
currentState
!
.
showButtonMenu
();
// The PopupMenuItem will appear after an animation, hence,
// we have to first wait for the tester to settle.
await
tester
.
pumpAndSettle
();
...
...
@@ -1571,7 +1534,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
(
...
...
@@ -1594,7 +1557,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
(
...
...
@@ -1618,19 +1581,19 @@ void main() {
),
);
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
});
}
class
TestApp
extends
StatefulWidget
{
const
TestApp
({
Key
key
,
this
.
textDirection
,
Key
?
key
,
required
this
.
textDirection
,
this
.
child
,
})
:
super
(
key:
key
);
final
TextDirection
textDirection
;
final
Widget
child
;
final
Widget
?
child
;
@override
_TestAppState
createState
()
=>
_TestAppState
();
...
...
@@ -1670,7 +1633,7 @@ class MenuObserver extends NavigatorObserver {
int
menuCount
=
0
;
@override
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
?
previousRoute
)
{
if
(
route
.
toString
().
contains
(
'_PopupMenuRoute'
))
{
menuCount
++;
}
...
...
packages/flutter/test/material/popup_menu_theme_test.dart
View file @
3961a12a
...
...
@@ -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'
;
...
...
@@ -79,7 +77,7 @@ void main() {
PopupMenuButton
<
void
>(
key:
popupButtonKey
,
itemBuilder:
(
BuildContext
context
)
{
return
<
PopupMenuEntry
<
Object
>>[
return
<
PopupMenuEntry
<
void
>>[
PopupMenuItem
<
void
>(
key:
popupItemKey
,
child:
const
Text
(
'Example'
),
...
...
@@ -139,7 +137,7 @@ void main() {
key:
popupButtonKey
,
itemBuilder:
(
BuildContext
context
)
{
return
<
PopupMenuEntry
<
Object
>>[
PopupMenuItem
<
void
>(
PopupMenuItem
<
Object
>(
key:
popupItemKey
,
child:
const
Text
(
'Example'
),
),
...
...
@@ -206,7 +204,7 @@ void main() {
color:
color
,
shape:
shape
,
itemBuilder:
(
BuildContext
context
)
{
return
<
PopupMenuEntry
<
Object
>>[
return
<
PopupMenuEntry
<
void
>>[
PopupMenuItem
<
void
>(
key:
popupItemKey
,
textStyle:
textStyle
,
...
...
@@ -270,7 +268,7 @@ void main() {
child:
PopupMenuButton
<
void
>(
key:
popupButtonKey
,
itemBuilder:
(
BuildContext
context
)
{
return
<
PopupMenuEntry
<
Object
>>[
return
<
PopupMenuEntry
<
void
>>[
PopupMenuItem
<
void
>(
key:
popupItemKey
,
child:
const
Text
(
'Example'
),
...
...
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