Skip to content

Commit e47c837

Browse files
Add test for menu_anchor.2.dart (flutter#151399)
Contributes to flutter#130459 It adds a test for - `examples/api/lib/material/menu_anchor/menu_anchor.2.dart`
1 parent 58068d8 commit e47c837

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

dev/bots/check_code_samples.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ final Set<String> _knownMissingTests = <String>{
319319
'examples/api/test/material/selection_container/selection_container.0_test.dart',
320320
'examples/api/test/material/color_scheme/dynamic_content_color.0_test.dart',
321321
'examples/api/test/material/platform_menu_bar/platform_menu_bar.0_test.dart',
322-
'examples/api/test/material/menu_anchor/menu_anchor.2_test.dart',
323322
'examples/api/test/material/flexible_space_bar/flexible_space_bar.0_test.dart',
324323
'examples/api/test/material/chip/deletable_chip_attributes.on_deleted.0_test.dart',
325324
'examples/api/test/material/expansion_panel/expansion_panel_list.expansion_panel_list_radio.0_test.dart',
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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/menu_anchor/menu_anchor.2.dart' as example;
7+
import 'package:flutter_test/flutter_test.dart';
8+
9+
void main() {
10+
testWidgets('The menu should display three items', (WidgetTester tester) async {
11+
await tester.pumpWidget(
12+
const example.MenuAnchorApp(),
13+
);
14+
15+
expect(find.widgetWithText(AppBar, 'MenuAnchorButton'), findsOne);
16+
expect(
17+
find.descendant(of: find.byType(MenuAnchor), matching: find.widgetWithIcon(IconButton, Icons.more_horiz)),
18+
findsOne,
19+
);
20+
21+
await tester.tap(find.byIcon(Icons.more_horiz));
22+
await tester.pumpAndSettle();
23+
24+
for (int i = 1; i <= 3; i++) {
25+
expect(find.widgetWithText(MenuItemButton, 'Item $i'), findsOne);
26+
}
27+
});
28+
}

0 commit comments

Comments
 (0)