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/gestures.dart';
6import 'package:flutter/material.dart';
7import 'package:flutter_api_samples/widgets/scrollbar/raw_scrollbar.0.dart' as example;
8import 'package:flutter_test/flutter_test.dart';
9
10void main() {
11 testWidgets('There are two scrollbars', (WidgetTester tester) async {
12 await tester.pumpWidget(const example.RawScrollbarExampleApp());
13
14 expect(find.widgetWithText(AppBar, 'RawScrollbar Sample'), findsOne);
15 expect(find.byType(Scrollbar), findsExactly(2));
16
17 expect(find.text('Scrollable 1 : Index 0'), findsOne);
18 expect(find.text('Scrollable 2 : Index 0'), findsOne);
19
20 final TestPointer pointer = TestPointer(1, PointerDeviceKind.mouse);
21 pointer.hover(tester.getCenter(find.byType(ListView).first));
22 await tester.sendEventToBinding(pointer.scroll(const Offset(0.0, 1000)));
23 await tester.pumpAndSettle();
24
25 expect(find.text('Scrollable 1 : Index 40'), findsOne);
26 expect(find.text('Scrollable 2 : Index 0'), findsOne);
27
28 pointer.hover(tester.getCenter(find.byType(ListView).last));
29 await tester.sendEventToBinding(pointer.scroll(const Offset(0.0, 1000)));
30 await tester.pumpAndSettle();
31
32 expect(find.text('Scrollable 1 : Index 40'), findsOne);
33 expect(find.text('Scrollable 2 : Index 20'), findsOne);
34 });
35}
36