Skip to content

Commit

Permalink
[rfw] Restore RFW to 100% coverage after ButtonBar update
Browse files Browse the repository at this point in the history
  • Loading branch information
TahaTesser committed Jan 31, 2024
1 parent 5b48c44 commit f3fe7e6
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 15 deletions.
5 changes: 5 additions & 0 deletions packages/rfw/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.0.22

* Adds more testing to restore coverage to 100%.
* Format documentation.

## 1.0.21

* Adds support for subscribing to the root of a `DynamicContent` object.
Expand Down
18 changes: 9 additions & 9 deletions packages/rfw/lib/src/flutter/material_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,18 @@ Map<String, LocalWidgetBuilder> get _materialWidgetsDefinitions => <String, Loca
);
},

// The ButtonBar widget in package:flutter/material.dart is planned to be deprecated
// in favor of the OverflowBar widget. This ButtonBar implementation uses the
// OverflowBar widget internally for backward compatibility. The ButtonBar
// widget in rfw package is not deprecated and will continue to be supported.
// The [ButtonBar] widget in Flutter's material library is planned to be deprecated
// in favor of the [OverflowBar] widget. This [ButtonBar] implementation uses the
// [OverflowBar] widget internally for backward compatibility. The [ButtonBar]
// widget in `rfw` package is not deprecated and will continue to be supported.
//
// The ButtonBar widget in package:flutter/material.dart has changed over time.
// The [ButtonBar] widget in Flutter's material library has changed over time.
// The following parameters are no longer supported:
// - buttonMinWidth
// - buttonHeight
// - buttonAlignedDropdown
// - `buttonMinWidth`
// - `buttonHeight`
// - `buttonAlignedDropdown`
//
// It is recommended to use the OverflowBar widget.
// It is recommended to use the [OverflowBar] widget.
'ButtonBar': (BuildContext context, DataSource source) {
final EdgeInsetsGeometry buttonPadding = ArgumentDecoders.edgeInsets(source, ['buttonPadding']) ?? const EdgeInsets.all(8.0);
final ButtonBarLayoutBehavior layoutBehavior = ArgumentDecoders.enumValue<ButtonBarLayoutBehavior>(ButtonBarLayoutBehavior.values, source, ['layoutBehavior'])
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 88 additions & 6 deletions packages/rfw/test/material_widgets_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ void main() {
),
),
);
expect(tester.takeException().toString(),
contains('Could not find remote widget named'));
expect(
tester.takeException().toString(),
contains('Could not find remote widget named'),
);

runtime.update(const LibraryName(<String>['test']), parseLibraryFile('''
import core;
Expand Down Expand Up @@ -225,6 +227,82 @@ void main() {
);
});

testWidgets('Implement ButtonBar properties', (WidgetTester tester) async {
final Runtime runtime = setupRuntime();
final DynamicContent data = DynamicContent();
final List<String> eventLog = <String>[];
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
home: RemoteWidget(
runtime: runtime,
data: data,
widget: const FullyQualifiedWidgetName(testName, 'root'),
onEvent: (String eventName, DynamicMap eventArguments) {
eventLog.add('$eventName $eventArguments');
},
),
),
);
expect(
tester.takeException().toString(),
contains('Could not find remote widget named'),
);

addTearDown(() async {
await tester.binding.setSurfaceSize(null);
});

runtime.update(testName, parseLibraryFile('''
import core;
import material;
widget root = Scaffold(
body: Center(
child: ButtonBar(
buttonPadding: [8.0],
layoutBehavior: 'constrained',
alignment: 'end',
overflowDirection: 'up',
overflowButtonSpacing: 8.0,
mainAxisSize: 'min',
children: [
ElevatedButton(
onPressed: event 'button' { },
child: Text(text: 'Elevated'),
),
OutlinedButton(
onPressed: event 'button' { },
child: Text(text: 'Outlined'),
),
TextButton(
onPressed: event 'button' { },
child: Text(text: 'Text'),
),
],
),
),
);
'''));
await tester.pump();

await expectLater(
find.byType(RemoteWidget),
matchesGoldenFile('goldens/material_test.button_bar_properties.png'),
skip: !runGoldens,
);

// Update the surface size for ButtonBar to overflow.
await tester.binding.setSurfaceSize(const Size(200.0, 600.0));
await tester.pump();

await expectLater(
find.byType(RemoteWidget),
matchesGoldenFile(
'goldens/material_test.button_bar_properties.overflow.png'),
skip: !runGoldens,
);
});

testWidgets('OverflowBar configured to resemble ButtonBar',
(WidgetTester tester) async {
final Runtime runtime = setupRuntime();
Expand All @@ -243,8 +321,10 @@ void main() {
),
),
);
expect(tester.takeException().toString(),
contains('Could not find remote widget named'));
expect(
tester.takeException().toString(),
contains('Could not find remote widget named'),
);

runtime.update(testName, parseLibraryFile('''
import core;
Expand Down Expand Up @@ -301,8 +381,10 @@ void main() {
),
),
);
expect(tester.takeException().toString(),
contains('Could not find remote widget named'));
expect(
tester.takeException().toString(),
contains('Could not find remote widget named'),
);

addTearDown(() async {
await tester.binding.setSurfaceSize(null);
Expand Down

0 comments on commit f3fe7e6

Please sign in to comment.