mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add test for restorable_route_future.0.dart
(#157708)
Contributes to https://github.com/flutter/flutter/issues/130459 It adds a test for - `examples/api/lib/widgets/navigator/restorable_route_future.0.dart`
This commit is contained in:
parent
bac39a3899
commit
ab256e5caf
@ -310,7 +310,6 @@ class SampleChecker {
|
||||
// See https://github.com/flutter/flutter/issues/130459
|
||||
final Set<String> _knownMissingTests = <String>{
|
||||
'examples/api/test/material/color_scheme/dynamic_content_color.0_test.dart',
|
||||
'examples/api/test/widgets/navigator/restorable_route_future.0_test.dart',
|
||||
'examples/api/test/widgets/nested_scroll_view/nested_scroll_view_state.0_test.dart',
|
||||
'examples/api/test/widgets/scroll_position/scroll_metrics_notification.0_test.dart',
|
||||
'examples/api/test/widgets/media_query/media_query_data.system_gesture_insets.0_test.dart',
|
||||
|
@ -0,0 +1,80 @@
|
||||
// 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/widgets/navigator/restorable_route_future.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('It pushes a restorable route and pops it', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.RestorableRouteFutureExampleApp(),
|
||||
);
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'RestorableRouteFuture Example'), findsOne);
|
||||
expect(find.byType(BackButton), findsNothing);
|
||||
|
||||
expect(find.text('Last count: 0'), findsOne);
|
||||
|
||||
await tester.tap(find.widgetWithText(ElevatedButton, 'Open Counter'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'Awesome Counter'), findsOne);
|
||||
expect(find.text('Count: 0'), findsOne);
|
||||
|
||||
await tester.tap(find.widgetWithIcon(FloatingActionButton, Icons.add));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Count: 1'), findsOne);
|
||||
|
||||
await tester.tap(find.byType(BackButton));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'RestorableRouteFuture Example'), findsOne);
|
||||
expect(find.text('Last count: 1'), findsOne);
|
||||
});
|
||||
|
||||
testWidgets('It pushes a restorable route and restores it', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.RestorableRouteFutureExampleApp(),
|
||||
);
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'RestorableRouteFuture Example'), findsOne);
|
||||
expect(find.byType(BackButton), findsNothing);
|
||||
|
||||
expect(find.text('Last count: 0'), findsOne);
|
||||
|
||||
await tester.tap(find.widgetWithText(ElevatedButton, 'Open Counter'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'Awesome Counter'), findsOne);
|
||||
expect(find.text('Count: 0'), findsOne);
|
||||
|
||||
await tester.tap(find.widgetWithIcon(FloatingActionButton, Icons.add));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Count: 1'), findsOne);
|
||||
|
||||
await tester.restartAndRestore();
|
||||
expect(find.byType(BackButton), findsOne);
|
||||
|
||||
expect(find.text('Count: 1'), findsOne);
|
||||
|
||||
final TestRestorationData data = await tester.getRestorationData();
|
||||
|
||||
await tester.tap(find.byType(BackButton));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(BackButton), findsNothing);
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'RestorableRouteFuture Example'), findsOne);
|
||||
expect(find.text('Last count: 1'), findsOne);
|
||||
|
||||
await tester.restoreFrom(data);
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'Awesome Counter'), findsOne);
|
||||
expect(find.byType(BackButton), findsOne);
|
||||
expect(find.text('Count: 1'), findsOne);
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user