Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: content/browser/renderer_host/pepper/pepper_gamepad_host_unittest.cc

Issue 2081583002: Migrating majority of gamepad from content/browser/ to device/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final tweaks Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "content/browser/gamepad/gamepad_test_helpers.h" 16 #include "content/browser/gamepad/gamepad_service_test_helpers.h"
17 #include "content/browser/renderer_host/pepper/browser_ppapi_host_test.h" 17 #include "content/browser/renderer_host/pepper/browser_ppapi_host_test.h"
18 #include "content/common/gamepad_hardware_buffer.h" 18 #include "content/common/gamepad_hardware_buffer.h"
19 #include "device/gamepad/gamepad_test_helpers.h"
19 #include "ppapi/c/pp_errors.h" 20 #include "ppapi/c/pp_errors.h"
20 #include "ppapi/host/host_message_context.h" 21 #include "ppapi/host/host_message_context.h"
21 #include "ppapi/proxy/gamepad_resource.h" 22 #include "ppapi/proxy/gamepad_resource.h"
22 #include "ppapi/proxy/ppapi_messages.h" 23 #include "ppapi/proxy/ppapi_messages.h"
23 #include "ppapi/proxy/resource_message_params.h" 24 #include "ppapi/proxy/resource_message_params.h"
24 #include "ppapi/shared_impl/ppb_gamepad_shared.h" 25 #include "ppapi/shared_impl/ppb_gamepad_shared.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 27
27 namespace content { 28 namespace content {
28 29
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 PepperGamepadHost gamepad_host( 146 PepperGamepadHost gamepad_host(
146 gamepad_service(), GetBrowserPpapiHost(), pp_instance, pp_resource); 147 gamepad_service(), GetBrowserPpapiHost(), pp_instance, pp_resource);
147 148
148 // Synthesize a request for gamepad data. 149 // Synthesize a request for gamepad data.
149 ppapi::host::HostMessageContext context( 150 ppapi::host::HostMessageContext context(
150 ppapi::proxy::ResourceMessageCallParams(pp_resource, 1)); 151 ppapi::proxy::ResourceMessageCallParams(pp_resource, 1));
151 EXPECT_EQ(PP_OK_COMPLETIONPENDING, 152 EXPECT_EQ(PP_OK_COMPLETIONPENDING,
152 gamepad_host.OnResourceMessageReceived( 153 gamepad_host.OnResourceMessageReceived(
153 PpapiHostMsg_Gamepad_RequestMemory(), &context)); 154 PpapiHostMsg_Gamepad_RequestMemory(), &context));
154 155
155 MockGamepadDataFetcher* fetcher = service_->data_fetcher(); 156 device::MockGamepadDataFetcher* fetcher = service_->data_fetcher();
156 fetcher->WaitForDataReadAndCallbacksIssued(); 157 fetcher->WaitForDataReadAndCallbacksIssued();
157 158
158 // It should not have sent the callback message. 159 // It should not have sent the callback message.
159 base::RunLoop().RunUntilIdle(); 160 base::RunLoop().RunUntilIdle();
160 EXPECT_EQ(0u, sink().message_count()); 161 EXPECT_EQ(0u, sink().message_count());
161 162
162 // Set a button down and wait for it to be read twice. 163 // Set a button down and wait for it to be read twice.
163 blink::WebGamepads button_down_data = default_data; 164 blink::WebGamepads button_down_data = default_data;
164 button_down_data.items[0].buttons[0].value = 1.f; 165 button_down_data.items[0].buttons[0].value = 1.f;
165 button_down_data.items[0].buttons[0].pressed = true; 166 button_down_data.items[0].buttons[0].pressed = true;
(...skipping 27 matching lines...) Expand all
193 buffer->buffer.items[0].buttons[i].pressed); 194 buffer->buffer.items[0].buttons[i].pressed);
194 } 195 }
195 196
196 // Duplicate requests should be denied. 197 // Duplicate requests should be denied.
197 EXPECT_EQ(PP_ERROR_FAILED, 198 EXPECT_EQ(PP_ERROR_FAILED,
198 gamepad_host.OnResourceMessageReceived( 199 gamepad_host.OnResourceMessageReceived(
199 PpapiHostMsg_Gamepad_RequestMemory(), &context)); 200 PpapiHostMsg_Gamepad_RequestMemory(), &context));
200 } 201 }
201 202
202 } // namespace content 203 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/pepper/pepper_gamepad_host.h ('k') | content/common/gamepad_user_gesture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698