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

Unified 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: Sad missing brackets 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/proto/cc_conversions.cc ('k') | cc/proto/region.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/proto/cc_conversions_unittest.cc
diff --git a/cc/proto/cc_conversions_unittest.cc b/cc/proto/cc_conversions_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f517f50f317a5480afde0f05c92e4343414531db
--- /dev/null
+++ b/cc/proto/cc_conversions_unittest.cc
@@ -0,0 +1,42 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/proto/cc_conversions.h"
+
+#include "cc/base/region.h"
+#include "cc/proto/region.pb.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/geometry/rect.h"
+
+namespace cc {
+namespace {
+
+void VerifySerializeAndDeserializeProto(const Region& region1) {
+ proto::Region proto;
+ RegionToProto(region1, &proto);
+ Region region2 = RegionFromProto(proto);
+ EXPECT_EQ(region1, region2);
+}
+
+TEST(RegionTest, SingleRectProtoConversion) {
+ Region region(gfx::Rect(14, 15, 16, 17));
+ VerifySerializeAndDeserializeProto(region);
+}
+
+TEST(RegionTest, MultipleRectProtoConversion) {
+ Region region(gfx::Rect(0, 0, 1, 1));
+ region.Union(gfx::Rect(9, 0, 1, 1));
+ region.Union(gfx::Rect(0, 9, 1, 1));
+ region.Union(gfx::Rect(9, 9, 1, 1));
+ VerifySerializeAndDeserializeProto(region);
+}
+
+TEST(RegionTest, IntersectedRectProtoConversion) {
+ Region region(gfx::Rect(0, 0, 10, 10));
+ region.Intersect(gfx::Rect(0, 0, 5, 5));
+ VerifySerializeAndDeserializeProto(region);
+}
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
+
+} // namespace
+} // namespace cc
« 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