Skip to content

Commit be0124d

Browse files
authored
[rfw] Restore RFW to 100% coverage after ButtonBar update (flutter#6020)
fixes [[`rfw`] Restore RFW to 100% coverage after ButtonBar update](flutter#142602) ### Before ![BEFORE](https://github.com/flutter/packages/assets/48603081/b0671646-d74e-4cc8-a421-23b7130788c8) ### After ![AFTER](https://github.com/flutter/packages/assets/48603081/c55c7974-fc8f-4c0a-a853-9f4fdf622bac)
1 parent 871a24b commit be0124d

6 files changed

+103
-16
lines changed

packages/rfw/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.0.22
2+
3+
* Adds more testing to restore coverage to 100%.
4+
* Format documentation.
5+
16
## 1.0.21
27

38
* Adds support for subscribing to the root of a `DynamicContent` object.

packages/rfw/lib/src/flutter/material_widgets.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,18 @@ Map<String, LocalWidgetBuilder> get _materialWidgetsDefinitions => <String, Loca
140140
);
141141
},
142142

143-
// The ButtonBar widget in package:flutter/material.dart is planned to be deprecated
144-
// in favor of the OverflowBar widget. This ButtonBar implementation uses the
145-
// OverflowBar widget internally for backward compatibility. The ButtonBar
146-
// widget in rfw package is not deprecated and will continue to be supported.
143+
// The [ButtonBar] widget in Flutter's material library is planned to be deprecated
144+
// in favor of the [OverflowBar] widget. This [ButtonBar] implementation uses the
145+
// [OverflowBar] widget internally for backward compatibility. The [ButtonBar]
146+
// widget in `rfw` package is not deprecated and will continue to be supported.
147147
//
148-
// The ButtonBar widget in package:flutter/material.dart has changed over time.
148+
// The [ButtonBar] widget in Flutter's material library has changed over time.
149149
// The following parameters are no longer supported:
150-
// - buttonMinWidth
151-
// - buttonHeight
152-
// - buttonAlignedDropdown
150+
// - `buttonMinWidth`
151+
// - `buttonHeight`
152+
// - `buttonAlignedDropdown`
153153
//
154-
// It is recommended to use the OverflowBar widget.
154+
// It is recommended to use the [OverflowBar] widget.
155155
'ButtonBar': (BuildContext context, DataSource source) {
156156
final EdgeInsetsGeometry buttonPadding = ArgumentDecoders.edgeInsets(source, ['buttonPadding']) ?? const EdgeInsets.all(8.0);
157157
final ButtonBarLayoutBehavior layoutBehavior = ArgumentDecoders.enumValue<ButtonBarLayoutBehavior>(ButtonBarLayoutBehavior.values, source, ['layoutBehavior'])

packages/rfw/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: rfw
22
description: "Remote Flutter widgets: a library for rendering declarative widget description files at runtime."
33
repository: https://github.com/flutter/packages/tree/main/packages/rfw
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+rfw%22
5-
version: 1.0.21
5+
version: 1.0.22
66

77
environment:
88
sdk: ">=3.0.0 <4.0.0"
Loading
Loading

packages/rfw/test/material_widgets_test.dart

Lines changed: 88 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ void main() {
3838
),
3939
),
4040
);
41-
expect(tester.takeException().toString(),
42-
contains('Could not find remote widget named'));
41+
expect(
42+
tester.takeException().toString(),
43+
contains('Could not find remote widget named'),
44+
);
4345

4446
runtime.update(const LibraryName(<String>['test']), parseLibraryFile('''
4547
import core;
@@ -225,6 +227,82 @@ void main() {
225227
);
226228
});
227229

230+
testWidgets('Implement ButtonBar properties', (WidgetTester tester) async {
231+
final Runtime runtime = setupRuntime();
232+
final DynamicContent data = DynamicContent();
233+
final List<String> eventLog = <String>[];
234+
await tester.pumpWidget(
235+
MaterialApp(
236+
theme: ThemeData(useMaterial3: false),
237+
home: RemoteWidget(
238+
runtime: runtime,
239+
data: data,
240+
widget: const FullyQualifiedWidgetName(testName, 'root'),
241+
onEvent: (String eventName, DynamicMap eventArguments) {
242+
eventLog.add('$eventName $eventArguments');
243+
},
244+
),
245+
),
246+
);
247+
expect(
248+
tester.takeException().toString(),
249+
contains('Could not find remote widget named'),
250+
);
251+
252+
addTearDown(() async {
253+
await tester.binding.setSurfaceSize(null);
254+
});
255+
256+
runtime.update(testName, parseLibraryFile('''
257+
import core;
258+
import material;
259+
widget root = Scaffold(
260+
body: Center(
261+
child: ButtonBar(
262+
buttonPadding: [8.0],
263+
layoutBehavior: 'constrained',
264+
alignment: 'end',
265+
overflowDirection: 'up',
266+
overflowButtonSpacing: 8.0,
267+
mainAxisSize: 'min',
268+
children: [
269+
ElevatedButton(
270+
onPressed: event 'button' { },
271+
child: Text(text: 'Elevated'),
272+
),
273+
OutlinedButton(
274+
onPressed: event 'button' { },
275+
child: Text(text: 'Outlined'),
276+
),
277+
TextButton(
278+
onPressed: event 'button' { },
279+
child: Text(text: 'Text'),
280+
),
281+
],
282+
),
283+
),
284+
);
285+
'''));
286+
await tester.pump();
287+
288+
await expectLater(
289+
find.byType(RemoteWidget),
290+
matchesGoldenFile('goldens/material_test.button_bar_properties.png'),
291+
skip: !runGoldens,
292+
);
293+
294+
// Update the surface size for ButtonBar to overflow.
295+
await tester.binding.setSurfaceSize(const Size(200.0, 600.0));
296+
await tester.pump();
297+
298+
await expectLater(
299+
find.byType(RemoteWidget),
300+
matchesGoldenFile(
301+
'goldens/material_test.button_bar_properties.overflow.png'),
302+
skip: !runGoldens,
303+
);
304+
});
305+
228306
testWidgets('OverflowBar configured to resemble ButtonBar',
229307
(WidgetTester tester) async {
230308
final Runtime runtime = setupRuntime();
@@ -243,8 +321,10 @@ void main() {
243321
),
244322
),
245323
);
246-
expect(tester.takeException().toString(),
247-
contains('Could not find remote widget named'));
324+
expect(
325+
tester.takeException().toString(),
326+
contains('Could not find remote widget named'),
327+
);
248328

249329
runtime.update(testName, parseLibraryFile('''
250330
import core;
@@ -301,8 +381,10 @@ void main() {
301381
),
302382
),
303383
);
304-
expect(tester.takeException().toString(),
305-
contains('Could not find remote widget named'));
384+
expect(
385+
tester.takeException().toString(),
386+
contains('Could not find remote widget named'),
387+
);
306388

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

0 commit comments

Comments
 (0)