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

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

Issue 1785843002: [mojo] Implement pipe fusion API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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
« no previous file with comments | « mojo/public/cpp/bindings/interface_request.h ('k') | mojo/public/cpp/system/message_pipe.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 c->D(); 707 c->D();
708 } 708 }
709 709
710 // While B & C have fallen out of scope, the pipes will remain until they are 710 // While B & C have fallen out of scope, the pipes will remain until they are
711 // flushed. 711 // flushed.
712 EXPECT_FALSE(a_impl.d_called()); 712 EXPECT_FALSE(a_impl.d_called());
713 run_loop.Run(); 713 run_loop.Run();
714 EXPECT_TRUE(a_impl.d_called()); 714 EXPECT_TRUE(a_impl.d_called());
715 } 715 }
716 716
717 class PingTestImpl : public sample::PingTest {
718 public:
719 explicit PingTestImpl(InterfaceRequest<sample::PingTest> request)
720 : binding_(this, std::move(request)) {}
721 ~PingTestImpl() override {}
722
723 private:
724 // sample::PingTest:
725 void Ping(const PingCallback& callback) override { callback.Run(); }
726
727 Binding<sample::PingTest> binding_;
728 };
729
730 // Tests that FuseProxy does what it's supposed to do.
731 TEST_F(InterfacePtrTest, Fusion) {
732 sample::PingTestPtr proxy;
733 PingTestImpl impl(GetProxy(&proxy));
734
735 // Create another PingTest pipe.
736 sample::PingTestPtr ptr;
737 sample::PingTestRequest request = GetProxy(&ptr);
738
739 // Fuse the new pipe to the one hanging off |impl|.
740 EXPECT_TRUE(FuseInterface(std::move(request), proxy.PassInterface()));
741
742 // Ping!
743 bool called = false;
744 base::RunLoop loop;
745 ptr->Ping([&called, &loop] {
746 called = true;
747 loop.Quit();
748 });
749 loop.Run();
750 EXPECT_TRUE(called);
751 }
752
717 } // namespace 753 } // namespace
718 } // namespace test 754 } // namespace test
719 } // namespace mojo 755 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/interface_request.h ('k') | mojo/public/cpp/system/message_pipe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698