Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "cc/proto/gfx_conversions.h" | 5 #include "cc/proto/gfx_conversions.h" |
| 6 | 6 |
| 7 #include "cc/proto/point.pb.h" | 7 #include "cc/proto/point.pb.h" |
| 8 #include "cc/proto/pointf.pb.h" | 8 #include "cc/proto/pointf.pb.h" |
| 9 #include "cc/proto/rect.pb.h" | 9 #include "cc/proto/rect.pb.h" |
| 10 #include "cc/proto/rectf.pb.h" | 10 #include "cc/proto/rectf.pb.h" |
| 11 #include "cc/proto/scroll_offset.pb.h" | |
| 11 #include "cc/proto/size.pb.h" | 12 #include "cc/proto/size.pb.h" |
| 12 #include "cc/proto/sizef.pb.h" | 13 #include "cc/proto/sizef.pb.h" |
| 13 #include "cc/proto/transform.pb.h" | 14 #include "cc/proto/transform.pb.h" |
| 15 #include "cc/proto/vector2df.pb.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/gfx/geometry/point.h" | 17 #include "ui/gfx/geometry/point.h" |
| 16 #include "ui/gfx/geometry/point_f.h" | 18 #include "ui/gfx/geometry/point_f.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| 18 #include "ui/gfx/geometry/rect_f.h" | 20 #include "ui/gfx/geometry/rect_f.h" |
| 21 #include "ui/gfx/geometry/scroll_offset.h" | |
| 19 #include "ui/gfx/geometry/size.h" | 22 #include "ui/gfx/geometry/size.h" |
| 20 #include "ui/gfx/geometry/size_f.h" | 23 #include "ui/gfx/geometry/size_f.h" |
| 24 #include "ui/gfx/geometry/vector2d_f.h" | |
| 21 #include "ui/gfx/transform.h" | 25 #include "ui/gfx/transform.h" |
| 22 | 26 |
| 23 namespace cc { | 27 namespace cc { |
| 24 namespace { | 28 namespace { |
| 25 | 29 |
| 26 TEST(GfxProtoConversionsTest, IntSerializationLimits) { | 30 TEST(GfxProtoConversionsTest, IntSerializationLimits) { |
| 27 // Test Point with the minimum int value. | 31 // Test Point with the minimum int value. |
| 28 { | 32 { |
| 29 gfx::Point point(std::numeric_limits<int>::min(), | 33 gfx::Point point(std::numeric_limits<int>::min(), |
| 30 std::numeric_limits<int>::min()); | 34 std::numeric_limits<int>::min()); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 EXPECT_EQ(transform.matrix().get(2, 3), proto.matrix(11)); | 170 EXPECT_EQ(transform.matrix().get(2, 3), proto.matrix(11)); |
| 167 EXPECT_EQ(transform.matrix().get(3, 0), proto.matrix(12)); | 171 EXPECT_EQ(transform.matrix().get(3, 0), proto.matrix(12)); |
| 168 EXPECT_EQ(transform.matrix().get(3, 1), proto.matrix(13)); | 172 EXPECT_EQ(transform.matrix().get(3, 1), proto.matrix(13)); |
| 169 EXPECT_EQ(transform.matrix().get(3, 2), proto.matrix(14)); | 173 EXPECT_EQ(transform.matrix().get(3, 2), proto.matrix(14)); |
| 170 EXPECT_EQ(transform.matrix().get(3, 3), proto.matrix(15)); | 174 EXPECT_EQ(transform.matrix().get(3, 3), proto.matrix(15)); |
| 171 | 175 |
| 172 // Test ProtoToTransform | 176 // Test ProtoToTransform |
| 173 EXPECT_EQ(transform, ProtoToTransform(proto)); | 177 EXPECT_EQ(transform, ProtoToTransform(proto)); |
| 174 } | 178 } |
| 175 | 179 |
| 180 TEST(GfxProtoConversionsTest, SerializeDeserializeVector2dF) { | |
| 181 const gfx::Vector2dF vector(5.1f, 10.2f); | |
|
vmpstr
2015/11/24 19:32:33
Can you add a few more random things? Maybe some n
Khushal
2015/11/24 22:22:40
Done.
| |
| 182 | |
| 183 // Test Vector2dFToProto | |
| 184 proto::Vector2dF proto; | |
| 185 Vector2dFToProto(vector, &proto); | |
| 186 EXPECT_EQ(vector.x(), proto.x()); | |
| 187 EXPECT_EQ(vector.y(), proto.y()); | |
| 188 | |
| 189 // Test ProtoToVector2dF | |
| 190 EXPECT_EQ(vector, ProtoToVector2dF(proto)); | |
| 191 } | |
| 192 | |
| 193 TEST(GfxProtoConversionsTest, SerializeDeserializeScrollOffset) { | |
| 194 const gfx::ScrollOffset scroll_offset(5.1f, 10.2f); | |
|
vmpstr
2015/11/24 19:32:33
Same here.
Khushal
2015/11/24 22:22:40
Done.
| |
| 195 | |
| 196 // Test ScrollOffsetToProto | |
| 197 proto::ScrollOffset proto; | |
| 198 ScrollOffsetToProto(scroll_offset, &proto); | |
| 199 EXPECT_EQ(scroll_offset.x(), proto.x()); | |
| 200 EXPECT_EQ(scroll_offset.y(), proto.y()); | |
| 201 | |
| 202 // Test ProtoToScrollOffset | |
| 203 EXPECT_EQ(scroll_offset, ProtoToScrollOffset(proto)); | |
| 204 } | |
| 205 | |
| 176 } // namespace | 206 } // namespace |
| 177 } // namespace cc | 207 } // namespace cc |
| OLD | NEW |