From b1ac78bff23cf65fa58afced8e9296bda02a2615 Mon Sep 17 00:00:00 2001 From: Lukas Klingsbo Date: Wed, 18 Sep 2024 10:55:23 +0200 Subject: [PATCH] chore: Update ubuntu_lints to 0.4.0 (#44) * chore: Bump ubuntu_lints to 0.4.0 * chore: Fix formatting --- lib/src/custom_matchers.dart | 26 ++- pubspec.yaml | 2 +- test/button_test.dart | 428 +++++++++++++++++++---------------- test/list_tile_test.dart | 46 ++-- test/menu_item_test.dart | 46 ++-- test/test_utils.dart | 10 +- test/text_field_test.dart | 48 ++-- test/title_bar_test.dart | 20 +- test/togglable_test.dart | 241 +++++++++++--------- 9 files changed, 482 insertions(+), 385 deletions(-) diff --git a/lib/src/custom_matchers.dart b/lib/src/custom_matchers.dart index 610aed7..3e90acb 100644 --- a/lib/src/custom_matchers.dart +++ b/lib/src/custom_matchers.dart @@ -32,9 +32,10 @@ class _IsCheckedMatcher extends CustomMatcher { Object? featureValueOf(covariant Finder finder) { final togglables = find .descendant( - of: finder, - matching: find.bySubtype>(), - matchRoot: true) + of: finder, + matching: find.bySubtype>(), + matchRoot: true, + ) .evaluate() .map((e) => e.widget as YaruTogglable); return togglables.single.checked; @@ -49,21 +50,26 @@ class _IsEnabledMatcher extends CustomMatcher { Object featureValueOf(covariant Finder finder) { final editables = find .descendant( - of: finder, matching: find.byType(TextField), matchRoot: true) + of: finder, + matching: find.byType(TextField), + matchRoot: true, + ) .evaluate() .map((e) => e.widget as TextField); final togglables = find .descendant( - of: finder, - matching: find.bySubtype>(), - matchRoot: true) + of: finder, + matching: find.bySubtype>(), + matchRoot: true, + ) .evaluate() .map((e) => e.widget as YaruTogglable); final tappables = find .descendant( - of: finder, - matching: find.bySubtype(), - matchRoot: true) + of: finder, + matching: find.bySubtype(), + matchRoot: true, + ) .evaluate() .map((e) => e.widget as InkResponse); return !editables.any((e) => e.enabled == false) && diff --git a/pubspec.yaml b/pubspec.yaml index 2414de8..acbd82a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,4 +19,4 @@ dependencies: dev_dependencies: mockito: ^5.4.0 plugin_platform_interface: ^2.1.4 - ubuntu_lints: ^0.3.0 + ubuntu_lints: ^0.4.0 diff --git a/test/button_test.dart b/test/button_test.dart index fad4d8b..b77558e 100644 --- a/test/button_test.dart +++ b/test/button_test.dart @@ -6,197 +6,239 @@ import 'package:yaru_test/yaru_test.dart'; import 'test_utils.dart'; void main() { - testWidgets('elevated button', (tester) async { - final testState = stateVariant.currentValue!; - - final focusNode = FocusNode(); - if (testState.hasFocus) { - focusNode.requestFocus(); - } - addTearDown(focusNode.dispose); - - var wasPressed = 0; - - await tester.pumpTestApp(ElevatedButton( - focusNode: focusNode, - onPressed: testState.isEnabled ? () => ++wasPressed : null, - child: const Text('elevated'), - )); - await tester.pump(); - - final button = find.button('elevated'); - expect(button, findsOneWidget); - expect(button, testState.hasFocus ? hasFocus : hasNoFocus); - expect(button, testState.isEnabled ? isEnabled : isDisabled); - - await tester.tapButton('elevated'); - expect(wasPressed, testState.isEnabled ? 1 : 0); - - await tester.tapButton(find.text('elevated')); - expect(wasPressed, testState.isEnabled ? 2 : 0); - }, variant: stateVariant); - - testWidgets('filled button', (tester) async { - final testState = stateVariant.currentValue!; - - final focusNode = FocusNode(); - if (testState.hasFocus) { - focusNode.requestFocus(); - } - addTearDown(focusNode.dispose); - - var wasPressed = 0; - - await tester.pumpTestApp(FilledButton( - focusNode: focusNode, - onPressed: testState.isEnabled ? () => ++wasPressed : null, - child: const Text('filled'), - )); - await tester.pump(); - - final button = find.button('filled'); - expect(button, findsOneWidget); - expect(button, testState.hasFocus ? hasFocus : hasNoFocus); - expect(button, testState.isEnabled ? isEnabled : isDisabled); - - await tester.tapButton('filled'); - expect(wasPressed, testState.isEnabled ? 1 : 0); - - await tester.tapButton(find.text('filled')); - expect(wasPressed, testState.isEnabled ? 2 : 0); - }, variant: stateVariant); - - testWidgets('icon button', (tester) async { - final testState = stateVariant.currentValue!; - - final focusNode = FocusNode(); - if (testState.hasFocus) { - focusNode.requestFocus(); - } - addTearDown(focusNode.dispose); - - await tester.pumpTestApp(IconButton( - focusNode: focusNode, - onPressed: testState.isEnabled ? () {} : null, - icon: const Icon(Icons.abc), - )); - await tester.pump(); - - final iconButton = find.iconButton(Icons.abc); - expect(iconButton, findsOneWidget); - expect(iconButton, testState.hasFocus ? hasFocus : hasNoFocus); - expect(iconButton, testState.isEnabled ? isEnabled : isDisabled); - }, variant: stateVariant); - - testWidgets('menu item', (tester) async { - final testState = stateVariant.currentValue!; - - final focusNode = FocusNode(); - if (testState.hasFocus) { - focusNode.requestFocus(); - } - addTearDown(focusNode.dispose); - - await tester.pumpTestApp(MenuItemButton( - focusNode: focusNode, - onPressed: testState.isEnabled ? () {} : null, - child: const Text('menu item'), - )); - await tester.pump(); - - final button = find.button('menu item'); - expect(button, findsOneWidget); - expect(button, testState.hasFocus ? hasFocus : hasNoFocus); - expect(button, testState.isEnabled ? isEnabled : isDisabled); - }, variant: stateVariant); - - testWidgets('option button', (tester) async { - final testState = stateVariant.currentValue!; - - final focusNode = FocusNode(); - if (testState.hasFocus) { - focusNode.requestFocus(); - } - addTearDown(focusNode.dispose); - - var wasPressed = 0; - - await tester.pumpTestApp(YaruOptionButton( - focusNode: focusNode, - onPressed: testState.isEnabled ? () => ++wasPressed : null, - child: const Text('option'), - )); - await tester.pump(); - - final button = find.button('option'); - expect(button, findsOneWidget); - expect(button, testState.hasFocus ? hasFocus : hasNoFocus); - expect(button, testState.isEnabled ? isEnabled : isDisabled); - - await tester.tapButton('option'); - expect(wasPressed, testState.isEnabled ? 1 : 0); - - await tester.tapButton(find.text('option')); - expect(wasPressed, testState.isEnabled ? 2 : 0); - }, variant: stateVariant); - - testWidgets('outlined button', (tester) async { - final testState = stateVariant.currentValue!; - - final focusNode = FocusNode(); - if (testState.hasFocus) { - focusNode.requestFocus(); - } - addTearDown(focusNode.dispose); - - var wasPressed = 0; - - await tester.pumpTestApp(OutlinedButton( - focusNode: focusNode, - onPressed: testState.isEnabled ? () => ++wasPressed : null, - child: const Text('outlined'), - )); - await tester.pump(); - - final button = find.button('outlined'); - expect(button, findsOneWidget); - expect(button, testState.hasFocus ? hasFocus : hasNoFocus); - expect(button, testState.isEnabled ? isEnabled : isDisabled); - - await tester.tapButton('outlined'); - expect(wasPressed, testState.isEnabled ? 1 : 0); - - await tester.tapButton(find.text('outlined')); - expect(wasPressed, testState.isEnabled ? 2 : 0); - }, variant: stateVariant); - - testWidgets('text button', (tester) async { - final testState = stateVariant.currentValue!; - - final focusNode = FocusNode(); - if (testState.hasFocus) { - focusNode.requestFocus(); - } - addTearDown(focusNode.dispose); - - var wasPressed = 0; - - await tester.pumpTestApp(TextButton( - focusNode: focusNode, - onPressed: testState.isEnabled ? () => ++wasPressed : null, - child: const Text('text'), - )); - await tester.pump(); - - final button = find.button('text'); - expect(button, findsOneWidget); - expect(button, testState.hasFocus ? hasFocus : hasNoFocus); - expect(button, testState.isEnabled ? isEnabled : isDisabled); - - await tester.tapButton('text'); - expect(wasPressed, testState.isEnabled ? 1 : 0); - - await tester.tapButton(find.text('text')); - expect(wasPressed, testState.isEnabled ? 2 : 0); - }, variant: stateVariant); + testWidgets( + 'elevated button', + (tester) async { + final testState = stateVariant.currentValue!; + + final focusNode = FocusNode(); + if (testState.hasFocus) { + focusNode.requestFocus(); + } + addTearDown(focusNode.dispose); + + var wasPressed = 0; + + await tester.pumpTestApp( + ElevatedButton( + focusNode: focusNode, + onPressed: testState.isEnabled ? () => ++wasPressed : null, + child: const Text('elevated'), + ), + ); + await tester.pump(); + + final button = find.button('elevated'); + expect(button, findsOneWidget); + expect(button, testState.hasFocus ? hasFocus : hasNoFocus); + expect(button, testState.isEnabled ? isEnabled : isDisabled); + + await tester.tapButton('elevated'); + expect(wasPressed, testState.isEnabled ? 1 : 0); + + await tester.tapButton(find.text('elevated')); + expect(wasPressed, testState.isEnabled ? 2 : 0); + }, + variant: stateVariant, + ); + + testWidgets( + 'filled button', + (tester) async { + final testState = stateVariant.currentValue!; + + final focusNode = FocusNode(); + if (testState.hasFocus) { + focusNode.requestFocus(); + } + addTearDown(focusNode.dispose); + + var wasPressed = 0; + + await tester.pumpTestApp( + FilledButton( + focusNode: focusNode, + onPressed: testState.isEnabled ? () => ++wasPressed : null, + child: const Text('filled'), + ), + ); + await tester.pump(); + + final button = find.button('filled'); + expect(button, findsOneWidget); + expect(button, testState.hasFocus ? hasFocus : hasNoFocus); + expect(button, testState.isEnabled ? isEnabled : isDisabled); + + await tester.tapButton('filled'); + expect(wasPressed, testState.isEnabled ? 1 : 0); + + await tester.tapButton(find.text('filled')); + expect(wasPressed, testState.isEnabled ? 2 : 0); + }, + variant: stateVariant, + ); + + testWidgets( + 'icon button', + (tester) async { + final testState = stateVariant.currentValue!; + + final focusNode = FocusNode(); + if (testState.hasFocus) { + focusNode.requestFocus(); + } + addTearDown(focusNode.dispose); + + await tester.pumpTestApp( + IconButton( + focusNode: focusNode, + onPressed: testState.isEnabled ? () {} : null, + icon: const Icon(Icons.abc), + ), + ); + await tester.pump(); + + final iconButton = find.iconButton(Icons.abc); + expect(iconButton, findsOneWidget); + expect(iconButton, testState.hasFocus ? hasFocus : hasNoFocus); + expect(iconButton, testState.isEnabled ? isEnabled : isDisabled); + }, + variant: stateVariant, + ); + + testWidgets( + 'menu item', + (tester) async { + final testState = stateVariant.currentValue!; + + final focusNode = FocusNode(); + if (testState.hasFocus) { + focusNode.requestFocus(); + } + addTearDown(focusNode.dispose); + + await tester.pumpTestApp( + MenuItemButton( + focusNode: focusNode, + onPressed: testState.isEnabled ? () {} : null, + child: const Text('menu item'), + ), + ); + await tester.pump(); + + final button = find.button('menu item'); + expect(button, findsOneWidget); + expect(button, testState.hasFocus ? hasFocus : hasNoFocus); + expect(button, testState.isEnabled ? isEnabled : isDisabled); + }, + variant: stateVariant, + ); + + testWidgets( + 'option button', + (tester) async { + final testState = stateVariant.currentValue!; + + final focusNode = FocusNode(); + if (testState.hasFocus) { + focusNode.requestFocus(); + } + addTearDown(focusNode.dispose); + + var wasPressed = 0; + + await tester.pumpTestApp( + YaruOptionButton( + focusNode: focusNode, + onPressed: testState.isEnabled ? () => ++wasPressed : null, + child: const Text('option'), + ), + ); + await tester.pump(); + + final button = find.button('option'); + expect(button, findsOneWidget); + expect(button, testState.hasFocus ? hasFocus : hasNoFocus); + expect(button, testState.isEnabled ? isEnabled : isDisabled); + + await tester.tapButton('option'); + expect(wasPressed, testState.isEnabled ? 1 : 0); + + await tester.tapButton(find.text('option')); + expect(wasPressed, testState.isEnabled ? 2 : 0); + }, + variant: stateVariant, + ); + + testWidgets( + 'outlined button', + (tester) async { + final testState = stateVariant.currentValue!; + + final focusNode = FocusNode(); + if (testState.hasFocus) { + focusNode.requestFocus(); + } + addTearDown(focusNode.dispose); + + var wasPressed = 0; + + await tester.pumpTestApp( + OutlinedButton( + focusNode: focusNode, + onPressed: testState.isEnabled ? () => ++wasPressed : null, + child: const Text('outlined'), + ), + ); + await tester.pump(); + + final button = find.button('outlined'); + expect(button, findsOneWidget); + expect(button, testState.hasFocus ? hasFocus : hasNoFocus); + expect(button, testState.isEnabled ? isEnabled : isDisabled); + + await tester.tapButton('outlined'); + expect(wasPressed, testState.isEnabled ? 1 : 0); + + await tester.tapButton(find.text('outlined')); + expect(wasPressed, testState.isEnabled ? 2 : 0); + }, + variant: stateVariant, + ); + + testWidgets( + 'text button', + (tester) async { + final testState = stateVariant.currentValue!; + + final focusNode = FocusNode(); + if (testState.hasFocus) { + focusNode.requestFocus(); + } + addTearDown(focusNode.dispose); + + var wasPressed = 0; + + await tester.pumpTestApp( + TextButton( + focusNode: focusNode, + onPressed: testState.isEnabled ? () => ++wasPressed : null, + child: const Text('text'), + ), + ); + await tester.pump(); + + final button = find.button('text'); + expect(button, findsOneWidget); + expect(button, testState.hasFocus ? hasFocus : hasNoFocus); + expect(button, testState.isEnabled ? isEnabled : isDisabled); + + await tester.tapButton('text'); + expect(wasPressed, testState.isEnabled ? 1 : 0); + + await tester.tapButton(find.text('text')); + expect(wasPressed, testState.isEnabled ? 2 : 0); + }, + variant: stateVariant, + ); } diff --git a/test/list_tile_test.dart b/test/list_tile_test.dart index 3e7c13f..0ad5002 100644 --- a/test/list_tile_test.dart +++ b/test/list_tile_test.dart @@ -5,28 +5,34 @@ import 'package:yaru_test/yaru_test.dart'; import 'test_utils.dart'; void main() { - testWidgets('list tile', (tester) async { - final testState = stateVariant.currentValue!; + testWidgets( + 'list tile', + (tester) async { + final testState = stateVariant.currentValue!; - final focusNode = FocusNode(); - if (testState.hasFocus) { - focusNode.requestFocus(); - } - addTearDown(focusNode.dispose); + final focusNode = FocusNode(); + if (testState.hasFocus) { + focusNode.requestFocus(); + } + addTearDown(focusNode.dispose); - await tester.pumpTestApp(ListTile( - focusNode: focusNode, - onTap: testState.isEnabled ? () {} : null, - title: const Text('list tile'), - )); - await tester.pump(); + await tester.pumpTestApp( + ListTile( + focusNode: focusNode, + onTap: testState.isEnabled ? () {} : null, + title: const Text('list tile'), + ), + ); + await tester.pump(); - expect(find.listTile('list tile'), findsOneWidget); - expect(find.listTile(find.text('list tile')), findsOneWidget); + expect(find.listTile('list tile'), findsOneWidget); + expect(find.listTile(find.text('list tile')), findsOneWidget); - final listTile = find.listTile('list tile'); - expect(listTile, findsOneWidget); - expect(listTile, testState.hasFocus ? hasFocus : hasNoFocus); - expect(listTile, testState.isEnabled ? isEnabled : isDisabled); - }, variant: stateVariant); + final listTile = find.listTile('list tile'); + expect(listTile, findsOneWidget); + expect(listTile, testState.hasFocus ? hasFocus : hasNoFocus); + expect(listTile, testState.isEnabled ? isEnabled : isDisabled); + }, + variant: stateVariant, + ); } diff --git a/test/menu_item_test.dart b/test/menu_item_test.dart index e7fae49..cbcbed4 100644 --- a/test/menu_item_test.dart +++ b/test/menu_item_test.dart @@ -5,28 +5,34 @@ import 'package:yaru_test/yaru_test.dart'; import 'test_utils.dart'; void main() { - testWidgets('menu item', (tester) async { - final testState = stateVariant.currentValue!; + testWidgets( + 'menu item', + (tester) async { + final testState = stateVariant.currentValue!; - final focusNode = FocusNode(); - if (testState.hasFocus) { - focusNode.requestFocus(); - } - addTearDown(focusNode.dispose); + final focusNode = FocusNode(); + if (testState.hasFocus) { + focusNode.requestFocus(); + } + addTearDown(focusNode.dispose); - await tester.pumpTestApp(MenuItemButton( - focusNode: focusNode, - onPressed: testState.isEnabled ? () {} : null, - child: const Text('menu item'), - )); - await tester.pump(); + await tester.pumpTestApp( + MenuItemButton( + focusNode: focusNode, + onPressed: testState.isEnabled ? () {} : null, + child: const Text('menu item'), + ), + ); + await tester.pump(); - expect(find.menuItem('menu item'), findsOneWidget); - expect(find.menuItem(find.text('menu item')), findsOneWidget); + expect(find.menuItem('menu item'), findsOneWidget); + expect(find.menuItem(find.text('menu item')), findsOneWidget); - final menuItem = find.menuItem('menu item'); - expect(menuItem, findsOneWidget); - expect(menuItem, testState.hasFocus ? hasFocus : hasNoFocus); - expect(menuItem, testState.isEnabled ? isEnabled : isDisabled); - }, variant: stateVariant); + final menuItem = find.menuItem('menu item'); + expect(menuItem, findsOneWidget); + expect(menuItem, testState.hasFocus ? hasFocus : hasNoFocus); + expect(menuItem, testState.isEnabled ? isEnabled : isDisabled); + }, + variant: stateVariant, + ); } diff --git a/test/test_utils.dart b/test/test_utils.dart index 2e4a0d1..810fc14 100644 --- a/test/test_utils.dart +++ b/test/test_utils.dart @@ -38,9 +38,11 @@ final partiallyTogglableStateVariant = ValueVariant({ extension WidgetTesterX on WidgetTester { Future pumpTestApp(Widget widget) { - return pumpWidget(MaterialApp( - theme: yaruLight, - home: Material(child: widget), - )); + return pumpWidget( + MaterialApp( + theme: yaruLight, + home: Material(child: widget), + ), + ); } } diff --git a/test/text_field_test.dart b/test/text_field_test.dart index d209244..0abbf63 100644 --- a/test/text_field_test.dart +++ b/test/text_field_test.dart @@ -6,13 +6,15 @@ import 'test_utils.dart'; void main() { testWidgets('find text field', (tester) async { - await tester.pumpTestApp(TextFormField( - initialValue: 'text field', - decoration: const InputDecoration( - hintText: 'hint text', - labelText: 'label text', + await tester.pumpTestApp( + TextFormField( + initialValue: 'text field', + decoration: const InputDecoration( + hintText: 'hint text', + labelText: 'label text', + ), ), - )); + ); expect(find.textField('text field'), findsOneWidget); expect(find.textField('hint text'), findsOneWidget); @@ -21,21 +23,27 @@ void main() { expect(find.textField(find.textContaining('text')), findsNWidgets(3)); }); - testWidgets('match text field', (tester) async { - final testState = stateVariant.currentValue!; + testWidgets( + 'match text field', + (tester) async { + final testState = stateVariant.currentValue!; - final controller = TextEditingController(text: 'text field'); - addTearDown(controller.dispose); + final controller = TextEditingController(text: 'text field'); + addTearDown(controller.dispose); - await tester.pumpTestApp(TextFormField( - autofocus: testState.hasFocus, - enabled: testState.isEnabled, - initialValue: 'text field', - )); - await tester.pump(); + await tester.pumpTestApp( + TextFormField( + autofocus: testState.hasFocus, + enabled: testState.isEnabled, + initialValue: 'text field', + ), + ); + await tester.pump(); - final textField = find.textField('text field'); - expect(textField, testState.hasFocus ? hasFocus : hasNoFocus); - expect(textField, testState.isEnabled ? isEnabled : isDisabled); - }, variant: stateVariant); + final textField = find.textField('text field'); + expect(textField, testState.hasFocus ? hasFocus : hasNoFocus); + expect(textField, testState.isEnabled ? isEnabled : isDisabled); + }, + variant: stateVariant, + ); } diff --git a/test/title_bar_test.dart b/test/title_bar_test.dart index bf5e861..1e9d203 100644 --- a/test/title_bar_test.dart +++ b/test/title_bar_test.dart @@ -7,15 +7,17 @@ import 'test_utils.dart'; void main() { testWidgets('find title bar', (tester) async { - await tester.pumpTestApp(YaruTitleBar( - title: const Text('title bar'), - actions: [ - IconButton( - icon: const Icon(Icons.add), - onPressed: () {}, - ), - ], - )); + await tester.pumpTestApp( + YaruTitleBar( + title: const Text('title bar'), + actions: [ + IconButton( + icon: const Icon(Icons.add), + onPressed: () {}, + ), + ], + ), + ); expect(find.titleBar('title bar'), findsOneWidget); expect(find.titleBar(find.text('title bar')), findsOneWidget); diff --git a/test/togglable_test.dart b/test/togglable_test.dart index fbfbd3b..64d5722 100644 --- a/test/togglable_test.dart +++ b/test/togglable_test.dart @@ -6,128 +6,153 @@ import 'package:yaru_test/yaru_test.dart'; import 'test_utils.dart'; void main() { - testWidgets('check button', (tester) async { - final testState = partiallyTogglableStateVariant.currentValue!; - - final focusNode = FocusNode(); - if (testState.hasFocus) { - focusNode.requestFocus(); - } - addTearDown(focusNode.dispose); - - await tester.pumpTestApp(YaruCheckButton( - focusNode: focusNode, - value: testState.isChecked - ? true - : testState.isPartiallyChecked - ? null - : false, - tristate: testState.isPartiallyChecked, - onChanged: testState.isEnabled ? (value) {} : null, - title: const Text('check button'), - )); - await tester.pump(); + testWidgets( + 'check button', + (tester) async { + final testState = partiallyTogglableStateVariant.currentValue!; + + final focusNode = FocusNode(); + if (testState.hasFocus) { + focusNode.requestFocus(); + } + addTearDown(focusNode.dispose); + + await tester.pumpTestApp( + YaruCheckButton( + focusNode: focusNode, + value: testState.isChecked + ? true + : testState.isPartiallyChecked + ? null + : false, + tristate: testState.isPartiallyChecked, + onChanged: testState.isEnabled ? (value) {} : null, + title: const Text('check button'), + ), + ); + await tester.pump(); - expect(find.checkButton('check button'), findsOneWidget); - expect(find.checkButton(find.text('check button')), findsOneWidget); + expect(find.checkButton('check button'), findsOneWidget); + expect(find.checkButton(find.text('check button')), findsOneWidget); - final checkButton = find.checkButton('check button'); - expect(checkButton, findsOneWidget); - expect(checkButton, testState.hasFocus ? hasFocus : hasNoFocus); - expect(checkButton, testState.isEnabled ? isEnabled : isDisabled); - expect( + final checkButton = find.checkButton('check button'); + expect(checkButton, findsOneWidget); + expect(checkButton, testState.hasFocus ? hasFocus : hasNoFocus); + expect(checkButton, testState.isEnabled ? isEnabled : isDisabled); + expect( checkButton, testState.isChecked ? isChecked : testState.isPartiallyChecked ? isPartiallyChecked - : isNotChecked); - }, variant: partiallyTogglableStateVariant); - - testWidgets('radio button', (tester) async { - final testState = togglableStateVariant.currentValue!; - - final focusNode = FocusNode(); - if (testState.hasFocus) { - focusNode.requestFocus(); - } - addTearDown(focusNode.dispose); - - final value = testState.isChecked ? Brightness.light : Brightness.dark; - - await tester.pumpTestApp(YaruRadioButton( - focusNode: focusNode, - value: value, - groupValue: Brightness.light, - onChanged: testState.isEnabled ? (value) {} : null, - title: const Text('radio button'), - )); - await tester.pump(); + : isNotChecked, + ); + }, + variant: partiallyTogglableStateVariant, + ); + + testWidgets( + 'radio button', + (tester) async { + final testState = togglableStateVariant.currentValue!; + + final focusNode = FocusNode(); + if (testState.hasFocus) { + focusNode.requestFocus(); + } + addTearDown(focusNode.dispose); + + final value = testState.isChecked ? Brightness.light : Brightness.dark; + + await tester.pumpTestApp( + YaruRadioButton( + focusNode: focusNode, + value: value, + groupValue: Brightness.light, + onChanged: testState.isEnabled ? (value) {} : null, + title: const Text('radio button'), + ), + ); + await tester.pump(); - expect(find.radio(value), findsOneWidget); - expect(find.radioButton('radio button'), findsOneWidget); - expect(find.radioButton(find.text('radio button')), - findsOneWidget); - - final radioButton = find.radioButton('radio button'); - expect(radioButton, findsOneWidget); - expect(radioButton, testState.hasFocus ? hasFocus : hasNoFocus); - expect(radioButton, testState.isChecked ? isChecked : isNotChecked); - expect(radioButton, testState.isEnabled ? isEnabled : isDisabled); - }, variant: togglableStateVariant); - - testWidgets('switch button', (tester) async { - final testState = togglableStateVariant.currentValue!; - - final focusNode = FocusNode(); - if (testState.hasFocus) { - focusNode.requestFocus(); - } - addTearDown(focusNode.dispose); - - await tester.pumpTestApp(YaruSwitchButton( - focusNode: focusNode, - value: testState.isChecked, - onChanged: testState.isEnabled ? (value) {} : null, - title: const Text('switch button'), - )); - await tester.pump(); + expect(find.radio(value), findsOneWidget); + expect(find.radioButton('radio button'), findsOneWidget); + expect( + find.radioButton(find.text('radio button')), + findsOneWidget, + ); + + final radioButton = find.radioButton('radio button'); + expect(radioButton, findsOneWidget); + expect(radioButton, testState.hasFocus ? hasFocus : hasNoFocus); + expect(radioButton, testState.isChecked ? isChecked : isNotChecked); + expect(radioButton, testState.isEnabled ? isEnabled : isDisabled); + }, + variant: togglableStateVariant, + ); + + testWidgets( + 'switch button', + (tester) async { + final testState = togglableStateVariant.currentValue!; + + final focusNode = FocusNode(); + if (testState.hasFocus) { + focusNode.requestFocus(); + } + addTearDown(focusNode.dispose); + + await tester.pumpTestApp( + YaruSwitchButton( + focusNode: focusNode, + value: testState.isChecked, + onChanged: testState.isEnabled ? (value) {} : null, + title: const Text('switch button'), + ), + ); + await tester.pump(); - expect(find.switchButton('switch button'), findsOneWidget); - expect(find.switchButton(find.text('switch button')), findsOneWidget); + expect(find.switchButton('switch button'), findsOneWidget); + expect(find.switchButton(find.text('switch button')), findsOneWidget); - final switchButton = find.switchButton('switch button'); - expect(switchButton, findsOneWidget); - expect(switchButton, testState.hasFocus ? hasFocus : hasNoFocus); - expect(switchButton, testState.isChecked ? isChecked : isNotChecked); - expect(switchButton, testState.isEnabled ? isEnabled : isDisabled); - }, variant: togglableStateVariant); + final switchButton = find.switchButton('switch button'); + expect(switchButton, findsOneWidget); + expect(switchButton, testState.hasFocus ? hasFocus : hasNoFocus); + expect(switchButton, testState.isChecked ? isChecked : isNotChecked); + expect(switchButton, testState.isEnabled ? isEnabled : isDisabled); + }, + variant: togglableStateVariant, + ); testWidgets('toggle', (tester) async { final values = [false, false, false]; - await tester.pumpTestApp(StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - YaruCheckButton( - value: values[0], - onChanged: (v) => setState(() => values[0] = v!), - title: const Text('check button'), - ), - YaruRadioButton( - value: values[1], - groupValue: true, - onChanged: (v) => setState(() => values[1] = !v!), - title: const Text('radio button'), - ), - YaruSwitchButton( - value: values[2], - onChanged: (v) => setState(() => values[2] = v), - title: const Text('switch button'), - ), - ], - ); - })); + await tester.pumpTestApp( + StatefulBuilder( + builder: (context, setState) { + return Column( + children: [ + YaruCheckButton( + value: values[0], + onChanged: (v) => setState(() => values[0] = v!), + title: const Text('check button'), + ), + YaruRadioButton( + value: values[1], + groupValue: true, + onChanged: (v) => setState(() => values[1] = !v!), + title: const Text('radio button'), + ), + YaruSwitchButton( + value: values[2], + onChanged: (v) => setState(() => values[2] = v), + title: const Text('switch button'), + ), + ], + ); + }, + ), + ); await tester.pump(); final checkButton = find.checkButton('check button');