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

Side by Side Diff: content/browser/gamepad/gamepad_test_helpers.cc

Issue 10912062: Implement the gamepad API in the IPC proxy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/gamepad/gamepad_test_helpers.h"
6
7 #include "base/system_monitor/system_monitor.h"
8 #include "content/browser/gamepad/gamepad_service.h"
9
10 namespace content {
11
12 MockGamepadDataFetcher::MockGamepadDataFetcher(
13 const WebKit::WebGamepads& test_data)
14 : test_data_(test_data),
15 read_data_(false, false) {
16 }
17
18 MockGamepadDataFetcher::~MockGamepadDataFetcher() {
19 }
20
21 void MockGamepadDataFetcher::GetGamepadData(WebKit::WebGamepads* pads,
22 bool devices_changed_hint) {
23 {
24 base::AutoLock lock(lock_);
25 *pads = test_data_;
26 }
27 read_data_.Signal();
28 }
29
30 void MockGamepadDataFetcher::WaitForDataRead() {
31 return read_data_.Wait();
32 }
33
34 void MockGamepadDataFetcher::SetTestData(const WebKit::WebGamepads& new_data) {
35 base::AutoLock lock(lock_);
36 test_data_ = new_data;
37 }
38
39 GamepadTestHelper::GamepadTestHelper() {
40 #if defined(OS_MACOSX)
41 base::SystemMonitor::AllocateSystemIOPorts();
42 #endif
43 system_monitor_.reset(new base::SystemMonitor);
44 }
45
46 GamepadTestHelper::~GamepadTestHelper() {
47 }
48
49 GamepadServiceTestConstructor::GamepadServiceTestConstructor(
50 const WebKit::WebGamepads& test_data) {
51 data_fetcher_ = new MockGamepadDataFetcher(test_data);
52 gamepad_service_ =
53 new GamepadService(scoped_ptr<GamepadDataFetcher>(data_fetcher_));
54 }
55
56 GamepadServiceTestConstructor::~GamepadServiceTestConstructor() {
57 delete gamepad_service_;
58 }
59
60 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gamepad/gamepad_test_helpers.h ('k') | content/browser/gamepad/platform_data_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698