OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/mus/public/cpp/tests/test_window_tree_client_setup.h" |
| 6 |
| 7 #include "components/mus/public/cpp/tests/test_window_tree.h" |
| 8 #include "components/mus/public/cpp/tests/window_tree_client_private.h" |
| 9 #include "components/mus/public/cpp/window_tree_client.h" |
| 10 |
| 11 namespace mus { |
| 12 |
| 13 TestWindowTreeClientSetup::TestWindowTreeClientSetup() {} |
| 14 |
| 15 TestWindowTreeClientSetup::~TestWindowTreeClientSetup() { |
| 16 std::unique_ptr<WindowTreeClient> window_tree_client = |
| 17 std::move(window_tree_client_); |
| 18 if (window_tree_client) |
| 19 window_tree_client->RemoveObserver(this); |
| 20 } |
| 21 |
| 22 void TestWindowTreeClientSetup::Init( |
| 23 WindowTreeClientDelegate* window_tree_delegate, |
| 24 WindowManagerDelegate* window_manager_delegate) { |
| 25 window_tree_.reset(new TestWindowTree); |
| 26 window_tree_client_.reset(new WindowTreeClient( |
| 27 window_tree_delegate, window_manager_delegate, nullptr)); |
| 28 static_cast<WindowTreeClient*>(window_tree_client_.get()) |
| 29 ->AddObserver(this); |
| 30 WindowTreeClientPrivate(window_tree_client_.get()) |
| 31 .OnEmbed(window_tree_.get()); |
| 32 } |
| 33 |
| 34 WindowTreeClient* TestWindowTreeClientSetup::window_tree_client() { |
| 35 return window_tree_client_.get(); |
| 36 } |
| 37 |
| 38 void TestWindowTreeClientSetup::OnWillDestroyClient( |
| 39 mus::WindowTreeClient* client) { |
| 40 // See comment in header as to why we do this. |
| 41 window_tree_client_.release(); |
| 42 } |
| 43 |
| 44 } // namespace mus |
OLD | NEW |