Update button tests for Material 3 by default (#128628)
This commit is contained in:
parent
353b8bc87d
commit
c5a81d1b35
@ -738,18 +738,21 @@ void main() {
|
|||||||
testWidgets('Does ElevatedButton contribute semantics', (WidgetTester tester) async {
|
testWidgets('Does ElevatedButton contribute semantics', (WidgetTester tester) async {
|
||||||
final SemanticsTester semantics = SemanticsTester(tester);
|
final SemanticsTester semantics = SemanticsTester(tester);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
textDirection: TextDirection.ltr,
|
data: ThemeData(useMaterial3: false),
|
||||||
child: Center(
|
child: Directionality(
|
||||||
child: ElevatedButton(
|
textDirection: TextDirection.ltr,
|
||||||
style: const ButtonStyle(
|
child: Center(
|
||||||
// Specifying minimumSize to mimic the original minimumSize for
|
child: ElevatedButton(
|
||||||
// RaisedButton so that the semantics tree's rect and transform
|
style: const ButtonStyle(
|
||||||
// match the original version of this test.
|
// Specifying minimumSize to mimic the original minimumSize for
|
||||||
minimumSize: MaterialStatePropertyAll<Size>(Size(88, 36)),
|
// RaisedButton so that the semantics tree's rect and transform
|
||||||
|
// match the original version of this test.
|
||||||
|
minimumSize: MaterialStatePropertyAll<Size>(Size(88, 36)),
|
||||||
|
),
|
||||||
|
onPressed: () { },
|
||||||
|
child: const Text('ABC'),
|
||||||
),
|
),
|
||||||
onPressed: () { },
|
|
||||||
child: const Text('ABC'),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -790,7 +793,7 @@ void main() {
|
|||||||
|
|
||||||
Widget buildFrame(MaterialTapTargetSize tapTargetSize, Key key) {
|
Widget buildFrame(MaterialTapTargetSize tapTargetSize, Key key) {
|
||||||
return Theme(
|
return Theme(
|
||||||
data: ThemeData(materialTapTargetSize: tapTargetSize),
|
data: ThemeData(useMaterial3: false, materialTapTargetSize: tapTargetSize),
|
||||||
child: Directionality(
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -838,9 +841,7 @@ void main() {
|
|||||||
Future<void> buildTest(VisualDensity visualDensity, {bool useText = false}) async {
|
Future<void> buildTest(VisualDensity visualDensity, {bool useText = false}) async {
|
||||||
return tester.pumpWidget(
|
return tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
// Test was setup using fonts from Material 2, so make sure we always
|
theme: ThemeData(useMaterial3: false),
|
||||||
// test against englishLike2014.
|
|
||||||
theme: ThemeData(textTheme: Typography.englishLike2014),
|
|
||||||
home: Directionality(
|
home: Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -1033,10 +1034,8 @@ void main() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
|
useMaterial3: false,
|
||||||
colorScheme: const ColorScheme.light(),
|
colorScheme: const ColorScheme.light(),
|
||||||
// Force Material 2 defaults for the typography and size
|
|
||||||
// default values as the test was designed against these settings.
|
|
||||||
textTheme: Typography.englishLike2014,
|
|
||||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||||
style: ElevatedButton.styleFrom(minimumSize: const Size(64, 36)),
|
style: ElevatedButton.styleFrom(minimumSize: const Size(64, 36)),
|
||||||
),
|
),
|
||||||
|
@ -14,7 +14,7 @@ import '../widgets/semantics_tester.dart';
|
|||||||
void main() {
|
void main() {
|
||||||
testWidgets('FilledButton, FilledButton.icon defaults', (WidgetTester tester) async {
|
testWidgets('FilledButton, FilledButton.icon defaults', (WidgetTester tester) async {
|
||||||
const ColorScheme colorScheme = ColorScheme.light();
|
const ColorScheme colorScheme = ColorScheme.light();
|
||||||
final ThemeData theme = ThemeData.from(colorScheme: colorScheme);
|
final ThemeData theme = ThemeData.from(useMaterial3: false, colorScheme: colorScheme);
|
||||||
|
|
||||||
// Enabled FilledButton
|
// Enabled FilledButton
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
@ -884,18 +884,21 @@ void main() {
|
|||||||
testWidgets('Does FilledButton contribute semantics', (WidgetTester tester) async {
|
testWidgets('Does FilledButton contribute semantics', (WidgetTester tester) async {
|
||||||
final SemanticsTester semantics = SemanticsTester(tester);
|
final SemanticsTester semantics = SemanticsTester(tester);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
textDirection: TextDirection.ltr,
|
data: ThemeData(useMaterial3: false),
|
||||||
child: Center(
|
child: Directionality(
|
||||||
child: FilledButton(
|
textDirection: TextDirection.ltr,
|
||||||
style: const ButtonStyle(
|
child: Center(
|
||||||
// Specifying minimumSize to mimic the original minimumSize for
|
child: FilledButton(
|
||||||
// RaisedButton so that the semantics tree's rect and transform
|
style: const ButtonStyle(
|
||||||
// match the original version of this test.
|
// Specifying minimumSize to mimic the original minimumSize for
|
||||||
minimumSize: MaterialStatePropertyAll<Size>(Size(88, 36)),
|
// RaisedButton so that the semantics tree's rect and transform
|
||||||
|
// match the original version of this test.
|
||||||
|
minimumSize: MaterialStatePropertyAll<Size>(Size(88, 36)),
|
||||||
|
),
|
||||||
|
onPressed: () { },
|
||||||
|
child: const Text('ABC'),
|
||||||
),
|
),
|
||||||
onPressed: () { },
|
|
||||||
child: const Text('ABC'),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -936,7 +939,7 @@ void main() {
|
|||||||
|
|
||||||
Widget buildFrame(MaterialTapTargetSize tapTargetSize, Key key) {
|
Widget buildFrame(MaterialTapTargetSize tapTargetSize, Key key) {
|
||||||
return Theme(
|
return Theme(
|
||||||
data: ThemeData(materialTapTargetSize: tapTargetSize),
|
data: ThemeData(useMaterial3: false, materialTapTargetSize: tapTargetSize),
|
||||||
child: Directionality(
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -984,9 +987,7 @@ void main() {
|
|||||||
Future<void> buildTest(VisualDensity visualDensity, {bool useText = false}) async {
|
Future<void> buildTest(VisualDensity visualDensity, {bool useText = false}) async {
|
||||||
return tester.pumpWidget(
|
return tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
// Test was setup using fonts from Material 2, so make sure we always
|
theme: ThemeData(useMaterial3: false),
|
||||||
// test against englishLike2014.
|
|
||||||
theme: ThemeData(textTheme: Typography.englishLike2014),
|
|
||||||
home: Directionality(
|
home: Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -1179,10 +1180,7 @@ void main() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
colorScheme: const ColorScheme.light(),
|
useMaterial3: false,
|
||||||
// Force Material 2 defaults for the typography and size
|
|
||||||
// default values as the test was designed against these settings.
|
|
||||||
textTheme: Typography.englishLike2014,
|
|
||||||
filledButtonTheme: FilledButtonThemeData(
|
filledButtonTheme: FilledButtonThemeData(
|
||||||
style: FilledButton.styleFrom(minimumSize: const Size(64, 36)),
|
style: FilledButton.styleFrom(minimumSize: const Size(64, 36)),
|
||||||
),
|
),
|
||||||
@ -1410,7 +1408,7 @@ void main() {
|
|||||||
const Color borderColor = Color(0xff4caf50);
|
const Color borderColor = Color(0xff4caf50);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(colorScheme: const ColorScheme.light(), textTheme: Typography.englishLike2014),
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: Center(
|
home: Center(
|
||||||
child: FilledButton(
|
child: FilledButton(
|
||||||
style: FilledButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
@ -1599,7 +1597,7 @@ void main() {
|
|||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(textTheme: Typography.englishLike2014),
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -693,6 +693,7 @@ void main() {
|
|||||||
bool resizeToAvoidBottomInset = true,
|
bool resizeToAvoidBottomInset = true,
|
||||||
}) {
|
}) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: MediaQuery(
|
home: MediaQuery(
|
||||||
data: data,
|
data: data,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
@ -1640,15 +1641,14 @@ const double _dockedOffsetY = 544.0;
|
|||||||
const double _containedOffsetY = 544.0 + 56.0 / 2;
|
const double _containedOffsetY = 544.0 + 56.0 / 2;
|
||||||
const double _miniFloatOffsetY = _floatOffsetY + kMiniButtonOffsetAdjustment;
|
const double _miniFloatOffsetY = _floatOffsetY + kMiniButtonOffsetAdjustment;
|
||||||
|
|
||||||
Widget _singleFabScaffold(
|
Widget _singleFabScaffold(FloatingActionButtonLocation location, {
|
||||||
FloatingActionButtonLocation location,
|
bool useMaterial3 = false,
|
||||||
{
|
FloatingActionButtonAnimator? animator,
|
||||||
FloatingActionButtonAnimator? animator,
|
bool mini = false,
|
||||||
bool mini = false,
|
TextDirection textDirection = TextDirection.ltr,
|
||||||
TextDirection textDirection = TextDirection.ltr,
|
}) {
|
||||||
}
|
|
||||||
) {
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
|
theme: ThemeData(useMaterial3: useMaterial3),
|
||||||
home: Directionality(
|
home: Directionality(
|
||||||
textDirection: textDirection,
|
textDirection: textDirection,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
@ -19,9 +19,8 @@ import '../widgets/semantics_tester.dart';
|
|||||||
import 'feedback_tester.dart';
|
import 'feedback_tester.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
final ThemeData material3Theme = ThemeData(useMaterial3: true);
|
||||||
final ThemeData material3Theme = ThemeData.light().copyWith(useMaterial3: true);
|
final ThemeData material2Theme = ThemeData(useMaterial3: false);
|
||||||
final ThemeData material2Theme = ThemeData.light().copyWith(useMaterial3: false);
|
|
||||||
|
|
||||||
testWidgets('Floating Action Button control test', (WidgetTester tester) async {
|
testWidgets('Floating Action Button control test', (WidgetTester tester) async {
|
||||||
bool didPressButton = false;
|
bool didPressButton = false;
|
||||||
@ -950,6 +949,7 @@ void main() {
|
|||||||
const Color splashColor = Color(0xcafefeed);
|
const Color splashColor = Color(0xcafefeed);
|
||||||
|
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(MaterialApp(
|
||||||
|
theme: material2Theme,
|
||||||
home: FloatingActionButton(
|
home: FloatingActionButton(
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
splashColor: splashColor,
|
splashColor: splashColor,
|
||||||
@ -1051,6 +1051,7 @@ void main() {
|
|||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
|
theme: material2Theme,
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
floatingActionButton: FloatingActionButton.extended(
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
label: const Text('', key: labelKey),
|
label: const Text('', key: labelKey),
|
||||||
|
@ -23,11 +23,14 @@ void main() {
|
|||||||
|
|
||||||
// Enabled MaterialButton
|
// Enabled MaterialButton
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
textDirection: TextDirection.ltr,
|
data: ThemeData(useMaterial3: false),
|
||||||
child: MaterialButton(
|
child: Directionality(
|
||||||
onPressed: () { },
|
textDirection: TextDirection.ltr,
|
||||||
child: const Text('button'),
|
child: MaterialButton(
|
||||||
|
onPressed: () { },
|
||||||
|
child: const Text('button'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -68,11 +71,14 @@ void main() {
|
|||||||
|
|
||||||
// Disabled MaterialButton
|
// Disabled MaterialButton
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
const Directionality(
|
Theme(
|
||||||
textDirection: TextDirection.ltr,
|
data: ThemeData(useMaterial3: false),
|
||||||
child: MaterialButton(
|
child: const Directionality(
|
||||||
onPressed: null,
|
textDirection: TextDirection.ltr,
|
||||||
child: Text('button'),
|
child: MaterialButton(
|
||||||
|
onPressed: null,
|
||||||
|
child: Text('button'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -442,6 +448,7 @@ void main() {
|
|||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Theme(
|
child: Theme(
|
||||||
data: ThemeData(
|
data: ThemeData(
|
||||||
|
useMaterial3: false,
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
),
|
),
|
||||||
child: buttonWidget,
|
child: buttonWidget,
|
||||||
@ -488,6 +495,7 @@ void main() {
|
|||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Theme(
|
child: Theme(
|
||||||
data: ThemeData(
|
data: ThemeData(
|
||||||
|
useMaterial3: false,
|
||||||
highlightColor: themeHighlightColor1,
|
highlightColor: themeHighlightColor1,
|
||||||
splashColor: themeSplashColor1,
|
splashColor: themeSplashColor1,
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
@ -516,6 +524,7 @@ void main() {
|
|||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Theme(
|
child: Theme(
|
||||||
data: ThemeData(
|
data: ThemeData(
|
||||||
|
useMaterial3: false,
|
||||||
highlightColor: themeHighlightColor2,
|
highlightColor: themeHighlightColor2,
|
||||||
splashColor: themeSplashColor2,
|
splashColor: themeSplashColor2,
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
@ -574,15 +583,20 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// enabled button
|
// enabled button
|
||||||
await tester.pumpWidget(Directionality(
|
await tester.pumpWidget(
|
||||||
textDirection: TextDirection.ltr,
|
Theme(
|
||||||
child: Center(
|
data: ThemeData(useMaterial3: false),
|
||||||
child: MaterialButton(
|
child: Directionality(
|
||||||
child: const Text('Button'),
|
textDirection: TextDirection.ltr,
|
||||||
onPressed: () { /* to make sure the button is enabled */ },
|
child: Center(
|
||||||
|
child: MaterialButton(
|
||||||
|
child: const Text('Button'),
|
||||||
|
onPressed: () { /* to make sure the button is enabled */ },
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
);
|
||||||
|
|
||||||
expect(semantics, hasSemantics(
|
expect(semantics, hasSemantics(
|
||||||
TestSemantics.root(
|
TestSemantics.root(
|
||||||
@ -607,15 +621,20 @@ void main() {
|
|||||||
));
|
));
|
||||||
|
|
||||||
// disabled button
|
// disabled button
|
||||||
await tester.pumpWidget(const Directionality(
|
await tester.pumpWidget(
|
||||||
textDirection: TextDirection.ltr,
|
Theme(
|
||||||
child: Center(
|
data: ThemeData(useMaterial3: false),
|
||||||
child: MaterialButton(
|
child: const Directionality(
|
||||||
onPressed: null, // button is disabled
|
textDirection: TextDirection.ltr,
|
||||||
child: Text('Button'),
|
child: Center(
|
||||||
|
child: MaterialButton(
|
||||||
|
onPressed: null, // button is disabled
|
||||||
|
child: Text('Button'),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
);
|
||||||
|
|
||||||
expect(semantics, hasSemantics(
|
expect(semantics, hasSemantics(
|
||||||
TestSemantics.root(
|
TestSemantics.root(
|
||||||
@ -773,6 +792,7 @@ void main() {
|
|||||||
Future<void> buildTest(VisualDensity visualDensity, {bool useText = false}) async {
|
Future<void> buildTest(VisualDensity visualDensity, {bool useText = false}) async {
|
||||||
return tester.pumpWidget(
|
return tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: Directionality(
|
home: Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: Center(
|
child: Center(
|
||||||
|
@ -42,7 +42,7 @@ void main() {
|
|||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
expect(material.color, Colors.transparent);
|
expect(material.color, Colors.transparent);
|
||||||
expect(material.elevation, 0.0);
|
expect(material.elevation, 0.0);
|
||||||
expect(material.shadowColor, material3 ? null : const Color(0xff000000));
|
expect(material.shadowColor, material3 ? Colors.transparent : const Color(0xff000000));
|
||||||
|
|
||||||
expect(material.shape, material3
|
expect(material.shape, material3
|
||||||
? StadiumBorder(side: BorderSide(color: colorScheme.outline))
|
? StadiumBorder(side: BorderSide(color: colorScheme.outline))
|
||||||
@ -82,7 +82,7 @@ void main() {
|
|||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
expect(material.color, Colors.transparent);
|
expect(material.color, Colors.transparent);
|
||||||
expect(material.elevation, 0.0);
|
expect(material.elevation, 0.0);
|
||||||
expect(material.shadowColor, material3 ? null : const Color(0xff000000));
|
expect(material.shadowColor, material3 ? Colors.transparent : const Color(0xff000000));
|
||||||
|
|
||||||
expect(material.shape, material3
|
expect(material.shape, material3
|
||||||
? StadiumBorder(side: BorderSide(color: colorScheme.outline))
|
? StadiumBorder(side: BorderSide(color: colorScheme.outline))
|
||||||
@ -125,7 +125,7 @@ void main() {
|
|||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
expect(material.color, Colors.transparent);
|
expect(material.color, Colors.transparent);
|
||||||
expect(material.elevation, 0.0);
|
expect(material.elevation, 0.0);
|
||||||
expect(material.shadowColor, material3 ? null : const Color(0xff000000));
|
expect(material.shadowColor, material3 ? Colors.transparent : const Color(0xff000000));
|
||||||
|
|
||||||
expect(material.shape, material3
|
expect(material.shape, material3
|
||||||
? StadiumBorder(side: BorderSide(color: colorScheme.outline))
|
? StadiumBorder(side: BorderSide(color: colorScheme.outline))
|
||||||
@ -160,7 +160,7 @@ void main() {
|
|||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
expect(material.color, Colors.transparent);
|
expect(material.color, Colors.transparent);
|
||||||
expect(material.elevation, 0.0);
|
expect(material.elevation, 0.0);
|
||||||
expect(material.shadowColor, material3 ? null : const Color(0xff000000));
|
expect(material.shadowColor, material3 ? Colors.transparent : const Color(0xff000000));
|
||||||
|
|
||||||
expect(material.shape, material3
|
expect(material.shape, material3
|
||||||
? StadiumBorder(side: BorderSide(color: colorScheme.onSurface.withOpacity(0.12)))
|
? StadiumBorder(side: BorderSide(color: colorScheme.onSurface.withOpacity(0.12)))
|
||||||
@ -966,18 +966,21 @@ void main() {
|
|||||||
testWidgets('OutlinedButton contributes semantics', (WidgetTester tester) async {
|
testWidgets('OutlinedButton contributes semantics', (WidgetTester tester) async {
|
||||||
final SemanticsTester semantics = SemanticsTester(tester);
|
final SemanticsTester semantics = SemanticsTester(tester);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
textDirection: TextDirection.ltr,
|
data: ThemeData(useMaterial3: false),
|
||||||
child: Center(
|
child: Directionality(
|
||||||
child: OutlinedButton(
|
textDirection: TextDirection.ltr,
|
||||||
style: const ButtonStyle(
|
child: Center(
|
||||||
// Specifying minimumSize to mimic the original minimumSize for
|
child: OutlinedButton(
|
||||||
// RaisedButton so that the corresponding button size matches
|
style: const ButtonStyle(
|
||||||
// the original version of this test.
|
// Specifying minimumSize to mimic the original minimumSize for
|
||||||
minimumSize: MaterialStatePropertyAll<Size>(Size(88, 36)),
|
// RaisedButton so that the corresponding button size matches
|
||||||
|
// the original version of this test.
|
||||||
|
minimumSize: MaterialStatePropertyAll<Size>(Size(88, 36)),
|
||||||
|
),
|
||||||
|
onPressed: () {},
|
||||||
|
child: const Text('ABC'),
|
||||||
),
|
),
|
||||||
onPressed: () {},
|
|
||||||
child: const Text('ABC'),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -1011,8 +1014,7 @@ void main() {
|
|||||||
testWidgets('OutlinedButton scales textScaleFactor', (WidgetTester tester) async {
|
testWidgets('OutlinedButton scales textScaleFactor', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Theme(
|
Theme(
|
||||||
// Force Material 2 typography.
|
data: ThemeData(useMaterial3: false),
|
||||||
data: ThemeData(textTheme: Typography.englishLike2014),
|
|
||||||
child: Directionality(
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
@ -1041,7 +1043,7 @@ void main() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Theme(
|
Theme(
|
||||||
// Force Material 2 typography.
|
// Force Material 2 typography.
|
||||||
data: ThemeData(textTheme: Typography.englishLike2014),
|
data: ThemeData(useMaterial3: false),
|
||||||
child: Directionality(
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
@ -1072,8 +1074,7 @@ void main() {
|
|||||||
// Set text scale large enough to expand text and button.
|
// Set text scale large enough to expand text and button.
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Theme(
|
Theme(
|
||||||
// Force Material 2 typography.
|
data: ThemeData(useMaterial3: false),
|
||||||
data: ThemeData(textTheme: Typography.englishLike2014),
|
|
||||||
child: Directionality(
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
@ -1131,7 +1132,7 @@ void main() {
|
|||||||
Future<void> buildTest(VisualDensity visualDensity, {bool useText = false}) async {
|
Future<void> buildTest(VisualDensity visualDensity, {bool useText = false}) async {
|
||||||
return tester.pumpWidget(
|
return tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(textTheme: Typography.englishLike2014),
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: Directionality(
|
home: Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -1261,10 +1262,7 @@ void main() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
colorScheme: const ColorScheme.light(),
|
useMaterial3: false,
|
||||||
// Force Material 2 defaults for the typography and size
|
|
||||||
// default values as the test was designed against these settings.
|
|
||||||
textTheme: Typography.englishLike2014,
|
|
||||||
outlinedButtonTheme: OutlinedButtonThemeData(
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
||||||
style: OutlinedButton.styleFrom(minimumSize: const Size(64, 36)),
|
style: OutlinedButton.styleFrom(minimumSize: const Size(64, 36)),
|
||||||
),
|
),
|
||||||
@ -1407,7 +1405,7 @@ void main() {
|
|||||||
testWidgets('Override OutlinedButton default padding', (WidgetTester tester) async {
|
testWidgets('Override OutlinedButton default padding', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData.from(colorScheme: const ColorScheme.light()),
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: Builder(
|
home: Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return MediaQuery(
|
return MediaQuery(
|
||||||
@ -1677,7 +1675,7 @@ void main() {
|
|||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(textTheme: Typography.englishLike2014),
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -17,13 +17,16 @@ void main() {
|
|||||||
bool pressed = false;
|
bool pressed = false;
|
||||||
const Color splashColor = Color(0xff00ff00);
|
const Color splashColor = Color(0xff00ff00);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
textDirection: TextDirection.ltr,
|
data: ThemeData(useMaterial3: false),
|
||||||
child: Center(
|
child: Directionality(
|
||||||
child: RawMaterialButton(
|
textDirection: TextDirection.ltr,
|
||||||
splashColor: splashColor,
|
child: Center(
|
||||||
onPressed: () { pressed = true; },
|
child: RawMaterialButton(
|
||||||
child: const Text('BUTTON'),
|
splashColor: splashColor,
|
||||||
|
onPressed: () { pressed = true; },
|
||||||
|
child: const Text('BUTTON'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -45,19 +48,22 @@ void main() {
|
|||||||
final FocusNode focusNode = FocusNode(debugLabel: 'Test Button');
|
final FocusNode focusNode = FocusNode(debugLabel: 'Test Button');
|
||||||
const Color splashColor = Color(0xff00ff00);
|
const Color splashColor = Color(0xff00ff00);
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Shortcuts(
|
Theme(
|
||||||
shortcuts: const <ShortcutActivator, Intent>{
|
data: ThemeData(useMaterial3: false),
|
||||||
SingleActivator(LogicalKeyboardKey.enter): ActivateIntent(),
|
child: Shortcuts(
|
||||||
SingleActivator(LogicalKeyboardKey.space): ActivateIntent(),
|
shortcuts: const <ShortcutActivator, Intent>{
|
||||||
},
|
SingleActivator(LogicalKeyboardKey.enter): ActivateIntent(),
|
||||||
child: Directionality(
|
SingleActivator(LogicalKeyboardKey.space): ActivateIntent(),
|
||||||
textDirection: TextDirection.ltr,
|
},
|
||||||
child: Center(
|
child: Directionality(
|
||||||
child: RawMaterialButton(
|
textDirection: TextDirection.ltr,
|
||||||
splashColor: splashColor,
|
child: Center(
|
||||||
focusNode: focusNode,
|
child: RawMaterialButton(
|
||||||
onPressed: () { pressed = true; },
|
splashColor: splashColor,
|
||||||
child: const Text('BUTTON'),
|
focusNode: focusNode,
|
||||||
|
onPressed: () { pressed = true; },
|
||||||
|
child: const Text('BUTTON'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -175,16 +181,19 @@ void main() {
|
|||||||
const Color fillColor = Color(0xFFEF5350);
|
const Color fillColor = Color(0xFFEF5350);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
textDirection: TextDirection.ltr,
|
data: ThemeData(useMaterial3: false),
|
||||||
child: Center(
|
child: Directionality(
|
||||||
child: RawMaterialButton(
|
textDirection: TextDirection.ltr,
|
||||||
materialTapTargetSize: MaterialTapTargetSize.padded,
|
child: Center(
|
||||||
onPressed: () { },
|
child: RawMaterialButton(
|
||||||
fillColor: fillColor,
|
materialTapTargetSize: MaterialTapTargetSize.padded,
|
||||||
highlightColor: highlightColor,
|
onPressed: () { },
|
||||||
splashColor: splashColor,
|
fillColor: fillColor,
|
||||||
child: const SizedBox(),
|
highlightColor: highlightColor,
|
||||||
|
splashColor: splashColor,
|
||||||
|
child: const SizedBox(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -207,16 +216,19 @@ void main() {
|
|||||||
const Color fillColor = Color(0xFFEF5350);
|
const Color fillColor = Color(0xFFEF5350);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Theme(
|
||||||
textDirection: TextDirection.ltr,
|
data: ThemeData(useMaterial3: false),
|
||||||
child: Center(
|
child: Directionality(
|
||||||
child: RawMaterialButton(
|
textDirection: TextDirection.ltr,
|
||||||
materialTapTargetSize: MaterialTapTargetSize.padded,
|
child: Center(
|
||||||
onPressed: () { },
|
child: RawMaterialButton(
|
||||||
fillColor: fillColor,
|
materialTapTargetSize: MaterialTapTargetSize.padded,
|
||||||
highlightColor: highlightColor,
|
onPressed: () { },
|
||||||
splashColor: splashColor,
|
fillColor: fillColor,
|
||||||
child: const SizedBox(),
|
highlightColor: highlightColor,
|
||||||
|
splashColor: splashColor,
|
||||||
|
child: const SizedBox(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -520,6 +532,7 @@ void main() {
|
|||||||
Future<void> buildTest(VisualDensity visualDensity, {bool useText = false}) async {
|
Future<void> buildTest(VisualDensity visualDensity, {bool useText = false}) async {
|
||||||
return tester.pumpWidget(
|
return tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: Directionality(
|
home: Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: Center(
|
child: Center(
|
||||||
|
@ -42,7 +42,7 @@ void main() {
|
|||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
expect(material.color, Colors.transparent);
|
expect(material.color, Colors.transparent);
|
||||||
expect(material.elevation, 0.0);
|
expect(material.elevation, 0.0);
|
||||||
expect(material.shadowColor, material3 ? null : const Color(0xff000000));
|
expect(material.shadowColor, material3 ? Colors.transparent : const Color(0xff000000));
|
||||||
expect(material.shape, material3
|
expect(material.shape, material3
|
||||||
? const StadiumBorder()
|
? const StadiumBorder()
|
||||||
: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))));
|
: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))));
|
||||||
@ -77,7 +77,7 @@ void main() {
|
|||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
expect(material.color, Colors.transparent);
|
expect(material.color, Colors.transparent);
|
||||||
expect(material.elevation, 0.0);
|
expect(material.elevation, 0.0);
|
||||||
expect(material.shadowColor, material3 ? null : const Color(0xff000000));
|
expect(material.shadowColor, material3 ? Colors.transparent : const Color(0xff000000));
|
||||||
expect(material.shape, material3
|
expect(material.shape, material3
|
||||||
? const StadiumBorder()
|
? const StadiumBorder()
|
||||||
: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))));
|
: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))));
|
||||||
@ -115,7 +115,7 @@ void main() {
|
|||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
expect(material.color, Colors.transparent);
|
expect(material.color, Colors.transparent);
|
||||||
expect(material.elevation, 0.0);
|
expect(material.elevation, 0.0);
|
||||||
expect(material.shadowColor, material3 ? null : const Color(0xff000000));
|
expect(material.shadowColor, material3 ? Colors.transparent : const Color(0xff000000));
|
||||||
expect(material.shape, material3
|
expect(material.shape, material3
|
||||||
? const StadiumBorder()
|
? const StadiumBorder()
|
||||||
: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))));
|
: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))));
|
||||||
@ -145,7 +145,7 @@ void main() {
|
|||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
expect(material.color, Colors.transparent);
|
expect(material.color, Colors.transparent);
|
||||||
expect(material.elevation, 0.0);
|
expect(material.elevation, 0.0);
|
||||||
expect(material.shadowColor, material3 ? null : const Color(0xff000000));
|
expect(material.shadowColor, material3 ? Colors.transparent : const Color(0xff000000));
|
||||||
expect(material.shape, material3
|
expect(material.shape, material3
|
||||||
? const StadiumBorder()
|
? const StadiumBorder()
|
||||||
: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))));
|
: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))));
|
||||||
@ -580,8 +580,7 @@ void main() {
|
|||||||
testWidgets('Does TextButton scale with font scale changes', (WidgetTester tester) async {
|
testWidgets('Does TextButton scale with font scale changes', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Theme(
|
Theme(
|
||||||
// Force Material 2 typography.
|
data: ThemeData(useMaterial3: false),
|
||||||
data: ThemeData(textTheme: Typography.englishLike2014),
|
|
||||||
child: Directionality(
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
@ -603,8 +602,7 @@ void main() {
|
|||||||
// textScaleFactor expands text, but not button.
|
// textScaleFactor expands text, but not button.
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Theme(
|
Theme(
|
||||||
// Force Material 2 typography.
|
data: ThemeData(useMaterial3: false),
|
||||||
data: ThemeData(textTheme: Typography.englishLike2014),
|
|
||||||
child: Directionality(
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
@ -632,8 +630,7 @@ void main() {
|
|||||||
// Set text scale large enough to expand text and button.
|
// Set text scale large enough to expand text and button.
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Theme(
|
Theme(
|
||||||
// Force Material 2 typography.
|
data: ThemeData(useMaterial3: false),
|
||||||
data: ThemeData(textTheme: Typography.englishLike2014),
|
|
||||||
child: Directionality(
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
@ -656,7 +653,7 @@ void main() {
|
|||||||
testWidgets('TextButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
|
testWidgets('TextButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
|
||||||
Widget buildFrame(MaterialTapTargetSize tapTargetSize, Key key) {
|
Widget buildFrame(MaterialTapTargetSize tapTargetSize, Key key) {
|
||||||
return Theme(
|
return Theme(
|
||||||
data: ThemeData(materialTapTargetSize: tapTargetSize),
|
data: ThemeData(useMaterial3: false, materialTapTargetSize: tapTargetSize),
|
||||||
child: Directionality(
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -925,7 +922,7 @@ void main() {
|
|||||||
Future<void> buildTest(VisualDensity visualDensity, { bool useText = false }) async {
|
Future<void> buildTest(VisualDensity visualDensity, { bool useText = false }) async {
|
||||||
return tester.pumpWidget(
|
return tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(textTheme: Typography.englishLike2014),
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: Directionality(
|
home: Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: Center(
|
child: Center(
|
||||||
@ -1065,10 +1062,8 @@ void main() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
|
useMaterial3: false,
|
||||||
colorScheme: const ColorScheme.light(),
|
colorScheme: const ColorScheme.light(),
|
||||||
// Force Material 2 defaults for the typography and size
|
|
||||||
// default values as the test was designed against these settings.
|
|
||||||
textTheme: Typography.englishLike2014,
|
|
||||||
textButtonTheme: TextButtonThemeData(
|
textButtonTheme: TextButtonThemeData(
|
||||||
style: TextButton.styleFrom(minimumSize: const Size(64, 36)),
|
style: TextButton.styleFrom(minimumSize: const Size(64, 36)),
|
||||||
),
|
),
|
||||||
@ -1484,7 +1479,7 @@ void main() {
|
|||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(textTheme: Typography.englishLike2014),
|
theme: ThemeData(useMaterial3: false),
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user