forked from Flutter-Bounty-Hunters/flutter_test_robots
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a WidgetTester extension to drag scroll bars (Resolves Flutter…
- Loading branch information
1 parent
e070688
commit 2ea212d
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:flutter/gestures.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
/// Simulates the user interacting with a Scrollbar. | ||
extension ScrollbarInteractions on WidgetTester { | ||
/// Press a scrollbar thumb at [thumbLocation] and drag it vertically by [delta] pixels. | ||
Future<void> dragScrollbar(Offset thumbLocation, double delta) async { | ||
//Hover to make the thumb visible with a duration long enough to run the fade in animation. | ||
final testPointer = TestPointer(1, PointerDeviceKind.mouse); | ||
|
||
await sendEventToBinding(testPointer.hover(thumbLocation, timeStamp: const Duration(seconds: 1))); | ||
await pumpAndSettle(); | ||
|
||
// Press the thumb. | ||
await sendEventToBinding(testPointer.down(thumbLocation)); | ||
await pump(const Duration(milliseconds: 40)); | ||
|
||
// Move the thumb down. | ||
await sendEventToBinding(testPointer.move(thumbLocation + Offset(0, delta))); | ||
await pump(); | ||
|
||
// Release the pointer. | ||
await sendEventToBinding(testPointer.up()); | ||
await pump(); | ||
} | ||
} |