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 <stdint.h> | 5 #include <stdint.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 base::Closure closure_; | 53 base::Closure closure_; |
54 }; | 54 }; |
55 int ImportedInterfaceImpl::do_something_count_ = 0; | 55 int ImportedInterfaceImpl::do_something_count_ = 0; |
56 | 56 |
57 class SampleNamedObjectImpl : public sample::NamedObject { | 57 class SampleNamedObjectImpl : public sample::NamedObject { |
58 public: | 58 public: |
59 explicit SampleNamedObjectImpl(InterfaceRequest<sample::NamedObject> request) | 59 explicit SampleNamedObjectImpl(InterfaceRequest<sample::NamedObject> request) |
60 : binding_(this, std::move(request)) {} | 60 : binding_(this, std::move(request)) {} |
61 void SetName(const mojo::String& name) override { name_ = name; } | 61 void SetName(const mojo::String& name) override { name_ = name; } |
62 | 62 |
63 void GetName(const mojo::Callback<void(mojo::String)>& callback) override { | 63 void GetName(const GetNameCallback& callback) override { |
64 callback.Run(name_); | 64 callback.Run(name_); |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 std::string name_; | 68 std::string name_; |
69 StrongBinding<sample::NamedObject> binding_; | 69 StrongBinding<sample::NamedObject> binding_; |
70 }; | 70 }; |
71 | 71 |
72 class SampleFactoryImpl : public sample::Factory { | 72 class SampleFactoryImpl : public sample::Factory { |
73 public: | 73 public: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 InterfaceRequest<sample::NamedObject> object_request) override { | 134 InterfaceRequest<sample::NamedObject> object_request) override { |
135 EXPECT_TRUE(object_request.is_pending()); | 135 EXPECT_TRUE(object_request.is_pending()); |
136 new SampleNamedObjectImpl(std::move(object_request)); | 136 new SampleNamedObjectImpl(std::move(object_request)); |
137 } | 137 } |
138 | 138 |
139 // These aren't called or implemented, but exist here to test that the | 139 // These aren't called or implemented, but exist here to test that the |
140 // methods are generated with the correct argument types for imported | 140 // methods are generated with the correct argument types for imported |
141 // interfaces. | 141 // interfaces. |
142 void RequestImportedInterface( | 142 void RequestImportedInterface( |
143 InterfaceRequest<imported::ImportedInterface> imported, | 143 InterfaceRequest<imported::ImportedInterface> imported, |
144 const mojo::Callback<void(InterfaceRequest<imported::ImportedInterface>)>& | 144 const RequestImportedInterfaceCallback& callback) override {} |
145 callback) override {} | |
146 void TakeImportedInterface( | 145 void TakeImportedInterface( |
147 imported::ImportedInterfacePtr imported, | 146 imported::ImportedInterfacePtr imported, |
148 const mojo::Callback<void(imported::ImportedInterfacePtr)>& callback) | 147 const TakeImportedInterfaceCallback& callback) override {} |
149 override {} | |
150 | 148 |
151 private: | 149 private: |
152 ScopedMessagePipeHandle pipe1_; | 150 ScopedMessagePipeHandle pipe1_; |
153 Binding<sample::Factory> binding_; | 151 Binding<sample::Factory> binding_; |
154 }; | 152 }; |
155 | 153 |
156 class HandlePassingTest : public testing::Test { | 154 class HandlePassingTest : public testing::Test { |
157 public: | 155 public: |
158 HandlePassingTest() {} | 156 HandlePassingTest() {} |
159 | 157 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 run_loop.Run(); | 360 run_loop.Run(); |
363 run_loop2.Run(); | 361 run_loop2.Run(); |
364 | 362 |
365 EXPECT_EQ(std::string("object1"), name1); | 363 EXPECT_EQ(std::string("object1"), name1); |
366 EXPECT_EQ(std::string("object2"), name2); | 364 EXPECT_EQ(std::string("object2"), name2); |
367 } | 365 } |
368 | 366 |
369 } // namespace | 367 } // namespace |
370 } // namespace test | 368 } // namespace test |
371 } // namespace mojo | 369 } // namespace mojo |
OLD | NEW |