cupertino_scrollbar.1_test.dart 1022 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
// Copyright 2014 The Flutter 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/cupertino.dart';
import 'package:flutter_api_samples/cupertino/scrollbar/cupertino_scrollbar.1.dart' as example;
import 'package:flutter_test/flutter_test.dart';

void main() {
  testWidgets('List view displays CupertinoScrollbar', (WidgetTester tester) async {
    await tester.pumpWidget(
      const example.ScrollbarApp(),
    );

    expect(find.text('Item 0'), findsOneWidget);
    final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(ListView)));
    await gesture.moveBy(const Offset(0.0, -100.0));
    await tester.pumpAndSettle();
    expect(find.text('Item 0'), findsNothing);

    final Finder scrollbar = find.byType(CupertinoScrollbar);
    expect(scrollbar, findsOneWidget);
    expect(tester.getTopLeft(scrollbar).dy, 0.0);
    expect(tester.getBottomLeft(scrollbar).dy, 600.0);
  });
}