OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <utility> |
| 6 |
5 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
6 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
7 #include "device/gamepad/public/cpp/gamepad.h" | 9 #include "device/gamepad/public/cpp/gamepad.h" |
8 #include "device/gamepad/public/interfaces/gamepad_struct_traits_test.mojom.h" | 10 #include "device/gamepad/public/interfaces/gamepad_struct_traits_test.mojom.h" |
9 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
10 #include "mojo/public/cpp/bindings/interface_request.h" | 12 #include "mojo/public/cpp/bindings/interface_request.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 | 14 |
13 namespace device { | 15 namespace device { |
14 | 16 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 closure.Run(); | 170 closure.Run(); |
169 } | 171 } |
170 | 172 |
171 } // namespace | 173 } // namespace |
172 | 174 |
173 class GamepadStructTraitsTest : public testing::Test, | 175 class GamepadStructTraitsTest : public testing::Test, |
174 public mojom::GamepadStructTraitsTest { | 176 public mojom::GamepadStructTraitsTest { |
175 protected: | 177 protected: |
176 GamepadStructTraitsTest() : binding_(this) {} | 178 GamepadStructTraitsTest() : binding_(this) {} |
177 | 179 |
178 void PassGamepad(const Gamepad& send, | 180 void PassGamepad(const Gamepad& send, PassGamepadCallback callback) override { |
179 const PassGamepadCallback& callback) override { | 181 std::move(callback).Run(send); |
180 callback.Run(send); | |
181 } | 182 } |
182 | 183 |
183 mojom::GamepadStructTraitsTestPtr GetGamepadStructTraitsTestProxy() { | 184 mojom::GamepadStructTraitsTestPtr GetGamepadStructTraitsTestProxy() { |
184 return binding_.CreateInterfacePtrAndBind(); | 185 return binding_.CreateInterfacePtrAndBind(); |
185 } | 186 } |
186 | 187 |
187 private: | 188 private: |
188 base::MessageLoop message_loop_; | 189 base::MessageLoop message_loop_; |
189 mojo::Binding<mojom::GamepadStructTraitsTest> binding_; | 190 mojo::Binding<mojom::GamepadStructTraitsTest> binding_; |
190 | 191 |
(...skipping 30 matching lines...) Expand all Loading... |
221 TEST_F(GamepadStructTraitsTest, GamepadPose_Null) { | 222 TEST_F(GamepadStructTraitsTest, GamepadPose_Null) { |
222 Gamepad send = GetWebGamepadInstance(GamepadPose_Null); | 223 Gamepad send = GetWebGamepadInstance(GamepadPose_Null); |
223 base::RunLoop loop; | 224 base::RunLoop loop; |
224 mojom::GamepadStructTraitsTestPtr proxy = GetGamepadStructTraitsTestProxy(); | 225 mojom::GamepadStructTraitsTestPtr proxy = GetGamepadStructTraitsTestProxy(); |
225 proxy->PassGamepad(send, | 226 proxy->PassGamepad(send, |
226 base::Bind(&ExpectWebGamepad, send, loop.QuitClosure())); | 227 base::Bind(&ExpectWebGamepad, send, loop.QuitClosure())); |
227 loop.Run(); | 228 loop.Run(); |
228 } | 229 } |
229 | 230 |
230 } // namespace device | 231 } // namespace device |
OLD | NEW |