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

Unified Diff: device/gamepad/gamepad_test_helpers.h

Issue 2563483006: Move gamepad_service out of content/ and into device/ (Closed)
Patch Set: addressed Blundell's review comments Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/gamepad/gamepad_shared_buffer.cc ('k') | device/gamepad/gamepad_test_helpers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/gamepad/gamepad_test_helpers.h
diff --git a/device/gamepad/gamepad_test_helpers.h b/device/gamepad/gamepad_test_helpers.h
index 14eb1767387da7b53eae085dac2f4a0e749625d1..b4f8c934780369c0b4bc07375a608dc8064ba2e1 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"
@@ -51,22 +52,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:
@@ -82,6 +67,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_
« no previous file with comments | « device/gamepad/gamepad_shared_buffer.cc ('k') | device/gamepad/gamepad_test_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698