| 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 <utility> |
| 6 |
| 5 #include "mojo/public/cpp/bindings/binding.h" | 7 #include "mojo/public/cpp/bindings/binding.h" |
| 6 #include "mojo/public/cpp/bindings/strong_binding.h" | 8 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 7 #include "mojo/public/cpp/environment/environment.h" | 9 #include "mojo/public/cpp/environment/environment.h" |
| 8 #include "mojo/public/cpp/test_support/test_utils.h" | 10 #include "mojo/public/cpp/test_support/test_utils.h" |
| 9 #include "mojo/public/cpp/utility/run_loop.h" | 11 #include "mojo/public/cpp/utility/run_loop.h" |
| 10 #include "mojo/public/interfaces/bindings/tests/sample_factory.mojom.h" | 12 #include "mojo/public/interfaces/bindings/tests/sample_factory.mojom.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 14 |
| 13 namespace mojo { | 15 namespace mojo { |
| 14 namespace test { | 16 namespace test { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 CreateMessagePipe(nullptr, &pipe0, &pipe1_); | 84 CreateMessagePipe(nullptr, &pipe0, &pipe1_); |
| 83 EXPECT_TRUE(WriteTextMessage(pipe1_.get(), text2)); | 85 EXPECT_TRUE(WriteTextMessage(pipe1_.get(), text2)); |
| 84 } | 86 } |
| 85 | 87 |
| 86 sample::ResponsePtr response(sample::Response::New()); | 88 sample::ResponsePtr response(sample::Response::New()); |
| 87 response->x = 2; | 89 response->x = 2; |
| 88 response->pipe = pipe0.Pass(); | 90 response->pipe = pipe0.Pass(); |
| 89 callback.Run(response.Pass(), text1); | 91 callback.Run(response.Pass(), text1); |
| 90 | 92 |
| 91 if (request->obj) | 93 if (request->obj) |
| 92 request->obj->DoSomething(); | 94 imported::ImportedInterfacePtr::Create(std::move(request->obj)) |
| 95 ->DoSomething(); |
| 93 } | 96 } |
| 94 | 97 |
| 95 void DoStuff2(ScopedDataPipeConsumerHandle pipe, | 98 void DoStuff2(ScopedDataPipeConsumerHandle pipe, |
| 96 const DoStuff2Callback& callback) override { | 99 const DoStuff2Callback& callback) override { |
| 97 // Read the data from the pipe, writing the response (as a string) to | 100 // Read the data from the pipe, writing the response (as a string) to |
| 98 // DidStuff2(). | 101 // DidStuff2(). |
| 99 ASSERT_TRUE(pipe.is_valid()); | 102 ASSERT_TRUE(pipe.is_valid()); |
| 100 uint32_t data_size = 0; | 103 uint32_t data_size = 0; |
| 101 ASSERT_EQ(MOJO_RESULT_OK, | 104 ASSERT_EQ(MOJO_RESULT_OK, |
| 102 ReadDataRaw( | 105 ReadDataRaw( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 119 } | 122 } |
| 120 | 123 |
| 121 // These aren't called or implemented, but exist here to test that the | 124 // These aren't called or implemented, but exist here to test that the |
| 122 // methods are generated with the correct argument types for imported | 125 // methods are generated with the correct argument types for imported |
| 123 // interfaces. | 126 // interfaces. |
| 124 void RequestImportedInterface( | 127 void RequestImportedInterface( |
| 125 InterfaceRequest<imported::ImportedInterface> imported, | 128 InterfaceRequest<imported::ImportedInterface> imported, |
| 126 const mojo::Callback<void(InterfaceRequest<imported::ImportedInterface>)>& | 129 const mojo::Callback<void(InterfaceRequest<imported::ImportedInterface>)>& |
| 127 callback) override {} | 130 callback) override {} |
| 128 void TakeImportedInterface( | 131 void TakeImportedInterface( |
| 129 imported::ImportedInterfacePtr imported, | 132 InterfaceHandle<imported::ImportedInterface> imported, |
| 130 const mojo::Callback<void(imported::ImportedInterfacePtr)>& callback) | 133 const mojo::Callback<void(InterfaceHandle<imported::ImportedInterface>)>& |
| 131 override {} | 134 callback) override {} |
| 132 | 135 |
| 133 private: | 136 private: |
| 134 ScopedMessagePipeHandle pipe1_; | 137 ScopedMessagePipeHandle pipe1_; |
| 135 Binding<sample::Factory> binding_; | 138 Binding<sample::Factory> binding_; |
| 136 }; | 139 }; |
| 137 | 140 |
| 138 class HandlePassingTest : public testing::Test { | 141 class HandlePassingTest : public testing::Test { |
| 139 public: | 142 public: |
| 140 void TearDown() override { PumpMessages(); } | 143 void TearDown() override { PumpMessages(); } |
| 141 | 144 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 346 |
| 344 PumpMessages(); // Yield for results. | 347 PumpMessages(); // Yield for results. |
| 345 | 348 |
| 346 EXPECT_EQ(std::string("object1"), name1); | 349 EXPECT_EQ(std::string("object1"), name1); |
| 347 EXPECT_EQ(std::string("object2"), name2); | 350 EXPECT_EQ(std::string("object2"), name2); |
| 348 } | 351 } |
| 349 | 352 |
| 350 } // namespace | 353 } // namespace |
| 351 } // namespace test | 354 } // namespace test |
| 352 } // namespace mojo | 355 } // namespace mojo |
| OLD | NEW |