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

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: fix network_service_loader 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 11 matching lines...) Expand all
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 ImportedInterfaceImpl 29 class ImportedInterfaceImpl
30 : public InterfaceImpl<imported::ImportedInterface> { 30 : public InterfaceImpl<imported::ImportedInterface> {
31 public: 31 public:
32 virtual void OnConnectionError() MOJO_OVERRIDE {
33 delete this;
34 }
35
36 virtual void DoSomething() MOJO_OVERRIDE { 32 virtual void DoSomething() MOJO_OVERRIDE {
37 do_something_count_++; 33 do_something_count_++;
38 } 34 }
39 35
40 static int do_something_count() { return do_something_count_; } 36 static int do_something_count() { return do_something_count_; }
41 37
42 private: 38 private:
43 static int do_something_count_; 39 static int do_something_count_;
44 }; 40 };
45 int ImportedInterfaceImpl::do_something_count_ = 0; 41 int ImportedInterfaceImpl::do_something_count_ = 0;
46 42
47 class SampleNamedObjectImpl : public InterfaceImpl<sample::NamedObject> { 43 class SampleNamedObjectImpl : public InterfaceImpl<sample::NamedObject> {
48 public: 44 public:
49 virtual void OnConnectionError() MOJO_OVERRIDE {
50 delete this;
51 }
52
53 virtual void SetName(const mojo::String& name) MOJO_OVERRIDE { 45 virtual void SetName(const mojo::String& name) MOJO_OVERRIDE {
54 name_ = name; 46 name_ = name;
55 } 47 }
56 48
57 virtual void GetName(const mojo::Callback<void(mojo::String)>& callback) 49 virtual void GetName(const mojo::Callback<void(mojo::String)>& callback)
58 MOJO_OVERRIDE { 50 MOJO_OVERRIDE {
59 callback.Run(name_); 51 callback.Run(name_);
60 } 52 }
61 53
62 private: 54 private:
63 std::string name_; 55 std::string name_;
64 }; 56 };
65 57
66 class SampleFactoryImpl : public InterfaceImpl<sample::Factory> { 58 class SampleFactoryImpl : public InterfaceImpl<sample::Factory> {
67 public: 59 public:
68 virtual void OnConnectionError() MOJO_OVERRIDE {
69 delete this;
70 }
71
72 virtual void DoStuff(sample::RequestPtr request, 60 virtual void DoStuff(sample::RequestPtr request,
73 ScopedMessagePipeHandle pipe) MOJO_OVERRIDE { 61 ScopedMessagePipeHandle pipe) MOJO_OVERRIDE {
74 std::string text1; 62 std::string text1;
75 if (pipe.is_valid()) 63 if (pipe.is_valid())
76 EXPECT_TRUE(ReadTextMessage(pipe.get(), &text1)); 64 EXPECT_TRUE(ReadTextMessage(pipe.get(), &text1));
77 65
78 std::string text2; 66 std::string text2;
79 if (request->pipe.is_valid()) { 67 if (request->pipe.is_valid()) {
80 EXPECT_TRUE(ReadTextMessage(request->pipe.get(), &text2)); 68 EXPECT_TRUE(ReadTextMessage(request->pipe.get(), &text2));
81 69
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 345
358 PumpMessages(); // Yield for results. 346 PumpMessages(); // Yield for results.
359 347
360 EXPECT_EQ(std::string("object1"), name1); 348 EXPECT_EQ(std::string("object1"), name1);
361 EXPECT_EQ(std::string("object2"), name2); 349 EXPECT_EQ(std::string("object2"), name2);
362 } 350 }
363 351
364 } // namespace 352 } // namespace
365 } // namespace test 353 } // namespace test
366 } // namespace mojo 354 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_impl_internal.h ('k') | mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698