scroll_interaction_test.dart 1.24 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/widgets.dart';
6
import 'package:flutter_test/flutter_test.dart';
7 8

void main() {
9
  testWidgets('Scroll flings twice in a row does not crash', (WidgetTester tester) async {
10
    await tester.pumpWidget(
11
      Directionality(
12
        textDirection: TextDirection.ltr,
13
        child: ListView(
14
          children: <Widget>[
15
            Container(height: 100000.0),
16 17 18 19
          ],
        ),
      ),
    );
20

21
    final ScrollableState scrollable =
Adam Barth's avatar
Adam Barth committed
22
      tester.state<ScrollableState>(find.byType(Scrollable));
23

24
    expect(scrollable.position.pixels, equals(0.0));
25

26
    await tester.flingFrom(const Offset(200.0, 300.0), const Offset(0.0, -200.0), 500.0);
27 28
    await tester.pump();
    await tester.pump(const Duration(seconds: 5));
29

30
    expect(scrollable.position.pixels, greaterThan(0.0));
31

32
    final double oldOffset = scrollable.position.pixels;
33

34
    await tester.flingFrom(const Offset(200.0, 300.0), const Offset(0.0, -200.0), 500.0);
35 36
    await tester.pump();
    await tester.pump(const Duration(seconds: 5));
37

38
    expect(scrollable.position.pixels, greaterThan(oldOffset));
39 40
  });
}