Add test for radio.toggleable.0.dart (#149153)

Contributes to https://github.com/flutter/flutter/issues/130459

It adds a test for
- `examples/api/lib/material/radio/radio.toggleable.0.dart`
This commit is contained in:
Valentin Vignal
2024-05-30 02:30:57 +08:00
committed by GitHub
parent 557fca4582
commit 2e275032d5
2 changed files with 32 additions and 1 deletions

View File

@@ -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',

View File

@@ -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),
);
}
});
}