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

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

Issue 1660403003: Mojo C++ bindings: Rename InterfaceInfoPtr -> InterfaceHandle (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: using {{InterfaceName}}Handle = InterfaceHandle<{{InterfaceName}}> Created 4 years, 10 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
OLDNEW
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/binding.h" 5 #include "mojo/public/cpp/bindings/binding.h"
6 #include "mojo/public/cpp/bindings/strong_binding.h" 6 #include "mojo/public/cpp/bindings/strong_binding.h"
7 #include "mojo/public/cpp/environment/environment.h" 7 #include "mojo/public/cpp/environment/environment.h"
8 #include "mojo/public/cpp/utility/run_loop.h" 8 #include "mojo/public/cpp/utility/run_loop.h"
9 #include "mojo/public/interfaces/bindings/tests/math_calculator.mojom.h" 9 #include "mojo/public/interfaces/bindings/tests/math_calculator.mojom.h"
10 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h" 10 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 TEST_F(InterfacePtrTest, Resettable) { 267 TEST_F(InterfacePtrTest, Resettable) {
268 math::CalculatorPtr a; 268 math::CalculatorPtr a;
269 269
270 EXPECT_TRUE(!a); 270 EXPECT_TRUE(!a);
271 271
272 MessagePipe pipe; 272 MessagePipe pipe;
273 273
274 // Save this so we can test it later. 274 // Save this so we can test it later.
275 Handle handle = pipe.handle0.get(); 275 Handle handle = pipe.handle0.get();
276 276
277 a = MakeProxy(InterfacePtrInfo<math::Calculator>(pipe.handle0.Pass(), 0u)); 277 a = MakeProxy(InterfaceHandle<math::Calculator>(pipe.handle0.Pass(), 0u));
278 278
279 EXPECT_FALSE(!a); 279 EXPECT_FALSE(!a);
280 280
281 a.reset(); 281 a.reset();
282 282
283 EXPECT_TRUE(!a); 283 EXPECT_TRUE(!a);
284 EXPECT_FALSE(a.internal_state()->router_for_testing()); 284 EXPECT_FALSE(a.internal_state()->router_for_testing());
285 285
286 // Test that handle was closed. 286 // Test that handle was closed.
287 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, CloseRaw(handle)); 287 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, CloseRaw(handle));
288 } 288 }
289 289
290 TEST_F(InterfacePtrTest, BindInvalidHandle) { 290 TEST_F(InterfacePtrTest, BindInvalidHandle) {
291 math::CalculatorPtr ptr; 291 math::CalculatorPtr ptr;
292 EXPECT_FALSE(ptr.get()); 292 EXPECT_FALSE(ptr.get());
293 EXPECT_FALSE(ptr); 293 EXPECT_FALSE(ptr);
294 294
295 ptr.Bind(InterfacePtrInfo<math::Calculator>()); 295 ptr.Bind(InterfaceHandle<math::Calculator>());
296 EXPECT_FALSE(ptr.get()); 296 EXPECT_FALSE(ptr.get());
297 EXPECT_FALSE(ptr); 297 EXPECT_FALSE(ptr);
298 } 298 }
299 299
300 TEST_F(InterfacePtrTest, EncounteredError) { 300 TEST_F(InterfacePtrTest, EncounteredError) {
301 math::CalculatorPtr proxy; 301 math::CalculatorPtr proxy;
302 MathCalculatorImpl calc_impl(GetProxy(&proxy)); 302 MathCalculatorImpl calc_impl(GetProxy(&proxy));
303 303
304 MathCalculatorUI calculator_ui(proxy.Pass()); 304 MathCalculatorUI calculator_ui(proxy.Pass());
305 305
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 Environment env; 486 Environment env;
487 RunLoop loop; 487 RunLoop loop;
488 488
489 bool error_received = false; 489 bool error_received = false;
490 bool destroyed = false; 490 bool destroyed = false;
491 MessagePipe pipe; 491 MessagePipe pipe;
492 new StrongMathCalculatorImpl(pipe.handle0.Pass(), &error_received, 492 new StrongMathCalculatorImpl(pipe.handle0.Pass(), &error_received,
493 &destroyed); 493 &destroyed);
494 494
495 math::CalculatorPtr calc; 495 math::CalculatorPtr calc;
496 calc.Bind(InterfacePtrInfo<math::Calculator>(pipe.handle1.Pass(), 0u)); 496 calc.Bind(InterfaceHandle<math::Calculator>(pipe.handle1.Pass(), 0u));
497 497
498 { 498 {
499 // Suppose this is instantiated in a process that has the other end of the 499 // Suppose this is instantiated in a process that has the other end of the
500 // message pipe. 500 // message pipe.
501 MathCalculatorUI calculator_ui(calc.Pass()); 501 MathCalculatorUI calculator_ui(calc.Pass());
502 502
503 calculator_ui.Add(2.0); 503 calculator_ui.Add(2.0);
504 calculator_ui.Multiply(5.0); 504 calculator_ui.Multiply(5.0);
505 505
506 loop.RunUntilIdle(); 506 loop.RunUntilIdle();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 TEST(WeakConnectorTest, Math) { 554 TEST(WeakConnectorTest, Math) {
555 Environment env; 555 Environment env;
556 RunLoop loop; 556 RunLoop loop;
557 557
558 bool error_received = false; 558 bool error_received = false;
559 bool destroyed = false; 559 bool destroyed = false;
560 MessagePipe pipe; 560 MessagePipe pipe;
561 WeakMathCalculatorImpl impl(pipe.handle0.Pass(), &error_received, &destroyed); 561 WeakMathCalculatorImpl impl(pipe.handle0.Pass(), &error_received, &destroyed);
562 562
563 math::CalculatorPtr calc; 563 math::CalculatorPtr calc;
564 calc.Bind(InterfacePtrInfo<math::Calculator>(pipe.handle1.Pass(), 0u)); 564 calc.Bind(InterfaceHandle<math::Calculator>(pipe.handle1.Pass(), 0u));
565 565
566 { 566 {
567 // Suppose this is instantiated in a process that has the other end of the 567 // Suppose this is instantiated in a process that has the other end of the
568 // message pipe. 568 // message pipe.
569 MathCalculatorUI calculator_ui(calc.Pass()); 569 MathCalculatorUI calculator_ui(calc.Pass());
570 570
571 calculator_ui.Add(2.0); 571 calculator_ui.Add(2.0);
572 calculator_ui.Multiply(5.0); 572 calculator_ui.Multiply(5.0);
573 573
574 loop.RunUntilIdle(); 574 loop.RunUntilIdle();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 // While B & C have fallen out of scope, the pipes will remain until they are 653 // While B & C have fallen out of scope, the pipes will remain until they are
654 // flushed. 654 // flushed.
655 EXPECT_FALSE(a_impl.d_called()); 655 EXPECT_FALSE(a_impl.d_called());
656 PumpMessages(); 656 PumpMessages();
657 EXPECT_TRUE(a_impl.d_called()); 657 EXPECT_TRUE(a_impl.d_called());
658 } 658 }
659 659
660 } // namespace 660 } // namespace
661 } // namespace test 661 } // namespace test
662 } // namespace mojo 662 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698