Skip to content

Commit 574b7e7

Browse files
Add test for raw_scrollbar.0.dart (#157989)
Contributes to flutter/flutter#130459 It adds a test for - `examples/api/lib/widgets/scrollbar/raw_scrollbar.0.dart`
1 parent ced3e85 commit 574b7e7

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

dev/bots/check_code_samples.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,5 @@ final Set<String> _knownMissingTests = <String>{
316316
'examples/api/test/widgets/scrollbar/raw_scrollbar.2_test.dart',
317317
'examples/api/test/widgets/scrollbar/raw_scrollbar.desktop.0_test.dart',
318318
'examples/api/test/widgets/scrollbar/raw_scrollbar.shape.0_test.dart',
319-
'examples/api/test/widgets/scrollbar/raw_scrollbar.0_test.dart',
320319
'examples/api/test/widgets/interactive_viewer/interactive_viewer.constrained.0_test.dart',
321320
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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

Comments
 (0)