| 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/bindings/error_handler.h" | 5 #include "mojo/public/cpp/bindings/error_handler.h" |
| 6 #include "mojo/public/cpp/environment/environment.h" | 6 #include "mojo/public/cpp/environment/environment.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/math_calculator.mojom.h" | 8 #include "mojo/public/interfaces/bindings/tests/math_calculator.mojom.h" |
| 9 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h" | 9 #include "mojo/public/interfaces/bindings/tests/sample_service.mojom.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 impl->WaitForIncomingMethodCall(); | 245 impl->WaitForIncomingMethodCall(); |
| 246 calculator_ui.WaitForIncomingMethodCall(); | 246 calculator_ui.WaitForIncomingMethodCall(); |
| 247 EXPECT_EQ(10.0, calculator_ui.GetOutput()); | 247 EXPECT_EQ(10.0, calculator_ui.GetOutput()); |
| 248 } | 248 } |
| 249 | 249 |
| 250 TEST_F(InterfacePtrTest, Movable) { | 250 TEST_F(InterfacePtrTest, Movable) { |
| 251 math::CalculatorPtr a; | 251 math::CalculatorPtr a; |
| 252 math::CalculatorPtr b; | 252 math::CalculatorPtr b; |
| 253 BindToProxy(new MathCalculatorImpl(), &b); | 253 BindToProxy(new MathCalculatorImpl(), &b); |
| 254 | 254 |
| 255 EXPECT_TRUE(!a.get()); | 255 EXPECT_TRUE(!a); |
| 256 EXPECT_FALSE(!b.get()); | 256 EXPECT_FALSE(!b); |
| 257 | 257 |
| 258 a = b.Pass(); | 258 a = b.Pass(); |
| 259 | 259 |
| 260 EXPECT_FALSE(!a.get()); | 260 EXPECT_FALSE(!a); |
| 261 EXPECT_TRUE(!b.get()); | 261 EXPECT_TRUE(!b); |
| 262 } | 262 } |
| 263 | 263 |
| 264 TEST_F(InterfacePtrTest, Resettable) { | 264 TEST_F(InterfacePtrTest, Resettable) { |
| 265 math::CalculatorPtr a; | 265 math::CalculatorPtr a; |
| 266 | 266 |
| 267 EXPECT_TRUE(!a.get()); | 267 EXPECT_TRUE(!a); |
| 268 | 268 |
| 269 MessagePipe pipe; | 269 MessagePipe pipe; |
| 270 | 270 |
| 271 // Save this so we can test it later. | 271 // Save this so we can test it later. |
| 272 Handle handle = pipe.handle0.get(); | 272 Handle handle = pipe.handle0.get(); |
| 273 | 273 |
| 274 a = MakeProxy<math::Calculator>(pipe.handle0.Pass()); | 274 a = MakeProxy<math::Calculator>(pipe.handle0.Pass()); |
| 275 | 275 |
| 276 EXPECT_FALSE(!a.get()); | 276 EXPECT_FALSE(!a); |
| 277 | 277 |
| 278 a.reset(); | 278 a.reset(); |
| 279 | 279 |
| 280 EXPECT_TRUE(!a.get()); | 280 EXPECT_TRUE(!a); |
| 281 EXPECT_FALSE(a.internal_state()->router_for_testing()); | 281 EXPECT_FALSE(a.internal_state()->router_for_testing()); |
| 282 | 282 |
| 283 // Test that handle was closed. | 283 // Test that handle was closed. |
| 284 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, CloseRaw(handle)); | 284 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, CloseRaw(handle)); |
| 285 } | 285 } |
| 286 | 286 |
| 287 TEST_F(InterfacePtrTest, EncounteredError) { | 287 TEST_F(InterfacePtrTest, EncounteredError) { |
| 288 math::CalculatorPtr proxy; | 288 math::CalculatorPtr proxy; |
| 289 MathCalculatorImpl* server = BindToProxy(new MathCalculatorImpl(), &proxy); | 289 MathCalculatorImpl* server = BindToProxy(new MathCalculatorImpl(), &proxy); |
| 290 | 290 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 sample::PortPtr()); | 394 sample::PortPtr()); |
| 395 | 395 |
| 396 PumpMessages(); | 396 PumpMessages(); |
| 397 | 397 |
| 398 EXPECT_EQ(2, impl->max_call_depth()); | 398 EXPECT_EQ(2, impl->max_call_depth()); |
| 399 } | 399 } |
| 400 | 400 |
| 401 } // namespace | 401 } // namespace |
| 402 } // namespace test | 402 } // namespace test |
| 403 } // namespace mojo | 403 } // namespace mojo |
| OLD | NEW |