scrollbar_paint_test.dart 1.44 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
// Copyright 2016 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/material.dart';

import '../rendering/mock_canvas.dart';

void main() {
11 12 13 14 15 16 17
  testWidgets('Viewport basic test (LTR)', (WidgetTester tester) async {
    await tester.pumpWidget(new Directionality(
      textDirection: TextDirection.ltr,
      child: new Scrollbar(
        child: new SingleChildScrollView(
          child: const SizedBox(width: 4000.0, height: 4000.0),
        ),
18 19
      ),
    ));
20
    expect(find.byType(Scrollbar), isNot(paints..rect()));
21
    await tester.fling(find.byType(SingleChildScrollView), const Offset(0.0, -10.0), 10.0);
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    expect(find.byType(Scrollbar), paints..rect(rect: new Rect.fromLTRB(800.0 - 6.0, 1.5, 800.0, 91.5)));
  });

  testWidgets('Viewport basic test (RTL)', (WidgetTester tester) async {
    await tester.pumpWidget(new Directionality(
      textDirection: TextDirection.rtl,
      child: new Scrollbar(
        child: new SingleChildScrollView(
          child: const SizedBox(width: 4000.0, height: 4000.0),
        ),
      ),
    ));
    expect(find.byType(Scrollbar), isNot(paints..rect()));
    await tester.fling(find.byType(SingleChildScrollView), const Offset(0.0, -10.0), 10.0);
    expect(find.byType(Scrollbar), paints..rect(rect: new Rect.fromLTRB(0.0, 1.5, 6.0, 91.5)));
37 38
  });
}