OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/pepper/pepper_gamepad_host.h" | 5 #include "content/browser/renderer_host/pepper/pepper_gamepad_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "content/browser/gamepad/gamepad_test_helpers.h" | 15 #include "content/browser/gamepad/gamepad_service_test_helpers.h" |
16 #include "content/browser/renderer_host/pepper/browser_ppapi_host_test.h" | 16 #include "content/browser/renderer_host/pepper/browser_ppapi_host_test.h" |
17 #include "content/common/gamepad_hardware_buffer.h" | 17 #include "content/common/gamepad_hardware_buffer.h" |
| 18 #include "device/gamepad/gamepad_test_helpers.h" |
18 #include "ppapi/c/pp_errors.h" | 19 #include "ppapi/c/pp_errors.h" |
19 #include "ppapi/host/host_message_context.h" | 20 #include "ppapi/host/host_message_context.h" |
20 #include "ppapi/proxy/gamepad_resource.h" | 21 #include "ppapi/proxy/gamepad_resource.h" |
21 #include "ppapi/proxy/ppapi_messages.h" | 22 #include "ppapi/proxy/ppapi_messages.h" |
22 #include "ppapi/proxy/resource_message_params.h" | 23 #include "ppapi/proxy/resource_message_params.h" |
23 #include "ppapi/shared_impl/ppb_gamepad_shared.h" | 24 #include "ppapi/shared_impl/ppb_gamepad_shared.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 | 28 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 PepperGamepadHost gamepad_host( | 145 PepperGamepadHost gamepad_host( |
145 gamepad_service(), GetBrowserPpapiHost(), pp_instance, pp_resource); | 146 gamepad_service(), GetBrowserPpapiHost(), pp_instance, pp_resource); |
146 | 147 |
147 // Synthesize a request for gamepad data. | 148 // Synthesize a request for gamepad data. |
148 ppapi::host::HostMessageContext context( | 149 ppapi::host::HostMessageContext context( |
149 ppapi::proxy::ResourceMessageCallParams(pp_resource, 1)); | 150 ppapi::proxy::ResourceMessageCallParams(pp_resource, 1)); |
150 EXPECT_EQ(PP_OK_COMPLETIONPENDING, | 151 EXPECT_EQ(PP_OK_COMPLETIONPENDING, |
151 gamepad_host.OnResourceMessageReceived( | 152 gamepad_host.OnResourceMessageReceived( |
152 PpapiHostMsg_Gamepad_RequestMemory(), &context)); | 153 PpapiHostMsg_Gamepad_RequestMemory(), &context)); |
153 | 154 |
154 MockGamepadDataFetcher* fetcher = service_->data_fetcher(); | 155 device::MockGamepadDataFetcher* fetcher = service_->data_fetcher(); |
155 fetcher->WaitForDataReadAndCallbacksIssued(); | 156 fetcher->WaitForDataReadAndCallbacksIssued(); |
156 | 157 |
157 // It should not have sent the callback message. | 158 // It should not have sent the callback message. |
158 service_->message_loop().RunUntilIdle(); | 159 service_->message_loop().RunUntilIdle(); |
159 EXPECT_EQ(0u, sink().message_count()); | 160 EXPECT_EQ(0u, sink().message_count()); |
160 | 161 |
161 // Set a button down and wait for it to be read twice. | 162 // Set a button down and wait for it to be read twice. |
162 blink::WebGamepads button_down_data = default_data; | 163 blink::WebGamepads button_down_data = default_data; |
163 button_down_data.items[0].buttons[0].value = 1.f; | 164 button_down_data.items[0].buttons[0].value = 1.f; |
164 button_down_data.items[0].buttons[0].pressed = true; | 165 button_down_data.items[0].buttons[0].pressed = true; |
(...skipping 27 matching lines...) Expand all Loading... |
192 buffer->buffer.items[0].buttons[i].pressed); | 193 buffer->buffer.items[0].buttons[i].pressed); |
193 } | 194 } |
194 | 195 |
195 // Duplicate requests should be denied. | 196 // Duplicate requests should be denied. |
196 EXPECT_EQ(PP_ERROR_FAILED, | 197 EXPECT_EQ(PP_ERROR_FAILED, |
197 gamepad_host.OnResourceMessageReceived( | 198 gamepad_host.OnResourceMessageReceived( |
198 PpapiHostMsg_Gamepad_RequestMemory(), &context)); | 199 PpapiHostMsg_Gamepad_RequestMemory(), &context)); |
199 } | 200 } |
200 | 201 |
201 } // namespace content | 202 } // namespace content |
OLD | NEW |