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