Skip to content

Commit 1732994

Browse files
Add test for material_banner.0.dart and material_banner.1.dart (flutter#148452)
Contributes to flutter#130459 It adds test for - `examples/api/lib/material/banner/material_banner.0.dart` - `examples/api/lib/material/banner/material_banner.2.dart` ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes
1 parent fa9992e commit 1732994

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

dev/bots/check_code_samples.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,6 @@ final Set<String> _knownMissingTests = <String>{
363363
'examples/api/test/material/segmented_button/segmented_button.0_test.dart',
364364
'examples/api/test/material/app_bar/sliver_app_bar.2_test.dart',
365365
'examples/api/test/material/app_bar/sliver_app_bar.3_test.dart',
366-
'examples/api/test/material/banner/material_banner.1_test.dart',
367-
'examples/api/test/material/banner/material_banner.0_test.dart',
368366
'examples/api/test/material/navigation_rail/navigation_rail.extended_animation.0_test.dart',
369367
'examples/api/test/rendering/growth_direction/growth_direction.0_test.dart',
370368
'examples/api/test/rendering/sliver_grid/sliver_grid_delegate_with_fixed_cross_axis_count.0_test.dart',
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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/banner/material_banner.0.dart' as example;
7+
import 'package:flutter_test/flutter_test.dart';
8+
9+
void main() {
10+
testWidgets('BottomNavigationBar Updates Screen Content', (WidgetTester tester) async {
11+
await tester.pumpWidget(
12+
const example.MaterialBannerExampleApp(),
13+
);
14+
15+
expect(find.byType(MaterialBanner), findsOne);
16+
expect(find.text('Hello, I am a Material Banner'), findsOne);
17+
expect(find.byIcon(Icons.agriculture_outlined), findsOne);
18+
expect(find.widgetWithText(TextButton, 'OPEN'), findsOne);
19+
expect(find.widgetWithText(TextButton, 'DISMISS'), findsOne);
20+
});
21+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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/banner/material_banner.1.dart' as example;
7+
import 'package:flutter_test/flutter_test.dart';
8+
9+
void main() {
10+
testWidgets('BottomNavigationBar Updates Screen Content', (WidgetTester tester) async {
11+
await tester.pumpWidget(
12+
const example.MaterialBannerExampleApp(),
13+
);
14+
15+
expect(find.byType(MaterialBanner), findsNothing);
16+
await tester.tap(find.widgetWithText(ElevatedButton, 'Show MaterialBanner'));
17+
await tester.pumpAndSettle();
18+
19+
expect(find.byType(MaterialBanner), findsOne);
20+
expect(find.text('Hello, I am a Material Banner'), findsOne);
21+
expect(find.byIcon(Icons.agriculture_outlined), findsOne);
22+
expect(find.widgetWithText(TextButton, 'DISMISS'), findsOne);
23+
24+
});
25+
}

0 commit comments

Comments
 (0)