Skip to content

Commit f704391

Browse files
Use local semantics tester in Material button tests (#186667)
Part of #182636. Switches the Material button test files that already have a local `semantics_tester.dart` copy from importing `../widgets/semantics_tester.dart` to importing the local Material test utility. This removes another small set of cross-library test utility imports ahead of the Material/Cupertino package split. Validation: - dart analyze packages/flutter/test/material/elevated_button_test.dart packages/flutter/test/material/filled_button_test.dart packages/flutter/test/material/material_button_test.dart packages/flutter/test/material/outlined_button_test.dart packages/flutter/test/material/text_button_test.dart - flutter test packages/flutter/test/material/elevated_button_test.dart packages/flutter/test/material/filled_button_test.dart packages/flutter/test/material/material_button_test.dart packages/flutter/test/material/outlined_button_test.dart packages/flutter/test/material/text_button_test.dart --------- Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
1 parent 92ca39b commit f704391

5 files changed

Lines changed: 86 additions & 93 deletions

File tree

packages/flutter/test/material/elevated_button_test.dart

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
88
import 'package:flutter/rendering.dart';
99
import 'package:flutter_test/flutter_test.dart';
1010

11-
import '../widgets/semantics_tester.dart';
11+
import 'semantics_tester.dart';
1212

1313
void main() {
1414
TextStyle iconStyle(WidgetTester tester, IconData icon) {
@@ -1629,32 +1629,30 @@ void main() {
16291629
}
16301630
});
16311631

1632-
testWidgets(
1633-
'ElevatedButton uses InkSparkle only for Android non-web when useMaterial3 is true',
1634-
(WidgetTester tester) async {
1635-
final theme = ThemeData();
1632+
testWidgets('ElevatedButton uses InkSparkle only for Android non-web when useMaterial3 is true', (
1633+
WidgetTester tester,
1634+
) async {
1635+
final theme = ThemeData();
16361636

1637-
await tester.pumpWidget(
1638-
MaterialApp(
1639-
theme: theme,
1640-
home: Center(
1641-
child: ElevatedButton(onPressed: () {}, child: const Text('button')),
1642-
),
1637+
await tester.pumpWidget(
1638+
MaterialApp(
1639+
theme: theme,
1640+
home: Center(
1641+
child: ElevatedButton(onPressed: () {}, child: const Text('button')),
16431642
),
1644-
);
1643+
),
1644+
);
16451645

1646-
final InkWell buttonInkWell = tester.widget<InkWell>(
1647-
find.descendant(of: find.byType(ElevatedButton), matching: find.byType(InkWell)),
1648-
);
1646+
final InkWell buttonInkWell = tester.widget<InkWell>(
1647+
find.descendant(of: find.byType(ElevatedButton), matching: find.byType(InkWell)),
1648+
);
16491649

1650-
if (debugDefaultTargetPlatformOverride! == TargetPlatform.android && !kIsWeb) {
1651-
expect(buttonInkWell.splashFactory, equals(InkSparkle.splashFactory));
1652-
} else {
1653-
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
1654-
}
1655-
},
1656-
variant: TargetPlatformVariant.all(),
1657-
);
1650+
if (debugDefaultTargetPlatformOverride! == TargetPlatform.android && !kIsWeb) {
1651+
expect(buttonInkWell.splashFactory, equals(InkSparkle.splashFactory));
1652+
} else {
1653+
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
1654+
}
1655+
}, variant: TargetPlatformVariant.all());
16581656

16591657
testWidgets('ElevatedButton uses InkRipple when useMaterial3 is false', (
16601658
WidgetTester tester,

packages/flutter/test/material/filled_button_test.dart

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
88
import 'package:flutter/rendering.dart';
99
import 'package:flutter_test/flutter_test.dart';
1010

11-
import '../widgets/semantics_tester.dart';
11+
import 'semantics_tester.dart';
1212

1313
void main() {
1414
TextStyle iconStyle(WidgetTester tester, IconData icon) {
@@ -1763,32 +1763,30 @@ void main() {
17631763
}
17641764
});
17651765

1766-
testWidgets(
1767-
'FilledButton uses InkSparkle only for Android non-web when useMaterial3 is true',
1768-
(WidgetTester tester) async {
1769-
final theme = ThemeData();
1766+
testWidgets('FilledButton uses InkSparkle only for Android non-web when useMaterial3 is true', (
1767+
WidgetTester tester,
1768+
) async {
1769+
final theme = ThemeData();
17701770

1771-
await tester.pumpWidget(
1772-
MaterialApp(
1773-
theme: theme,
1774-
home: Center(
1775-
child: FilledButton(onPressed: () {}, child: const Text('button')),
1776-
),
1771+
await tester.pumpWidget(
1772+
MaterialApp(
1773+
theme: theme,
1774+
home: Center(
1775+
child: FilledButton(onPressed: () {}, child: const Text('button')),
17771776
),
1778-
);
1777+
),
1778+
);
17791779

1780-
final InkWell buttonInkWell = tester.widget<InkWell>(
1781-
find.descendant(of: find.byType(FilledButton), matching: find.byType(InkWell)),
1782-
);
1780+
final InkWell buttonInkWell = tester.widget<InkWell>(
1781+
find.descendant(of: find.byType(FilledButton), matching: find.byType(InkWell)),
1782+
);
17831783

1784-
if (debugDefaultTargetPlatformOverride! == TargetPlatform.android && !kIsWeb) {
1785-
expect(buttonInkWell.splashFactory, equals(InkSparkle.splashFactory));
1786-
} else {
1787-
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
1788-
}
1789-
},
1790-
variant: TargetPlatformVariant.all(),
1791-
);
1784+
if (debugDefaultTargetPlatformOverride! == TargetPlatform.android && !kIsWeb) {
1785+
expect(buttonInkWell.splashFactory, equals(InkSparkle.splashFactory));
1786+
} else {
1787+
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
1788+
}
1789+
}, variant: TargetPlatformVariant.all());
17921790

17931791
testWidgets('FilledButton.icon does not overflow', (WidgetTester tester) async {
17941792
// Regression test for https://github.com/flutter/flutter/issues/77815

packages/flutter/test/material/material_button_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import 'package:flutter/gestures.dart';
77
import 'package:flutter/material.dart';
88
import 'package:flutter/rendering.dart';
99
import 'package:flutter_test/flutter_test.dart';
10-
import '../widgets/semantics_tester.dart';
10+
11+
import 'semantics_tester.dart';
1112

1213
void main() {
1314
setUp(() {

packages/flutter/test/material/outlined_button_test.dart

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'package:flutter/material.dart';
1313
import 'package:flutter/rendering.dart';
1414
import 'package:flutter_test/flutter_test.dart';
1515

16-
import '../widgets/semantics_tester.dart';
16+
import 'semantics_tester.dart';
1717

1818
void main() {
1919
TextStyle iconStyle(WidgetTester tester, IconData icon) {
@@ -1858,32 +1858,30 @@ void main() {
18581858
}
18591859
});
18601860

1861-
testWidgets(
1862-
'OutlinedButton uses InkSparkle only for Android non-web when useMaterial3 is true',
1863-
(WidgetTester tester) async {
1864-
final theme = ThemeData();
1861+
testWidgets('OutlinedButton uses InkSparkle only for Android non-web when useMaterial3 is true', (
1862+
WidgetTester tester,
1863+
) async {
1864+
final theme = ThemeData();
18651865

1866-
await tester.pumpWidget(
1867-
MaterialApp(
1868-
theme: theme,
1869-
home: Center(
1870-
child: OutlinedButton(onPressed: () {}, child: const Text('button')),
1871-
),
1866+
await tester.pumpWidget(
1867+
MaterialApp(
1868+
theme: theme,
1869+
home: Center(
1870+
child: OutlinedButton(onPressed: () {}, child: const Text('button')),
18721871
),
1873-
);
1872+
),
1873+
);
18741874

1875-
final InkWell buttonInkWell = tester.widget<InkWell>(
1876-
find.descendant(of: find.byType(OutlinedButton), matching: find.byType(InkWell)),
1877-
);
1875+
final InkWell buttonInkWell = tester.widget<InkWell>(
1876+
find.descendant(of: find.byType(OutlinedButton), matching: find.byType(InkWell)),
1877+
);
18781878

1879-
if (debugDefaultTargetPlatformOverride! == TargetPlatform.android && !kIsWeb) {
1880-
expect(buttonInkWell.splashFactory, equals(InkSparkle.splashFactory));
1881-
} else {
1882-
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
1883-
}
1884-
},
1885-
variant: TargetPlatformVariant.all(),
1886-
);
1879+
if (debugDefaultTargetPlatformOverride! == TargetPlatform.android && !kIsWeb) {
1880+
expect(buttonInkWell.splashFactory, equals(InkSparkle.splashFactory));
1881+
} else {
1882+
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
1883+
}
1884+
}, variant: TargetPlatformVariant.all());
18871885

18881886
testWidgets('OutlinedButton uses InkRipple when useMaterial3 is false', (
18891887
WidgetTester tester,

packages/flutter/test/material/text_button_test.dart

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
88
import 'package:flutter/rendering.dart';
99
import 'package:flutter_test/flutter_test.dart';
1010

11-
import '../widgets/semantics_tester.dart';
11+
import 'semantics_tester.dart';
1212

1313
void main() {
1414
TextStyle iconStyle(WidgetTester tester, IconData icon) {
@@ -1572,32 +1572,30 @@ void main() {
15721572
}
15731573
});
15741574

1575-
testWidgets(
1576-
'TextButton uses InkSparkle only for Android non-web when useMaterial3 is true',
1577-
(WidgetTester tester) async {
1578-
final theme = ThemeData();
1575+
testWidgets('TextButton uses InkSparkle only for Android non-web when useMaterial3 is true', (
1576+
WidgetTester tester,
1577+
) async {
1578+
final theme = ThemeData();
15791579

1580-
await tester.pumpWidget(
1581-
MaterialApp(
1582-
theme: theme,
1583-
home: Center(
1584-
child: TextButton(onPressed: () {}, child: const Text('button')),
1585-
),
1580+
await tester.pumpWidget(
1581+
MaterialApp(
1582+
theme: theme,
1583+
home: Center(
1584+
child: TextButton(onPressed: () {}, child: const Text('button')),
15861585
),
1587-
);
1586+
),
1587+
);
15881588

1589-
final InkWell buttonInkWell = tester.widget<InkWell>(
1590-
find.descendant(of: find.byType(TextButton), matching: find.byType(InkWell)),
1591-
);
1589+
final InkWell buttonInkWell = tester.widget<InkWell>(
1590+
find.descendant(of: find.byType(TextButton), matching: find.byType(InkWell)),
1591+
);
15921592

1593-
if (debugDefaultTargetPlatformOverride! == TargetPlatform.android && !kIsWeb) {
1594-
expect(buttonInkWell.splashFactory, equals(InkSparkle.splashFactory));
1595-
} else {
1596-
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
1597-
}
1598-
},
1599-
variant: TargetPlatformVariant.all(),
1600-
);
1593+
if (debugDefaultTargetPlatformOverride! == TargetPlatform.android && !kIsWeb) {
1594+
expect(buttonInkWell.splashFactory, equals(InkSparkle.splashFactory));
1595+
} else {
1596+
expect(buttonInkWell.splashFactory, equals(InkRipple.splashFactory));
1597+
}
1598+
}, variant: TargetPlatformVariant.all());
16011599

16021600
testWidgets('TextButton uses InkRipple when useMaterial3 is false', (WidgetTester tester) async {
16031601
final theme = ThemeData(useMaterial3: false);

0 commit comments

Comments
 (0)