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

Side by Side Diff: ui/gfx/interpolated_transform_unittest.cc

Issue 23724024: Refactor TransformPoint{,Reverse}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and resolve conflicts. Created 7 years, 3 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 | « ui/compositor/layer.cc ('k') | ui/gfx/transform.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/interpolated_transform.h" 5 #include "ui/gfx/interpolated_transform.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/rect.h" 9 #include "ui/gfx/rect.h"
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 gfx::Point pivot(100, 100); 83 gfx::Point pivot(100, 100);
84 gfx::Point above_pivot(100, 200); 84 gfx::Point above_pivot(100, 200);
85 ui::InterpolatedRotation rot(0, 90); 85 ui::InterpolatedRotation rot(0, 90);
86 ui::InterpolatedTransformAboutPivot interpolated_xform( 86 ui::InterpolatedTransformAboutPivot interpolated_xform(
87 pivot, 87 pivot,
88 new ui::InterpolatedRotation(0, 90)); 88 new ui::InterpolatedRotation(0, 90));
89 gfx::Transform result = interpolated_xform.Interpolate(0.0f); 89 gfx::Transform result = interpolated_xform.Interpolate(0.0f);
90 CheckApproximatelyEqual(gfx::Transform(), result); 90 CheckApproximatelyEqual(gfx::Transform(), result);
91 result = interpolated_xform.Interpolate(1.0f); 91 result = interpolated_xform.Interpolate(1.0f);
92 gfx::Point expected_result = pivot; 92 gfx::Point expected_result = pivot;
93 result.TransformPoint(pivot); 93 result.TransformPoint(&pivot);
94 EXPECT_EQ(expected_result, pivot); 94 EXPECT_EQ(expected_result, pivot);
95 expected_result = gfx::Point(0, 100); 95 expected_result = gfx::Point(0, 100);
96 result.TransformPoint(above_pivot); 96 result.TransformPoint(&above_pivot);
97 EXPECT_EQ(expected_result, above_pivot); 97 EXPECT_EQ(expected_result, above_pivot);
98 } 98 }
99 99
100 TEST(InterpolatedTransformTest, InterpolatedScaleAboutPivot) { 100 TEST(InterpolatedTransformTest, InterpolatedScaleAboutPivot) {
101 gfx::Point pivot(100, 100); 101 gfx::Point pivot(100, 100);
102 gfx::Point above_pivot(100, 200); 102 gfx::Point above_pivot(100, 200);
103 ui::InterpolatedTransformAboutPivot interpolated_xform( 103 ui::InterpolatedTransformAboutPivot interpolated_xform(
104 pivot, 104 pivot,
105 new ui::InterpolatedScale(gfx::Point3F(1, 1, 1), gfx::Point3F(2, 2, 2))); 105 new ui::InterpolatedScale(gfx::Point3F(1, 1, 1), gfx::Point3F(2, 2, 2)));
106 gfx::Transform result = interpolated_xform.Interpolate(0.0f); 106 gfx::Transform result = interpolated_xform.Interpolate(0.0f);
107 CheckApproximatelyEqual(gfx::Transform(), result); 107 CheckApproximatelyEqual(gfx::Transform(), result);
108 result = interpolated_xform.Interpolate(1.0f); 108 result = interpolated_xform.Interpolate(1.0f);
109 gfx::Point expected_result = pivot; 109 gfx::Point expected_result = pivot;
110 result.TransformPoint(pivot); 110 result.TransformPoint(&pivot);
111 EXPECT_EQ(expected_result, pivot); 111 EXPECT_EQ(expected_result, pivot);
112 expected_result = gfx::Point(100, 300); 112 expected_result = gfx::Point(100, 300);
113 result.TransformPoint(above_pivot); 113 result.TransformPoint(&above_pivot);
114 EXPECT_EQ(expected_result, above_pivot); 114 EXPECT_EQ(expected_result, above_pivot);
115 } 115 }
116 116
117 ui::InterpolatedTransform* GetScreenRotation(int degrees, bool reversed) { 117 ui::InterpolatedTransform* GetScreenRotation(int degrees, bool reversed) {
118 gfx::Point old_pivot; 118 gfx::Point old_pivot;
119 gfx::Point new_pivot; 119 gfx::Point new_pivot;
120 120
121 int width = 1920; 121 int width = 1920;
122 int height = 180; 122 int height = 180;
123 123
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 gfx::Transform interpolated = maximize->Interpolate(1.0f); 225 gfx::Transform interpolated = maximize->Interpolate(1.0f);
226 SkMatrix44& m = interpolated.matrix(); 226 SkMatrix44& m = interpolated.matrix();
227 // Upper-left 3x3 matrix should all be 0, 1 or -1. 227 // Upper-left 3x3 matrix should all be 0, 1 or -1.
228 for (int row = 0; row < 3; ++row) { 228 for (int row = 0; row < 3; ++row) {
229 for (int col = 0; col < 3; ++col) { 229 for (int col = 0; col < 3; ++col) {
230 float entry = m.get(row, col); 230 float entry = m.get(row, col);
231 EXPECT_TRUE(entry == 0 || entry == 1 || entry == -1); 231 EXPECT_TRUE(entry == 0 || entry == 1 || entry == -1);
232 } 232 }
233 } 233 }
234 } 234 }
OLDNEW
« no previous file with comments | « ui/compositor/layer.cc ('k') | ui/gfx/transform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698