implicit_animations_test.dart 1.89 KB
Newer Older
1 2 3 4 5 6 7 8 9
// 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/widgets.dart';

void main() {
  testWidgets('BoxConstraintsTween control test', (WidgetTester tester) async {
10
    final BoxConstraintsTween tween = new BoxConstraintsTween(
11 12
      begin: new BoxConstraints.tight(const Size(20.0, 50.0)),
      end: new BoxConstraints.tight(const Size(10.0, 30.0))
13
    );
14
    final BoxConstraints result = tween.lerp(0.25);
15 16 17 18 19 20 21
    expect(result.minWidth, 17.5);
    expect(result.maxWidth, 17.5);
    expect(result.minHeight, 45.0);
    expect(result.maxHeight, 45.0);
  });

  testWidgets('DecorationTween control test', (WidgetTester tester) async {
22
    final DecorationTween tween = new DecorationTween(
23 24
      begin: const BoxDecoration(color: const Color(0xFF00FF00)),
      end: const BoxDecoration(color: const Color(0xFFFFFF00))
25
    );
26
    final BoxDecoration result = tween.lerp(0.25);
27
    expect(result.color, const Color(0xFF3FFF00));
28 29 30
  });

  testWidgets('EdgeInsetsTween control test', (WidgetTester tester) async {
31
    final EdgeInsetsTween tween = new EdgeInsetsTween(
32 33
      begin: const EdgeInsets.symmetric(vertical: 50.0),
      end: const EdgeInsets.only(top: 10.0, bottom: 30.0)
34
    );
35
    final EdgeInsets result = tween.lerp(0.25);
36 37 38 39 40 41 42
    expect(result.left, 0.0);
    expect(result.right, 0.0);
    expect(result.top, 40.0);
    expect(result.bottom, 45.0);
  });

  testWidgets('Matrix4Tween control test', (WidgetTester tester) async {
43
    final Matrix4Tween tween = new Matrix4Tween(
44 45 46
      begin: new Matrix4.translationValues(10.0, 20.0, 30.0),
      end: new Matrix4.translationValues(14.0, 24.0, 34.0)
    );
47
    final Matrix4 result = tween.lerp(0.25);
48 49 50
    expect(result, equals(new Matrix4.translationValues(11.0, 21.0, 31.0)));
  });
}