Unverified Commit 160618b1 authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

Add missing `Switch.onFocusChange` test (#126685)

parent d021109d
......@@ -3370,6 +3370,35 @@ void main() {
..rrect(color: const Color(0xffffffff)),
);
});
testWidgets('Switch.onFocusChange callback', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Switch');
bool focused = false;
await tester.pumpWidget(MaterialApp(
home: Material(
child: Center(
child: Switch(
value: true,
focusNode: focusNode,
onFocusChange: (bool value) {
focused = value;
},
onChanged:(bool newValue) {},
),
),
),
));
focusNode.requestFocus();
await tester.pump();
expect(focused, isTrue);
expect(focusNode.hasFocus, isTrue);
focusNode.unfocus();
await tester.pump();
expect(focused, isFalse);
expect(focusNode.hasFocus, isFalse);
});
}
class DelayedImageProvider extends ImageProvider<DelayedImageProvider> {
......
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