| 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 "base/system_monitor/system_monitor.h" | |
| 8 #include "content/browser/gamepad/gamepad_service.h" | 7 #include "content/browser/gamepad/gamepad_service.h" |
| 9 | 8 |
| 10 namespace content { | 9 namespace content { |
| 11 | 10 |
| 12 MockGamepadDataFetcher::MockGamepadDataFetcher( | 11 MockGamepadDataFetcher::MockGamepadDataFetcher( |
| 13 const WebKit::WebGamepads& test_data) | 12 const WebKit::WebGamepads& test_data) |
| 14 : test_data_(test_data), | 13 : test_data_(test_data), |
| 15 read_data_(false, false) { | 14 read_data_(false, false) { |
| 16 } | 15 } |
| 17 | 16 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 30 void MockGamepadDataFetcher::WaitForDataRead() { | 29 void MockGamepadDataFetcher::WaitForDataRead() { |
| 31 return read_data_.Wait(); | 30 return read_data_.Wait(); |
| 32 } | 31 } |
| 33 | 32 |
| 34 void MockGamepadDataFetcher::SetTestData(const WebKit::WebGamepads& new_data) { | 33 void MockGamepadDataFetcher::SetTestData(const WebKit::WebGamepads& new_data) { |
| 35 base::AutoLock lock(lock_); | 34 base::AutoLock lock(lock_); |
| 36 test_data_ = new_data; | 35 test_data_ = new_data; |
| 37 } | 36 } |
| 38 | 37 |
| 39 GamepadTestHelper::GamepadTestHelper() { | 38 GamepadTestHelper::GamepadTestHelper() { |
| 40 #if defined(OS_MACOSX) | |
| 41 base::SystemMonitor::AllocateSystemIOPorts(); | |
| 42 #endif | |
| 43 system_monitor_.reset(new base::SystemMonitor); | |
| 44 } | 39 } |
| 45 | 40 |
| 46 GamepadTestHelper::~GamepadTestHelper() { | 41 GamepadTestHelper::~GamepadTestHelper() { |
| 47 } | 42 } |
| 48 | 43 |
| 49 GamepadServiceTestConstructor::GamepadServiceTestConstructor( | 44 GamepadServiceTestConstructor::GamepadServiceTestConstructor( |
| 50 const WebKit::WebGamepads& test_data) { | 45 const WebKit::WebGamepads& test_data) { |
| 51 data_fetcher_ = new MockGamepadDataFetcher(test_data); | 46 data_fetcher_ = new MockGamepadDataFetcher(test_data); |
| 52 gamepad_service_ = | 47 gamepad_service_ = |
| 53 new GamepadService(scoped_ptr<GamepadDataFetcher>(data_fetcher_)); | 48 new GamepadService(scoped_ptr<GamepadDataFetcher>(data_fetcher_)); |
| 54 } | 49 } |
| 55 | 50 |
| 56 GamepadServiceTestConstructor::~GamepadServiceTestConstructor() { | 51 GamepadServiceTestConstructor::~GamepadServiceTestConstructor() { |
| 57 delete gamepad_service_; | 52 delete gamepad_service_; |
| 58 } | 53 } |
| 59 | 54 |
| 60 } // namespace content | 55 } // namespace content |
| OLD | NEW |