From 55fa5ae07f5b0e4661554cc3ea73700644b5dace Mon Sep 17 00:00:00 2001 From: Valentin Vignal <32538273+ValentinVignal@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:01:59 +0800 Subject: [PATCH] Add test for `page_storage.0.dart` (#157770) Contributes to https://github.com/flutter/flutter/issues/130459 It adds a test for - `examples/api/lib/widgets/page_storage/page_storage.0.dart` --- dev/bots/check_code_samples.dart | 1 - .../page_storage/page_storage.0_test.dart | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 examples/api/test/widgets/page_storage/page_storage.0_test.dart 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); + }); +}