Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: components/mus/public/cpp/tests/test_window_tree_client_setup.cc

Issue 2072343002: Changes how window manager obtains WindowTree from mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/mus/public/cpp/tests/test_window_tree_client_setup.h" 5 #include "components/mus/public/cpp/tests/test_window_tree_client_setup.h"
6 6
7 #include "components/mus/public/cpp/tests/test_window_tree.h" 7 #include "components/mus/public/cpp/tests/test_window_tree.h"
8 #include "components/mus/public/cpp/tests/window_tree_client_private.h" 8 #include "components/mus/public/cpp/tests/window_tree_client_private.h"
9 #include "components/mus/public/cpp/window_tree_client.h" 9 #include "components/mus/public/cpp/window_tree_client.h"
10 #include "ui/display/display.h"
10 11
11 namespace mus { 12 namespace mus {
12 13
13 TestWindowTreeClientSetup::TestWindowTreeClientSetup() {} 14 TestWindowTreeClientSetup::TestWindowTreeClientSetup() {}
14 15
15 TestWindowTreeClientSetup::~TestWindowTreeClientSetup() { 16 TestWindowTreeClientSetup::~TestWindowTreeClientSetup() {
16 std::unique_ptr<WindowTreeClient> window_tree_client = 17 std::unique_ptr<WindowTreeClient> window_tree_client =
17 std::move(window_tree_client_); 18 std::move(window_tree_client_);
18 if (window_tree_client) 19 if (window_tree_client)
19 window_tree_client->RemoveObserver(this); 20 window_tree_client->RemoveObserver(this);
20 } 21 }
21 22
22 void TestWindowTreeClientSetup::Init( 23 void TestWindowTreeClientSetup::Init(
24 WindowTreeClientDelegate* window_tree_delegate) {
25 CommonInit(window_tree_delegate, nullptr);
26 WindowTreeClientPrivate(window_tree_client_.get())
27 .OnEmbed(window_tree_.get());
28 }
29
30 void TestWindowTreeClientSetup::InitForWindowManager(
31 WindowTreeClientDelegate* window_tree_delegate,
32 WindowManagerDelegate* window_manager_delegate,
33 const display::Display& display) {
34 CommonInit(window_tree_delegate, window_manager_delegate);
35 WindowTreeClientPrivate(window_tree_client_.get())
36 .SetTreeAndClientId(window_tree_.get(), 1);
37 }
38
39 WindowTreeClient* TestWindowTreeClientSetup::window_tree_client() {
40 return window_tree_client_.get();
41 }
42
43 void TestWindowTreeClientSetup::CommonInit(
23 WindowTreeClientDelegate* window_tree_delegate, 44 WindowTreeClientDelegate* window_tree_delegate,
24 WindowManagerDelegate* window_manager_delegate) { 45 WindowManagerDelegate* window_manager_delegate) {
25 window_tree_.reset(new TestWindowTree); 46 window_tree_.reset(new TestWindowTree);
26 window_tree_client_.reset(new WindowTreeClient( 47 window_tree_client_.reset(new WindowTreeClient(
27 window_tree_delegate, window_manager_delegate, nullptr)); 48 window_tree_delegate, window_manager_delegate, nullptr));
28 static_cast<WindowTreeClient*>(window_tree_client_.get()) 49 static_cast<WindowTreeClient*>(window_tree_client_.get())
29 ->AddObserver(this); 50 ->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 } 51 }
37 52
38 void TestWindowTreeClientSetup::OnWillDestroyClient( 53 void TestWindowTreeClientSetup::OnWillDestroyClient(
39 mus::WindowTreeClient* client) { 54 mus::WindowTreeClient* client) {
40 // See comment in header as to why we do this. 55 // See comment in header as to why we do this.
41 window_tree_client_.release(); 56 window_tree_client_.release();
42 } 57 }
43 58
44 } // namespace mus 59 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698