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 "mojo/public/cpp/environment/environment.h" | 5 #include "mojo/public/cpp/environment/environment.h" |
6 #include "mojo/public/cpp/test_support/test_utils.h" | 6 #include "mojo/public/cpp/test_support/test_utils.h" |
7 #include "mojo/public/cpp/utility/run_loop.h" | 7 #include "mojo/public/cpp/utility/run_loop.h" |
8 #include "mojo/public/interfaces/bindings/tests/sample_factory.mojom.h" | 8 #include "mojo/public/interfaces/bindings/tests/sample_factory.mojom.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 TEST_F(HandlePassingTest, Basic) { | 170 TEST_F(HandlePassingTest, Basic) { |
171 sample::FactoryPtr factory; | 171 sample::FactoryPtr factory; |
172 BindToProxy(new SampleFactoryImpl(), &factory); | 172 BindToProxy(new SampleFactoryImpl(), &factory); |
173 | 173 |
174 SampleFactoryClientImpl factory_client; | 174 SampleFactoryClientImpl factory_client; |
175 factory_client.set_expected_text_reply(kText1); | 175 factory_client.set_expected_text_reply(kText1); |
176 | 176 |
177 factory.set_client(&factory_client); | 177 factory.set_client(&factory_client); |
178 | 178 |
179 ScopedMessagePipeHandle pipe0, pipe1; | 179 MessagePipe pipe0; |
180 CreateMessagePipe(&pipe0, &pipe1); | 180 EXPECT_TRUE(WriteTextMessage(pipe0.handle1.get(), kText1)); |
181 | 181 |
182 EXPECT_TRUE(WriteTextMessage(pipe1.get(), kText1)); | 182 MessagePipe pipe1; |
183 | 183 EXPECT_TRUE(WriteTextMessage(pipe1.handle1.get(), kText2)); |
184 ScopedMessagePipeHandle pipe2, pipe3; | |
185 CreateMessagePipe(&pipe2, &pipe3); | |
186 | |
187 EXPECT_TRUE(WriteTextMessage(pipe3.get(), kText2)); | |
188 | 184 |
189 sample::RequestPtr request(sample::Request::New()); | 185 sample::RequestPtr request(sample::Request::New()); |
190 request->x = 1; | 186 request->x = 1; |
191 request->pipe = pipe2.Pass(); | 187 request->pipe = pipe1.handle0.Pass(); |
192 factory->DoStuff(request.Pass(), pipe0.Pass()); | 188 factory->DoStuff(request.Pass(), pipe0.handle0.Pass()); |
193 | 189 |
194 EXPECT_FALSE(factory_client.got_response()); | 190 EXPECT_FALSE(factory_client.got_response()); |
195 | 191 |
196 PumpMessages(); | 192 PumpMessages(); |
197 | 193 |
198 EXPECT_TRUE(factory_client.got_response()); | 194 EXPECT_TRUE(factory_client.got_response()); |
199 } | 195 } |
200 | 196 |
201 TEST_F(HandlePassingTest, PassInvalid) { | 197 TEST_F(HandlePassingTest, PassInvalid) { |
202 sample::FactoryPtr factory; | 198 sample::FactoryPtr factory; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 318 |
323 PumpMessages(); // Yield for results. | 319 PumpMessages(); // Yield for results. |
324 | 320 |
325 EXPECT_EQ(std::string("object1"), name1); | 321 EXPECT_EQ(std::string("object1"), name1); |
326 EXPECT_EQ(std::string("object2"), name2); | 322 EXPECT_EQ(std::string("object2"), name2); |
327 } | 323 } |
328 | 324 |
329 } // namespace | 325 } // namespace |
330 } // namespace test | 326 } // namespace test |
331 } // namespace mojo | 327 } // namespace mojo |
OLD | NEW |