| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_TEST_WINDOW_TREE_CLIENT_SETUP_H_ | 5 #ifndef SERVICES_UI_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_CLIENT_SETUP_H_ |
| 6 #define SERVICES_UI_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_CLIENT_SETUP_H_ | 6 #define SERVICES_UI_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_CLIENT_SETUP_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "services/ui/public/cpp/window_tree_client_observer.h" | |
| 12 | 11 |
| 13 namespace display { | 12 namespace display { |
| 14 class Display; | 13 class Display; |
| 15 } | 14 } |
| 16 | 15 |
| 17 namespace ui { | 16 namespace ui { |
| 18 | 17 |
| 19 class TestWindowTree; | 18 class TestWindowTree; |
| 20 class WindowManagerDelegate; | 19 class WindowManagerDelegate; |
| 21 class WindowTreeClient; | 20 class WindowTreeClient; |
| 22 class WindowTreeClientDelegate; | 21 class WindowTreeClientDelegate; |
| 23 | 22 |
| 24 // TestWindowTreeClientSetup is used to create a WindowTreeClient that is not | 23 // TestWindowTreeClientSetup is used to create a WindowTreeClient that is not |
| 25 // connected to mus. | 24 // connected to mus. |
| 26 class TestWindowTreeClientSetup : public ui::WindowTreeClientObserver { | 25 class TestWindowTreeClientSetup { |
| 27 public: | 26 public: |
| 28 TestWindowTreeClientSetup(); | 27 TestWindowTreeClientSetup(); |
| 29 ~TestWindowTreeClientSetup() override; | 28 ~TestWindowTreeClientSetup(); |
| 30 | 29 |
| 31 // Initializes the WindowTreeClient. | 30 // Initializes the WindowTreeClient. |
| 32 void Init(WindowTreeClientDelegate* window_tree_delegate); | 31 void Init(WindowTreeClientDelegate* window_tree_delegate); |
| 33 void InitForWindowManager(WindowTreeClientDelegate* window_tree_delegate, | 32 void InitForWindowManager(WindowTreeClientDelegate* window_tree_delegate, |
| 34 WindowManagerDelegate* window_manager_delegate, | 33 WindowManagerDelegate* window_manager_delegate, |
| 35 const display::Display& display); | 34 const display::Display& display); |
| 36 | 35 |
| 37 // The WindowTree that WindowTreeClient talks to. | 36 // The WindowTree that WindowTreeClient talks to. |
| 38 TestWindowTree* window_tree() { return window_tree_.get(); } | 37 TestWindowTree* window_tree() { return window_tree_.get(); } |
| 39 | 38 |
| 39 // Returns ownership of WindowTreeClient to the caller. |
| 40 std::unique_ptr<WindowTreeClient> OwnWindowTreeClient(); |
| 41 |
| 40 WindowTreeClient* window_tree_client(); | 42 WindowTreeClient* window_tree_client(); |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 // Called by both implementations of init to perform common initialization. | 45 // Called by both implementations of init to perform common initialization. |
| 44 void CommonInit(WindowTreeClientDelegate* window_tree_delegate, | 46 void CommonInit(WindowTreeClientDelegate* window_tree_delegate, |
| 45 WindowManagerDelegate* window_manager_delegate); | 47 WindowManagerDelegate* window_manager_delegate); |
| 46 | 48 |
| 47 // ui::WindowTreeClientObserver: | |
| 48 void OnDidDestroyClient(ui::WindowTreeClient* client) override; | |
| 49 | |
| 50 std::unique_ptr<TestWindowTree> window_tree_; | 49 std::unique_ptr<TestWindowTree> window_tree_; |
| 51 | 50 |
| 52 // See description of WindowTreeClientDelegate for details on ownership. The | |
| 53 // WindowTreeClient may be deleted during shutdown by the test. If not, | |
| 54 // we own it and must delete it. | |
| 55 std::unique_ptr<WindowTreeClient> window_tree_client_; | 51 std::unique_ptr<WindowTreeClient> window_tree_client_; |
| 56 | 52 |
| 57 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeClientSetup); | 53 DISALLOW_COPY_AND_ASSIGN(TestWindowTreeClientSetup); |
| 58 }; | 54 }; |
| 59 | 55 |
| 60 } // namespace ui | 56 } // namespace ui |
| 61 | 57 |
| 62 #endif // SERVICES_UI_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_CLIENT_SETUP_H_ | 58 #endif // SERVICES_UI_PUBLIC_CPP_TESTS_TEST_WINDOW_TREE_CLIENT_SETUP_H_ |
| OLD | NEW |