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

Side by Side Diff: mojo/public/cpp/bindings/tests/equals_unittest.cc

Issue 2136733002: Mojo C++ bindings: add a new mode to generator to use native STL/WTF types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@67_new
Patch Set: . Created 4 years, 5 months 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <utility> 5 #include <utility>
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h" 8 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 RectPairPtr p2(p1.Clone()); 54 RectPairPtr p2(p1.Clone());
55 EXPECT_TRUE(p1.Equals(p2)); 55 EXPECT_TRUE(p1.Equals(p2));
56 p2->second->width = 0; 56 p2->second->width = 0;
57 EXPECT_FALSE(p1.Equals(p2)); 57 EXPECT_FALSE(p1.Equals(p2));
58 p2->second.reset(); 58 p2->second.reset();
59 EXPECT_FALSE(p1.Equals(p2)); 59 EXPECT_FALSE(p1.Equals(p2));
60 } 60 }
61 61
62 TEST_F(EqualsTest, Array) { 62 TEST_F(EqualsTest, Array) {
63 NamedRegionPtr n1(NamedRegion::New()); 63 NamedRegionPtr n1(NamedRegion::New());
64 n1->name = "n1"; 64 n1->name.emplace("n1");
65 n1->rects.push_back(CreateRect()); 65 n1->rects.emplace();
66 n1->rects->push_back(CreateRect());
66 NamedRegionPtr n2(n1.Clone()); 67 NamedRegionPtr n2(n1.Clone());
67 EXPECT_TRUE(n1.Equals(n2)); 68 EXPECT_TRUE(n1.Equals(n2));
68 69
69 n2->rects = nullptr; 70 n2->rects = base::nullopt;
70 EXPECT_FALSE(n1.Equals(n2)); 71 EXPECT_FALSE(n1.Equals(n2));
71 n2->rects.resize(0); 72 n2->rects.emplace();
72 EXPECT_FALSE(n1.Equals(n2)); 73 EXPECT_FALSE(n1.Equals(n2));
73 74
74 n2->rects.push_back(CreateRect()); 75 n2->rects->push_back(CreateRect());
75 n2->rects.push_back(CreateRect()); 76 n2->rects->push_back(CreateRect());
76 EXPECT_FALSE(n1.Equals(n2)); 77 EXPECT_FALSE(n1.Equals(n2));
77 78
78 n2->rects.resize(1); 79 n2->rects->resize(1);
79 n2->rects[0]->width = 0; 80 (*n2->rects)[0]->width = 0;
80 EXPECT_FALSE(n1.Equals(n2)); 81 EXPECT_FALSE(n1.Equals(n2));
81 82
82 n2->rects[0] = CreateRect(); 83 (*n2->rects)[0] = CreateRect();
83 EXPECT_TRUE(n1.Equals(n2)); 84 EXPECT_TRUE(n1.Equals(n2));
84 } 85 }
85 86
86 TEST_F(EqualsTest, Map) { 87 TEST_F(EqualsTest, Map) {
87 auto n1(NamedRegion::New()); 88 auto n1(NamedRegion::New());
88 n1->name = "foo"; 89 n1->name.emplace("foo");
89 n1->rects.push_back(CreateRect()); 90 n1->rects.emplace();
91 n1->rects->push_back(CreateRect());
90 92
91 Map<std::string, NamedRegionPtr> m1; 93 Map<std::string, NamedRegionPtr> m1;
92 m1.insert("foo", std::move(n1)); 94 m1.insert("foo", std::move(n1));
93 95
94 decltype(m1) m2; 96 decltype(m1) m2;
95 EXPECT_FALSE(m1.Equals(m2)); 97 EXPECT_FALSE(m1.Equals(m2));
96 98
97 m2.insert("bar", m1.at("foo").Clone()); 99 m2.insert("bar", m1.at("foo").Clone());
98 EXPECT_FALSE(m1.Equals(m2)); 100 EXPECT_FALSE(m1.Equals(m2));
99 101
100 m2 = m1.Clone(); 102 m2 = m1.Clone();
101 m2.at("foo")->name = "monkey"; 103 m2.at("foo")->name.emplace("monkey");
102 EXPECT_FALSE(m1.Equals(m2)); 104 EXPECT_FALSE(m1.Equals(m2));
103 105
104 m2 = m1.Clone(); 106 m2 = m1.Clone();
105 m2.at("foo")->rects.push_back(Rect::New()); 107 m2.at("foo")->rects->push_back(Rect::New());
106 EXPECT_FALSE(m1.Equals(m2)); 108 EXPECT_FALSE(m1.Equals(m2));
107 109
108 m2.at("foo")->rects.resize(1); 110 m2.at("foo")->rects->resize(1);
109 m2.at("foo")->rects[0]->width = 1; 111 (*m2.at("foo")->rects)[0]->width = 1;
110 EXPECT_FALSE(m1.Equals(m2)); 112 EXPECT_FALSE(m1.Equals(m2));
111 113
112 m2 = m1.Clone(); 114 m2 = m1.Clone();
113 EXPECT_TRUE(m1.Equals(m2)); 115 EXPECT_TRUE(m1.Equals(m2));
114 } 116 }
115 117
116 TEST_F(EqualsTest, InterfacePtr) { 118 TEST_F(EqualsTest, InterfacePtr) {
117 base::MessageLoop message_loop; 119 base::MessageLoop message_loop;
118 120
119 SomeInterfacePtr inf1; 121 SomeInterfacePtr inf1;
(...skipping 30 matching lines...) Expand all
150 EXPECT_FALSE(req1.Equals(req2)); 152 EXPECT_FALSE(req1.Equals(req2));
151 153
152 SomeInterfacePtr inf2; 154 SomeInterfacePtr inf2;
153 req2 = GetProxy(&inf2); 155 req2 = GetProxy(&inf2);
154 156
155 EXPECT_FALSE(req1.Equals(req2)); 157 EXPECT_FALSE(req1.Equals(req2));
156 } 158 }
157 159
158 } // test 160 } // test
159 } // mojo 161 } // mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/e2e_perftest.cc ('k') | mojo/public/cpp/bindings/tests/handle_passing_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698