Index: device/gamepad/gamepad_test_helpers.h |
diff --git a/device/gamepad/gamepad_test_helpers.h b/device/gamepad/gamepad_test_helpers.h |
index 4e482dc1b064e615d297a61aa32397480ae7acb5..26910d21ab89347358a46e47e667e50d24c9f79e 100644 |
--- a/device/gamepad/gamepad_test_helpers.h |
+++ b/device/gamepad/gamepad_test_helpers.h |
@@ -12,6 +12,7 @@ |
#include "base/synchronization/lock.h" |
#include "base/synchronization/waitable_event.h" |
#include "device/gamepad/gamepad_data_fetcher.h" |
+#include "device/gamepad/gamepad_service.h" |
#include "device/gamepad/gamepad_shared_buffer.h" |
#include "third_party/WebKit/public/platform/WebGamepads.h" |
@@ -53,22 +54,6 @@ class MockGamepadDataFetcher : public GamepadDataFetcher { |
DISALLOW_COPY_AND_ASSIGN(MockGamepadDataFetcher); |
}; |
-class MockGamepadSharedBuffer : public GamepadSharedBuffer { |
- public: |
- MockGamepadSharedBuffer(); |
- |
- base::SharedMemory* shared_memory() override; |
- blink::WebGamepads* buffer() override; |
- |
- void WriteBegin() override; |
- void WriteEnd() override; |
- |
- private: |
- base::SharedMemory shared_memory_; |
- |
- DISALLOW_COPY_AND_ASSIGN(MockGamepadSharedBuffer); |
-}; |
- |
// Base class for the other test helpers. This just sets up the system monitor. |
class GamepadTestHelper { |
public: |
@@ -84,6 +69,26 @@ class GamepadTestHelper { |
DISALLOW_COPY_AND_ASSIGN(GamepadTestHelper); |
}; |
+// Constructs a GamepadService with a mock data source. This bypasses the |
+// global singleton for the gamepad service. |
+class GamepadServiceTestConstructor : public GamepadTestHelper { |
+ public: |
+ explicit GamepadServiceTestConstructor(const blink::WebGamepads& test_data); |
+ ~GamepadServiceTestConstructor() override; |
+ |
+ GamepadService* gamepad_service() { return gamepad_service_; } |
+ MockGamepadDataFetcher* data_fetcher() { return data_fetcher_; } |
+ |
+ private: |
+ // Owning pointer (can't be a scoped_ptr due to private destructor). |
+ GamepadService* gamepad_service_; |
+ |
+ // Pointer owned by the provider (which is owned by the gamepad service). |
+ MockGamepadDataFetcher* data_fetcher_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(GamepadServiceTestConstructor); |
+}; |
+ |
} // namespace device |
#endif // DEVICE_GAMEPAD_GAMEPAD_TEST_HELPERS_H_ |