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/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "content/browser/gamepad/gamepad_data_fetcher.h" | 13 #include "content/browser/gamepad/gamepad_data_fetcher.h" |
14 #include "third_party/WebKit/public/platform/WebGamepads.h" | 14 #include "third_party/WebKit/public/platform/WebGamepads.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 class GamepadService; | 18 class GamepadService; |
19 | 19 |
20 // Data fetcher that returns canned data for the gamepad provider. | 20 // Data fetcher that returns canned data for the gamepad provider. |
21 class MockGamepadDataFetcher : public GamepadDataFetcher { | 21 class MockGamepadDataFetcher : public GamepadDataFetcher { |
22 public: | 22 public: |
23 // Initializes the fetcher with the given gamepad data, which will be | 23 // Initializes the fetcher with the given gamepad data, which will be |
24 // returned when the provider queries us. | 24 // returned when the provider queries us. |
25 explicit MockGamepadDataFetcher(const blink::WebGamepads& test_data); | 25 explicit MockGamepadDataFetcher(const blink::WebGamepads& test_data); |
26 | 26 |
27 ~MockGamepadDataFetcher() override; | 27 ~MockGamepadDataFetcher() override; |
28 | 28 |
29 // GamepadDataFetcher. | 29 // GamepadDataFetcher. |
30 void GetGamepadData(blink::WebGamepads* pads, | 30 void GetGamepadData(bool devices_changed_hint) override; |
31 bool devices_changed_hint) override; | |
32 | 31 |
33 // Blocks the current thread until the GamepadProvider reads from this | 32 // Blocks the current thread until the GamepadProvider reads from this |
34 // fetcher on the background thread. | 33 // fetcher on the background thread. |
35 void WaitForDataRead(); | 34 void WaitForDataRead(); |
36 | 35 |
37 // Blocks the current thread until the GamepadProvider reads from this | 36 // Blocks the current thread until the GamepadProvider reads from this |
38 // fetcher on the background thread and issued all callbacks related to the | 37 // fetcher on the background thread and issued all callbacks related to the |
39 // read on the client's thread. | 38 // read on the client's thread. |
40 void WaitForDataReadAndCallbacksIssued(); | 39 void WaitForDataReadAndCallbacksIssued(); |
41 | 40 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 80 |
82 // Pointer owned by the provider (which is owned by the gamepad service). | 81 // Pointer owned by the provider (which is owned by the gamepad service). |
83 MockGamepadDataFetcher* data_fetcher_; | 82 MockGamepadDataFetcher* data_fetcher_; |
84 | 83 |
85 DISALLOW_COPY_AND_ASSIGN(GamepadServiceTestConstructor); | 84 DISALLOW_COPY_AND_ASSIGN(GamepadServiceTestConstructor); |
86 }; | 85 }; |
87 | 86 |
88 } // namespace content | 87 } // namespace content |
89 | 88 |
90 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ | 89 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ |
OLD | NEW |