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( | 18 virtual void EchoString(const String& a, |
19 const String& a, | 19 const Callback<void(String)>& callback) override { |
20 const Callback<void(String)>& callback) MOJO_OVERRIDE { | |
21 Callback<void(String)> callback_copy; | 20 Callback<void(String)> callback_copy; |
22 // Make sure operator= is used. | 21 // Make sure operator= is used. |
23 callback_copy = callback; | 22 callback_copy = callback; |
24 callback_copy.Run(a); | 23 callback_copy.Run(a); |
25 } | 24 } |
26 | 25 |
27 virtual void EchoStrings( | 26 virtual void EchoStrings( |
28 const String& a, | 27 const String& a, |
29 const String& b, | 28 const String& b, |
30 const Callback<void(String, String)>& callback) MOJO_OVERRIDE { | 29 const Callback<void(String, String)>& callback) override { |
31 callback.Run(a, b); | 30 callback.Run(a, b); |
32 } | 31 } |
33 | 32 |
34 virtual void EchoMessagePipeHandle( | 33 virtual void EchoMessagePipeHandle( |
35 ScopedMessagePipeHandle a, | 34 ScopedMessagePipeHandle a, |
36 const Callback<void(ScopedMessagePipeHandle)>& callback) MOJO_OVERRIDE { | 35 const Callback<void(ScopedMessagePipeHandle)>& callback) override { |
37 callback.Run(a.Pass()); | 36 callback.Run(a.Pass()); |
38 } | 37 } |
39 | 38 |
40 virtual void EchoEnum(sample::Enum a, | 39 virtual void EchoEnum(sample::Enum a, |
41 const Callback<void(sample::Enum)>& callback) | 40 const Callback<void(sample::Enum)>& callback) override { |
42 MOJO_OVERRIDE { | |
43 callback.Run(a); | 41 callback.Run(a); |
44 } | 42 } |
45 }; | 43 }; |
46 | 44 |
47 class StringRecorder { | 45 class StringRecorder { |
48 public: | 46 public: |
49 explicit StringRecorder(std::string* buf) : buf_(buf) { | 47 explicit StringRecorder(std::string* buf) : buf_(buf) { |
50 } | 48 } |
51 void Run(const String& a) const { | 49 void Run(const String& a) const { |
52 *buf_ = a; | 50 *buf_ = a; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 provider->EchoEnum(sample::ENUM_VALUE, EnumRecorder(&value)); | 142 provider->EchoEnum(sample::ENUM_VALUE, EnumRecorder(&value)); |
145 | 143 |
146 PumpMessages(); | 144 PumpMessages(); |
147 | 145 |
148 EXPECT_EQ(sample::ENUM_VALUE, value); | 146 EXPECT_EQ(sample::ENUM_VALUE, value); |
149 } | 147 } |
150 | 148 |
151 } // namespace | 149 } // namespace |
152 } // namespace test | 150 } // namespace test |
153 } // namespace mojo | 151 } // namespace mojo |
OLD | NEW |