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

Side by Side Diff: cc/proto/cc_conversions_unittest.cc

Issue 1460503004: Add support for converting cc::Region to and from protobuf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add-more-conversions
Patch Set: Added test for union of overlapping rects. Updated intersect-test to match. Created 5 years 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 | « cc/proto/cc_conversions.cc ('k') | cc/proto/region.proto » ('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 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) {
vmpstr 2015/11/23 23:09:20 I'd also add one Region region(gfx::Rect(0, 0, 10
nyquist 2015/11/23 23:37:35 Done.
42 Region region(gfx::Rect(0, 0, 10, 10));
43 region.Union(gfx::Rect(5, 5, 10, 10));
44 VerifySerializeAndDeserializeProto(region);
45 }
46
47 } // namespace
48 } // namespace cc
OLDNEW
« no previous file with comments | « cc/proto/cc_conversions.cc ('k') | cc/proto/region.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698