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 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ | 5 #ifndef CONTENT_BROWSER_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ |
6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ | 6 #define CONTENT_BROWSER_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
12 #include "content/browser/gamepad/gamepad_data_fetcher.h" | 12 #include "content/browser/gamepad/gamepad_data_fetcher.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGamepads. h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGamepads. h" |
14 | 14 |
15 namespace base { | |
16 class SystemMonitor; | |
17 } | |
18 | |
19 namespace content { | 15 namespace content { |
20 | 16 |
21 class GamepadService; | 17 class GamepadService; |
22 | 18 |
23 // Data fetcher that returns canned data for the gamepad provider. | 19 // Data fetcher that returns canned data for the gamepad provider. |
24 class MockGamepadDataFetcher : public GamepadDataFetcher { | 20 class MockGamepadDataFetcher : public GamepadDataFetcher { |
25 public: | 21 public: |
26 // Initializes the fetcher with the given gamepad data, which will be | 22 // Initializes the fetcher with the given gamepad data, which will be |
27 // returned when the provider queries us. | 23 // returned when the provider queries us. |
28 explicit MockGamepadDataFetcher(const WebKit::WebGamepads& test_data); | 24 explicit MockGamepadDataFetcher(const WebKit::WebGamepads& test_data); |
(...skipping 24 matching lines...) Expand all Loading... | |
53 public: | 49 public: |
54 GamepadTestHelper(); | 50 GamepadTestHelper(); |
55 virtual ~GamepadTestHelper(); | 51 virtual ~GamepadTestHelper(); |
56 | 52 |
57 MessageLoop& message_loop() { return message_loop_; } | 53 MessageLoop& message_loop() { return message_loop_; } |
58 | 54 |
59 private: | 55 private: |
60 // This must be constructed before the system monitor. | 56 // This must be constructed before the system monitor. |
61 MessageLoop message_loop_; | 57 MessageLoop message_loop_; |
62 | 58 |
63 scoped_ptr<base::SystemMonitor> system_monitor_; | |
vandebo (ex-Chrome)
2012/10/29 18:04:38
I think this is still needed because gampadProvide
Hongbo Min
2012/10/30 14:33:47
I grep the code and didn't find the related code,
| |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(GamepadTestHelper); | 59 DISALLOW_COPY_AND_ASSIGN(GamepadTestHelper); |
66 }; | 60 }; |
67 | 61 |
68 // Constructs a GamepadService with a mock data source. This bypasses the | 62 // Constructs a GamepadService with a mock data source. This bypasses the |
69 // global singleton for the gamepad service. | 63 // global singleton for the gamepad service. |
70 class GamepadServiceTestConstructor : public GamepadTestHelper { | 64 class GamepadServiceTestConstructor : public GamepadTestHelper { |
71 public: | 65 public: |
72 GamepadServiceTestConstructor(const WebKit::WebGamepads& test_data); | 66 GamepadServiceTestConstructor(const WebKit::WebGamepads& test_data); |
73 virtual ~GamepadServiceTestConstructor(); | 67 virtual ~GamepadServiceTestConstructor(); |
74 | 68 |
75 GamepadService* gamepad_service() { return gamepad_service_; } | 69 GamepadService* gamepad_service() { return gamepad_service_; } |
76 MockGamepadDataFetcher* data_fetcher() { return data_fetcher_; } | 70 MockGamepadDataFetcher* data_fetcher() { return data_fetcher_; } |
77 | 71 |
78 private: | 72 private: |
79 // Owning pointer (can't be a scoped_ptr due to private destructor). | 73 // Owning pointer (can't be a scoped_ptr due to private destructor). |
80 GamepadService* gamepad_service_; | 74 GamepadService* gamepad_service_; |
81 | 75 |
82 // Pointer owned by the provider (which is owned by the gamepad service). | 76 // Pointer owned by the provider (which is owned by the gamepad service). |
83 MockGamepadDataFetcher* data_fetcher_; | 77 MockGamepadDataFetcher* data_fetcher_; |
84 | 78 |
85 DISALLOW_COPY_AND_ASSIGN(GamepadServiceTestConstructor); | 79 DISALLOW_COPY_AND_ASSIGN(GamepadServiceTestConstructor); |
86 }; | 80 }; |
87 | 81 |
88 } // namespace content | 82 } // namespace content |
89 | 83 |
90 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ | 84 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ |
OLD | NEW |