| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 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.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(handle1_value)); | 320 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(handle1_value)); |
| 321 } | 321 } |
| 322 | 322 |
| 323 TEST_F(HandlePassingTest, CreateNamedObject) { | 323 TEST_F(HandlePassingTest, CreateNamedObject) { |
| 324 sample::FactoryPtr factory; | 324 sample::FactoryPtr factory; |
| 325 SampleFactoryImpl factory_impl(MakeRequest(&factory)); | 325 SampleFactoryImpl factory_impl(MakeRequest(&factory)); |
| 326 | 326 |
| 327 sample::NamedObjectPtr object1; | 327 sample::NamedObjectPtr object1; |
| 328 EXPECT_FALSE(object1); | 328 EXPECT_FALSE(object1); |
| 329 | 329 |
| 330 InterfaceRequest<sample::NamedObject> object1_request = MakeRequest(&object1); | 330 InterfaceRequest<sample::NamedObject> object1_request(&object1); |
| 331 EXPECT_TRUE(object1_request.is_pending()); | 331 EXPECT_TRUE(object1_request.is_pending()); |
| 332 factory->CreateNamedObject(std::move(object1_request)); | 332 factory->CreateNamedObject(std::move(object1_request)); |
| 333 EXPECT_FALSE(object1_request.is_pending()); // We've passed the request. | 333 EXPECT_FALSE(object1_request.is_pending()); // We've passed the request. |
| 334 | 334 |
| 335 ASSERT_TRUE(object1); | 335 ASSERT_TRUE(object1); |
| 336 object1->SetName("object1"); | 336 object1->SetName("object1"); |
| 337 | 337 |
| 338 sample::NamedObjectPtr object2; | 338 sample::NamedObjectPtr object2; |
| 339 factory->CreateNamedObject(MakeRequest(&object2)); | 339 factory->CreateNamedObject(MakeRequest(&object2)); |
| 340 object2->SetName("object2"); | 340 object2->SetName("object2"); |
| 341 | 341 |
| 342 base::RunLoop run_loop, run_loop2; | 342 base::RunLoop run_loop, run_loop2; |
| 343 std::string name1; | 343 std::string name1; |
| 344 object1->GetName(MakeStringRecorder(&name1, run_loop.QuitClosure())); | 344 object1->GetName(MakeStringRecorder(&name1, run_loop.QuitClosure())); |
| 345 | 345 |
| 346 std::string name2; | 346 std::string name2; |
| 347 object2->GetName(MakeStringRecorder(&name2, run_loop2.QuitClosure())); | 347 object2->GetName(MakeStringRecorder(&name2, run_loop2.QuitClosure())); |
| 348 | 348 |
| 349 run_loop.Run(); | 349 run_loop.Run(); |
| 350 run_loop2.Run(); | 350 run_loop2.Run(); |
| 351 | 351 |
| 352 EXPECT_EQ(std::string("object1"), name1); | 352 EXPECT_EQ(std::string("object1"), name1); |
| 353 EXPECT_EQ(std::string("object2"), name2); | 353 EXPECT_EQ(std::string("object2"), name2); |
| 354 } | 354 } |
| 355 | 355 |
| 356 } // namespace | 356 } // namespace |
| 357 } // namespace test | 357 } // namespace test |
| 358 } // namespace mojo | 358 } // namespace mojo |
| OLD | NEW |