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

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

Issue 694743002: Fix folder icon animation in app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@launcher_page_api_do_actual_thing
Patch Set: Created 6 years, 1 month 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
« ui/gfx/transform_util.cc ('K') | « ui/gfx/transform_util.cc ('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
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/transform_util.h" 5 #include "ui/gfx/transform_util.h"
6 6
7 #include "base/logging.h"
Matt Giuca 2014/11/04 01:05:18 Don't think you need this.
calamity 2014/11/04 01:40:30 Done.
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gfx/point.h" 9 #include "ui/gfx/point.h"
9 #include "ui/gfx/point3_f.h" 10 #include "ui/gfx/point3_f.h"
10 #include "ui/gfx/rect.h" 11 #include "ui/gfx/rect.h"
11 12
12 namespace gfx { 13 namespace gfx {
13 namespace { 14 namespace {
14 15
15 TEST(TransformUtilTest, GetScaleTransform) { 16 TEST(TransformUtilTest, GetScaleTransform) {
16 const Point kAnchor(20, 40); 17 const Point kAnchor(20, 40);
17 const float kScale = 0.5f; 18 const float kScale = 0.5f;
18 19
19 Transform scale = GetScaleTransform(kAnchor, kScale); 20 Transform scale = GetScaleTransform(kAnchor, kScale);
20 21
21 const int kOffset = 10; 22 const int kOffset = 10;
22 for (int sign_x = -1; sign_x <= 1; ++sign_x) { 23 for (int sign_x = -1; sign_x <= 1; ++sign_x) {
23 for (int sign_y = -1; sign_y <= 1; ++sign_y) { 24 for (int sign_y = -1; sign_y <= 1; ++sign_y) {
24 Point test(kAnchor.x() + sign_x * kOffset, 25 Point test(kAnchor.x() + sign_x * kOffset,
25 kAnchor.y() + sign_y * kOffset); 26 kAnchor.y() + sign_y * kOffset);
26 scale.TransformPoint(&test); 27 scale.TransformPoint(&test);
27 28
28 EXPECT_EQ(Point(kAnchor.x() + sign_x * kOffset * kScale, 29 EXPECT_EQ(Point(kAnchor.x() + sign_x * kOffset * kScale,
29 kAnchor.y() + sign_y * kOffset * kScale), 30 kAnchor.y() + sign_y * kOffset * kScale),
30 test); 31 test);
31 } 32 }
32 } 33 }
33 } 34 }
34 35
36 TEST(TransformUtilTest, GetRectTransform) {
Matt Giuca 2014/11/04 01:05:18 Good test.
37 gfx::Rect from(20, 40, 40, 40);
38 gfx::Rect to(-10, 20, 80, 20);
39
40 Transform transform = GetRectTransform(from, to);
41
42 std::vector<std::pair<gfx::Point, gfx::Point> > test_data;
43 test_data.push_back(std::make_pair(from.origin(), to.origin()));
44 test_data.push_back(std::make_pair(from.bottom_right(), to.bottom_right()));
45 test_data.push_back(std::make_pair(from.CenterPoint(), to.CenterPoint()));
46
47 for (const auto& data : test_data) {
48 Point test = data.first;
49 transform.TransformPoint(&test);
50 EXPECT_EQ(data.second, test);
51 }
52 }
53
35 TEST(TransformUtilTest, SnapRotation) { 54 TEST(TransformUtilTest, SnapRotation) {
36 Transform result(Transform::kSkipInitialization); 55 Transform result(Transform::kSkipInitialization);
37 Transform transform; 56 Transform transform;
38 transform.RotateAboutZAxis(89.99); 57 transform.RotateAboutZAxis(89.99);
39 58
40 Rect viewport(1920, 1200); 59 Rect viewport(1920, 1200);
41 bool snapped = SnapTransform(&result, transform, viewport); 60 bool snapped = SnapTransform(&result, transform, viewport);
42 61
43 EXPECT_TRUE(snapped) << "Viewport should snap for this rotation."; 62 EXPECT_TRUE(snapped) << "Viewport should snap for this rotation.";
44 } 63 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 transform.Translate3d(SkDoubleToMScalar(30.5), SkDoubleToMScalar(20.0), 190 transform.Translate3d(SkDoubleToMScalar(30.5), SkDoubleToMScalar(20.0),
172 SkDoubleToMScalar(10.1)); 191 SkDoubleToMScalar(10.1));
173 transform.SkewX(20.0); 192 transform.SkewX(20.0);
174 Rect viewport(1920, 1200); 193 Rect viewport(1920, 1200);
175 bool snapped = SnapTransform(&result, transform, viewport); 194 bool snapped = SnapTransform(&result, transform, viewport);
176 EXPECT_FALSE(snapped) << "Skewed viewport should not snap."; 195 EXPECT_FALSE(snapped) << "Skewed viewport should not snap.";
177 } 196 }
178 197
179 } // namespace 198 } // namespace
180 } // namespace gfx 199 } // namespace gfx
OLDNEW
« ui/gfx/transform_util.cc ('K') | « ui/gfx/transform_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698