| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 SERVICES_UI_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ | 5 #ifndef SERVICES_UI_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ |
| 6 #define SERVICES_UI_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ | 6 #define SERVICES_UI_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "services/service_manager/public/cpp/interface_factory.h" | 12 #include "services/service_manager/public/cpp/interface_factory.h" |
| 13 #include "services/ui/public/cpp/tests/window_server_shelltest_base.h" | 13 #include "services/ui/public/cpp/tests/window_server_shelltest_base.h" |
| 14 #include "services/ui/public/cpp/window_manager_delegate.h" | 14 #include "services/ui/public/cpp/window_manager_delegate.h" |
| 15 #include "services/ui/public/cpp/window_tree_client_delegate.h" | 15 #include "services/ui/public/cpp/window_tree_client_delegate.h" |
| 16 #include "services/ui/public/interfaces/window_tree.mojom.h" | 16 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 17 #include "services/ui/public/interfaces/window_tree_host.mojom.h" | |
| 18 | 17 |
| 19 namespace ui { | 18 namespace ui { |
| 20 | 19 |
| 21 // WindowServerTestBase is a base class for use with shell tests that use | 20 // WindowServerTestBase is a base class for use with shell tests that use |
| 22 // WindowServer. SetUp() connects to the WindowServer and blocks until OnEmbed() | 21 // WindowServer. SetUp() connects to the WindowServer and blocks until OnEmbed() |
| 23 // has been invoked. window_manager() can be used to access the WindowServer | 22 // has been invoked. window_manager() can be used to access the WindowServer |
| 24 // established as part of SetUp(). | 23 // established as part of SetUp(). |
| 25 class WindowServerTestBase | 24 class WindowServerTestBase |
| 26 : public WindowServerServiceTestBase, | 25 : public WindowServerServiceTestBase, |
| 27 public WindowTreeClientDelegate, | 26 public WindowTreeClientDelegate, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 44 // Quits a run loop started by DoRunLoopWithTimeout(). Returns true on | 43 // Quits a run loop started by DoRunLoopWithTimeout(). Returns true on |
| 45 // success, false if a RunLoop isn't running. | 44 // success, false if a RunLoop isn't running. |
| 46 static bool QuitRunLoop() WARN_UNUSED_RESULT; | 45 static bool QuitRunLoop() WARN_UNUSED_RESULT; |
| 47 | 46 |
| 48 WindowTreeClient* window_manager() { return window_manager_; } | 47 WindowTreeClient* window_manager() { return window_manager_; } |
| 49 WindowManagerClient* window_manager_client() { | 48 WindowManagerClient* window_manager_client() { |
| 50 return window_manager_client_; | 49 return window_manager_client_; |
| 51 } | 50 } |
| 52 | 51 |
| 53 protected: | 52 protected: |
| 54 mojom::WindowTreeHost* host() { return host_.get(); } | |
| 55 WindowTreeClient* most_recent_client() { | |
| 56 return most_recent_client_; | |
| 57 } | |
| 58 | |
| 59 void set_window_manager_delegate(WindowManagerDelegate* delegate) { | 53 void set_window_manager_delegate(WindowManagerDelegate* delegate) { |
| 60 window_manager_delegate_ = delegate; | 54 window_manager_delegate_ = delegate; |
| 61 } | 55 } |
| 62 | 56 |
| 63 // Cleans up internal state then deletes |client|. | 57 // Cleans up internal state then deletes |client|. |
| 64 void DeleteWindowTreeClient(ui::WindowTreeClient* client); | 58 void DeleteWindowTreeClient(ui::WindowTreeClient* client); |
| 65 | 59 |
| 66 // testing::Test: | 60 // testing::Test: |
| 67 void SetUp() override; | 61 void SetUp() override; |
| 68 | 62 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 96 const gfx::Point& cursor_location, | 90 const gfx::Point& cursor_location, |
| 97 const base::Callback<void(bool)>& on_done) override; | 91 const base::Callback<void(bool)>& on_done) override; |
| 98 void OnWmCancelMoveLoop(Window* window) override; | 92 void OnWmCancelMoveLoop(Window* window) override; |
| 99 mojom::EventResult OnAccelerator(uint32_t accelerator_id, | 93 mojom::EventResult OnAccelerator(uint32_t accelerator_id, |
| 100 const ui::Event& event) override; | 94 const ui::Event& event) override; |
| 101 | 95 |
| 102 // InterfaceFactory<WindowTreeClient>: | 96 // InterfaceFactory<WindowTreeClient>: |
| 103 void Create(const service_manager::Identity& remote_identity, | 97 void Create(const service_manager::Identity& remote_identity, |
| 104 mojo::InterfaceRequest<mojom::WindowTreeClient> request) override; | 98 mojo::InterfaceRequest<mojom::WindowTreeClient> request) override; |
| 105 | 99 |
| 106 // Used to receive the most recent window tree client loaded by an embed | |
| 107 // action. | |
| 108 WindowTreeClient* most_recent_client_; | |
| 109 | |
| 110 private: | 100 private: |
| 111 mojom::WindowTreeHostPtr host_; | |
| 112 | |
| 113 std::set<std::unique_ptr<WindowTreeClient>> window_tree_clients_; | 101 std::set<std::unique_ptr<WindowTreeClient>> window_tree_clients_; |
| 114 | 102 |
| 115 // The window server connection held by the window manager (app running at | 103 // The window server connection held by the window manager (app running at |
| 116 // the root window). | 104 // the root window). |
| 117 WindowTreeClient* window_manager_; | 105 WindowTreeClient* window_manager_; |
| 118 | 106 |
| 119 // A test can override the WM-related behaviour by installing its own | 107 // A test can override the WM-related behaviour by installing its own |
| 120 // WindowManagerDelegate during the test. | 108 // WindowManagerDelegate during the test. |
| 121 WindowManagerDelegate* window_manager_delegate_; | 109 WindowManagerDelegate* window_manager_delegate_; |
| 122 | 110 |
| 123 WindowManagerClient* window_manager_client_; | 111 WindowManagerClient* window_manager_client_; |
| 124 | 112 |
| 125 bool window_tree_client_lost_connection_ = false; | 113 bool window_tree_client_lost_connection_ = false; |
| 126 | 114 |
| 127 DISALLOW_COPY_AND_ASSIGN(WindowServerTestBase); | 115 DISALLOW_COPY_AND_ASSIGN(WindowServerTestBase); |
| 128 }; | 116 }; |
| 129 | 117 |
| 130 } // namespace ui | 118 } // namespace ui |
| 131 | 119 |
| 132 #endif // SERVICES_UI_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ | 120 #endif // SERVICES_UI_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ |
| OLD | NEW |