Skip to content

Commit 84876e5

Browse files
Add test for scaffold.0.dart and scaffold.2.dart (flutter#148166)
Contributes to flutter#130459 It adds test for - `examples/api/lib/material/scaffold/scaffold.0.dart` - `examples/api/lib/material/scaffold/scaffold.2.dart` It also modifies the `scaffold.1_test.dart` because the only difference with scaffold 0 is the background color, so I figured the test should include it
1 parent 3beeed4 commit 84876e5

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

dev/bots/check_code_samples.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,7 @@ final Set<String> _knownMissingTests = <String>{
351351
'examples/api/test/material/scaffold/scaffold.drawer.0_test.dart',
352352
'examples/api/test/material/scaffold/scaffold_messenger.of.0_test.dart',
353353
'examples/api/test/material/scaffold/scaffold_messenger.0_test.dart',
354-
'examples/api/test/material/scaffold/scaffold.0_test.dart',
355354
'examples/api/test/material/scaffold/scaffold_state.show_bottom_sheet.0_test.dart',
356-
'examples/api/test/material/scaffold/scaffold.2_test.dart',
357355
'examples/api/test/material/scaffold/scaffold_messenger_state.show_material_banner.0_test.dart',
358356
'examples/api/test/material/scaffold/scaffold_messenger.of.1_test.dart',
359357
'examples/api/test/material/scaffold/scaffold_messenger_state.show_snack_bar.0_test.dart',
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/scaffold/scaffold.0.dart' as example;
7+
import 'package:flutter_test/flutter_test.dart';
8+
9+
void main() {
10+
testWidgets('The count should be incremented when the floating action button is tapped', (WidgetTester tester) async {
11+
await tester.pumpWidget(
12+
const example.ScaffoldExampleApp(),
13+
);
14+
15+
expect(find.widgetWithText(AppBar, 'Sample Code'), findsOne);
16+
expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne);
17+
expect(find.text('You have pressed the button 0 times.'), findsOne);
18+
19+
for (int i = 1; i <= 5; i++) {
20+
await tester.tap(find.byType(FloatingActionButton));
21+
await tester.pump();
22+
expect(find.text('You have pressed the button $i times.'), findsOne);
23+
}
24+
});
25+
}

examples/api/test/material/scaffold/scaffold.1_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@ void main() {
2121
await tester.pump();
2222
expect(find.text('You have pressed the button $i times.'), findsOne);
2323
}
24+
25+
final Scaffold scaffold = tester.firstWidget<Scaffold>(find.byType(Scaffold));
26+
expect(scaffold.backgroundColor, Colors.blueGrey.shade200);
2427
});
2528
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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/scaffold/scaffold.2.dart' as example;
7+
import 'package:flutter_test/flutter_test.dart';
8+
9+
void main() {
10+
testWidgets('The count should be incremented when the centered floating action button is tapped', (WidgetTester tester) async {
11+
await tester.pumpWidget(
12+
const example.ScaffoldExampleApp(),
13+
);
14+
15+
expect(find.widgetWithText(AppBar, 'Sample Code'), findsOne);
16+
expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne);
17+
expect(find.text('You have pressed the button 0 times.'), findsOne);
18+
expect(find.byType(BottomAppBar), findsOne);
19+
expect(tester.getCenter(find.byType(FloatingActionButton)).dx, 400);
20+
21+
for (int i = 1; i <= 5; i++) {
22+
await tester.tap(find.byType(FloatingActionButton));
23+
await tester.pump();
24+
expect(find.text('You have pressed the button $i times.'), findsOne);
25+
}
26+
});
27+
}

0 commit comments

Comments
 (0)