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

Side by Side Diff: cc/base/region_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: Addressed comments from dtrainor Created 5 years, 1 month 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/base/region.h" 5 #include "cc/base/region.h"
6 6
7 #include "cc/proto/region.pb.h"
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 9
9 namespace cc { 10 namespace cc {
10 namespace { 11 namespace {
11 12
12 #define TEST_INSIDE_RECT(r, x, y, w, h) \ 13 #define TEST_INSIDE_RECT(r, x, y, w, h) \
13 EXPECT_TRUE(r.Contains(gfx::Point(x, y))); \ 14 EXPECT_TRUE(r.Contains(gfx::Point(x, y))); \
14 EXPECT_TRUE(r.Contains(gfx::Point(x + w - 1, y))); \ 15 EXPECT_TRUE(r.Contains(gfx::Point(x + w - 1, y))); \
15 EXPECT_TRUE(r.Contains(gfx::Point(x, y + h - 1))); \ 16 EXPECT_TRUE(r.Contains(gfx::Point(x, y + h - 1))); \
16 EXPECT_TRUE(r.Contains(gfx::Point(x + w - 1, y + h - 1))); \ 17 EXPECT_TRUE(r.Contains(gfx::Point(x + w - 1, y + h - 1))); \
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 444
444 r1 = gfx::Rect(0, 0, 50, 50); 445 r1 = gfx::Rect(0, 0, 50, 50);
445 r1.Union(gfx::Rect(100, 0, 50, 50)); 446 r1.Union(gfx::Rect(100, 0, 50, 50));
446 r1.Union(gfx::Rect(0, 0, 500, 500)); 447 r1.Union(gfx::Rect(0, 0, 500, 500));
447 r3 = r1; 448 r3 = r1;
448 r1.Swap(&r2); 449 r1.Swap(&r2);
449 EXPECT_EQ(r1.ToString(), Region(gfx::Rect(0, 0, 50, 50)).ToString()); 450 EXPECT_EQ(r1.ToString(), Region(gfx::Rect(0, 0, 50, 50)).ToString());
450 EXPECT_EQ(r2.ToString(), r3.ToString()); 451 EXPECT_EQ(r2.ToString(), r3.ToString());
451 } 452 }
452 453
454 TEST(RegionTest, ProtoConversion) {
455 Region region1(gfx::Rect(14, 15, 16, 17));
456 proto::Region proto;
457 region1.ToProtobuf(&proto);
458 Region region2;
459 region2.FromProtobuf(proto);
460 EXPECT_EQ(region1, region2);
461 }
462
453 } // namespace 463 } // namespace
454 } // namespace cc 464 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698