Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: packages/charted/test.disabled/interpolators/easing_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style
5 * license that can be found in the LICENSE file or at
6 * https://developers.google.com/open-source/licenses/bsd
7 */
8
9 part of charted.test.interpolators;
10
11 testEasing() {
12 test('easeClamp clamps function returned value to [0, 1]', () {
13 EasingFn f = (t) => t;
14 EasingFn clampedFn = clampEasingFn(f);
15 expect(clampedFn(-1), equals(0));
16 expect(clampedFn(0), equals(0));
17 expect(clampedFn(0.5), equals(0.5));
18 expect(clampedFn(1), equals(1));
19 expect(clampedFn(1.5), equals(1));
20 });
21
22 test('easeReverse returns the reversed ease function of parameter', () {
23 EasingFn f = (t) => t * t;
24 EasingFn reversedFn = reverseEasingFn(f);
25 expect(reversedFn(0), equals(0));
26 expect(reversedFn(0.5), equals(0.75));
27 expect(reversedFn(1), equals(1));
28 });
29
30 test('easeReflect returns the reflected ease function of parameter', () {
31 EasingFn f = (t) => t * t;
32 EasingFn reflectedFn = reflectEasingFn(f);
33 expect(reflectedFn(0), equals(0));
34 expect(reflectedFn(0.25), equals(0.125));
35 expect(reflectedFn(0.5), equals(0.5));
36 expect(reflectedFn(0.75), equals(0.875));
37 expect(reflectedFn(1), equals(1));
38 });
39
40 test('easePoly returns the pow ease function', () {
41 EasingFn fn = easePoly(3);
42 expect(fn(0), equals(0));
43 expect(fn(0.5), equals(0.125));
44 expect(fn(1), equals(1));
45 });
46
47 test('easeCubicInOut returns the in-out ease function', () {
48 EasingFn fn = easeCubicInOut();
49 expect(fn(0), equals(0));
50 expect(fn(0.25), equals(0.0625));
51 expect(fn(0.5), equals(0.5));
52 expect(fn(0.75), equals(0.9375));
53 expect(fn(1), equals(1));
54 });
55
56 test('easeSin returns the sin ease function', () {
57 EasingFn fn = easeSin();
58 expect(fn(0), equals(0));
59 expect(fn(2 / 3), closeTo(0.5, EPSILON));
60 expect(fn(1), closeTo(1, EPSILON));
61 });
62
63 test('easeExp returns the sin ease function', () {
64 EasingFn fn = easeExp();
65 expect(fn(0), equals(0.0009765625));
66 expect(fn(0.5), equals(0.03125));
67 expect(fn(1), equals(1));
68 });
69
70 test('easeCircle returns the sin ease function', () {
71 EasingFn fn = easeCircle();
72 expect(fn(0), equals(0));
73 expect(fn(0.5), closeTo(0.1339745962155614, EPSILON));
74 expect(fn(1), equals(1));
75 });
76
77 test('easeElastic returns an elastic ease function', () {
78 EasingFn fn = easeElastic();
79 expect(fn(0), closeTo(0.7966042495754591, EPSILON));
80 expect(fn(0.25), closeTo(1.0929845855896863, EPSILON));
81 expect(fn(0.5), closeTo(0.9754637077195417, EPSILON));
82 expect(fn(0.75), closeTo(1.0052459611883011, EPSILON));
83 expect(fn(1), closeTo(0.9990238855152622, EPSILON));
84 });
85
86 test('easeBack returns a back ease function', () {
87 EasingFn fn = easeBack();
88 expect(fn(0), closeTo(0, EPSILON));
89 expect(fn(0.25), closeTo(-0.06413656250000001, EPSILON));
90 expect(fn(0.5), closeTo(-0.08769750000000004, EPSILON));
91 expect(fn(0.75), closeTo(0.1825903124999999, EPSILON));
92 expect(fn(1), closeTo(1, EPSILON));
93 });
94
95 test('easeBounce returns a bounce ease function', () {
96 EasingFn fn = easeBounce();
97 expect(fn(0), closeTo(0, EPSILON));
98 expect(fn(0.1), closeTo(0.075625, EPSILON));
99 expect(fn(0.2), closeTo(0.3025, EPSILON));
100 expect(fn(0.3), closeTo(0.680625, EPSILON));
101 expect(fn(0.4), closeTo(0.91, EPSILON));
102 expect(fn(0.5), closeTo(0.765625, EPSILON));
103 expect(fn(0.6), closeTo(0.7725, EPSILON));
104 expect(fn(0.7), closeTo(0.930625, EPSILON));
105 expect(fn(0.8), closeTo(0.94, EPSILON));
106 expect(fn(0.9), closeTo(0.988125, EPSILON));
107 expect(fn(1), closeTo(1, EPSILON));
108 });
109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698