| 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" | 17 #include "services/ui/public/interfaces/window_tree_host.mojom.h" |
| 18 | 18 |
| 19 namespace ui { | 19 namespace ui { |
| 20 | 20 |
| 21 // WindowServerTestBase is a base class for use with shell tests that use | 21 // WindowServerTestBase is a base class for use with shell tests that use |
| 22 // WindowServer. SetUp() connects to the WindowServer and blocks until OnEmbed() | 22 // WindowServer. SetUp() connects to the WindowServer and blocks until OnEmbed() |
| 23 // has been invoked. window_manager() can be used to access the WindowServer | 23 // has been invoked. window_manager() can be used to access the WindowServer |
| 24 // established as part of SetUp(). | 24 // established as part of SetUp(). |
| 25 class WindowServerTestBase | 25 class WindowServerTestBase |
| 26 : public WindowServerServiceTestBase, | 26 : public WindowServerServiceTestBase, |
| 27 public WindowTreeClientDelegate, | 27 public WindowTreeClientDelegate, |
| 28 public WindowManagerDelegate, | 28 public WindowManagerDelegate, |
| 29 public shell::InterfaceFactory<mojom::WindowTreeClient> { | 29 public service_manager::InterfaceFactory<mojom::WindowTreeClient> { |
| 30 public: | 30 public: |
| 31 WindowServerTestBase(); | 31 WindowServerTestBase(); |
| 32 ~WindowServerTestBase() override; | 32 ~WindowServerTestBase() override; |
| 33 | 33 |
| 34 // True if WindowTreeClientDelegate::OnLostConnection() was called. | 34 // True if WindowTreeClientDelegate::OnLostConnection() was called. |
| 35 bool window_tree_client_lost_connection() const { | 35 bool window_tree_client_lost_connection() const { |
| 36 return window_tree_client_lost_connection_; | 36 return window_tree_client_lost_connection_; |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs. | 39 // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 60 window_manager_delegate_ = delegate; | 60 window_manager_delegate_ = delegate; |
| 61 } | 61 } |
| 62 | 62 |
| 63 // Cleans up internal state then deletes |client|. | 63 // Cleans up internal state then deletes |client|. |
| 64 void DeleteWindowTreeClient(ui::WindowTreeClient* client); | 64 void DeleteWindowTreeClient(ui::WindowTreeClient* client); |
| 65 | 65 |
| 66 // testing::Test: | 66 // testing::Test: |
| 67 void SetUp() override; | 67 void SetUp() override; |
| 68 | 68 |
| 69 // WindowServerServiceTestBase: | 69 // WindowServerServiceTestBase: |
| 70 bool OnConnect(const shell::Identity& remote_identity, | 70 bool OnConnect(const service_manager::Identity& remote_identity, |
| 71 shell::InterfaceRegistry* registry) override; | 71 service_manager::InterfaceRegistry* registry) override; |
| 72 | 72 |
| 73 // WindowTreeClientDelegate: | 73 // WindowTreeClientDelegate: |
| 74 void OnEmbed(Window* root) override; | 74 void OnEmbed(Window* root) override; |
| 75 void OnLostConnection(WindowTreeClient* client) override; | 75 void OnLostConnection(WindowTreeClient* client) override; |
| 76 void OnEmbedRootDestroyed(Window* root) override; | 76 void OnEmbedRootDestroyed(Window* root) override; |
| 77 void OnPointerEventObserved(const ui::PointerEvent& event, | 77 void OnPointerEventObserved(const ui::PointerEvent& event, |
| 78 Window* target) override; | 78 Window* target) override; |
| 79 | 79 |
| 80 // WindowManagerDelegate: | 80 // WindowManagerDelegate: |
| 81 void SetWindowManagerClient(WindowManagerClient* client) override; | 81 void SetWindowManagerClient(WindowManagerClient* client) override; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 void OnWmDisplayRemoved(Window* window) override; | 92 void OnWmDisplayRemoved(Window* window) override; |
| 93 void OnWmPerformMoveLoop(Window* window, | 93 void OnWmPerformMoveLoop(Window* window, |
| 94 mojom::MoveLoopSource source, | 94 mojom::MoveLoopSource source, |
| 95 const gfx::Point& cursor_location, | 95 const gfx::Point& cursor_location, |
| 96 const base::Callback<void(bool)>& on_done) override; | 96 const base::Callback<void(bool)>& on_done) override; |
| 97 void OnWmCancelMoveLoop(Window* window) override; | 97 void OnWmCancelMoveLoop(Window* window) override; |
| 98 mojom::EventResult OnAccelerator(uint32_t accelerator_id, | 98 mojom::EventResult OnAccelerator(uint32_t accelerator_id, |
| 99 const ui::Event& event) override; | 99 const ui::Event& event) override; |
| 100 | 100 |
| 101 // InterfaceFactory<WindowTreeClient>: | 101 // InterfaceFactory<WindowTreeClient>: |
| 102 void Create(const shell::Identity& remote_identity, | 102 void Create(const service_manager::Identity& remote_identity, |
| 103 mojo::InterfaceRequest<mojom::WindowTreeClient> request) override; | 103 mojo::InterfaceRequest<mojom::WindowTreeClient> request) override; |
| 104 | 104 |
| 105 // Used to receive the most recent window tree client loaded by an embed | 105 // Used to receive the most recent window tree client loaded by an embed |
| 106 // action. | 106 // action. |
| 107 WindowTreeClient* most_recent_client_; | 107 WindowTreeClient* most_recent_client_; |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 mojom::WindowTreeHostPtr host_; | 110 mojom::WindowTreeHostPtr host_; |
| 111 | 111 |
| 112 std::set<std::unique_ptr<WindowTreeClient>> window_tree_clients_; | 112 std::set<std::unique_ptr<WindowTreeClient>> window_tree_clients_; |
| 113 | 113 |
| 114 // The window server connection held by the window manager (app running at | 114 // The window server connection held by the window manager (app running at |
| 115 // the root window). | 115 // the root window). |
| 116 WindowTreeClient* window_manager_; | 116 WindowTreeClient* window_manager_; |
| 117 | 117 |
| 118 // A test can override the WM-related behaviour by installing its own | 118 // A test can override the WM-related behaviour by installing its own |
| 119 // WindowManagerDelegate during the test. | 119 // WindowManagerDelegate during the test. |
| 120 WindowManagerDelegate* window_manager_delegate_; | 120 WindowManagerDelegate* window_manager_delegate_; |
| 121 | 121 |
| 122 WindowManagerClient* window_manager_client_; | 122 WindowManagerClient* window_manager_client_; |
| 123 | 123 |
| 124 bool window_tree_client_lost_connection_ = false; | 124 bool window_tree_client_lost_connection_ = false; |
| 125 | 125 |
| 126 DISALLOW_COPY_AND_ASSIGN(WindowServerTestBase); | 126 DISALLOW_COPY_AND_ASSIGN(WindowServerTestBase); |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 } // namespace ui | 129 } // namespace ui |
| 130 | 130 |
| 131 #endif // SERVICES_UI_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ | 131 #endif // SERVICES_UI_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ |
| OLD | NEW |