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
4513e96a
Unverified
Commit
4513e96a
authored
Oct 08, 2020
by
Michael Goderbauer
Committed by
GitHub
Oct 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate more material tests (#67591)
parent
b79e3462
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
146 additions
and
157 deletions
+146
-157
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+72
-71
text_button_test.dart
packages/flutter/test/material/text_button_test.dart
+38
-40
text_button_theme_test.dart
packages/flutter/test/material/text_button_theme_test.dart
+12
-14
text_field_focus_test.dart
packages/flutter/test/material/text_field_focus_test.dart
+2
-4
text_field_helper_text_test.dart
...es/flutter/test/material/text_field_helper_text_test.dart
+0
-2
text_field_restoration_test.dart
...es/flutter/test/material/text_field_restoration_test.dart
+2
-4
text_field_splash_test.dart
packages/flutter/test/material/text_field_splash_test.dart
+20
-22
No files found.
packages/flutter/test/material/tabs_test.dart
View file @
4513e96a
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
@@ -11,11 +9,12 @@ import 'package:flutter/widgets.dart';
...
@@ -11,11 +9,12 @@ import 'package:flutter/widgets.dart';
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/physics.dart'
;
import
'package:flutter/physics.dart'
;
import
'../flutter_test_alternative.dart'
show
Fake
;
import
'../rendering/mock_canvas.dart'
;
import
'../rendering/mock_canvas.dart'
;
import
'../rendering/recording_canvas.dart'
;
import
'../rendering/recording_canvas.dart'
;
import
'../widgets/semantics_tester.dart'
;
import
'../widgets/semantics_tester.dart'
;
Widget
boilerplate
(
{
Widget
child
,
TextDirection
textDirection
=
TextDirection
.
ltr
})
{
Widget
boilerplate
(
{
Widget
?
child
,
TextDirection
textDirection
=
TextDirection
.
ltr
})
{
return
Localizations
(
return
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
...
@@ -32,27 +31,27 @@ Widget boilerplate({ Widget child, TextDirection textDirection = TextDirection.l
...
@@ -32,27 +31,27 @@ Widget boilerplate({ Widget child, TextDirection textDirection = TextDirection.l
}
}
class
StateMarker
extends
StatefulWidget
{
class
StateMarker
extends
StatefulWidget
{
const
StateMarker
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
const
StateMarker
({
Key
?
key
,
this
.
child
})
:
super
(
key:
key
);
final
Widget
child
;
final
Widget
?
child
;
@override
@override
StateMarkerState
createState
()
=>
StateMarkerState
();
StateMarkerState
createState
()
=>
StateMarkerState
();
}
}
class
StateMarkerState
extends
State
<
StateMarker
>
{
class
StateMarkerState
extends
State
<
StateMarker
>
{
String
marker
;
String
?
marker
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
if
(
widget
.
child
!=
null
)
if
(
widget
.
child
!=
null
)
return
widget
.
child
;
return
widget
.
child
!
;
return
Container
();
return
Container
();
}
}
}
}
class
AlwaysKeepAliveWidget
extends
StatefulWidget
{
class
AlwaysKeepAliveWidget
extends
StatefulWidget
{
const
AlwaysKeepAliveWidget
({
Key
key
})
:
super
(
key:
key
);
const
AlwaysKeepAliveWidget
({
Key
?
key
})
:
super
(
key:
key
);
static
String
text
=
'AlwaysKeepAlive'
;
static
String
text
=
'AlwaysKeepAlive'
;
@override
@override
AlwaysKeepAliveState
createState
()
=>
AlwaysKeepAliveState
();
AlwaysKeepAliveState
createState
()
=>
AlwaysKeepAliveState
();
...
@@ -75,7 +74,7 @@ class _NestedTabBarContainer extends StatelessWidget {
...
@@ -75,7 +74,7 @@ class _NestedTabBarContainer extends StatelessWidget {
this
.
tabController
,
this
.
tabController
,
});
});
final
TabController
tabController
;
final
TabController
?
tabController
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
...
@@ -107,11 +106,11 @@ class _NestedTabBarContainer extends StatelessWidget {
...
@@ -107,11 +106,11 @@ class _NestedTabBarContainer extends StatelessWidget {
}
}
Widget
buildFrame
(
{
Widget
buildFrame
(
{
Key
tabBarKey
,
Key
?
tabBarKey
,
List
<
String
>
tabs
,
required
List
<
String
>
tabs
,
String
value
,
required
String
value
,
bool
isScrollable
=
false
,
bool
isScrollable
=
false
,
Color
indicatorColor
,
Color
?
indicatorColor
,
})
{
})
{
return
boilerplate
(
return
boilerplate
(
child:
DefaultTabController
(
child:
DefaultTabController
(
...
@@ -131,10 +130,10 @@ typedef TabControllerFrameBuilder = Widget Function(BuildContext context, TabCon
...
@@ -131,10 +130,10 @@ typedef TabControllerFrameBuilder = Widget Function(BuildContext context, TabCon
class
TabControllerFrame
extends
StatefulWidget
{
class
TabControllerFrame
extends
StatefulWidget
{
const
TabControllerFrame
({
const
TabControllerFrame
({
Key
key
,
Key
?
key
,
this
.
length
,
required
this
.
length
,
this
.
initialIndex
=
0
,
this
.
initialIndex
=
0
,
this
.
builder
,
required
this
.
builder
,
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
final
int
length
;
final
int
length
;
...
@@ -146,7 +145,7 @@ class TabControllerFrame extends StatefulWidget {
...
@@ -146,7 +145,7 @@ class TabControllerFrame extends StatefulWidget {
}
}
class
TabControllerFrameState
extends
State
<
TabControllerFrame
>
with
SingleTickerProviderStateMixin
{
class
TabControllerFrameState
extends
State
<
TabControllerFrame
>
with
SingleTickerProviderStateMixin
{
TabController
_controller
;
late
TabController
_controller
;
@override
@override
void
initState
()
{
void
initState
()
{
...
@@ -170,7 +169,7 @@ class TabControllerFrameState extends State<TabControllerFrame> with SingleTicke
...
@@ -170,7 +169,7 @@ class TabControllerFrameState extends State<TabControllerFrame> with SingleTicke
}
}
}
}
Widget
buildLeftRightApp
(
{
List
<
String
>
tabs
,
String
value
})
{
Widget
buildLeftRightApp
(
{
required
List
<
String
>
tabs
,
required
String
value
})
{
return
MaterialApp
(
return
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
android
),
theme:
ThemeData
(
platform:
TargetPlatform
.
android
),
home:
DefaultTabController
(
home:
DefaultTabController
(
...
@@ -198,7 +197,7 @@ class TabIndicatorRecordingCanvas extends TestRecordingCanvas {
...
@@ -198,7 +197,7 @@ class TabIndicatorRecordingCanvas extends TestRecordingCanvas {
TabIndicatorRecordingCanvas
(
this
.
indicatorColor
);
TabIndicatorRecordingCanvas
(
this
.
indicatorColor
);
final
Color
indicatorColor
;
final
Color
indicatorColor
;
Rect
indicatorRect
;
late
Rect
indicatorRect
;
@override
@override
void
drawLine
(
Offset
p1
,
Offset
p2
,
Paint
paint
)
{
void
drawLine
(
Offset
p1
,
Offset
p2
,
Paint
paint
)
{
...
@@ -210,10 +209,10 @@ class TabIndicatorRecordingCanvas extends TestRecordingCanvas {
...
@@ -210,10 +209,10 @@ class TabIndicatorRecordingCanvas extends TestRecordingCanvas {
}
}
class
TestScrollPhysics
extends
ScrollPhysics
{
class
TestScrollPhysics
extends
ScrollPhysics
{
const
TestScrollPhysics
({
ScrollPhysics
parent
})
:
super
(
parent:
parent
);
const
TestScrollPhysics
({
ScrollPhysics
?
parent
})
:
super
(
parent:
parent
);
@override
@override
TestScrollPhysics
applyTo
(
ScrollPhysics
ancestor
)
{
TestScrollPhysics
applyTo
(
ScrollPhysics
?
ancestor
)
{
return
TestScrollPhysics
(
parent:
buildParent
(
ancestor
));
return
TestScrollPhysics
(
parent:
buildParent
(
ancestor
));
}
}
...
@@ -255,7 +254,7 @@ void main() {
...
@@ -255,7 +254,7 @@ void main() {
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
fontFamily:
'Ahem'
),
home:
const
Center
(
child:
Material
(
child:
Tab
(
text:
'x'
)))),
MaterialApp
(
theme:
ThemeData
(
fontFamily:
'Ahem'
),
home:
const
Center
(
child:
Material
(
child:
Tab
(
text:
'x'
)))),
);
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
byType
(
RichText
)).
text
.
style
.
fontFamily
,
'Ahem'
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
byType
(
RichText
)).
text
.
style
!
.
fontFamily
,
'Ahem'
);
expect
(
tester
.
getSize
(
find
.
byType
(
Tab
)),
const
Size
(
14.0
,
46.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Tab
)),
const
Size
(
14.0
,
46.0
));
});
});
...
@@ -263,7 +262,7 @@ void main() {
...
@@ -263,7 +262,7 @@ void main() {
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
fontFamily:
'Ahem'
),
home:
const
Center
(
child:
Material
(
child:
Tab
(
icon:
SizedBox
(
width:
10.0
,
height:
10.0
),
text:
'x'
)))),
MaterialApp
(
theme:
ThemeData
(
fontFamily:
'Ahem'
),
home:
const
Center
(
child:
Material
(
child:
Tab
(
icon:
SizedBox
(
width:
10.0
,
height:
10.0
),
text:
'x'
)))),
);
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
byType
(
RichText
)).
text
.
style
.
fontFamily
,
'Ahem'
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
byType
(
RichText
)).
text
.
style
!
.
fontFamily
,
'Ahem'
);
expect
(
tester
.
getSize
(
find
.
byType
(
Tab
)),
const
Size
(
14.0
,
72.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Tab
)),
const
Size
(
14.0
,
72.0
));
});
});
...
@@ -287,7 +286,7 @@ void main() {
...
@@ -287,7 +286,7 @@ void main() {
),
),
),
),
);
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
byType
(
RichText
)).
text
.
style
.
fontFamily
,
'Ahem'
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
byType
(
RichText
)).
text
.
style
!
.
fontFamily
,
'Ahem'
);
expect
(
tester
.
getSize
(
find
.
byType
(
Tab
)),
const
Size
(
210.0
,
72.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Tab
)),
const
Size
(
210.0
,
72.0
));
});
});
...
@@ -295,7 +294,7 @@ void main() {
...
@@ -295,7 +294,7 @@ void main() {
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
fontFamily:
'Ahem'
),
home:
const
Center
(
child:
Material
(
child:
Tab
(
icon:
SizedBox
(
width:
10.0
,
height:
10.0
),
child:
Text
(
'x'
))))),
MaterialApp
(
theme:
ThemeData
(
fontFamily:
'Ahem'
),
home:
const
Center
(
child:
Material
(
child:
Tab
(
icon:
SizedBox
(
width:
10.0
,
height:
10.0
),
child:
Text
(
'x'
))))),
);
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
byType
(
RichText
)).
text
.
style
.
fontFamily
,
'Ahem'
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
byType
(
RichText
)).
text
.
style
!
.
fontFamily
,
'Ahem'
);
expect
(
tester
.
getSize
(
find
.
byType
(
Tab
)),
const
Size
(
14.0
,
72.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Tab
)),
const
Size
(
14.0
,
72.0
));
});
});
...
@@ -330,7 +329,7 @@ void main() {
...
@@ -330,7 +329,7 @@ void main() {
expect
(
find
.
text
(
'A'
),
findsOneWidget
);
expect
(
find
.
text
(
'A'
),
findsOneWidget
);
expect
(
find
.
text
(
'B'
),
findsOneWidget
);
expect
(
find
.
text
(
'B'
),
findsOneWidget
);
expect
(
find
.
text
(
'C'
),
findsOneWidget
);
expect
(
find
.
text
(
'C'
),
findsOneWidget
);
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'A'
)));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'A'
)))
!
;
expect
(
controller
,
isNotNull
);
expect
(
controller
,
isNotNull
);
expect
(
controller
.
index
,
2
);
expect
(
controller
.
index
,
2
);
expect
(
controller
.
previousIndex
,
2
);
expect
(
controller
.
previousIndex
,
2
);
...
@@ -366,7 +365,7 @@ void main() {
...
@@ -366,7 +365,7 @@ void main() {
expect
(
find
.
text
(
'A'
),
findsOneWidget
);
expect
(
find
.
text
(
'A'
),
findsOneWidget
);
expect
(
find
.
text
(
'B'
),
findsOneWidget
);
expect
(
find
.
text
(
'B'
),
findsOneWidget
);
expect
(
find
.
text
(
'C'
),
findsOneWidget
);
expect
(
find
.
text
(
'C'
),
findsOneWidget
);
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'A'
)));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'A'
)))
!
;
expect
(
controller
.
index
,
2
);
expect
(
controller
.
index
,
2
);
expect
(
controller
.
previousIndex
,
2
);
expect
(
controller
.
previousIndex
,
2
);
...
@@ -387,7 +386,7 @@ void main() {
...
@@ -387,7 +386,7 @@ void main() {
final
List
<
String
>
tabs
=
<
String
>[
'AAAAAA'
,
'BBBBBB'
,
'CCCCCC'
,
'DDDDDD'
,
'EEEEEE'
,
'FFFFFF'
,
'GGGGGG'
,
'HHHHHH'
,
'IIIIII'
,
'JJJJJJ'
,
'KKKKKK'
,
'LLLLLL'
];
final
List
<
String
>
tabs
=
<
String
>[
'AAAAAA'
,
'BBBBBB'
,
'CCCCCC'
,
'DDDDDD'
,
'EEEEEE'
,
'FFFFFF'
,
'GGGGGG'
,
'HHHHHH'
,
'IIIIII'
,
'JJJJJJ'
,
'KKKKKK'
,
'LLLLLL'
];
const
Key
tabBarKey
=
Key
(
'TabBar'
);
const
Key
tabBarKey
=
Key
(
'TabBar'
);
await
tester
.
pumpWidget
(
buildFrame
(
tabs:
tabs
,
value:
'AAAAAA'
,
isScrollable:
true
,
tabBarKey:
tabBarKey
));
await
tester
.
pumpWidget
(
buildFrame
(
tabs:
tabs
,
value:
'AAAAAA'
,
isScrollable:
true
,
tabBarKey:
tabBarKey
));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'AAAAAA'
)));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'AAAAAA'
)))
!
;
expect
(
controller
,
isNotNull
);
expect
(
controller
,
isNotNull
);
expect
(
controller
.
index
,
0
);
expect
(
controller
.
index
,
0
);
...
@@ -407,7 +406,7 @@ void main() {
...
@@ -407,7 +406,7 @@ void main() {
final
List
<
String
>
tabs
=
<
String
>[
'AAAA'
,
'BBBB'
,
'CCCC'
,
'DDDD'
,
'EEEE'
,
'FFFF'
,
'GGGG'
,
'HHHH'
,
'IIII'
,
'JJJJ'
,
'KKKK'
,
'LLLL'
];
final
List
<
String
>
tabs
=
<
String
>[
'AAAA'
,
'BBBB'
,
'CCCC'
,
'DDDD'
,
'EEEE'
,
'FFFF'
,
'GGGG'
,
'HHHH'
,
'IIII'
,
'JJJJ'
,
'KKKK'
,
'LLLL'
];
const
Key
tabBarKey
=
Key
(
'TabBar'
);
const
Key
tabBarKey
=
Key
(
'TabBar'
);
await
tester
.
pumpWidget
(
buildFrame
(
tabs:
tabs
,
value:
'AAAA'
,
isScrollable:
true
,
tabBarKey:
tabBarKey
));
await
tester
.
pumpWidget
(
buildFrame
(
tabs:
tabs
,
value:
'AAAA'
,
isScrollable:
true
,
tabBarKey:
tabBarKey
));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'AAAA'
)));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'AAAA'
)))
!
;
expect
(
controller
,
isNotNull
);
expect
(
controller
,
isNotNull
);
expect
(
controller
.
index
,
0
);
expect
(
controller
.
index
,
0
);
...
@@ -447,7 +446,7 @@ void main() {
...
@@ -447,7 +446,7 @@ void main() {
}
}
await
tester
.
pumpWidget
(
builder
());
await
tester
.
pumpWidget
(
builder
());
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'AAAAAA'
)));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'AAAAAA'
)))
!
;
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
tabs
[
0
])));
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
tabs
[
0
])));
await
gesture
.
moveBy
(
const
Offset
(-
600.0
,
0.0
));
await
gesture
.
moveBy
(
const
Offset
(-
600.0
,
0.0
));
...
@@ -504,7 +503,7 @@ void main() {
...
@@ -504,7 +503,7 @@ void main() {
expect
(
find
.
text
(
'LEFT CHILD'
),
findsOneWidget
);
expect
(
find
.
text
(
'LEFT CHILD'
),
findsOneWidget
);
expect
(
find
.
text
(
'RIGHT CHILD'
),
findsNothing
);
expect
(
find
.
text
(
'RIGHT CHILD'
),
findsNothing
);
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'LEFT'
)));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'LEFT'
)))
!
;
expect
(
controller
.
index
,
0
);
expect
(
controller
.
index
,
0
);
// Fling to the left, switch from the 'LEFT' tab to the 'RIGHT'
// Fling to the left, switch from the 'LEFT' tab to the 'RIGHT'
...
@@ -533,7 +532,7 @@ void main() {
...
@@ -533,7 +532,7 @@ void main() {
expect
(
find
.
text
(
'LEFT CHILD'
),
findsOneWidget
);
expect
(
find
.
text
(
'LEFT CHILD'
),
findsOneWidget
);
expect
(
find
.
text
(
'RIGHT CHILD'
),
findsNothing
);
expect
(
find
.
text
(
'RIGHT CHILD'
),
findsNothing
);
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'LEFT'
)));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'LEFT'
)))
!
;
expect
(
controller
.
index
,
0
);
expect
(
controller
.
index
,
0
);
final
Offset
flingStart
=
tester
.
getCenter
(
find
.
text
(
'LEFT CHILD'
));
final
Offset
flingStart
=
tester
.
getCenter
(
find
.
text
(
'LEFT CHILD'
));
...
@@ -554,7 +553,7 @@ void main() {
...
@@ -554,7 +553,7 @@ void main() {
expect
(
find
.
text
(
'LEFT CHILD'
),
findsOneWidget
);
expect
(
find
.
text
(
'LEFT CHILD'
),
findsOneWidget
);
expect
(
find
.
text
(
'RIGHT CHILD'
),
findsNothing
);
expect
(
find
.
text
(
'RIGHT CHILD'
),
findsNothing
);
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'LEFT'
)));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'LEFT'
)))
!
;
expect
(
controller
.
index
,
0
);
expect
(
controller
.
index
,
0
);
final
Offset
flingStart
=
tester
.
getCenter
(
find
.
text
(
'LEFT CHILD'
));
final
Offset
flingStart
=
tester
.
getCenter
(
find
.
text
(
'LEFT CHILD'
));
...
@@ -577,7 +576,7 @@ void main() {
...
@@ -577,7 +576,7 @@ void main() {
expect
(
find
.
text
(
'LEFT CHILD'
),
findsOneWidget
);
expect
(
find
.
text
(
'LEFT CHILD'
),
findsOneWidget
);
expect
(
find
.
text
(
'RIGHT CHILD'
),
findsNothing
);
expect
(
find
.
text
(
'RIGHT CHILD'
),
findsNothing
);
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'LEFT'
)));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'LEFT'
)))
!
;
expect
(
controller
.
index
,
0
);
expect
(
controller
.
index
,
0
);
final
Offset
flingStart
=
tester
.
getCenter
(
find
.
text
(
'LEFT CHILD'
));
final
Offset
flingStart
=
tester
.
getCenter
(
find
.
text
(
'LEFT CHILD'
));
...
@@ -645,12 +644,12 @@ void main() {
...
@@ -645,12 +644,12 @@ void main() {
final
List
<
String
>
tabs
=
<
String
>[
'LEFT'
,
'RIGHT'
];
final
List
<
String
>
tabs
=
<
String
>[
'LEFT'
,
'RIGHT'
];
await
tester
.
pumpWidget
(
buildLeftRightApp
(
tabs:
tabs
,
value:
'LEFT'
));
await
tester
.
pumpWidget
(
buildLeftRightApp
(
tabs:
tabs
,
value:
'LEFT'
));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'LEFT'
)));
final
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'LEFT'
)))
!
;
expect
(
controller
,
isNotNull
);
expect
(
controller
,
isNotNull
);
expect
(
controller
.
index
,
0
);
expect
(
controller
.
index
,
0
);
String
value
;
late
String
value
;
controller
.
addListener
(()
{
controller
.
addListener
(()
{
value
=
tabs
[
controller
.
index
];
value
=
tabs
[
controller
.
index
];
});
});
...
@@ -676,7 +675,7 @@ void main() {
...
@@ -676,7 +675,7 @@ void main() {
testWidgets
(
'Explicit TabController'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Explicit TabController'
,
(
WidgetTester
tester
)
async
{
final
List
<
String
>
tabs
=
<
String
>[
'LEFT'
,
'RIGHT'
];
final
List
<
String
>
tabs
=
<
String
>[
'LEFT'
,
'RIGHT'
];
TabController
tabController
;
late
TabController
tabController
;
Widget
buildTabControllerFrame
(
BuildContext
context
,
TabController
controller
)
{
Widget
buildTabControllerFrame
(
BuildContext
context
,
TabController
controller
)
{
tabController
=
controller
;
tabController
=
controller
;
...
@@ -714,8 +713,8 @@ void main() {
...
@@ -714,8 +713,8 @@ void main() {
expect
(
tabController
.
index
,
1
);
expect
(
tabController
.
index
,
1
);
expect
(
tabController
.
previousIndex
,
1
);
expect
(
tabController
.
previousIndex
,
1
);
expect
(
tabController
.
indexIsChanging
,
false
);
expect
(
tabController
.
indexIsChanging
,
false
);
expect
(
tabController
.
animation
.
value
,
1.0
);
expect
(
tabController
.
animation
!
.
value
,
1.0
);
expect
(
tabController
.
animation
.
status
,
AnimationStatus
.
forward
);
expect
(
tabController
.
animation
!
.
status
,
AnimationStatus
.
forward
);
tabController
.
index
=
0
;
tabController
.
index
=
0
;
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
500
));
...
@@ -735,7 +734,7 @@ void main() {
...
@@ -735,7 +734,7 @@ void main() {
// https://github.com/flutter/flutter/pull/7387#pullrequestreview-15630946
// https://github.com/flutter/flutter/pull/7387#pullrequestreview-15630946
final
List
<
String
>
tabs
=
<
String
>[
'A'
,
'B'
,
'C'
];
final
List
<
String
>
tabs
=
<
String
>[
'A'
,
'B'
,
'C'
];
TabController
tabController
;
late
TabController
tabController
;
Widget
buildTabControllerFrame
(
BuildContext
context
,
TabController
controller
)
{
Widget
buildTabControllerFrame
(
BuildContext
context
,
TabController
controller
)
{
tabController
=
controller
;
tabController
=
controller
;
...
@@ -766,8 +765,8 @@ void main() {
...
@@ -766,8 +765,8 @@ void main() {
length:
tabs
.
length
,
length:
tabs
.
length
,
));
));
tabController
.
animation
.
addListener
(()
{
tabController
.
animation
!
.
addListener
(()
{
if
(
tabController
.
animation
.
status
==
AnimationStatus
.
forward
)
if
(
tabController
.
animation
!
.
status
==
AnimationStatus
.
forward
)
tabController
.
index
=
2
;
tabController
.
index
=
2
;
expect
(
tabController
.
indexIsChanging
,
true
);
expect
(
tabController
.
indexIsChanging
,
true
);
});
});
...
@@ -803,8 +802,8 @@ void main() {
...
@@ -803,8 +802,8 @@ void main() {
length:
2
,
length:
2
,
);
);
Color
firstColor
;
late
Color
firstColor
;
Color
secondColor
;
late
Color
secondColor
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
boilerplate
(
boilerplate
(
...
@@ -815,13 +814,13 @@ void main() {
...
@@ -815,13 +814,13 @@ void main() {
tabs:
<
Widget
>[
tabs:
<
Widget
>[
Builder
(
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
firstColor
=
IconTheme
.
of
(
context
).
color
;
firstColor
=
IconTheme
.
of
(
context
).
color
!
;
return
const
Text
(
'First'
);
return
const
Text
(
'First'
);
}
}
),
),
Builder
(
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
secondColor
=
IconTheme
.
of
(
context
).
color
;
secondColor
=
IconTheme
.
of
(
context
).
color
!
;
return
const
Text
(
'Second'
);
return
const
Text
(
'Second'
);
}
}
),
),
...
@@ -1175,7 +1174,7 @@ void main() {
...
@@ -1175,7 +1174,7 @@ void main() {
);
);
final
TabBar
tabBar
=
tester
.
widget
(
find
.
byType
(
TabBar
));
final
TabBar
tabBar
=
tester
.
widget
(
find
.
byType
(
TabBar
));
final
double
position
=
tabBar
.
physics
.
applyPhysicsToUserOffset
(
null
,
10
);
final
double
position
=
tabBar
.
physics
!.
applyPhysicsToUserOffset
(
MockScrollMetrics
()
,
10
);
expect
(
position
,
equals
(
20
));
expect
(
position
,
equals
(
20
));
});
});
...
@@ -1438,7 +1437,7 @@ void main() {
...
@@ -1438,7 +1437,7 @@ void main() {
double
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
30.0
)
/
2.0
;
double
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
30.0
)
/
2.0
;
double
tabBottom
=
tabTop
+
30.0
;
double
tabBottom
=
tabTop
+
30.0
;
Rect
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
Rect
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
0
].
key
)),
tabRect
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
0
].
key
!
)),
tabRect
);
// Tab1 width = 140, height = 40
// Tab1 width = 140, height = 40
...
@@ -1447,7 +1446,7 @@ void main() {
...
@@ -1447,7 +1446,7 @@ void main() {
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
40.0
)
/
2.0
;
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
40.0
)
/
2.0
;
tabBottom
=
tabTop
+
40.0
;
tabBottom
=
tabTop
+
40.0
;
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
1
].
key
)),
tabRect
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
1
].
key
!
)),
tabRect
);
// Tab2 width = 150, height = 50
// Tab2 width = 150, height = 50
...
@@ -1456,7 +1455,7 @@ void main() {
...
@@ -1456,7 +1455,7 @@ void main() {
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
50.0
)
/
2.0
;
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
50.0
)
/
2.0
;
tabBottom
=
tabTop
+
50.0
;
tabBottom
=
tabTop
+
50.0
;
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
2
].
key
)),
tabRect
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
2
].
key
!
)),
tabRect
);
// Tab 0 selected, indicator padding resolves to left: 100.0
// Tab 0 selected, indicator padding resolves to left: 100.0
const
double
indicatorLeft
=
100.0
+
indicatorWeight
/
2.0
;
const
double
indicatorLeft
=
100.0
+
indicatorWeight
/
2.0
;
...
@@ -1508,7 +1507,7 @@ void main() {
...
@@ -1508,7 +1507,7 @@ void main() {
double
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
50.0
)
/
2.0
;
double
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
50.0
)
/
2.0
;
double
tabBottom
=
tabTop
+
50.0
;
double
tabBottom
=
tabTop
+
50.0
;
Rect
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
Rect
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
2
].
key
)),
tabRect
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
2
].
key
!
)),
tabRect
);
// Tab1 width = 140, height = 40
// Tab1 width = 140, height = 40
tabLeft
=
tabRight
+
kTabLabelPadding
.
right
+
kTabLabelPadding
.
left
;
tabLeft
=
tabRight
+
kTabLabelPadding
.
right
+
kTabLabelPadding
.
left
;
...
@@ -1516,7 +1515,7 @@ void main() {
...
@@ -1516,7 +1515,7 @@ void main() {
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
40.0
)
/
2.0
;
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
40.0
)
/
2.0
;
tabBottom
=
tabTop
+
40.0
;
tabBottom
=
tabTop
+
40.0
;
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
1
].
key
)),
tabRect
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
1
].
key
!
)),
tabRect
);
// Tab0 width = 130, height = 30
// Tab0 width = 130, height = 30
tabLeft
=
tabRight
+
kTabLabelPadding
.
right
+
kTabLabelPadding
.
left
;
tabLeft
=
tabRight
+
kTabLabelPadding
.
right
+
kTabLabelPadding
.
left
;
...
@@ -1524,7 +1523,7 @@ void main() {
...
@@ -1524,7 +1523,7 @@ void main() {
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
30.0
)
/
2.0
;
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
30.0
)
/
2.0
;
tabBottom
=
tabTop
+
30.0
;
tabBottom
=
tabTop
+
30.0
;
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
0
].
key
)),
tabRect
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
0
].
key
!
)),
tabRect
);
// Tab 0 selected, indicator padding resolves to right: 100.0
// Tab 0 selected, indicator padding resolves to right: 100.0
final
double
indicatorLeft
=
tabLeft
-
kTabLabelPadding
.
left
+
indicatorWeight
/
2.0
;
final
double
indicatorLeft
=
tabLeft
-
kTabLabelPadding
.
left
+
indicatorWeight
/
2.0
;
...
@@ -1578,7 +1577,7 @@ void main() {
...
@@ -1578,7 +1577,7 @@ void main() {
double
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
30.0
)
/
2.0
;
double
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
30.0
)
/
2.0
;
double
tabBottom
=
tabTop
+
30.0
;
double
tabBottom
=
tabTop
+
30.0
;
Rect
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
Rect
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
0
].
key
)),
tabRect
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
0
].
key
!
)),
tabRect
);
// Tab1 width = 140, height = 40
// Tab1 width = 140, height = 40
tabLeft
=
tabRight
+
labelPadding
.
right
+
labelPadding
.
left
;
tabLeft
=
tabRight
+
labelPadding
.
right
+
labelPadding
.
left
;
...
@@ -1586,7 +1585,7 @@ void main() {
...
@@ -1586,7 +1585,7 @@ void main() {
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
40.0
)
/
2.0
;
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
40.0
)
/
2.0
;
tabBottom
=
tabTop
+
40.0
;
tabBottom
=
tabTop
+
40.0
;
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
1
].
key
)),
tabRect
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
1
].
key
!
)),
tabRect
);
// Tab2 width = 150, height = 50
// Tab2 width = 150, height = 50
tabLeft
=
tabRight
+
labelPadding
.
right
+
labelPadding
.
left
;
tabLeft
=
tabRight
+
labelPadding
.
right
+
labelPadding
.
left
;
...
@@ -1594,7 +1593,7 @@ void main() {
...
@@ -1594,7 +1593,7 @@ void main() {
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
50.0
)
/
2.0
;
tabTop
=
(
tabBarHeight
-
indicatorWeight
-
50.0
)
/
2.0
;
tabBottom
=
tabTop
+
50.0
;
tabBottom
=
tabTop
+
50.0
;
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
tabRect
=
Rect
.
fromLTRB
(
tabLeft
,
tabTop
,
tabRight
,
tabBottom
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
2
].
key
)),
tabRect
);
expect
(
tester
.
getRect
(
find
.
byKey
(
tabs
[
2
].
key
!
)),
tabRect
);
// Tab 0 selected, indicatorPadding == labelPadding
// Tab 0 selected, indicatorPadding == labelPadding
final
double
indicatorLeft
=
indicatorPadding
.
left
+
indicatorWeight
/
2.0
;
final
double
indicatorLeft
=
indicatorPadding
.
left
+
indicatorWeight
/
2.0
;
...
@@ -2018,8 +2017,8 @@ void main() {
...
@@ -2018,8 +2017,8 @@ void main() {
int
tabIndex
=
-
1
;
int
tabIndex
=
-
1
;
Widget
buildFrame
({
Widget
buildFrame
({
TabController
controller
,
required
TabController
controller
,
List
<
String
>
tabs
,
required
List
<
String
>
tabs
,
})
{
})
{
return
boilerplate
(
return
boilerplate
(
child:
Container
(
child:
Container
(
...
@@ -2123,7 +2122,7 @@ void main() {
...
@@ -2123,7 +2122,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
// Test default cursor
// Test default cursor
await
tester
.
pumpWidget
(
MaterialApp
(
home:
DefaultTabController
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
DefaultTabController
(
...
@@ -2138,7 +2137,7 @@ void main() {
...
@@ -2138,7 +2137,7 @@ void main() {
),
),
),
),
));
));
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
});
});
testWidgets
(
'TabController changes'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'TabController changes'
,
(
WidgetTester
tester
)
async
{
...
@@ -2330,7 +2329,7 @@ void main() {
...
@@ -2330,7 +2329,7 @@ void main() {
];
];
final
TabController
controller
=
TabController
(
vsync:
const
TestVSync
(),
length:
tabs
.
length
);
final
TabController
controller
=
TabController
(
vsync:
const
TestVSync
(),
length:
tabs
.
length
);
Widget
buildTestWidget
({
double
width
,
double
height
})
{
Widget
buildTestWidget
({
double
?
width
,
double
?
height
})
{
return
MaterialApp
(
return
MaterialApp
(
home:
Center
(
home:
Center
(
child:
SizedBox
(
child:
SizedBox
(
...
@@ -2398,7 +2397,7 @@ void main() {
...
@@ -2398,7 +2397,7 @@ void main() {
),
),
);
);
}
}
TabController
getController
()
=>
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'A'
)));
TabController
getController
()
=>
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'A'
)))
!
;
await
tester
.
pumpWidget
(
buildTabs
(
threeTabs
));
await
tester
.
pumpWidget
(
buildTabs
(
threeTabs
));
await
tester
.
tap
(
find
.
text
(
'B'
));
await
tester
.
tap
(
find
.
text
(
'B'
));
...
@@ -2593,7 +2592,7 @@ void main() {
...
@@ -2593,7 +2592,7 @@ void main() {
Tab
(
text:
'A'
),
Tab
(
text:
'B'
),
Tab
(
text:
'C'
)
Tab
(
text:
'A'
),
Tab
(
text:
'B'
),
Tab
(
text:
'C'
)
];
];
const
Color
indicatorColor
=
Color
(
0xFFFF0000
);
const
Color
indicatorColor
=
Color
(
0xFFFF0000
);
TabController
tabController
;
late
TabController
tabController
;
Widget
buildTabControllerFrame
(
BuildContext
context
,
TabController
controller
)
{
Widget
buildTabControllerFrame
(
BuildContext
context
,
TabController
controller
)
{
tabController
=
controller
;
tabController
=
controller
;
...
@@ -2609,7 +2608,7 @@ void main() {
...
@@ -2609,7 +2608,7 @@ void main() {
body:
TabBarView
(
body:
TabBarView
(
controller:
controller
,
controller:
controller
,
children:
tabs
.
map
((
Tab
tab
)
{
children:
tabs
.
map
((
Tab
tab
)
{
return
Center
(
child:
Text
(
tab
.
text
));
return
Center
(
child:
Text
(
tab
.
text
!
));
}).
toList
(),
}).
toList
(),
),
),
),
),
...
@@ -2677,8 +2676,8 @@ void main() {
...
@@ -2677,8 +2676,8 @@ void main() {
length:
2
,
length:
2
,
);
);
Color
firstColor
;
late
Color
firstColor
;
Color
secondColor
;
late
Color
secondColor
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
boilerplate
(
boilerplate
(
...
@@ -2688,11 +2687,11 @@ void main() {
...
@@ -2688,11 +2687,11 @@ void main() {
unselectedLabelColor:
Colors
.
black
,
unselectedLabelColor:
Colors
.
black
,
tabs:
<
Widget
>[
tabs:
<
Widget
>[
Builder
(
builder:
(
BuildContext
context
)
{
Builder
(
builder:
(
BuildContext
context
)
{
firstColor
=
DefaultTextStyle
.
of
(
context
).
style
.
color
;
firstColor
=
DefaultTextStyle
.
of
(
context
).
style
.
color
!
;
return
const
Text
(
'First'
);
return
const
Text
(
'First'
);
}),
}),
Builder
(
builder:
(
BuildContext
context
)
{
Builder
(
builder:
(
BuildContext
context
)
{
secondColor
=
DefaultTextStyle
.
of
(
context
).
style
.
color
;
secondColor
=
DefaultTextStyle
.
of
(
context
).
style
.
color
!
;
return
const
Text
(
'Second'
);
return
const
Text
(
'Second'
);
}),
}),
],
],
...
@@ -2764,18 +2763,18 @@ void main() {
...
@@ -2764,18 +2763,18 @@ void main() {
pageController
.
jumpTo
(
300.0
);
pageController
.
jumpTo
(
300.0
);
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
tabController
.
animation
.
value
,
pageController
.
page
);
expect
(
tabController
.
animation
!
.
value
,
pageController
.
page
);
// Touch TabBarView while ballistic scrolling is happening and
// Touch TabBarView while ballistic scrolling is happening and
// check if tabController's animation value properly follows page value.
// check if tabController's animation value properly follows page value.
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
PageView
)));
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
PageView
)));
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
tabController
.
animation
.
value
,
pageController
.
page
);
expect
(
tabController
.
animation
!
.
value
,
pageController
.
page
);
});
});
}
}
class
KeepAliveInk
extends
StatefulWidget
{
class
KeepAliveInk
extends
StatefulWidget
{
const
KeepAliveInk
(
this
.
title
,
{
Key
key
})
:
super
(
key:
key
);
const
KeepAliveInk
(
this
.
title
,
{
Key
?
key
})
:
super
(
key:
key
);
final
String
title
;
final
String
title
;
@override
@override
State
<
StatefulWidget
>
createState
()
{
State
<
StatefulWidget
>
createState
()
{
...
@@ -2825,3 +2824,5 @@ class TabBarDemo extends StatelessWidget {
...
@@ -2825,3 +2824,5 @@ class TabBarDemo extends StatelessWidget {
);
);
}
}
}
}
class
MockScrollMetrics
extends
Fake
implements
ScrollMetrics
{}
packages/flutter/test/material/text_button_test.dart
View file @
4513e96a
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/gestures.dart'
;
...
@@ -43,10 +41,10 @@ void main() {
...
@@ -43,10 +41,10 @@ void main() {
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
4.0
)));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
4.0
)));
expect
(
material
.
textStyle
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
.
fontSize
,
14
);
expect
(
material
.
textStyle
!
.
fontSize
,
14
);
expect
(
material
.
textStyle
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
textStyle
!
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
type
,
MaterialType
.
button
);
expect
(
material
.
type
,
MaterialType
.
button
);
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
TextButton
));
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
TextButton
));
...
@@ -68,10 +66,10 @@ void main() {
...
@@ -68,10 +66,10 @@ void main() {
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
4.0
)));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
4.0
)));
expect
(
material
.
textStyle
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
.
fontSize
,
14
);
expect
(
material
.
textStyle
!
.
fontSize
,
14
);
expect
(
material
.
textStyle
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
textStyle
!
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
type
,
MaterialType
.
button
);
expect
(
material
.
type
,
MaterialType
.
button
);
// Disabled TextButton
// Disabled TextButton
...
@@ -96,10 +94,10 @@ void main() {
...
@@ -96,10 +94,10 @@ void main() {
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
4.0
)));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
4.0
)));
expect
(
material
.
textStyle
.
color
,
colorScheme
.
onSurface
.
withOpacity
(
0.38
));
expect
(
material
.
textStyle
!
.
color
,
colorScheme
.
onSurface
.
withOpacity
(
0.38
));
expect
(
material
.
textStyle
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
.
fontSize
,
14
);
expect
(
material
.
textStyle
!
.
fontSize
,
14
);
expect
(
material
.
textStyle
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
textStyle
!
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
type
,
MaterialType
.
button
);
expect
(
material
.
type
,
MaterialType
.
button
);
});
});
...
@@ -161,9 +159,9 @@ void main() {
...
@@ -161,9 +159,9 @@ void main() {
MaterialState
.
focused
,
MaterialState
.
focused
,
};
};
if
(
states
.
any
(
interactiveStates
.
contains
))
{
if
(
states
.
any
(
interactiveStates
.
contains
))
{
return
Colors
.
blue
[
900
];
return
Colors
.
blue
[
900
]
!
;
}
}
return
Colors
.
blue
[
800
];
return
Colors
.
blue
[
800
]
!
;
}
}
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -258,8 +256,8 @@ void main() {
...
@@ -258,8 +256,8 @@ void main() {
),
),
);
);
Color
textColor
()
{
Color
?
textColor
()
{
return
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'TextButton'
)).
text
.
style
.
color
;
return
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'TextButton'
)).
text
.
style
?
.
color
;
}
}
// Default, not disabled.
// Default, not disabled.
...
@@ -329,7 +327,7 @@ void main() {
...
@@ -329,7 +327,7 @@ void main() {
),
),
);
);
Color
iconColor
()
=>
_iconStyle
(
tester
,
Icons
.
add
)
.
color
;
Color
?
iconColor
()
=>
_iconStyle
(
tester
,
Icons
.
add
)?
.
color
;
// Default, not disabled.
// Default, not disabled.
expect
(
iconColor
(),
equals
(
defaultColor
));
expect
(
iconColor
(),
equals
(
defaultColor
));
...
@@ -378,7 +376,7 @@ void main() {
...
@@ -378,7 +376,7 @@ void main() {
testWidgets
(
'Does TextButton work with hover'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Does TextButton work with hover'
,
(
WidgetTester
tester
)
async
{
const
Color
hoverColor
=
Color
(
0xff001122
);
const
Color
hoverColor
=
Color
(
0xff001122
);
Color
getOverlayColor
(
Set
<
MaterialState
>
states
)
{
Color
?
getOverlayColor
(
Set
<
MaterialState
>
states
)
{
return
states
.
contains
(
MaterialState
.
hovered
)
?
hoverColor
:
null
;
return
states
.
contains
(
MaterialState
.
hovered
)
?
hoverColor
:
null
;
}
}
...
@@ -388,7 +386,7 @@ void main() {
...
@@ -388,7 +386,7 @@ void main() {
child:
Material
(
child:
Material
(
child:
TextButton
(
child:
TextButton
(
style:
ButtonStyle
(
style:
ButtonStyle
(
overlayColor:
MaterialStateProperty
.
resolveWith
<
Color
>(
getOverlayColor
),
overlayColor:
MaterialStateProperty
.
resolveWith
<
Color
?
>(
getOverlayColor
),
),
),
child:
Container
(),
child:
Container
(),
onPressed:
()
{
/* to make sure the button is enabled */
},
onPressed:
()
{
/* to make sure the button is enabled */
},
...
@@ -411,7 +409,7 @@ void main() {
...
@@ -411,7 +409,7 @@ void main() {
testWidgets
(
'Does TextButton work with focus'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Does TextButton work with focus'
,
(
WidgetTester
tester
)
async
{
const
Color
focusColor
=
Color
(
0xff001122
);
const
Color
focusColor
=
Color
(
0xff001122
);
Color
getOverlayColor
(
Set
<
MaterialState
>
states
)
{
Color
?
getOverlayColor
(
Set
<
MaterialState
>
states
)
{
return
states
.
contains
(
MaterialState
.
focused
)
?
focusColor
:
null
;
return
states
.
contains
(
MaterialState
.
focused
)
?
focusColor
:
null
;
}
}
...
@@ -421,7 +419,7 @@ void main() {
...
@@ -421,7 +419,7 @@ void main() {
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
child:
TextButton
(
child:
TextButton
(
style:
ButtonStyle
(
style:
ButtonStyle
(
overlayColor:
MaterialStateProperty
.
resolveWith
<
Color
>(
getOverlayColor
),
overlayColor:
MaterialStateProperty
.
resolveWith
<
Color
?
>(
getOverlayColor
),
),
),
focusNode:
focusNode
,
focusNode:
focusNode
,
onPressed:
()
{
},
onPressed:
()
{
},
...
@@ -430,7 +428,7 @@ void main() {
...
@@ -430,7 +428,7 @@ void main() {
),
),
);
);
WidgetsBinding
.
instance
.
focusManager
.
highlightStrategy
=
FocusHighlightStrategy
.
alwaysTraditional
;
WidgetsBinding
.
instance
!
.
focusManager
.
highlightStrategy
=
FocusHighlightStrategy
.
alwaysTraditional
;
focusNode
.
requestFocus
();
focusNode
.
requestFocus
();
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -590,7 +588,7 @@ void main() {
...
@@ -590,7 +588,7 @@ void main() {
bool
wasPressed
;
bool
wasPressed
;
Finder
textButton
;
Finder
textButton
;
Widget
buildFrame
({
VoidCallback
onPressed
,
VoidCallback
onLongPress
})
{
Widget
buildFrame
({
VoidCallback
?
onPressed
,
VoidCallback
?
onLongPress
})
{
return
Directionality
(
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
child:
TextButton
(
child:
TextButton
(
...
@@ -731,7 +729,7 @@ void main() {
...
@@ -731,7 +729,7 @@ void main() {
const
List
<
double
>
textScaleFactorOptions
=
<
double
>[
0.5
,
1.0
,
1.25
,
1.5
,
2.0
,
2.5
,
3.0
,
4.0
];
const
List
<
double
>
textScaleFactorOptions
=
<
double
>[
0.5
,
1.0
,
1.25
,
1.5
,
2.0
,
2.5
,
3.0
,
4.0
];
const
List
<
TextDirection
>
textDirectionOptions
=
<
TextDirection
>[
TextDirection
.
ltr
,
TextDirection
.
rtl
];
const
List
<
TextDirection
>
textDirectionOptions
=
<
TextDirection
>[
TextDirection
.
ltr
,
TextDirection
.
rtl
];
const
List
<
Widget
>
iconOptions
=
<
Widget
>[
null
,
Icon
(
Icons
.
add
,
size:
18
,
key:
iconKey
)];
const
List
<
Widget
?>
iconOptions
=
<
Widget
?
>[
null
,
Icon
(
Icons
.
add
,
size:
18
,
key:
iconKey
)];
// Expected values for each textScaleFactor.
// Expected values for each textScaleFactor.
final
Map
<
double
,
double
>
paddingVertical
=
<
double
,
double
>{
final
Map
<
double
,
double
>
paddingVertical
=
<
double
,
double
>{
...
@@ -781,7 +779,7 @@ void main() {
...
@@ -781,7 +779,7 @@ void main() {
}
}
/// Computes the padding between two [Rect]s, one inside the other.
/// Computes the padding between two [Rect]s, one inside the other.
EdgeInsets
paddingBetween
({
Rect
parent
,
Rect
child
})
{
EdgeInsets
paddingBetween
({
required
Rect
parent
,
required
Rect
child
})
{
assert
(
parent
.
intersect
(
child
)
==
child
);
assert
(
parent
.
intersect
(
child
)
==
child
);
return
EdgeInsets
.
fromLTRB
(
return
EdgeInsets
.
fromLTRB
(
child
.
left
-
parent
.
left
,
child
.
left
-
parent
.
left
,
...
@@ -793,7 +791,7 @@ void main() {
...
@@ -793,7 +791,7 @@ void main() {
for
(
final
double
textScaleFactor
in
textScaleFactorOptions
)
{
for
(
final
double
textScaleFactor
in
textScaleFactorOptions
)
{
for
(
final
TextDirection
textDirection
in
textDirectionOptions
)
{
for
(
final
TextDirection
textDirection
in
textDirectionOptions
)
{
for
(
final
Widget
icon
in
iconOptions
)
{
for
(
final
Widget
?
icon
in
iconOptions
)
{
final
String
testName
=
'TextButton'
final
String
testName
=
'TextButton'
', text scale
$textScaleFactor
'
', text scale
$textScaleFactor
'
'
${icon != null ? ", with icon" : ""}
'
'
${icon != null ? ", with icon" : ""}
'
...
@@ -806,7 +804,7 @@ void main() {
...
@@ -806,7 +804,7 @@ void main() {
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
return
MediaQuery
(
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
textScaleFactor:
textScaleFactor
,
textScaleFactor:
textScaleFactor
,
),
),
child:
Directionality
(
child:
Directionality
(
...
@@ -845,12 +843,12 @@ void main() {
...
@@ -845,12 +843,12 @@ void main() {
// Compute expected padding, and check.
// Compute expected padding, and check.
final
double
expectedPaddingTop
=
paddingVertical
[
textScaleFactor
];
final
double
expectedPaddingTop
=
paddingVertical
[
textScaleFactor
]
!
;
final
double
expectedPaddingBottom
=
paddingVertical
[
textScaleFactor
];
final
double
expectedPaddingBottom
=
paddingVertical
[
textScaleFactor
]
!
;
final
double
expectedPaddingStart
=
icon
!=
null
final
double
expectedPaddingStart
=
icon
!=
null
?
textPaddingWithIconHorizontal
[
textScaleFactor
]
?
textPaddingWithIconHorizontal
[
textScaleFactor
]
!
:
textPaddingWithoutIconHorizontal
[
textScaleFactor
];
:
textPaddingWithoutIconHorizontal
[
textScaleFactor
]
!
;
final
double
expectedPaddingEnd
=
expectedPaddingStart
;
final
double
expectedPaddingEnd
=
expectedPaddingStart
;
final
EdgeInsets
expectedPadding
=
EdgeInsetsDirectional
.
fromSTEB
(
final
EdgeInsets
expectedPadding
=
EdgeInsetsDirectional
.
fromSTEB
(
...
@@ -867,9 +865,9 @@ void main() {
...
@@ -867,9 +865,9 @@ void main() {
final
RenderBox
labelRenderBox
=
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
labelKey
));
final
RenderBox
labelRenderBox
=
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
labelKey
));
final
Rect
labelBounds
=
globalBounds
(
labelRenderBox
);
final
Rect
labelBounds
=
globalBounds
(
labelRenderBox
);
final
RenderBox
iconRenderBox
=
icon
==
null
?
null
:
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
iconKey
));
final
RenderBox
?
iconRenderBox
=
icon
==
null
?
null
:
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
iconKey
));
final
Rect
iconBounds
=
icon
==
null
?
null
:
globalBounds
(
iconRenderBox
);
final
Rect
?
iconBounds
=
icon
==
null
?
null
:
globalBounds
(
iconRenderBox
!
);
final
Rect
childBounds
=
icon
==
null
?
labelBounds
:
labelBounds
.
expandToInclude
(
iconBounds
);
final
Rect
childBounds
=
icon
==
null
?
labelBounds
:
labelBounds
.
expandToInclude
(
iconBounds
!
);
// We measure the `InkResponse` descendant of the button
// We measure the `InkResponse` descendant of the button
// element, because the button has a larger `RenderBox`
// element, because the button has a larger `RenderBox`
...
@@ -918,8 +916,8 @@ void main() {
...
@@ -918,8 +916,8 @@ void main() {
// Check the gap between the icon and the label
// Check the gap between the icon and the label
if
(
icon
!=
null
)
{
if
(
icon
!=
null
)
{
final
double
gapWidth
=
textDirection
==
TextDirection
.
ltr
final
double
gapWidth
=
textDirection
==
TextDirection
.
ltr
?
labelBounds
.
left
-
iconBounds
.
right
?
labelBounds
.
left
-
iconBounds
!
.
right
:
iconBounds
.
left
-
labelBounds
.
right
;
:
iconBounds
!
.
left
-
labelBounds
.
right
;
expect
(
gapWidth
,
paddingWithIconGap
[
textScaleFactor
]);
expect
(
gapWidth
,
paddingWithIconGap
[
textScaleFactor
]);
}
}
...
@@ -948,7 +946,7 @@ void main() {
...
@@ -948,7 +946,7 @@ void main() {
home:
Builder
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
return
MediaQuery
(
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
textScaleFactor:
2
,
textScaleFactor:
2
,
),
),
child:
Scaffold
(
child:
Scaffold
(
...
@@ -978,7 +976,7 @@ void main() {
...
@@ -978,7 +976,7 @@ void main() {
}
}
TextStyle
_iconStyle
(
WidgetTester
tester
,
IconData
icon
)
{
TextStyle
?
_iconStyle
(
WidgetTester
tester
,
IconData
icon
)
{
final
RichText
iconRichText
=
tester
.
widget
<
RichText
>(
final
RichText
iconRichText
=
tester
.
widget
<
RichText
>(
find
.
descendant
(
of:
find
.
byIcon
(
icon
),
matching:
find
.
byType
(
RichText
)),
find
.
descendant
(
of:
find
.
byIcon
(
icon
),
matching:
find
.
byType
(
RichText
)),
);
);
...
...
packages/flutter/test/material/text_button_theme_test.dart
View file @
4513e96a
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -37,10 +35,10 @@ void main() {
...
@@ -37,10 +35,10 @@ void main() {
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
elevation
,
0.0
);
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shadowColor
,
const
Color
(
0xff000000
));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
4.0
)));
expect
(
material
.
shape
,
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
4.0
)));
expect
(
material
.
textStyle
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
.
fontSize
,
14
);
expect
(
material
.
textStyle
!
.
fontSize
,
14
);
expect
(
material
.
textStyle
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
textStyle
!
.
fontWeight
,
FontWeight
.
w500
);
});
});
group
(
'[Theme, TextTheme, TextButton style overrides]'
,
()
{
group
(
'[Theme, TextTheme, TextButton style overrides]'
,
()
{
...
@@ -78,7 +76,7 @@ void main() {
...
@@ -78,7 +76,7 @@ void main() {
enableFeedback:
enableFeedback
,
enableFeedback:
enableFeedback
,
);
);
Widget
buildFrame
({
ButtonStyle
buttonStyle
,
ButtonStyle
themeStyle
,
ButtonStyle
overallStyle
})
{
Widget
buildFrame
({
ButtonStyle
?
buttonStyle
,
ButtonStyle
?
themeStyle
,
ButtonStyle
?
overallStyle
})
{
final
Widget
child
=
Builder
(
final
Widget
child
=
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
return
TextButton
(
return
TextButton
(
...
@@ -123,15 +121,15 @@ void main() {
...
@@ -123,15 +121,15 @@ void main() {
void
checkButton
(
WidgetTester
tester
)
{
void
checkButton
(
WidgetTester
tester
)
{
final
Material
material
=
tester
.
widget
<
Material
>(
findMaterial
);
final
Material
material
=
tester
.
widget
<
Material
>(
findMaterial
);
final
InkWell
inkWell
=
tester
.
widget
<
InkWell
>(
findInkWell
);
final
InkWell
inkWell
=
tester
.
widget
<
InkWell
>(
findInkWell
);
expect
(
material
.
textStyle
.
color
,
primaryColor
);
expect
(
material
.
textStyle
!
.
color
,
primaryColor
);
expect
(
material
.
textStyle
.
fontSize
,
12
);
expect
(
material
.
textStyle
!
.
fontSize
,
12
);
expect
(
material
.
color
,
backgroundColor
);
expect
(
material
.
color
,
backgroundColor
);
expect
(
material
.
shadowColor
,
shadowColor
);
expect
(
material
.
shadowColor
,
shadowColor
);
expect
(
material
.
elevation
,
elevation
);
expect
(
material
.
elevation
,
elevation
);
expect
(
MaterialStateProperty
.
resolveAs
<
MouseCursor
>(
inkWell
.
mouseCursor
,
enabled
),
enabledMouseCursor
);
expect
(
MaterialStateProperty
.
resolveAs
<
MouseCursor
?
>(
inkWell
.
mouseCursor
,
enabled
),
enabledMouseCursor
);
expect
(
MaterialStateProperty
.
resolveAs
<
MouseCursor
>(
inkWell
.
mouseCursor
,
disabled
),
disabledMouseCursor
);
expect
(
MaterialStateProperty
.
resolveAs
<
MouseCursor
?
>(
inkWell
.
mouseCursor
,
disabled
),
disabledMouseCursor
);
expect
(
inkWell
.
overlayColor
.
resolve
(
hovered
),
primaryColor
.
withOpacity
(
0.04
));
expect
(
inkWell
.
overlayColor
!
.
resolve
(
hovered
),
primaryColor
.
withOpacity
(
0.04
));
expect
(
inkWell
.
overlayColor
.
resolve
(
focused
),
primaryColor
.
withOpacity
(
0.12
));
expect
(
inkWell
.
overlayColor
!
.
resolve
(
focused
),
primaryColor
.
withOpacity
(
0.12
));
expect
(
inkWell
.
enableFeedback
,
enableFeedback
);
expect
(
inkWell
.
enableFeedback
,
enableFeedback
);
expect
(
material
.
borderRadius
,
null
);
expect
(
material
.
borderRadius
,
null
);
expect
(
material
.
shape
,
shape
);
expect
(
material
.
shape
,
shape
);
...
@@ -183,7 +181,7 @@ void main() {
...
@@ -183,7 +181,7 @@ void main() {
const
Color
shadowColor
=
Color
(
0xff000001
);
const
Color
shadowColor
=
Color
(
0xff000001
);
const
Color
overiddenColor
=
Color
(
0xff000002
);
const
Color
overiddenColor
=
Color
(
0xff000002
);
Widget
buildFrame
({
Color
overallShadowColor
,
Color
themeShadowColor
,
Color
shadowColor
})
{
Widget
buildFrame
({
Color
?
overallShadowColor
,
Color
?
themeShadowColor
,
Color
?
shadowColor
})
{
return
MaterialApp
(
return
MaterialApp
(
theme:
ThemeData
.
from
(
colorScheme:
colorScheme
).
copyWith
(
theme:
ThemeData
.
from
(
colorScheme:
colorScheme
).
copyWith
(
shadowColor:
overallShadowColor
,
shadowColor:
overallShadowColor
,
...
...
packages/flutter/test/material/text_field_focus_test.dart
View file @
4513e96a
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
@@ -40,7 +38,7 @@ void main() {
...
@@ -40,7 +38,7 @@ void main() {
expect
(
tester
.
testTextInput
.
isVisible
,
isFalse
);
expect
(
tester
.
testTextInput
.
isVisible
,
isFalse
);
Navigator
.
of
(
tester
.
element
(
find
.
text
(
'Dialog'
))).
pop
();
Navigator
.
of
(
tester
.
element
(
find
.
text
(
'Dialog'
)))
!
.
pop
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
focusNode
.
hasPrimaryFocus
,
isTrue
);
expect
(
focusNode
.
hasPrimaryFocus
,
isTrue
);
...
@@ -177,7 +175,7 @@ void main() {
...
@@ -177,7 +175,7 @@ void main() {
testWidgets
(
'Focus keep-alive works with GlobalKey reparenting'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Focus keep-alive works with GlobalKey reparenting'
,
(
WidgetTester
tester
)
async
{
final
FocusNode
focusNode
=
FocusNode
();
final
FocusNode
focusNode
=
FocusNode
();
Widget
makeTest
(
String
prefix
)
{
Widget
makeTest
(
String
?
prefix
)
{
return
MaterialApp
(
return
MaterialApp
(
home:
Material
(
home:
Material
(
child:
ListView
(
child:
ListView
(
...
...
packages/flutter/test/material/text_field_helper_text_test.dart
View file @
4513e96a
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter/test/material/text_field_restoration_test.dart
View file @
4513e96a
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -74,7 +72,7 @@ Future<void> restoreAndVerify(WidgetTester tester) async {
...
@@ -74,7 +72,7 @@ Future<void> restoreAndVerify(WidgetTester tester) async {
}
}
class
TestWidget
extends
StatefulWidget
{
class
TestWidget
extends
StatefulWidget
{
const
TestWidget
({
Key
key
,
this
.
useExternal
=
false
})
:
super
(
key:
key
);
const
TestWidget
({
Key
?
key
,
this
.
useExternal
=
false
})
:
super
(
key:
key
);
final
bool
useExternal
;
final
bool
useExternal
;
...
@@ -89,7 +87,7 @@ class TestWidgetState extends State<TestWidget> with RestorationMixin {
...
@@ -89,7 +87,7 @@ class TestWidgetState extends State<TestWidget> with RestorationMixin {
String
get
restorationId
=>
'widget'
;
String
get
restorationId
=>
'widget'
;
@override
@override
void
restoreState
(
RestorationBucket
oldBucket
,
bool
initialRestore
)
{
void
restoreState
(
RestorationBucket
?
oldBucket
,
bool
initialRestore
)
{
registerForRestoration
(
controller
,
'controller'
);
registerForRestoration
(
controller
,
'controller'
);
}
}
...
...
packages/flutter/test/material/text_field_splash_test.dart
View file @
4513e96a
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/gestures.dart'
show
kPressTimeout
;
import
'package:flutter/gestures.dart'
show
kPressTimeout
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -14,17 +12,17 @@ bool cancelCalled = false;
...
@@ -14,17 +12,17 @@ bool cancelCalled = false;
class
TestInkSplash
extends
InkSplash
{
class
TestInkSplash
extends
InkSplash
{
TestInkSplash
({
TestInkSplash
({
MaterialInkController
controller
,
required
MaterialInkController
controller
,
RenderBox
referenceBox
,
required
RenderBox
referenceBox
,
Offset
position
,
Offset
?
position
,
Color
color
,
required
Color
color
,
bool
containedInkWell
=
false
,
bool
containedInkWell
=
false
,
RectCallback
rectCallback
,
RectCallback
?
rectCallback
,
BorderRadius
borderRadius
,
BorderRadius
?
borderRadius
,
ShapeBorder
customBorder
,
ShapeBorder
?
customBorder
,
double
radius
,
double
?
radius
,
VoidCallback
onRemoved
,
VoidCallback
?
onRemoved
,
TextDirection
textDirection
,
required
TextDirection
textDirection
,
})
:
super
(
})
:
super
(
controller:
controller
,
controller:
controller
,
referenceBox:
referenceBox
,
referenceBox:
referenceBox
,
...
@@ -57,17 +55,17 @@ class TestInkSplashFactory extends InteractiveInkFeatureFactory {
...
@@ -57,17 +55,17 @@ class TestInkSplashFactory extends InteractiveInkFeatureFactory {
@override
@override
InteractiveInkFeature
create
({
InteractiveInkFeature
create
({
MaterialInkController
controller
,
required
MaterialInkController
controller
,
RenderBox
referenceBox
,
required
RenderBox
referenceBox
,
Offset
position
,
Offset
?
position
,
Color
color
,
required
Color
color
,
bool
containedInkWell
=
false
,
bool
containedInkWell
=
false
,
RectCallback
rectCallback
,
RectCallback
?
rectCallback
,
BorderRadius
borderRadius
,
BorderRadius
?
borderRadius
,
ShapeBorder
customBorder
,
ShapeBorder
?
customBorder
,
double
radius
,
double
?
radius
,
VoidCallback
onRemoved
,
VoidCallback
?
onRemoved
,
TextDirection
textDirection
,
required
TextDirection
textDirection
,
})
{
})
{
return
TestInkSplash
(
return
TestInkSplash
(
controller:
controller
,
controller:
controller
,
...
...
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