Unverified Commit 0c3c38dc authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

[reland] Refactor ToggleButtons (remove RawMaterialButton) (#101760)

parent 3f2cb241
...@@ -142,15 +142,15 @@ void main() { ...@@ -142,15 +142,15 @@ void main() {
TextStyle textStyle; TextStyle textStyle;
textStyle = tester.widget<DefaultTextStyle>(find.descendant( textStyle = tester.widget<DefaultTextStyle>(find.descendant(
of: find.widgetWithText(RawMaterialButton, 'First child'), of: find.widgetWithText(TextButton, 'First child'),
matching: find.byType(DefaultTextStyle), matching: find.byType(DefaultTextStyle),
)).style; )).style;
expect(textStyle.textBaseline, TextBaseline.ideographic); expect(textStyle.textBaseline, TextBaseline.ideographic);
expect(textStyle.fontSize, 20.0); expect(textStyle.fontSize, 20.0);
expect(textStyle.color, isNot(Colors.orange)); expect(textStyle.color, isNot(Colors.orange));
textStyle = tester.widget<DefaultTextStyle>(find.descendant( textStyle = tester.widget<DefaultTextStyle>(find.descendant(
of: find.widgetWithText(RawMaterialButton, 'Second child'), of: find.widgetWithText(TextButton, 'Second child'),
matching: find.byType(DefaultTextStyle), matching: find.byType(DefaultTextStyle),
)).style; )).style;
expect(textStyle.textBaseline, TextBaseline.ideographic); expect(textStyle.textBaseline, TextBaseline.ideographic);
...@@ -171,6 +171,7 @@ void main() { ...@@ -171,6 +171,7 @@ void main() {
), ),
), ),
child: ToggleButtons( child: ToggleButtons(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
isSelected: const <bool>[false, false, false], isSelected: const <bool>[false, false, false],
onPressed: (int index) {}, onPressed: (int index) {},
children: const <Widget>[ children: const <Widget>[
...@@ -184,13 +185,13 @@ void main() { ...@@ -184,13 +185,13 @@ void main() {
), ),
); );
Rect firstRect = tester.getRect(find.byType(RawMaterialButton).at(0)); Rect firstRect = tester.getRect(find.byType(TextButton).at(0));
expect(firstRect.width, 50.0); expect(firstRect.width, 50.0);
expect(firstRect.height, 60.0); expect(firstRect.height, 60.0);
Rect secondRect = tester.getRect(find.byType(RawMaterialButton).at(1)); Rect secondRect = tester.getRect(find.byType(TextButton).at(1));
expect(secondRect.width, 50.0); expect(secondRect.width, 50.0);
expect(secondRect.height, 60.0); expect(secondRect.height, 60.0);
Rect thirdRect = tester.getRect(find.byType(RawMaterialButton).at(2)); Rect thirdRect = tester.getRect(find.byType(TextButton).at(2));
expect(thirdRect.width, 50.0); expect(thirdRect.width, 50.0);
expect(thirdRect.height, 60.0); expect(thirdRect.height, 60.0);
...@@ -206,6 +207,7 @@ void main() { ...@@ -206,6 +207,7 @@ void main() {
), ),
), ),
child: ToggleButtons( child: ToggleButtons(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
isSelected: const <bool>[false, false, false], isSelected: const <bool>[false, false, false],
onPressed: (int index) {}, onPressed: (int index) {},
children: const <Widget>[ children: const <Widget>[
...@@ -219,13 +221,13 @@ void main() { ...@@ -219,13 +221,13 @@ void main() {
), ),
); );
firstRect = tester.getRect(find.byType(RawMaterialButton).at(0)); firstRect = tester.getRect(find.byType(TextButton).at(0));
expect(firstRect.width, 20.0); expect(firstRect.width, 20.0);
expect(firstRect.height, 10.0); expect(firstRect.height, 10.0);
secondRect = tester.getRect(find.byType(RawMaterialButton).at(1)); secondRect = tester.getRect(find.byType(TextButton).at(1));
expect(secondRect.width, 20.0); expect(secondRect.width, 20.0);
expect(secondRect.height, 10.0); expect(secondRect.height, 10.0);
thirdRect = tester.getRect(find.byType(RawMaterialButton).at(2)); thirdRect = tester.getRect(find.byType(TextButton).at(2));
expect(thirdRect.width, 20.0); expect(thirdRect.width, 20.0);
expect(thirdRect.height, 10.0); expect(thirdRect.height, 10.0);
}); });
...@@ -235,13 +237,13 @@ void main() { ...@@ -235,13 +237,13 @@ void main() {
(WidgetTester tester) async { (WidgetTester tester) async {
TextStyle buttonTextStyle(String text) { TextStyle buttonTextStyle(String text) {
return tester.widget<DefaultTextStyle>(find.descendant( return tester.widget<DefaultTextStyle>(find.descendant(
of: find.widgetWithText(RawMaterialButton, text), of: find.widgetWithText(TextButton, text),
matching: find.byType(DefaultTextStyle), matching: find.byType(DefaultTextStyle),
)).style; )).style;
} }
IconTheme iconTheme(IconData icon) { IconTheme iconTheme(IconData icon) {
return tester.widget(find.descendant( return tester.widget(find.descendant(
of: find.widgetWithIcon(RawMaterialButton, icon), of: find.widgetWithIcon(TextButton, icon),
matching: find.byType(IconTheme), matching: find.byType(IconTheme),
)); ));
} }
...@@ -356,7 +358,7 @@ void main() { ...@@ -356,7 +358,7 @@ void main() {
); );
final Material material = tester.widget<Material>(find.descendant( final Material material = tester.widget<Material>(find.descendant(
of: find.byType(RawMaterialButton), of: find.byType(TextButton),
matching: find.byType(Material), matching: find.byType(Material),
)); ));
expect(material.color, customFillColor); expect(material.color, customFillColor);
...@@ -367,7 +369,7 @@ void main() { ...@@ -367,7 +369,7 @@ void main() {
Material buttonColor(String text) { Material buttonColor(String text) {
return tester.widget<Material>( return tester.widget<Material>(
find.descendant( find.descendant(
of: find.byType(RawMaterialButton), of: find.byType(TextButton),
matching: find.widgetWithText(Material, text), matching: find.widgetWithText(Material, text),
), ),
); );
...@@ -476,7 +478,6 @@ void main() { ...@@ -476,7 +478,6 @@ void main() {
inkFeatures, inkFeatures,
paints paints
..circle(color: splashColor) ..circle(color: splashColor)
..rect(color: highlightColor),
); );
await touchGesture.up(); await touchGesture.up();
...@@ -507,7 +508,6 @@ void main() { ...@@ -507,7 +508,6 @@ void main() {
await hoverGesture.removePointer(); await hoverGesture.removePointer();
}); });
testWidgets( testWidgets(
'Theme border width and border colors for enabled, selected and disabled states', 'Theme border width and border colors for enabled, selected and disabled states',
(WidgetTester tester) async { (WidgetTester tester) async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment