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

Side by Side Diff: ui/gfx/geometry/axis_transform2d_unittest.cc

Issue 2563743004: [3/5] Add translated rasterization support for RasterBuffer & below (Closed)
Patch Set: rebase & fix last nits Created 3 years, 8 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/gfx/geometry/axis_transform2d.cc ('k') | ui/gfx/test/gfx_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/gfx/geometry/axis_transform2d.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gfx/test/gfx_util.h"
9
10 namespace gfx {
11 namespace {
12
13 TEST(AxisTransform2dTest, Mapping) {
14 AxisTransform2d t(1.25f, Vector2dF(3.75f, 55.f));
15
16 PointF p(150.f, 100.f);
17 EXPECT_EQ(PointF(191.25f, 180.f), t.MapPoint(p));
18 EXPECT_POINTF_EQ(PointF(117.f, 36.f), t.InverseMapPoint(p));
19
20 RectF r(150.f, 100.f, 22.5f, 37.5f);
21 EXPECT_EQ(RectF(191.25f, 180.f, 28.125f, 46.875f), t.MapRect(r));
22 EXPECT_RECTF_EQ(RectF(117.f, 36.f, 18.f, 30.f), t.InverseMapRect(r));
23 }
24
25 TEST(AxisTransform2dTest, Scaling) {
26 {
27 AxisTransform2d t(1.25f, Vector2dF(3.75f, 55.f));
28 EXPECT_EQ(AxisTransform2d(1.5625f, Vector2dF(3.75f, 55.f)),
29 PreScaleAxisTransform2d(t, 1.25));
30 t.PreScale(1.25);
31 EXPECT_EQ(AxisTransform2d(1.5625f, Vector2dF(3.75f, 55.f)), t);
32 }
33
34 {
35 AxisTransform2d t(1.25f, Vector2dF(3.75f, 55.f));
36 EXPECT_EQ(AxisTransform2d(1.5625f, Vector2dF(4.6875f, 68.75f)),
37 PostScaleAxisTransform2d(t, 1.25));
38 t.PostScale(1.25);
39 EXPECT_EQ(AxisTransform2d(1.5625f, Vector2dF(4.6875f, 68.75f)), t);
40 }
41 }
42
43 TEST(AxisTransform2dTest, Translating) {
44 Vector2dF tr(3.f, -5.f);
45 {
46 AxisTransform2d t(1.25f, Vector2dF(3.75f, 55.f));
47 EXPECT_EQ(AxisTransform2d(1.25f, Vector2dF(7.5f, 48.75f)),
48 PreTranslateAxisTransform2d(t, tr));
49 t.PreTranslate(tr);
50 EXPECT_EQ(AxisTransform2d(1.25f, Vector2dF(7.5f, 48.75f)), t);
51 }
52
53 {
54 AxisTransform2d t(1.25f, Vector2dF(3.75f, 55.f));
55 EXPECT_EQ(AxisTransform2d(1.25f, Vector2dF(6.75f, 50.f)),
56 PostTranslateAxisTransform2d(t, tr));
57 t.PostTranslate(tr);
58 EXPECT_EQ(AxisTransform2d(1.25f, Vector2dF(6.75f, 50.f)), t);
59 }
60 }
61
62 TEST(AxisTransform2dTest, Concat) {
63 AxisTransform2d pre(1.25f, Vector2dF(3.75f, 55.f));
64 AxisTransform2d post(0.5f, Vector2dF(10.f, 5.f));
65 AxisTransform2d expectation(0.625f, Vector2dF(11.875f, 32.5f));
66 EXPECT_EQ(expectation, ConcatAxisTransform2d(post, pre));
67
68 AxisTransform2d post_concat = pre;
69 post_concat.PostConcat(post);
70 EXPECT_EQ(expectation, post_concat);
71
72 AxisTransform2d pre_concat = post;
73 pre_concat.PreConcat(pre);
74 EXPECT_EQ(expectation, pre_concat);
75 }
76
77 TEST(AxisTransform2dTest, Inverse) {
78 AxisTransform2d t(1.25f, Vector2dF(3.75f, 55.f));
79 AxisTransform2d inv_inplace = t;
80 inv_inplace.Invert();
81 AxisTransform2d inv_out_of_place = InvertAxisTransform2d(t);
82
83 EXPECT_AXIS_TRANSFORM2D_EQ(inv_inplace, inv_out_of_place);
84 EXPECT_AXIS_TRANSFORM2D_EQ(AxisTransform2d(),
85 ConcatAxisTransform2d(t, inv_inplace));
86 EXPECT_AXIS_TRANSFORM2D_EQ(AxisTransform2d(),
87 ConcatAxisTransform2d(inv_inplace, t));
88 }
89
90 } // namespace
91 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/axis_transform2d.cc ('k') | ui/gfx/test/gfx_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698