Chromium Code Reviews| 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 #include "services/ui/public/cpp/tests/test_window_tree_client_setup.h" | 5 #include "services/ui/public/cpp/tests/test_window_tree_client_setup.h" |
| 6 | 6 |
| 7 #include "services/ui/public/cpp/tests/test_window_tree.h" | 7 #include "services/ui/public/cpp/tests/test_window_tree.h" |
| 8 #include "services/ui/public/cpp/tests/window_tree_client_private.h" | 8 #include "services/ui/public/cpp/tests/window_tree_client_private.h" |
| 9 #include "services/ui/public/cpp/window_tree_client.h" | 9 #include "services/ui/public/cpp/window_tree_client.h" |
| 10 #include "ui/display/display.h" | 10 #include "ui/display/display.h" |
| 11 | 11 |
| 12 namespace ui { | 12 namespace ui { |
| 13 | 13 |
| 14 TestWindowTreeClientSetup::TestWindowTreeClientSetup() {} | 14 TestWindowTreeClientSetup::TestWindowTreeClientSetup() {} |
| 15 | 15 |
| 16 TestWindowTreeClientSetup::~TestWindowTreeClientSetup() { | 16 TestWindowTreeClientSetup::~TestWindowTreeClientSetup() {} |
| 17 std::unique_ptr<WindowTreeClient> window_tree_client = | |
| 18 std::move(window_tree_client_); | |
| 19 if (window_tree_client) | |
| 20 window_tree_client->RemoveObserver(this); | |
| 21 } | |
| 22 | 17 |
| 23 void TestWindowTreeClientSetup::Init( | 18 void TestWindowTreeClientSetup::Init( |
| 24 WindowTreeClientDelegate* window_tree_delegate) { | 19 WindowTreeClientDelegate* window_tree_delegate) { |
| 25 CommonInit(window_tree_delegate, nullptr); | 20 CommonInit(window_tree_delegate, nullptr); |
| 26 WindowTreeClientPrivate(window_tree_client_.get()) | 21 WindowTreeClientPrivate(window_tree_client_.get()) |
| 27 .OnEmbed(window_tree_.get()); | 22 .OnEmbed(window_tree_.get()); |
| 28 } | 23 } |
| 29 | 24 |
| 30 void TestWindowTreeClientSetup::InitForWindowManager( | 25 void TestWindowTreeClientSetup::InitForWindowManager( |
| 31 WindowTreeClientDelegate* window_tree_delegate, | 26 WindowTreeClientDelegate* window_tree_delegate, |
| 32 WindowManagerDelegate* window_manager_delegate, | 27 WindowManagerDelegate* window_manager_delegate, |
| 33 const display::Display& display) { | 28 const display::Display& display) { |
| 34 CommonInit(window_tree_delegate, window_manager_delegate); | 29 CommonInit(window_tree_delegate, window_manager_delegate); |
| 35 WindowTreeClientPrivate(window_tree_client_.get()) | 30 WindowTreeClientPrivate(window_tree_client_.get()) |
| 36 .SetTreeAndClientId(window_tree_.get(), 1); | 31 .SetTreeAndClientId(window_tree_.get(), 1); |
| 37 } | 32 } |
| 38 | 33 |
| 34 std::unique_ptr<WindowTreeClient> | |
| 35 TestWindowTreeClientSetup::OwnWindowTreeClient() { | |
| 36 return std::move(window_tree_client_); | |
|
sadrul
2016/09/02 17:04:15
Would it make sense to DCHECK(window_tree_client_)
sky
2016/09/06 17:15:42
Done.
| |
| 37 } | |
| 38 | |
| 39 WindowTreeClient* TestWindowTreeClientSetup::window_tree_client() { | 39 WindowTreeClient* TestWindowTreeClientSetup::window_tree_client() { |
| 40 return window_tree_client_.get(); | 40 return window_tree_client_.get(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void TestWindowTreeClientSetup::CommonInit( | 43 void TestWindowTreeClientSetup::CommonInit( |
| 44 WindowTreeClientDelegate* window_tree_delegate, | 44 WindowTreeClientDelegate* window_tree_delegate, |
| 45 WindowManagerDelegate* window_manager_delegate) { | 45 WindowManagerDelegate* window_manager_delegate) { |
| 46 window_tree_.reset(new TestWindowTree); | 46 window_tree_.reset(new TestWindowTree); |
| 47 window_tree_client_.reset(new WindowTreeClient( | 47 window_tree_client_.reset(new WindowTreeClient( |
| 48 window_tree_delegate, window_manager_delegate, nullptr)); | 48 window_tree_delegate, window_manager_delegate, nullptr)); |
| 49 static_cast<WindowTreeClient*>(window_tree_client_.get()) | |
| 50 ->AddObserver(this); | |
| 51 } | |
| 52 | |
| 53 void TestWindowTreeClientSetup::OnDidDestroyClient( | |
| 54 ui::WindowTreeClient* client) { | |
| 55 // See comment in header as to why we do this. | |
| 56 window_tree_client_.release(); | |
| 57 } | 49 } |
| 58 | 50 |
| 59 } // namespace ui | 51 } // namespace ui |
| OLD | NEW |