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

Unified Diff: services/ui/ws/test_utils.h

Issue 2326203002: services/ui: Add WindowServerTestHelper. (Closed)
Patch Set: self nit Created 4 years, 3 months 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 | « services/ui/ws/display_unittest.cc ('k') | services/ui/ws/test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/test_utils.h
diff --git a/services/ui/ws/test_utils.h b/services/ui/ws/test_utils.h
index 5aa74cc3cc48d73d8e60dc605edc3b8bf64c2231..a5a7c90925802a45cc7a6a1acb2c21e5001de132 100644
--- a/services/ui/ws/test_utils.h
+++ b/services/ui/ws/test_utils.h
@@ -505,6 +505,33 @@ class TestWindowServerDelegate : public WindowServerDelegate {
// -----------------------------------------------------------------------------
+// Helper class which creates and sets up the necessary objects for tests that
+// use the WindowServer.
+class WindowServerTestHelper {
+ public:
+ WindowServerTestHelper();
+ ~WindowServerTestHelper();
+
+ WindowServer* window_server() { return window_server_.get(); }
+ int32_t cursor_id() const { return cursor_id_; }
+
+ TestWindowServerDelegate* window_server_delegate() {
+ return &window_server_delegate_;
+ }
+ base::MessageLoop* message_loop() { return &message_loop_; }
+
+ private:
+ int32_t cursor_id_;
+ TestPlatformDisplayFactory platform_display_factory_;
+ TestWindowServerDelegate window_server_delegate_;
+ std::unique_ptr<WindowServer> window_server_;
+ base::MessageLoop message_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowServerTestHelper);
+};
+
+// -----------------------------------------------------------------------------
+
// Helper class which owns all of the necessary objects to test event targeting
// of ServerWindow objects.
class WindowEventTargetingHelper {
@@ -528,32 +555,27 @@ class WindowEventTargetingHelper {
// Sets the task runner for |message_loop_|
void SetTaskRunner(scoped_refptr<base::SingleThreadTaskRunner> task_runner);
- int32_t cursor_id() { return cursor_id_; }
+ int32_t cursor_id() const { return ws_test_helper_.cursor_id(); }
Display* display() { return display_; }
TestWindowTreeBinding* last_binding() {
- return window_server_delegate_.last_binding();
+ return ws_test_helper_.window_server_delegate()->last_binding();
}
TestWindowTreeClient* last_window_tree_client() {
- return window_server_delegate_.last_client();
+ return ws_test_helper_.window_server_delegate()->last_client();
}
TestWindowTreeClient* wm_client() { return wm_client_; }
- WindowServer* window_server() { return window_server_.get(); }
+ WindowServer* window_server() { return ws_test_helper_.window_server(); }
private:
+ WindowServerTestHelper ws_test_helper_;
// TestWindowTreeClient that is used for the WM client. Owned by
// |window_server_delegate_|
TestWindowTreeClient* wm_client_;
- int32_t cursor_id_;
- TestPlatformDisplayFactory platform_display_factory_;
- TestWindowServerDelegate window_server_delegate_;
// Owned by WindowServer
TestDisplayBinding* display_binding_;
// Owned by WindowServer's DisplayManager.
Display* display_;
scoped_refptr<SurfacesState> surfaces_state_;
- std::unique_ptr<WindowServer> window_server_;
- // Needed to Bind to |wm_client_|
- base::MessageLoop message_loop_;
DISALLOW_COPY_AND_ASSIGN(WindowEventTargetingHelper);
};
« no previous file with comments | « services/ui/ws/display_unittest.cc ('k') | services/ui/ws/test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698