Skip to content

Commit 1ec4907

Browse files
Add test for expansion_panel_list.expansion_panel_list_radio.0_test.dart (flutter#151730)
Contributes to flutter#130459 It adds a test for - `examples/api/test/material/expansion_panel/expansion_panel_list.expansion_panel_list_radio.0_test.dart`
1 parent f2c1c72 commit 1ec4907

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

dev/bots/check_code_samples.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ final Set<String> _knownMissingTests = <String>{
321321
'examples/api/test/material/platform_menu_bar/platform_menu_bar.0_test.dart',
322322
'examples/api/test/material/flexible_space_bar/flexible_space_bar.0_test.dart',
323323
'examples/api/test/material/chip/deletable_chip_attributes.on_deleted.0_test.dart',
324-
'examples/api/test/material/expansion_panel/expansion_panel_list.expansion_panel_list_radio.0_test.dart',
325324
'examples/api/test/material/search_anchor/search_anchor.0_test.dart',
326325
'examples/api/test/material/search_anchor/search_anchor.1_test.dart',
327326
'examples/api/test/material/search_anchor/search_anchor.2_test.dart',
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter/material.dart';
6+
import 'package:flutter_api_samples/material/expansion_panel/expansion_panel_list.expansion_panel_list_radio.0.dart' as example;
7+
import 'package:flutter_test/flutter_test.dart';
8+
9+
void main() {
10+
testWidgets('ExpansionPanelList.radio can expand one item at the time', (WidgetTester tester) async {
11+
await tester.pumpWidget(
12+
const example.ExpansionPanelListRadioExampleApp(),
13+
);
14+
15+
expect(find.widgetWithText(AppBar, 'ExpansionPanelList.radio Sample'), findsOne);
16+
expect(find.byType(ExpansionPanelList), findsOne);
17+
for (int i = 0; i < 8; i++) {
18+
expect(find.widgetWithText(ListTile, 'Panel $i'), findsOne);
19+
}
20+
21+
// The default expanded item is 2.
22+
for (int i = 0; i < 8; i++) {
23+
expect(
24+
tester.widget<ExpandIcon>(find.byType(ExpandIcon).at(i)).isExpanded,
25+
i == 2,
26+
reason: 'Only the panel 2 should be expanded',
27+
);
28+
}
29+
30+
// Open all the panels one by one.
31+
for (int index = 0; index < 8; index++) {
32+
await tester.ensureVisible(find.byType(ExpandIcon).at(index));
33+
await tester.tap(find.byType(ExpandIcon).at(index));
34+
await tester.pumpAndSettle();
35+
for (int i = 0; i < 8; i++) {
36+
expect(
37+
tester.widget<ExpandIcon>(find.byType(ExpandIcon).at(i)).isExpanded,
38+
i == index,
39+
reason: 'Only the panel $index should be expanded',
40+
);
41+
}
42+
}
43+
});
44+
}

0 commit comments

Comments
 (0)