| 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 <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "content/browser/gamepad/gamepad_test_helpers.h" | 9 #include "content/browser/gamepad/gamepad_test_helpers.h" |
| 10 #include "content/browser/renderer_host/pepper/browser_ppapi_host_test.h" | 10 #include "content/browser/renderer_host/pepper/browser_ppapi_host_test.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 // It should have sent a callback. | 172 // It should have sent a callback. |
| 173 service_->message_loop().RunAllPending(); | 173 service_->message_loop().RunAllPending(); |
| 174 ppapi::proxy::ResourceMessageReplyParams reply_params; | 174 ppapi::proxy::ResourceMessageReplyParams reply_params; |
| 175 IPC::Message reply_msg; | 175 IPC::Message reply_msg; |
| 176 ASSERT_TRUE(sink().GetFirstResourceReplyMatching( | 176 ASSERT_TRUE(sink().GetFirstResourceReplyMatching( |
| 177 PpapiPluginMsg_Gamepad_SendMemory::ID, &reply_params, &reply_msg)); | 177 PpapiPluginMsg_Gamepad_SendMemory::ID, &reply_params, &reply_msg)); |
| 178 | 178 |
| 179 // Extract the shared memory handle. | 179 // Extract the shared memory handle. |
| 180 base::SharedMemoryHandle reply_handle; | 180 base::SharedMemoryHandle reply_handle; |
| 181 EXPECT_TRUE(reply_params.GetSharedMemoryHandleAtIndex(0, &reply_handle)); | 181 EXPECT_TRUE(reply_params.TakeSharedMemoryHandleAtIndex(0, &reply_handle)); |
| 182 | 182 |
| 183 // Validate the shared memory. | 183 // Validate the shared memory. |
| 184 base::SharedMemory shared_memory(reply_handle, true); | 184 base::SharedMemory shared_memory(reply_handle, true); |
| 185 EXPECT_TRUE(shared_memory.Map(sizeof(ppapi::ContentGamepadHardwareBuffer))); | 185 EXPECT_TRUE(shared_memory.Map(sizeof(ppapi::ContentGamepadHardwareBuffer))); |
| 186 const ppapi::ContentGamepadHardwareBuffer* buffer = | 186 const ppapi::ContentGamepadHardwareBuffer* buffer = |
| 187 static_cast<const ppapi::ContentGamepadHardwareBuffer*>( | 187 static_cast<const ppapi::ContentGamepadHardwareBuffer*>( |
| 188 shared_memory.memory()); | 188 shared_memory.memory()); |
| 189 EXPECT_EQ(button_down_data.length, buffer->buffer.length); | 189 EXPECT_EQ(button_down_data.length, buffer->buffer.length); |
| 190 EXPECT_EQ(button_down_data.items[0].buttonsLength, | 190 EXPECT_EQ(button_down_data.items[0].buttonsLength, |
| 191 buffer->buffer.items[0].buttons_length); | 191 buffer->buffer.items[0].buttons_length); |
| 192 for (size_t i = 0; i < ppapi::WebKitGamepad::kButtonsLengthCap; i++) { | 192 for (size_t i = 0; i < ppapi::WebKitGamepad::kButtonsLengthCap; i++) { |
| 193 EXPECT_EQ(button_down_data.items[0].buttons[i], | 193 EXPECT_EQ(button_down_data.items[0].buttons[i], |
| 194 buffer->buffer.items[0].buttons[i]); | 194 buffer->buffer.items[0].buttons[i]); |
| 195 } | 195 } |
| 196 | 196 |
| 197 // Duplicate requests should be denied. | 197 // Duplicate requests should be denied. |
| 198 EXPECT_EQ(PP_ERROR_FAILED, | 198 EXPECT_EQ(PP_ERROR_FAILED, |
| 199 gamepad_host.OnResourceMessageReceived( | 199 gamepad_host.OnResourceMessageReceived( |
| 200 PpapiHostMsg_Gamepad_RequestMemory(), | 200 PpapiHostMsg_Gamepad_RequestMemory(), |
| 201 &context)); | 201 &context)); |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace content | 204 } // namespace content |
| OLD | NEW |