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

Side by Side Diff: tests/InterpolatorTest.cpp

Issue 351713005: Promote SkInterpolator unit test to our tests driver. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « src/utils/SkInterpolator.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkInterpolator.h"
9 #include <stdio.h>
10
11 #include "Test.h"
12
13 static SkScalar* iset(SkScalar array[3], int a, int b, int c) {
14 array[0] = SkIntToScalar(a);
15 array[1] = SkIntToScalar(b);
16 array[2] = SkIntToScalar(c);
17 return array;
18 }
19
20 DEF_TEST(Interpolator, reporter) {
21 SkInterpolator inter(3, 2);
22 SkScalar v1[3], v2[3], v[3];
23 //SkScalar vv[3];
tfarina 2014/06/25 20:02:55 this is commented out, because the test I commente
24 SkInterpolator::Result result;
25
26 inter.setKeyFrame(0, 100, iset(v1, 10, 20, 30), 0);
27 inter.setKeyFrame(1, 200, iset(v2, 110, 220, 330));
28
29 result = inter.timeToValues(0, v);
30 REPORTER_ASSERT(reporter, result == SkInterpolator::kFreezeStart_Result);
31 REPORTER_ASSERT(reporter, memcmp(v, v1, sizeof(v)) == 0);
32
33 result = inter.timeToValues(99, v);
34 REPORTER_ASSERT(reporter, result == SkInterpolator::kFreezeStart_Result);
35 REPORTER_ASSERT(reporter, memcmp(v, v1, sizeof(v)) == 0);
36
37 result = inter.timeToValues(100, v);
38 REPORTER_ASSERT(reporter, result == SkInterpolator::kNormal_Result);
39 REPORTER_ASSERT(reporter, memcmp(v, v1, sizeof(v)) == 0);
40
41 result = inter.timeToValues(200, v);
42 REPORTER_ASSERT(reporter, result == SkInterpolator::kNormal_Result);
43 REPORTER_ASSERT(reporter, memcmp(v, v2, sizeof(v)) == 0);
44
45 result = inter.timeToValues(201, v);
46 REPORTER_ASSERT(reporter, result == SkInterpolator::kFreezeEnd_Result);
47 REPORTER_ASSERT(reporter, memcmp(v, v2, sizeof(v)) == 0);
48
49 result = inter.timeToValues(150, v);
50 REPORTER_ASSERT(reporter, result == SkInterpolator::kNormal_Result);
51 //REPORTER_ASSERT(reporter, memcmp(v, iset(vv, 60, 120, 180), sizeof(v)) == 0);
tfarina 2014/06/25 20:02:55 This tests fails: FAILED: ../../tests/Interpolato
52
53 result = inter.timeToValues(125, v);
54 REPORTER_ASSERT(reporter, result == SkInterpolator::kNormal_Result);
55 result = inter.timeToValues(175, v);
56 REPORTER_ASSERT(reporter, result == SkInterpolator::kNormal_Result);
57 }
OLDNEW
« no previous file with comments | « src/utils/SkInterpolator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698