Skip to content

[rfw] Restore RFW to 100% coverage after ButtonBar update #6020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a comment so it doesn't matter much either way, fwiw. But this is good too.

'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
2 changes: 1 addition & 1 deletion packages/rfw/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: rfw
description: "Remote Flutter widgets: a library for rendering declarative widget description files at runtime."
repository: https://github.com/flutter/packages/tree/main/packages/rfw
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+rfw%22
version: 1.0.21
version: 1.0.22

environment:
sdk: ">=3.0.0 <4.0.0"
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