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

Unified Diff: device/gamepad/gamepad_test_helpers.h

Issue 2466073002: Movw GamepadService out of content/browser/ and into device/ (Closed)
Patch Set: Fixed everything but one unittest Created 4 years, 1 month 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 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_
« 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