| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/proto/cc_conversions.h" | |
| 6 | |
| 7 #include "cc/base/region.h" | |
| 8 #include "cc/proto/region.pb.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 #include "ui/gfx/geometry/rect.h" | |
| 11 | |
| 12 namespace cc { | |
| 13 namespace { | |
| 14 | |
| 15 void VerifySerializeAndDeserializeProto(const Region& region1) { | |
| 16 proto::Region proto; | |
| 17 RegionToProto(region1, &proto); | |
| 18 Region region2 = RegionFromProto(proto); | |
| 19 EXPECT_EQ(region1, region2); | |
| 20 } | |
| 21 | |
| 22 TEST(RegionTest, SingleRectProtoConversion) { | |
| 23 Region region(gfx::Rect(14, 15, 16, 17)); | |
| 24 VerifySerializeAndDeserializeProto(region); | |
| 25 } | |
| 26 | |
| 27 TEST(RegionTest, MultipleRectProtoConversion) { | |
| 28 Region region(gfx::Rect(0, 0, 1, 1)); | |
| 29 region.Union(gfx::Rect(9, 0, 1, 1)); | |
| 30 region.Union(gfx::Rect(0, 9, 1, 1)); | |
| 31 region.Union(gfx::Rect(9, 9, 1, 1)); | |
| 32 VerifySerializeAndDeserializeProto(region); | |
| 33 } | |
| 34 | |
| 35 TEST(RegionTest, OverlappingRectIntersectProtoConversion) { | |
| 36 Region region(gfx::Rect(0, 0, 10, 10)); | |
| 37 region.Intersect(gfx::Rect(5, 5, 10, 10)); | |
| 38 VerifySerializeAndDeserializeProto(region); | |
| 39 } | |
| 40 | |
| 41 TEST(RegionTest, OverlappingRectUnionProtoConversion) { | |
| 42 Region region(gfx::Rect(0, 0, 10, 10)); | |
| 43 region.Union(gfx::Rect(5, 5, 10, 10)); | |
| 44 VerifySerializeAndDeserializeProto(region); | |
| 45 } | |
| 46 | |
| 47 TEST(RegionTest, OverlappingRectSubtractProtoConversion) { | |
| 48 Region region(gfx::Rect(0, 0, 10, 10)); | |
| 49 region.Subtract(gfx::Rect(5, 5, 1, 1)); | |
| 50 VerifySerializeAndDeserializeProto(region); | |
| 51 } | |
| 52 | |
| 53 TEST(ScrollbarOrientationTest, ScrollbarOrientationToProtoConversion) { | |
| 54 ASSERT_NE(ScrollbarOrientation::HORIZONTAL, ScrollbarOrientation::VERTICAL); | |
| 55 ScrollbarOrientation orientation = ScrollbarOrientation::HORIZONTAL; | |
| 56 EXPECT_EQ(orientation, ScrollbarOrientationFromProto( | |
| 57 ScrollbarOrientationToProto(orientation))); | |
| 58 | |
| 59 orientation = ScrollbarOrientation::VERTICAL; | |
| 60 EXPECT_EQ(orientation, ScrollbarOrientationFromProto( | |
| 61 ScrollbarOrientationToProto(orientation))); | |
| 62 } | |
| 63 | |
| 64 } // namespace | |
| 65 } // namespace cc | |
| OLD | NEW |