scroll_interaction_test.dart 1.25 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 11 12 13 14 15 16 17 18 19
    await tester.pumpWidget(
      new Directionality(
        textDirection: TextDirection.ltr,
        child: new ListView(
          children: <Widget>[
            new Container(height: 100000.0)
          ],
        ),
      ),
    );
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
  });
}