|
1 | 1 | import 'package:checks/checks.dart';
|
| 2 | +import 'package:flutter/foundation.dart'; |
2 | 3 | import 'package:flutter/widgets.dart';
|
3 | 4 | import 'package:flutter_test/flutter_test.dart';
|
4 | 5 | import 'package:zulip/widgets/scrolling.dart';
|
@@ -255,6 +256,46 @@ void main() {
|
255 | 256 | // … without moving any farther.
|
256 | 257 | check(position.extentAfter).equals(0);
|
257 | 258 | });
|
| 259 | + |
| 260 | + testWidgets('starting from overscroll, just drift', (tester) async { |
| 261 | + debugDefaultTargetPlatformOverride = TargetPlatform.iOS; |
| 262 | + await prepare(tester, topHeight: 400, bottomHeight: 400); |
| 263 | + |
| 264 | + // Drag into overscroll. |
| 265 | + await tester.drag(findBottom, Offset(0, -100)); |
| 266 | + await tester.pump(); |
| 267 | + final offset1 = position.pixels - position.maxScrollExtent; |
| 268 | + check(offset1).isGreaterThan(100 / 2); |
| 269 | + check(position.activity).isA<BallisticScrollActivity>(); |
| 270 | + |
| 271 | + // Start drifting back into range. |
| 272 | + await tester.pump(Duration(milliseconds: 10)); |
| 273 | + final offset2 = position.pixels - position.maxScrollExtent; |
| 274 | + check(offset2)..isGreaterThan(0.0)..isLessThan(offset1); |
| 275 | + check(position.activity).isA<BallisticScrollActivity>() |
| 276 | + .velocity.isLessThan(0); |
| 277 | + |
| 278 | + // Invoke `scrollToEnd`. The motion should stop… |
| 279 | + position.scrollToEnd(); |
| 280 | + await tester.pump(); |
| 281 | + check(position.pixels - position.maxScrollExtent).equals(offset2); |
| 282 | + check(position.activity).isA<BallisticScrollActivity>() |
| 283 | + .velocity.equals(0); |
| 284 | + |
| 285 | + // … and resume drifting from there… |
| 286 | + await tester.pump(Duration(milliseconds: 10)); |
| 287 | + final offset3 = position.pixels - position.maxScrollExtent; |
| 288 | + check(offset3)..isGreaterThan(0.0)..isLessThan(offset2); |
| 289 | + check(position.activity).isA<BallisticScrollActivity>() |
| 290 | + .velocity.isLessThan(0); |
| 291 | + |
| 292 | + // … to eventually return to being in range. |
| 293 | + await tester.pump(Duration(seconds: 1)); |
| 294 | + check(position.pixels - position.maxScrollExtent).equals(0); |
| 295 | + check(position.activity).isA<IdleScrollActivity>(); |
| 296 | + |
| 297 | + debugDefaultTargetPlatformOverride = null; |
| 298 | + }); |
258 | 299 | });
|
259 | 300 | });
|
260 | 301 | }
|
0 commit comments