| 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 COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ | 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ |
| 6 #define COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ | 6 #define COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "components/mus/public/cpp/tests/window_server_shelltest_base.h" | 10 #include "components/mus/public/cpp/tests/window_server_shelltest_base.h" |
| 11 #include "components/mus/public/cpp/window_manager_delegate.h" | 11 #include "components/mus/public/cpp/window_manager_delegate.h" |
| 12 #include "components/mus/public/cpp/window_tree_delegate.h" | 12 #include "components/mus/public/cpp/window_tree_delegate.h" |
| 13 #include "components/mus/public/interfaces/window_tree.mojom.h" | 13 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 14 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 14 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
| 15 #include "services/shell/public/cpp/interface_factory.h" | 15 #include "services/shell/public/cpp/interface_factory.h" |
| 16 | 16 |
| 17 namespace mus { | 17 namespace mus { |
| 18 | 18 |
| 19 // WindowServerTestBase is a base class for use with shell tests that use | 19 // WindowServerTestBase is a base class for use with shell tests that use |
| 20 // WindowServer. SetUp() connects to the WindowServer and blocks until OnEmbed() | 20 // WindowServer. SetUp() connects to the WindowServer and blocks until OnEmbed() |
| 21 // has been invoked. window_manager() can be used to access the WindowServer | 21 // has been invoked. window_manager() can be used to access the WindowServer |
| 22 // established as part of SetUp(). | 22 // established as part of SetUp(). |
| 23 class WindowServerTestBase | 23 class WindowServerTestBase |
| 24 : public WindowServerShellTestBase, | 24 : public WindowServerShellTestBase, |
| 25 public WindowTreeDelegate, | 25 public WindowTreeDelegate, |
| 26 public WindowManagerDelegate, | 26 public WindowManagerDelegate, |
| 27 public mojo::InterfaceFactory<mojom::WindowTreeClient> { | 27 public shell::InterfaceFactory<mojom::WindowTreeClient> { |
| 28 public: | 28 public: |
| 29 WindowServerTestBase(); | 29 WindowServerTestBase(); |
| 30 ~WindowServerTestBase() override; | 30 ~WindowServerTestBase() override; |
| 31 | 31 |
| 32 // True if WindowTreeDelegate::OnConnectionLost() was called. | 32 // True if WindowTreeDelegate::OnConnectionLost() was called. |
| 33 bool window_tree_connection_destroyed() const { | 33 bool window_tree_connection_destroyed() const { |
| 34 return window_tree_connection_destroyed_; | 34 return window_tree_connection_destroyed_; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs. | 37 // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 void set_window_manager_delegate(WindowManagerDelegate* delegate) { | 57 void set_window_manager_delegate(WindowManagerDelegate* delegate) { |
| 58 window_manager_delegate_ = delegate; | 58 window_manager_delegate_ = delegate; |
| 59 } | 59 } |
| 60 | 60 |
| 61 // testing::Test: | 61 // testing::Test: |
| 62 void SetUp() override; | 62 void SetUp() override; |
| 63 | 63 |
| 64 // WindowServerShellTestBase: | 64 // WindowServerShellTestBase: |
| 65 bool AcceptConnection(mojo::Connection* connection) override; | 65 bool AcceptConnection(shell::Connection* connection) override; |
| 66 | 66 |
| 67 // WindowTreeDelegate: | 67 // WindowTreeDelegate: |
| 68 void OnEmbed(Window* root) override; | 68 void OnEmbed(Window* root) override; |
| 69 void OnConnectionLost(WindowTreeConnection* connection) override; | 69 void OnConnectionLost(WindowTreeConnection* connection) override; |
| 70 | 70 |
| 71 // WindowManagerDelegate: | 71 // WindowManagerDelegate: |
| 72 void SetWindowManagerClient(WindowManagerClient* client) override; | 72 void SetWindowManagerClient(WindowManagerClient* client) override; |
| 73 bool OnWmSetBounds(Window* window, gfx::Rect* bounds) override; | 73 bool OnWmSetBounds(Window* window, gfx::Rect* bounds) override; |
| 74 bool OnWmSetProperty(Window* window, | 74 bool OnWmSetProperty(Window* window, |
| 75 const std::string& name, | 75 const std::string& name, |
| 76 scoped_ptr<std::vector<uint8_t>>* new_data) override; | 76 scoped_ptr<std::vector<uint8_t>>* new_data) override; |
| 77 Window* OnWmCreateTopLevelWindow( | 77 Window* OnWmCreateTopLevelWindow( |
| 78 std::map<std::string, std::vector<uint8_t>>* properties) override; | 78 std::map<std::string, std::vector<uint8_t>>* properties) override; |
| 79 void OnAccelerator(uint32_t id, const ui::Event& event) override; | 79 void OnAccelerator(uint32_t id, const ui::Event& event) override; |
| 80 | 80 |
| 81 // InterfaceFactory<WindowTreeClient>: | 81 // InterfaceFactory<WindowTreeClient>: |
| 82 void Create(mojo::Connection* connection, | 82 void Create(shell::Connection* connection, |
| 83 mojo::InterfaceRequest<mojom::WindowTreeClient> request) override; | 83 mojo::InterfaceRequest<mojom::WindowTreeClient> request) override; |
| 84 | 84 |
| 85 // Used to receive the most recent window tree connection loaded by an embed | 85 // Used to receive the most recent window tree connection loaded by an embed |
| 86 // action. | 86 // action. |
| 87 WindowTreeConnection* most_recent_connection_; | 87 WindowTreeConnection* most_recent_connection_; |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 mojom::WindowTreeHostPtr host_; | 90 mojom::WindowTreeHostPtr host_; |
| 91 | 91 |
| 92 // The window server connection held by the window manager (app running at | 92 // The window server connection held by the window manager (app running at |
| 93 // the root window). | 93 // the root window). |
| 94 WindowTreeConnection* window_manager_; | 94 WindowTreeConnection* window_manager_; |
| 95 | 95 |
| 96 // A test can override the WM-related behaviour by installing its own | 96 // A test can override the WM-related behaviour by installing its own |
| 97 // WindowManagerDelegate during the test. | 97 // WindowManagerDelegate during the test. |
| 98 WindowManagerDelegate* window_manager_delegate_; | 98 WindowManagerDelegate* window_manager_delegate_; |
| 99 | 99 |
| 100 WindowManagerClient* window_manager_client_; | 100 WindowManagerClient* window_manager_client_; |
| 101 | 101 |
| 102 bool window_tree_connection_destroyed_; | 102 bool window_tree_connection_destroyed_; |
| 103 | 103 |
| 104 DISALLOW_COPY_AND_ASSIGN(WindowServerTestBase); | 104 DISALLOW_COPY_AND_ASSIGN(WindowServerTestBase); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 } // namespace mus | 107 } // namespace mus |
| 108 | 108 |
| 109 #endif // COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ | 109 #endif // COMPONENTS_MUS_PUBLIC_CPP_TESTS_WINDOW_SERVER_TEST_BASE_H_ |
| OLD | NEW |