Skip to content

Commit b6c14d7

Browse files
authored
Test of CustomScrollViewExampleApp (#152431)
CustomScrollViewExampleApp Part of flutter/flutter#130459 The test is checking: - if all crucial Widgets are initially visible - if IconButton click will expand existing SliverList - if IconButton click and mouse scroll will reveal additional SliverList
1 parent aa934ac commit b6c14d7

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

dev/bots/check_code_samples.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,5 @@ final Set<String> _knownMissingTests = <String>{
358358
'examples/api/test/widgets/restoration/restoration_mixin.0_test.dart',
359359
'examples/api/test/widgets/actions/focusable_action_detector.0_test.dart',
360360
'examples/api/test/widgets/focus_scope/focus_scope.0_test.dart',
361-
'examples/api/test/widgets/scroll_view/custom_scroll_view.1_test.dart',
362361
'examples/api/test/gestures/pointer_signal_resolver/pointer_signal_resolver.0_test.dart',
363362
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter/material.dart';
6+
import 'package:flutter_api_samples/widgets/scroll_view/custom_scroll_view.1.dart' as example;
7+
import 'package:flutter_test/flutter_test.dart';
8+
9+
void main() {
10+
testWidgets('What should be visible in the initial state.', (WidgetTester tester) async {
11+
await tester.pumpWidget(const example.CustomScrollViewExampleApp());
12+
13+
expect(find.descendant(
14+
of: find.byType(IconButton),
15+
matching: find.byIcon(Icons.add),
16+
), findsOne);
17+
expect(find.byType(SliverList), findsOne);
18+
19+
// Initial state should present only "Item: 0" on the SliverList.
20+
expect(find.widgetWithText(SliverList, 'Item: 0'), findsOne);
21+
expect(find.widgetWithText(SliverList, 'Item: -1'), findsNothing);
22+
expect(find.widgetWithText(SliverList, 'Item: 1'), findsNothing);
23+
});
24+
25+
testWidgets('Items are added correctly', (WidgetTester tester) async {
26+
await tester.pumpWidget(const example.CustomScrollViewExampleApp());
27+
28+
await tester.tap(find.byType(IconButton));
29+
await tester.pump();
30+
31+
// 'Item: -1' is invisible before scrolling.
32+
expect(find.widgetWithText(SliverList, 'Item: -1'), findsNothing);
33+
expect(find.widgetWithText(SliverList, 'Item: 1'), findsOne);
34+
35+
// Scroll the updated screen.
36+
await tester.drag(find.byType(CustomScrollView), const Offset(0.0, 50.0));
37+
await tester.pump();
38+
39+
// An additional SliverList appears.
40+
expect(find.byType(SliverList), findsExactly(2));
41+
42+
// All items are visible.
43+
expect(find.widgetWithText(SliverList, 'Item: -1'), findsOne);
44+
expect(find.widgetWithText(SliverList, 'Item: 0'), findsOne);
45+
expect(find.widgetWithText(SliverList, 'Item: 1'), findsOne);
46+
});
47+
}

0 commit comments

Comments
 (0)