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`
This commit is contained in:
Valentin Vignal
2024-10-29 17:01:59 +08:00
committed by GitHub
parent 662bac8f37
commit 55fa5ae07f
2 changed files with 39 additions and 1 deletions

View File

@@ -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);
});
}