Skip to content

Commit

Permalink
Add test for radio.toggleable.0.dart (#149153)
Browse files Browse the repository at this point in the history
Contributes to flutter/flutter#130459

It adds a test for
- `examples/api/lib/material/radio/radio.toggleable.0.dart`
  • Loading branch information
ValentinVignal authored May 29, 2024
1 parent 557fca4 commit 2e27503
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
1 change: 0 additions & 1 deletion dev/bots/check_code_samples.dart
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ final Set<String> _knownMissingTests = <String>{
'examples/api/test/material/text_form_field/text_form_field.1_test.dart',
'examples/api/test/material/scrollbar/scrollbar.1_test.dart',
'examples/api/test/material/dropdown_menu/dropdown_menu.1_test.dart',
'examples/api/test/material/radio/radio.toggleable.0_test.dart',
'examples/api/test/material/search_anchor/search_anchor.0_test.dart',
'examples/api/test/material/search_anchor/search_anchor.1_test.dart',
'examples/api/test/material/search_anchor/search_anchor.2_test.dart',
Expand Down
32 changes: 32 additions & 0 deletions examples/api/test/material/radio/radio.toggleable.0_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:flutter_api_samples/material/radio/radio.toggleable.0.dart'
as example;
import 'package:flutter_test/flutter_test.dart';

void main() {
testWidgets('StreamBuilder listens to internal stream', (WidgetTester tester) async {
await tester.pumpWidget(
const example.ToggleableExampleApp(),
);

expect(find.byType(Radio<int>), findsExactly(5));
expect(find.text('Hercules Mulligan'), findsOne);
expect(find.text('Eliza Hamilton'), findsOne);
expect(find.text('Philip Schuyler'), findsOne);
expect(find.text('Maria Reynolds'), findsOne);
expect(find.text('Samuel Seabury'), findsOne);

for (int i = 0; i < 5; i++) {
await tester.tap(find.byType(Radio<int>).at(i));
await tester.pump();
expect(
find.byWidgetPredicate((Widget widget) => widget is Radio<int> && widget.groupValue == i),
findsExactly(5),
);
}
});
}

0 comments on commit 2e27503

Please sign in to comment.