| 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/gamepad/gamepad_test_helpers.h" | 5 #include "content/browser/gamepad/gamepad_test_helpers.h" |
| 6 | 6 |
| 7 #include "content/browser/gamepad/gamepad_service.h" | 7 #include "content/browser/gamepad/gamepad_service.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| 11 MockGamepadDataFetcher::MockGamepadDataFetcher( | 11 MockGamepadDataFetcher::MockGamepadDataFetcher( |
| 12 const WebKit::WebGamepads& test_data) | 12 const blink::WebGamepads& test_data) |
| 13 : test_data_(test_data), | 13 : test_data_(test_data), |
| 14 read_data_(false, false) { | 14 read_data_(false, false) { |
| 15 } | 15 } |
| 16 | 16 |
| 17 MockGamepadDataFetcher::~MockGamepadDataFetcher() { | 17 MockGamepadDataFetcher::~MockGamepadDataFetcher() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 void MockGamepadDataFetcher::GetGamepadData(WebKit::WebGamepads* pads, | 20 void MockGamepadDataFetcher::GetGamepadData(blink::WebGamepads* pads, |
| 21 bool devices_changed_hint) { | 21 bool devices_changed_hint) { |
| 22 { | 22 { |
| 23 base::AutoLock lock(lock_); | 23 base::AutoLock lock(lock_); |
| 24 *pads = test_data_; | 24 *pads = test_data_; |
| 25 } | 25 } |
| 26 read_data_.Signal(); | 26 read_data_.Signal(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void MockGamepadDataFetcher::WaitForDataRead() { | 29 void MockGamepadDataFetcher::WaitForDataRead() { |
| 30 return read_data_.Wait(); | 30 return read_data_.Wait(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void MockGamepadDataFetcher::SetTestData(const WebKit::WebGamepads& new_data) { | 33 void MockGamepadDataFetcher::SetTestData(const blink::WebGamepads& new_data) { |
| 34 base::AutoLock lock(lock_); | 34 base::AutoLock lock(lock_); |
| 35 test_data_ = new_data; | 35 test_data_ = new_data; |
| 36 } | 36 } |
| 37 | 37 |
| 38 GamepadTestHelper::GamepadTestHelper() { | 38 GamepadTestHelper::GamepadTestHelper() { |
| 39 } | 39 } |
| 40 | 40 |
| 41 GamepadTestHelper::~GamepadTestHelper() { | 41 GamepadTestHelper::~GamepadTestHelper() { |
| 42 } | 42 } |
| 43 | 43 |
| 44 GamepadServiceTestConstructor::GamepadServiceTestConstructor( | 44 GamepadServiceTestConstructor::GamepadServiceTestConstructor( |
| 45 const WebKit::WebGamepads& test_data) { | 45 const blink::WebGamepads& test_data) { |
| 46 data_fetcher_ = new MockGamepadDataFetcher(test_data); | 46 data_fetcher_ = new MockGamepadDataFetcher(test_data); |
| 47 gamepad_service_ = | 47 gamepad_service_ = |
| 48 new GamepadService(scoped_ptr<GamepadDataFetcher>(data_fetcher_)); | 48 new GamepadService(scoped_ptr<GamepadDataFetcher>(data_fetcher_)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 GamepadServiceTestConstructor::~GamepadServiceTestConstructor() { | 51 GamepadServiceTestConstructor::~GamepadServiceTestConstructor() { |
| 52 delete gamepad_service_; | 52 delete gamepad_service_; |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace content | 55 } // namespace content |
| OLD | NEW |