scroll_interaction_test.dart 1.12 KB
Newer Older
1 2 3 4 5 6 7 8
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';

void main() {
9
  testWidgets('Scroll flings twice in a row does not crash', (WidgetTester tester) async {
10
    await tester.pumpWidget(new ListView(
11 12 13 14
      children: <Widget>[
        new Container(height: 100000.0)
      ]
    ));
15

Adam Barth's avatar
Adam Barth committed
16 17
    ScrollableState scrollable =
      tester.state<ScrollableState>(find.byType(Scrollable));
18

19
    expect(scrollable.position.pixels, equals(0.0));
20

21
    await tester.flingFrom(const Point(200.0, 300.0), const Offset(0.0, -200.0), 500.0);
22 23
    await tester.pump();
    await tester.pump(const Duration(seconds: 5));
24

25
    expect(scrollable.position.pixels, greaterThan(0.0));
26

27
    double oldOffset = scrollable.position.pixels;
28

29
    await tester.flingFrom(const Point(200.0, 300.0), const Offset(0.0, -200.0), 500.0);
30 31
    await tester.pump();
    await tester.pump(const Duration(seconds: 5));
32

33
    expect(scrollable.position.pixels, greaterThan(oldOffset));
34 35
  });
}