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

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

Issue 2031823002: Mojo C++ bindings: more consistent Clone() and Equals(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/cpp/bindings/lib/value_traits.h"
9 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h" 8 #include "mojo/public/interfaces/bindings/tests/test_structs.mojom.h"
10 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
11 10
12 namespace mojo { 11 namespace mojo {
13 namespace test { 12 namespace test {
14 13
15 namespace { 14 namespace {
16 15
17 RectPtr CreateRect() { 16 RectPtr CreateRect() {
18 RectPtr r = Rect::New(); 17 RectPtr r = Rect::New();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 107
109 m2.at("foo")->rects.resize(1); 108 m2.at("foo")->rects.resize(1);
110 m2.at("foo")->rects[0]->width = 1; 109 m2.at("foo")->rects[0]->width = 1;
111 EXPECT_FALSE(m1.Equals(m2)); 110 EXPECT_FALSE(m1.Equals(m2));
112 111
113 m2 = m1.Clone(); 112 m2 = m1.Clone();
114 EXPECT_TRUE(m1.Equals(m2)); 113 EXPECT_TRUE(m1.Equals(m2));
115 } 114 }
116 115
117 TEST_F(EqualsTest, InterfacePtr) { 116 TEST_F(EqualsTest, InterfacePtr) {
118 using InterfaceValueTraits = mojo::internal::ValueTraits<SomeInterfacePtr>;
119
120 base::MessageLoop message_loop; 117 base::MessageLoop message_loop;
121 118
122 SomeInterfacePtr inf1; 119 SomeInterfacePtr inf1;
123 SomeInterfacePtr inf2; 120 SomeInterfacePtr inf2;
124 121
125 EXPECT_TRUE(InterfaceValueTraits::Equals(inf1, inf1)); 122 EXPECT_TRUE(inf1.Equals(inf1));
126 EXPECT_TRUE(InterfaceValueTraits::Equals(inf1, inf2)); 123 EXPECT_TRUE(inf1.Equals(inf2));
127 124
128 auto inf1_request = GetProxy(&inf1); 125 auto inf1_request = GetProxy(&inf1);
129 ALLOW_UNUSED_LOCAL(inf1_request); 126 ALLOW_UNUSED_LOCAL(inf1_request);
130 127
131 EXPECT_TRUE(InterfaceValueTraits::Equals(inf1, inf1)); 128 EXPECT_TRUE(inf1.Equals(inf1));
132 EXPECT_FALSE(InterfaceValueTraits::Equals(inf1, inf2)); 129 EXPECT_FALSE(inf1.Equals(inf2));
133 130
134 auto inf2_request = GetProxy(&inf2); 131 auto inf2_request = GetProxy(&inf2);
135 ALLOW_UNUSED_LOCAL(inf2_request); 132 ALLOW_UNUSED_LOCAL(inf2_request);
136 133
137 EXPECT_FALSE(InterfaceValueTraits::Equals(inf1, inf2)); 134 EXPECT_FALSE(inf1.Equals(inf2));
138 } 135 }
139 136
140 TEST_F(EqualsTest, InterfaceRequest) { 137 TEST_F(EqualsTest, InterfaceRequest) {
141 using RequestValueTraits =
142 mojo::internal::ValueTraits<InterfaceRequest<SomeInterface>>;
143
144 base::MessageLoop message_loop; 138 base::MessageLoop message_loop;
145 139
146 InterfaceRequest<SomeInterface> req1; 140 InterfaceRequest<SomeInterface> req1;
147 InterfaceRequest<SomeInterface> req2; 141 InterfaceRequest<SomeInterface> req2;
148 142
149 EXPECT_TRUE(RequestValueTraits::Equals(req1, req1)); 143 EXPECT_TRUE(req1.Equals(req1));
150 EXPECT_TRUE(RequestValueTraits::Equals(req1, req2)); 144 EXPECT_TRUE(req1.Equals(req2));
151 145
152 SomeInterfacePtr inf1; 146 SomeInterfacePtr inf1;
153 req1 = GetProxy(&inf1); 147 req1 = GetProxy(&inf1);
154 148
155 EXPECT_TRUE(RequestValueTraits::Equals(req1, req1)); 149 EXPECT_TRUE(req1.Equals(req1));
156 EXPECT_FALSE(RequestValueTraits::Equals(req1, req2)); 150 EXPECT_FALSE(req1.Equals(req2));
157 151
158 SomeInterfacePtr inf2; 152 SomeInterfacePtr inf2;
159 req2 = GetProxy(&inf2); 153 req2 = GetProxy(&inf2);
160 154
161 EXPECT_FALSE(RequestValueTraits::Equals(req1, req2)); 155 EXPECT_FALSE(req1.Equals(req2));
162 } 156 }
163 157
164 } // test 158 } // test
165 } // mojo 159 } // mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/map.h ('k') | mojo/public/cpp/bindings/tests/struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698