Chromium Code Reviews| 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, IntersectedRectProtoConversion) { | |
| 36 Region region(gfx::Rect(0, 0, 10, 10)); | |
| 37 region.Intersect(gfx::Rect(0, 0, 5, 5)); | |
| 38 VerifySerializeAndDeserializeProto(region); | |
| 39 } | |
|
vmpstr
2015/11/23 21:10:04
If you have a region that's constructed as a union
nyquist
2015/11/23 22:31:29
Yes, that works. Added test for this. Thanks!
How
| |
| 40 | |
| 41 } // namespace | |
| 42 } // namespace cc | |
| OLD | NEW |