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

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

Issue 380413003: Mojo: Use InterfaceFactory<Interface> for service registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review feedback Created 6 years, 5 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 | Annotate | Revision Log
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/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 10 matching lines...) Expand all
21 } 21 }
22 void Run(const String& a) const { 22 void Run(const String& a) const {
23 *buf_ = a.To<std::string>(); 23 *buf_ = a.To<std::string>();
24 } 24 }
25 private: 25 private:
26 std::string* buf_; 26 std::string* buf_;
27 }; 27 };
28 28
29 class SampleNamedObjectImpl : public InterfaceImpl<sample::NamedObject> { 29 class SampleNamedObjectImpl : public InterfaceImpl<sample::NamedObject> {
30 public: 30 public:
31 virtual void OnConnectionError() MOJO_OVERRIDE {
32 delete this;
33 }
34
35 virtual void SetName(const mojo::String& name) MOJO_OVERRIDE { 31 virtual void SetName(const mojo::String& name) MOJO_OVERRIDE {
36 name_ = name; 32 name_ = name;
37 } 33 }
38 34
39 virtual void GetName(const mojo::Callback<void(mojo::String)>& callback) 35 virtual void GetName(const mojo::Callback<void(mojo::String)>& callback)
40 MOJO_OVERRIDE { 36 MOJO_OVERRIDE {
41 callback.Run(name_); 37 callback.Run(name_);
42 } 38 }
43 39
44 private: 40 private:
45 std::string name_; 41 std::string name_;
46 }; 42 };
47 43
48 class SampleFactoryImpl : public InterfaceImpl<sample::Factory> { 44 class SampleFactoryImpl : public InterfaceImpl<sample::Factory> {
49 public: 45 public:
50 virtual void OnConnectionError() MOJO_OVERRIDE {
51 delete this;
52 }
53
54 virtual void DoStuff(sample::RequestPtr request, 46 virtual void DoStuff(sample::RequestPtr request,
55 ScopedMessagePipeHandle pipe) MOJO_OVERRIDE { 47 ScopedMessagePipeHandle pipe) MOJO_OVERRIDE {
56 std::string text1; 48 std::string text1;
57 if (pipe.is_valid()) 49 if (pipe.is_valid())
58 EXPECT_TRUE(ReadTextMessage(pipe.get(), &text1)); 50 EXPECT_TRUE(ReadTextMessage(pipe.get(), &text1));
59 51
60 std::string text2; 52 std::string text2;
61 if (request->pipe.is_valid()) { 53 if (request->pipe.is_valid()) {
62 EXPECT_TRUE(ReadTextMessage(request->pipe.get(), &text2)); 54 EXPECT_TRUE(ReadTextMessage(request->pipe.get(), &text2));
63 55
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 322
331 PumpMessages(); // Yield for results. 323 PumpMessages(); // Yield for results.
332 324
333 EXPECT_EQ(std::string("object1"), name1); 325 EXPECT_EQ(std::string("object1"), name1);
334 EXPECT_EQ(std::string("object2"), name2); 326 EXPECT_EQ(std::string("object2"), name2);
335 } 327 }
336 328
337 } // namespace 329 } // namespace
338 } // namespace test 330 } // namespace test
339 } // namespace mojo 331 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698