Skip to content

Commit 879fa83

Browse files
Add test for scrollbar.1.dart (flutter#151463)
Contributes to flutter#130459 It adds a test for - `examples/api/lib/material/scrollbar/scrollbar.1.dart`
1 parent ea7c77f commit 879fa83

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

dev/bots/check_code_samples.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ final Set<String> _knownMissingTests = <String>{
322322
'examples/api/test/material/flexible_space_bar/flexible_space_bar.0_test.dart',
323323
'examples/api/test/material/chip/deletable_chip_attributes.on_deleted.0_test.dart',
324324
'examples/api/test/material/expansion_panel/expansion_panel_list.expansion_panel_list_radio.0_test.dart',
325-
'examples/api/test/material/scrollbar/scrollbar.1_test.dart',
326325
'examples/api/test/material/search_anchor/search_anchor.0_test.dart',
327326
'examples/api/test/material/search_anchor/search_anchor.1_test.dart',
328327
'examples/api/test/material/search_anchor/search_anchor.2_test.dart',

examples/api/test/material/scrollbar/scrollbar.0_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,22 @@ void main() {
1818

1919
expect(tester.takeException(), isNull);
2020
}, variant: TargetPlatformVariant.all());
21+
22+
testWidgets('The scrollbar should be painted when the user scrolls', (WidgetTester tester) async {
23+
await tester.pumpWidget(
24+
const example.ScrollbarExampleApp(),
25+
);
26+
await tester.pump();
27+
await tester.pump(const Duration(milliseconds: 10)); // Wait for the thumb to start appearing.
28+
29+
expect(find.text('item 0'), findsOne);
30+
expect(find.text('item 9'), findsNothing);
31+
expect(find.byType(Scrollbar), isNot(paints..rect()));
32+
33+
await tester.fling(find.byType(Scrollbar).last, const Offset(0, -300), 10.0);
34+
35+
expect(find.text('item 0'), findsNothing);
36+
expect(find.text('item 9'), findsOne);
37+
expect(find.byType(Scrollbar).last, paints..rect());
38+
});
2139
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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/material/scrollbar/scrollbar.1.dart' as example;
7+
import 'package:flutter_test/flutter_test.dart';
8+
9+
void main() {
10+
testWidgets('The scrollbar thumb should be visible at all time', (WidgetTester tester) async {
11+
await tester.pumpWidget(
12+
const example.ScrollbarExampleApp(),
13+
);
14+
await tester.pump();
15+
await tester.pump(const Duration(milliseconds: 10)); // Wait for the thumb to start appearing.
16+
17+
expect(find.widgetWithText(AppBar, 'Scrollbar Sample'), findsOne);
18+
19+
expect(find.text('item 0'), findsOne);
20+
expect(find.text('item 9'), findsNothing);
21+
expect(find.byType(Scrollbar), paints..rect());
22+
23+
await tester.fling(find.byType(Scrollbar).last, const Offset(0, -300), 10.0);
24+
25+
expect(find.text('item 0'), findsNothing);
26+
expect(find.text('item 9'), findsOne);
27+
expect(find.byType(Scrollbar), paints..rect());
28+
});
29+
}

0 commit comments

Comments
 (0)