ink_paint_test.dart 1.76 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
// Copyright 2017 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/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';

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

void main() {
  testWidgets('Does the ink widget render a border radius', (WidgetTester tester) async {
13 14
    final Color highlightColor = const Color(0xAAFF0000);
    final Color splashColor = const Color(0xAA0000FF);
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
    final BorderRadius borderRadius = new BorderRadius.circular(6.0);

    await tester.pumpWidget(
      new Material(
        child: new Center(
          child: new Container(
            width: 200.0,
            height: 60.0,
            child: new InkWell(
              borderRadius: borderRadius,
              highlightColor: highlightColor,
              splashColor: splashColor,
              onTap: () { },
            ),
          ),
        ),
      ),
    );

34
    final Offset center = tester.getCenter(find.byType(InkWell));
35 36
    final TestGesture gesture = await tester.startGesture(center);
    await tester.pump(); // start gesture
37
    await tester.pump(const Duration(milliseconds: 200)); // wait for splash to be well under way
38

39
    final RenderBox box = Material.of(tester.element(find.byType(InkWell))) as dynamic;
40 41 42
    expect(
      box,
      paints
43
        ..clipRRect(rrect: new RRect.fromLTRBR(300.0, 270.0, 500.0, 330.0, const Radius.circular(6.0)))
44 45
        ..circle(x: 400.0, y: 300.0, radius: 21.0, color: splashColor)
        ..rrect(
46
          rrect: new RRect.fromLTRBR(300.0, 270.0, 500.0, 330.0, const Radius.circular(6.0)),
47 48 49 50 51 52 53
          color: highlightColor,
        )
    );

    await gesture.up();
  });
}