OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_import.mojom.h" | 8 #include "mojo/public/interfaces/bindings/tests/sample_import.mojom.h" |
9 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h" | 9 #include "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 namespace mojo { | 12 namespace mojo { |
13 namespace test { | 13 namespace test { |
14 namespace { | 14 namespace { |
15 | 15 |
16 class ProviderImpl : public InterfaceImpl<sample::Provider> { | 16 class ProviderImpl : public InterfaceImpl<sample::Provider> { |
17 public: | 17 public: |
18 virtual void EchoString(const String& a, | 18 void EchoString(const String& a, |
19 const Callback<void(String)>& callback) override { | 19 const Callback<void(String)>& callback) override { |
20 Callback<void(String)> callback_copy; | 20 Callback<void(String)> callback_copy; |
21 // Make sure operator= is used. | 21 // Make sure operator= is used. |
22 callback_copy = callback; | 22 callback_copy = callback; |
23 callback_copy.Run(a); | 23 callback_copy.Run(a); |
24 } | 24 } |
25 | 25 |
26 virtual void EchoStrings( | 26 void EchoStrings(const String& a, |
27 const String& a, | 27 const String& b, |
28 const String& b, | 28 const Callback<void(String, String)>& callback) override { |
29 const Callback<void(String, String)>& callback) override { | |
30 callback.Run(a, b); | 29 callback.Run(a, b); |
31 } | 30 } |
32 | 31 |
33 virtual void EchoMessagePipeHandle( | 32 void EchoMessagePipeHandle( |
34 ScopedMessagePipeHandle a, | 33 ScopedMessagePipeHandle a, |
35 const Callback<void(ScopedMessagePipeHandle)>& callback) override { | 34 const Callback<void(ScopedMessagePipeHandle)>& callback) override { |
36 callback.Run(a.Pass()); | 35 callback.Run(a.Pass()); |
37 } | 36 } |
38 | 37 |
39 virtual void EchoEnum(sample::Enum a, | 38 void EchoEnum(sample::Enum a, |
40 const Callback<void(sample::Enum)>& callback) override { | 39 const Callback<void(sample::Enum)>& callback) override { |
41 callback.Run(a); | 40 callback.Run(a); |
42 } | 41 } |
43 }; | 42 }; |
44 | 43 |
45 class StringRecorder { | 44 class StringRecorder { |
46 public: | 45 public: |
47 explicit StringRecorder(std::string* buf) : buf_(buf) {} | 46 explicit StringRecorder(std::string* buf) : buf_(buf) {} |
48 void Run(const String& a) const { *buf_ = a; } | 47 void Run(const String& a) const { *buf_ = a; } |
49 void Run(const String& a, const String& b) const { | 48 void Run(const String& a, const String& b) const { |
50 *buf_ = a.get() + b.get(); | 49 *buf_ = a.get() + b.get(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 provider->EchoEnum(sample::ENUM_VALUE, EnumRecorder(&value)); | 133 provider->EchoEnum(sample::ENUM_VALUE, EnumRecorder(&value)); |
135 | 134 |
136 PumpMessages(); | 135 PumpMessages(); |
137 | 136 |
138 EXPECT_EQ(sample::ENUM_VALUE, value); | 137 EXPECT_EQ(sample::ENUM_VALUE, value); |
139 } | 138 } |
140 | 139 |
141 } // namespace | 140 } // namespace |
142 } // namespace test | 141 } // namespace test |
143 } // namespace mojo | 142 } // namespace mojo |
OLD | NEW |