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
5import 'package:flutter/material.dart';
6import 'package:flutter_api_samples/material/scrollbar/scrollbar.0.dart' as example;
7import 'package:flutter_test/flutter_test.dart';
8
9void main() {
10 testWidgets('Scrollbar.0 works well on all platforms', (WidgetTester tester) async {
11 await tester.pumpWidget(const example.ScrollbarExampleApp());
12
13 final Finder buttonFinder = find.byType(Scrollbar);
14 await tester.drag(buttonFinder.last, const Offset(0, 100.0));
15
16 expect(tester.takeException(), isNull);
17 }, variant: TargetPlatformVariant.all());
18
19 testWidgets('The scrollbar should be painted when the user scrolls', (WidgetTester tester) async {
20 await tester.pumpWidget(const example.ScrollbarExampleApp());
21 await tester.pump();
22 await tester.pump(const Duration(milliseconds: 10)); // Wait for the thumb to start appearing.
23
24 expect(find.text('item 0'), findsOne);
25 expect(find.text('item 9'), findsNothing);
26 expect(find.byType(Scrollbar), isNot(paints..rect()));
27
28 await tester.fling(find.byType(Scrollbar).last, const Offset(0, -300), 10.0);
29
30 expect(find.text('item 0'), findsNothing);
31 expect(find.text('item 9'), findsOne);
32 expect(find.byType(Scrollbar).last, paints..rect());
33 });
34}
35