| 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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 virtual ~MockGamepadDataFetcher(); | 26 virtual ~MockGamepadDataFetcher(); |
| 27 | 27 |
| 28 // GamepadDataFetcher. | 28 // GamepadDataFetcher. |
| 29 virtual void GetGamepadData(blink::WebGamepads* pads, | 29 virtual void GetGamepadData(blink::WebGamepads* pads, |
| 30 bool devices_changed_hint) OVERRIDE; | 30 bool devices_changed_hint) OVERRIDE; |
| 31 | 31 |
| 32 // Blocks the current thread until the GamepadProvider reads from this | 32 // Blocks the current thread until the GamepadProvider reads from this |
| 33 // fetcher on the background thread. | 33 // fetcher on the background thread. |
| 34 void WaitForDataRead(); | 34 void WaitForDataRead(); |
| 35 | 35 |
| 36 // Blocks the current thread until the GamepadProvider reads from this |
| 37 // fetcher on the background thread and issued all callbacks related to the |
| 38 // read on the client's thread. |
| 39 void WaitForDataReadAndCallbacksIssued(); |
| 40 |
| 36 // Updates the test data. | 41 // Updates the test data. |
| 37 void SetTestData(const blink::WebGamepads& new_data); | 42 void SetTestData(const blink::WebGamepads& new_data); |
| 38 | 43 |
| 39 private: | 44 private: |
| 40 base::Lock lock_; | 45 base::Lock lock_; |
| 41 blink::WebGamepads test_data_; | 46 blink::WebGamepads test_data_; |
| 42 base::WaitableEvent read_data_; | 47 base::WaitableEvent read_data_; |
| 43 | 48 |
| 44 DISALLOW_COPY_AND_ASSIGN(MockGamepadDataFetcher); | 49 DISALLOW_COPY_AND_ASSIGN(MockGamepadDataFetcher); |
| 45 }; | 50 }; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 75 | 80 |
| 76 // 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). |
| 77 MockGamepadDataFetcher* data_fetcher_; | 82 MockGamepadDataFetcher* data_fetcher_; |
| 78 | 83 |
| 79 DISALLOW_COPY_AND_ASSIGN(GamepadServiceTestConstructor); | 84 DISALLOW_COPY_AND_ASSIGN(GamepadServiceTestConstructor); |
| 80 }; | 85 }; |
| 81 | 86 |
| 82 } // namespace content | 87 } // namespace content |
| 83 | 88 |
| 84 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ | 89 #endif // CONTENT_BROWSER_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ |
| OLD | NEW |