mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Contributes to https://github.com/flutter/flutter/issues/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
29 lines
1.1 KiB
Dart
29 lines
1.1 KiB
Dart
// 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/scaffold/scaffold.1.dart' as example;
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
testWidgets('The count should be incremented when the floating action button is tapped', (WidgetTester tester) async {
|
|
await tester.pumpWidget(
|
|
const example.ScaffoldExampleApp(),
|
|
);
|
|
|
|
expect(find.widgetWithText(AppBar, 'Sample Code'), findsOne);
|
|
expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne);
|
|
expect(find.text('You have pressed the button 0 times.'), findsOne);
|
|
|
|
for (int i = 1; i <= 5; i++) {
|
|
await tester.tap(find.byType(FloatingActionButton));
|
|
await tester.pump();
|
|
expect(find.text('You have pressed the button $i times.'), findsOne);
|
|
}
|
|
|
|
final Scaffold scaffold = tester.firstWidget<Scaffold>(find.byType(Scaffold));
|
|
expect(scaffold.backgroundColor, Colors.blueGrey.shade200);
|
|
});
|
|
}
|