diff --git a/dev/bots/check_code_samples.dart b/dev/bots/check_code_samples.dart index c97b72e3e6..b590bb2bb3 100644 --- a/dev/bots/check_code_samples.dart +++ b/dev/bots/check_code_samples.dart @@ -314,7 +314,6 @@ final Set _knownMissingTests = { 'examples/api/test/widgets/media_query/media_query_data.system_gesture_insets.0_test.dart', 'examples/api/test/widgets/image/image.frame_builder.0_test.dart', 'examples/api/test/widgets/image/image.loading_builder.0_test.dart', - 'examples/api/test/widgets/page_storage/page_storage.0_test.dart', 'examples/api/test/widgets/scrollbar/raw_scrollbar.1_test.dart', 'examples/api/test/widgets/scrollbar/raw_scrollbar.2_test.dart', 'examples/api/test/widgets/scrollbar/raw_scrollbar.desktop.0_test.dart', diff --git a/examples/api/test/widgets/page_storage/page_storage.0_test.dart b/examples/api/test/widgets/page_storage/page_storage.0_test.dart new file mode 100644 index 0000000000..13a05b6d9e --- /dev/null +++ b/examples/api/test/widgets/page_storage/page_storage.0_test.dart @@ -0,0 +1,39 @@ +// 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/page_storage/page_storage.0.dart' as example; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Can choose to stay on page', (WidgetTester tester) async { + await tester.pumpWidget( + const example.PageStorageExampleApp(), + ); + + expect(find.widgetWithText(AppBar, 'Persistence Example'), findsOne); + + expect(find.text('0'), findsOne); + + await tester.scrollUntilVisible(find.text('10'), 100); + + expect(find.text('0'), findsNothing); + + await tester.tap(find.byIcon(Icons.settings)); + await tester.pumpAndSettle(); + + expect(find.text('0'), findsOne); + await tester.scrollUntilVisible(find.text('20'), 100); + + await tester.tap(find.byIcon(Icons.home)); + await tester.pumpAndSettle(); + + expect(find.text('10'), findsOne); + + await tester.tap(find.byIcon(Icons.settings)); + await tester.pumpAndSettle(); + + expect(find.text('20'), findsOne); + }); +}