Unverified Commit 328a262e authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Revert "Toggable Refactor (#76745)" (#77068)

This reverts commit 14552a96.
parent 9964e8fe
...@@ -99,7 +99,7 @@ void main() { ...@@ -99,7 +99,7 @@ void main() {
), ),
)); ));
expect(tester.getSemantics(find.byType(Checkbox)), matchesSemantics( expect(tester.getSemantics(find.byWidgetPredicate((Widget widget) => widget.runtimeType.toString() == '_CheckboxRenderObjectWidget')), matchesSemantics(
hasCheckedState: true, hasCheckedState: true,
hasEnabledState: true, hasEnabledState: true,
// isFocusable is delayed by 1 frame. // isFocusable is delayed by 1 frame.
...@@ -108,7 +108,7 @@ void main() { ...@@ -108,7 +108,7 @@ void main() {
await tester.pump(); await tester.pump();
// isFocusable should be false now after the 1 frame delay. // isFocusable should be false now after the 1 frame delay.
expect(tester.getSemantics(find.byType(Checkbox)), matchesSemantics( expect(tester.getSemantics(find.byWidgetPredicate((Widget widget) => widget.runtimeType.toString() == '_CheckboxRenderObjectWidget')), matchesSemantics(
hasCheckedState: true, hasCheckedState: true,
hasEnabledState: true, hasEnabledState: true,
)); ));
...@@ -120,7 +120,7 @@ void main() { ...@@ -120,7 +120,7 @@ void main() {
), ),
)); ));
expect(tester.getSemantics(find.byType(Checkbox)), matchesSemantics( expect(tester.getSemantics(find.byWidgetPredicate((Widget widget) => widget.runtimeType.toString() == '_CheckboxRenderObjectWidget')), matchesSemantics(
hasCheckedState: true, hasCheckedState: true,
hasEnabledState: true, hasEnabledState: true,
isChecked: true, isChecked: true,
...@@ -290,7 +290,7 @@ void main() { ...@@ -290,7 +290,7 @@ void main() {
); );
await tester.tap(find.byType(Checkbox)); await tester.tap(find.byType(Checkbox));
final RenderObject object = tester.firstRenderObject(find.byType(Checkbox)); final RenderObject object = tester.firstRenderObject(find.byType(Focus));
expect(checkboxValue, true); expect(checkboxValue, true);
expect(semanticEvent, <String, dynamic>{ expect(semanticEvent, <String, dynamic>{
...@@ -319,8 +319,10 @@ void main() { ...@@ -319,8 +319,10 @@ void main() {
); );
} }
RenderBox getCheckboxRenderer() { RenderToggleable getCheckboxRenderer() {
return tester.renderObject<RenderBox>(find.byType(Checkbox)); return tester.renderObject<RenderToggleable>(find.byWidgetPredicate((Widget widget) {
return widget.runtimeType.toString() == '_CheckboxRenderObjectWidget';
}));
} }
await tester.pumpWidget(buildFrame(false)); await tester.pumpWidget(buildFrame(false));
...@@ -375,8 +377,10 @@ void main() { ...@@ -375,8 +377,10 @@ void main() {
); );
} }
RenderBox getCheckboxRenderer() { RenderToggleable getCheckboxRenderer() {
return tester.renderObject<RenderBox>(find.byType(Checkbox)); return tester.renderObject<RenderToggleable>(find.byWidgetPredicate((Widget widget) {
return widget.runtimeType.toString() == '_CheckboxRenderObjectWidget';
}));
} }
await tester.pumpWidget(buildFrame(checkColor: checkColor)); await tester.pumpWidget(buildFrame(checkColor: checkColor));
...@@ -449,10 +453,11 @@ void main() { ...@@ -449,10 +453,11 @@ void main() {
paints paints
..circle(color: Colors.orange[500]) ..circle(color: Colors.orange[500])
..drrect( ..drrect(
color: const Color(0x8a000000), color: const Color(0x8a000000),
outer: RRect.fromLTRBR(15.0, 15.0, 33.0, 33.0, const Radius.circular(1.0)), outer: RRect.fromLTRBR(
inner: RRect.fromLTRBR(17.0, 17.0, 31.0, 31.0, const Radius.circular(-1.0)), 391.0, 291.0, 409.0, 309.0, const Radius.circular(1.0)),
), inner: RRect.fromLTRBR(393.0,
293.0, 407.0, 307.0, const Radius.circular(-1.0))),
); );
// Check what happens when disabled. // Check what happens when disabled.
...@@ -464,10 +469,11 @@ void main() { ...@@ -464,10 +469,11 @@ void main() {
Material.of(tester.element(find.byType(Checkbox))), Material.of(tester.element(find.byType(Checkbox))),
paints paints
..drrect( ..drrect(
color: const Color(0x61000000), color: const Color(0x61000000),
outer: RRect.fromLTRBR(15.0, 15.0, 33.0, 33.0, const Radius.circular(1.0)), outer: RRect.fromLTRBR(
inner: RRect.fromLTRBR(17.0, 17.0, 31.0, 31.0, const Radius.circular(-1.0)), 391.0, 291.0, 409.0, 309.0, const Radius.circular(1.0)),
), inner: RRect.fromLTRBR(393.0,
293.0, 407.0, 307.0, const Radius.circular(-1.0))),
); );
}); });
...@@ -819,8 +825,10 @@ void main() { ...@@ -819,8 +825,10 @@ void main() {
); );
} }
RenderBox getCheckboxRenderer() { RenderToggleable getCheckboxRenderer() {
return tester.renderObject<RenderBox>(find.byType(Checkbox)); return tester.renderObject<RenderToggleable>(find.byWidgetPredicate((Widget widget) {
return widget.runtimeType.toString() == '_CheckboxRenderObjectWidget';
}));
} }
await tester.pumpWidget(buildFrame(enabled: true)); await tester.pumpWidget(buildFrame(enabled: true));
...@@ -870,8 +878,10 @@ void main() { ...@@ -870,8 +878,10 @@ void main() {
); );
} }
RenderBox getCheckboxRenderer() { RenderToggleable getCheckboxRenderer() {
return tester.renderObject<RenderBox>(find.byType(Checkbox)); return tester.renderObject<RenderToggleable>(find.byWidgetPredicate((Widget widget) {
return widget.runtimeType.toString() == '_CheckboxRenderObjectWidget';
}));
} }
await tester.pumpWidget(buildFrame()); await tester.pumpWidget(buildFrame());
...@@ -927,9 +937,11 @@ void main() { ...@@ -927,9 +937,11 @@ void main() {
paints paints
..drrect( ..drrect(
color: const Color(0xfff44336), color: const Color(0xfff44336),
outer: RRect.fromLTRBR(15.0, 15.0, 33.0, 33.0, const Radius.circular(5)), outer: RRect.fromLTRBR(
inner: RRect.fromLTRBR(19.0, 19.0, 29.0, 29.0, const Radius.circular(1)), 391.0, 291.0, 409.0, 309.0, const Radius.circular(5)),
), inner: RRect.fromLTRBR(
395.0, 295.0, 405.0, 305.0, const Radius.circular(1)))
,
); );
}); });
...@@ -1172,29 +1184,6 @@ void main() { ...@@ -1172,29 +1184,6 @@ void main() {
await gesture.up(); await gesture.up();
}); });
testWidgets('Do not crash when widget disappears while pointer is down', (WidgetTester tester) async {
Widget buildCheckbox(bool show) {
return MaterialApp(
home: Material(
child: Center(
child: show ? Checkbox(value: true, onChanged: (_) { }) : Container(),
),
),
);
}
await tester.pumpWidget(buildCheckbox(true));
final Offset center = tester.getCenter(find.byType(Checkbox));
// Put a pointer down on the screen.
final TestGesture gesture = await tester.startGesture(center);
await tester.pump();
// While the pointer is down, the widget disappears.
await tester.pumpWidget(buildCheckbox(false));
expect(find.byType(Checkbox), findsNothing);
// Release pointer after widget disappeared.
gesture.up();
});
} }
class _SelectedGrabMouseCursor extends MaterialStateMouseCursor { class _SelectedGrabMouseCursor extends MaterialStateMouseCursor {
......
...@@ -308,7 +308,7 @@ void main() { ...@@ -308,7 +308,7 @@ void main() {
)); ));
await tester.tap(find.byKey(key)); await tester.tap(find.byKey(key));
final RenderObject object = tester.firstRenderObject(find.byKey(key)); final RenderObject object = tester.firstRenderObject(find.byType(Focus));
expect(radioValue, 1); expect(radioValue, 1);
expect(semanticEvent, <String, dynamic>{ expect(semanticEvent, <String, dynamic>{
...@@ -1078,29 +1078,4 @@ void main() { ...@@ -1078,29 +1078,4 @@ void main() {
reason: 'Hovered Radio should use overlay color $hoverOverlayColor over $hoverColor', reason: 'Hovered Radio should use overlay color $hoverOverlayColor over $hoverColor',
); );
}); });
testWidgets('Do not crash when widget disappears while pointer is down', (WidgetTester tester) async {
final Key key = UniqueKey();
Widget buildRadio(bool show) {
return MaterialApp(
home: Material(
child: Center(
child: show ? Radio<bool>(key: key, value: true, groupValue: false, onChanged: (_) { }) : Container(),
)
),
);
}
await tester.pumpWidget(buildRadio(true));
final Offset center = tester.getCenter(find.byKey(key));
// Put a pointer down on the screen.
final TestGesture gesture = await tester.startGesture(center);
await tester.pump();
// While the pointer is down, the widget disappears.
await tester.pumpWidget(buildRadio(false));
expect(find.byKey(key), findsNothing);
// Release pointer after widget disappeared.
gesture.up();
});
} }
...@@ -37,7 +37,7 @@ void main() { ...@@ -37,7 +37,7 @@ void main() {
expect(log, equals(<dynamic>[false, '-', false])); expect(log, equals(<dynamic>[false, '-', false]));
}); });
testWidgets('SwitchListTile semantics test', (WidgetTester tester) async { testWidgets('SwitchListTile control test', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(wrap( await tester.pumpWidget(wrap(
child: Column( child: Column(
......
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