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

Side by Side Diff: ui/gfx/geometry/mojo/geometry_struct_traits_unittest.cc

Issue 2033583002: Implement gfx::Vector2d and gfx::Vector2dF StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary deps Created 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "mojo/public/cpp/bindings/binding_set.h" 6 #include "mojo/public/cpp/bindings/binding_set.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gfx/geometry/mojo/geometry_traits_test_service.mojom.h" 8 #include "ui/gfx/geometry/mojo/geometry_traits_test_service.mojom.h"
9 #include "ui/gfx/geometry/point.h" 9 #include "ui/gfx/geometry/point.h"
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 void EchoInsets(const Insets& i, 52 void EchoInsets(const Insets& i,
53 const EchoInsetsCallback& callback) override { 53 const EchoInsetsCallback& callback) override {
54 callback.Run(i); 54 callback.Run(i);
55 } 55 }
56 56
57 void EchoInsetsF(const InsetsF& i, 57 void EchoInsetsF(const InsetsF& i,
58 const EchoInsetsFCallback& callback) override { 58 const EchoInsetsFCallback& callback) override {
59 callback.Run(i); 59 callback.Run(i);
60 } 60 }
61 61
62 void EchoVector2d(const Vector2d& v,
63 const EchoVector2dCallback& callback) override {
64 callback.Run(v);
65 }
66
67 void EchoVector2dF(const Vector2dF& v,
68 const EchoVector2dFCallback& callback) override {
69 callback.Run(v);
70 }
71
62 base::MessageLoop loop_; 72 base::MessageLoop loop_;
63 mojo::BindingSet<GeometryTraitsTestService> traits_test_bindings_; 73 mojo::BindingSet<GeometryTraitsTestService> traits_test_bindings_;
64 74
65 DISALLOW_COPY_AND_ASSIGN(GeometryStructTraitsTest); 75 DISALLOW_COPY_AND_ASSIGN(GeometryStructTraitsTest);
66 }; 76 };
67 77
68 } // namespace 78 } // namespace
69 79
70 TEST_F(GeometryStructTraitsTest, Point) { 80 TEST_F(GeometryStructTraitsTest, Point) {
71 const int32_t x = 1234; 81 const int32_t x = 1234;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 gfx::InsetsF input(top, left, bottom, right); 174 gfx::InsetsF input(top, left, bottom, right);
165 mojom::GeometryTraitsTestServicePtr proxy = GetTraitsTestProxy(); 175 mojom::GeometryTraitsTestServicePtr proxy = GetTraitsTestProxy();
166 gfx::InsetsF output; 176 gfx::InsetsF output;
167 proxy->EchoInsetsF(input, &output); 177 proxy->EchoInsetsF(input, &output);
168 EXPECT_EQ(top, output.top()); 178 EXPECT_EQ(top, output.top());
169 EXPECT_EQ(left, output.left()); 179 EXPECT_EQ(left, output.left());
170 EXPECT_EQ(bottom, output.bottom()); 180 EXPECT_EQ(bottom, output.bottom());
171 EXPECT_EQ(right, output.right()); 181 EXPECT_EQ(right, output.right());
172 } 182 }
173 183
184 TEST_F(GeometryStructTraitsTest, Vector2d) {
185 const int32_t x = 1234;
186 const int32_t y = -5678;
187 gfx::Vector2d input(x, y);
188 mojom::GeometryTraitsTestServicePtr proxy = GetTraitsTestProxy();
189 gfx::Vector2d output;
190 proxy->EchoVector2d(input, &output);
191 EXPECT_EQ(x, output.x());
192 EXPECT_EQ(y, output.y());
193 }
194
195 TEST_F(GeometryStructTraitsTest, Vector2dF) {
196 const float x = 1234.5f;
197 const float y = 6789.6f;
198 gfx::Vector2dF input(x, y);
199 mojom::GeometryTraitsTestServicePtr proxy = GetTraitsTestProxy();
200 gfx::Vector2dF output;
201 proxy->EchoVector2dF(input, &output);
202 EXPECT_EQ(x, output.x());
203 EXPECT_EQ(y, output.y());
204 }
205
174 } // namespace gfx 206 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/mojo/geometry_struct_traits.h ('k') | ui/gfx/geometry/mojo/geometry_traits_test_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698