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

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

Issue 2012693002: Generate a templated Clone method for all mojo structs. (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
« no previous file with comments | « no previous file | mojo/public/interfaces/bindings/tests/struct_with_traits.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "mojo/public/cpp/bindings/binding_set.h" 10 #include "mojo/public/cpp/bindings/binding_set.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 EXPECT_EQ(input.get_uint64(), passed.get_uint64()); 235 EXPECT_EQ(input.get_uint64(), passed.get_uint64());
236 EXPECT_EQ(input.get_string(), passed.get_string()); 236 EXPECT_EQ(input.get_string(), passed.get_string());
237 EXPECT_EQ(input.get_string_array(), passed.get_string_array()); 237 EXPECT_EQ(input.get_string_array(), passed.get_string_array());
238 EXPECT_EQ(input.get_struct(), passed.get_struct()); 238 EXPECT_EQ(input.get_struct(), passed.get_struct());
239 EXPECT_EQ(input.get_struct_array(), passed.get_struct_array()); 239 EXPECT_EQ(input.get_struct_array(), passed.get_struct_array());
240 loop.Quit(); 240 loop.Quit();
241 }); 241 });
242 loop.Run(); 242 loop.Run();
243 } 243 }
244 244
245 TEST_F(StructTraitsTest, CloneStructWithTraitsContainer) {
246 StructWithTraitsContainerPtr container = StructWithTraitsContainer::New();
247 container->f_struct.set_uint32(7);
248 container->f_struct.set_uint64(42);
249 StructWithTraitsContainerPtr cloned_container = container.Clone();
250 EXPECT_EQ(7u, cloned_container->f_struct.get_uint32());
251 EXPECT_EQ(42u, cloned_container->f_struct.get_uint64());
252
253 }
254
245 TEST_F(StructTraitsTest, EchoPassByValueStructWithTraits) { 255 TEST_F(StructTraitsTest, EchoPassByValueStructWithTraits) {
246 MessagePipe mp; 256 MessagePipe mp;
247 PassByValueStructWithTraitsImpl input; 257 PassByValueStructWithTraitsImpl input;
248 input.get_mutable_handle().reset(mp.handle0.release()); 258 input.get_mutable_handle().reset(mp.handle0.release());
249 259
250 base::RunLoop loop; 260 base::RunLoop loop;
251 TraitsTestServicePtr proxy = GetTraitsTestProxy(); 261 TraitsTestServicePtr proxy = GetTraitsTestProxy();
252 262
253 ScopedMessagePipeHandle received; 263 ScopedMessagePipeHandle received;
254 proxy->EchoPassByValueStructWithTraits( 264 proxy->EchoPassByValueStructWithTraits(
(...skipping 20 matching lines...) Expand all
275 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); 285 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer));
276 EXPECT_EQ(MOJO_RESULT_OK, 286 EXPECT_EQ(MOJO_RESULT_OK,
277 ReadMessageRaw(received.get(), buffer, &buffer_size, nullptr, 287 ReadMessageRaw(received.get(), buffer, &buffer_size, nullptr,
278 nullptr, MOJO_READ_MESSAGE_FLAG_NONE)); 288 nullptr, MOJO_READ_MESSAGE_FLAG_NONE));
279 EXPECT_EQ(kHelloSize, buffer_size); 289 EXPECT_EQ(kHelloSize, buffer_size);
280 EXPECT_STREQ(kHello, buffer); 290 EXPECT_STREQ(kHello, buffer);
281 } 291 }
282 292
283 } // namespace test 293 } // namespace test
284 } // namespace mojo 294 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/public/interfaces/bindings/tests/struct_with_traits.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698