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

Side by Side Diff: ui/aura/test/aura_test_helper.cc

Issue 2563783002: ui + mus: Split ContextFactory into ContextFactory(Client) and ContextFactoryPrivate (Closed)
Patch Set: Restore mash Created 4 years 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
« no previous file with comments | « ui/aura/test/aura_test_helper.h ('k') | ui/aura/window_tree_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/aura/test/aura_test_helper.h" 5 #include "ui/aura/test/aura_test_helper.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "ui/aura/client/default_capture_client.h" 10 #include "ui/aura/client/default_capture_client.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 void AuraTestHelper::EnableMusWithWindowTreeClient( 71 void AuraTestHelper::EnableMusWithWindowTreeClient(
72 WindowTreeClient* window_tree_client) { 72 WindowTreeClient* window_tree_client) {
73 DCHECK(!setup_called_); 73 DCHECK(!setup_called_);
74 DCHECK_EQ(Mode::LOCAL, mode_); 74 DCHECK_EQ(Mode::LOCAL, mode_);
75 mode_ = Mode::MUS; 75 mode_ = Mode::MUS;
76 window_tree_client_ = window_tree_client; 76 window_tree_client_ = window_tree_client;
77 } 77 }
78 78
79 void AuraTestHelper::SetUp(ui::ContextFactory* context_factory) { 79 void AuraTestHelper::SetUp(ui::ContextFactory* context_factory,
80 ui::ContextFactoryPrivate* context_factory_private) {
80 setup_called_ = true; 81 setup_called_ = true;
81 82
82 if (mode_ != Mode::MUS) { 83 if (mode_ != Mode::MUS) {
83 // Assume if an explicit WindowTreeClient was created then a WmState was 84 // Assume if an explicit WindowTreeClient was created then a WmState was
84 // already created. 85 // already created.
85 wm_state_ = base::MakeUnique<wm::WMState>(); 86 wm_state_ = base::MakeUnique<wm::WMState>();
86 } 87 }
87 // Needs to be before creating WindowTreeClient. 88 // Needs to be before creating WindowTreeClient.
88 focus_client_ = base::MakeUnique<TestFocusClient>(); 89 focus_client_ = base::MakeUnique<TestFocusClient>();
89 capture_client_ = base::MakeUnique<client::DefaultCaptureClient>(); 90 capture_client_ = base::MakeUnique<client::DefaultCaptureClient>();
90 const Env::Mode env_mode = 91 const Env::Mode env_mode =
91 (mode_ == Mode::LOCAL) ? Env::Mode::LOCAL : Env::Mode::MUS; 92 (mode_ == Mode::LOCAL) ? Env::Mode::LOCAL : Env::Mode::MUS;
92 if (mode_ == Mode::MUS_CREATE_WINDOW_TREE_CLIENT) 93 if (mode_ == Mode::MUS_CREATE_WINDOW_TREE_CLIENT)
93 InitWindowTreeClient(); 94 InitWindowTreeClient();
94 if (!Env::GetInstanceDontCreate()) 95 if (!Env::GetInstanceDontCreate())
95 env_ = Env::CreateInstance(env_mode); 96 env_ = Env::CreateInstance(env_mode);
96 EnvTestHelper env_helper; 97 EnvTestHelper env_helper;
97 // Always reset the mode. This really only matters for if Env was created 98 // Always reset the mode. This really only matters for if Env was created
98 // above. 99 // above.
99 env_helper.SetMode(env_mode); 100 env_helper.SetMode(env_mode);
100 env_helper.SetWindowTreeClient(window_tree_client_); 101 env_helper.SetWindowTreeClient(window_tree_client_);
101 Env::GetInstance()->SetActiveFocusClient(focus_client_.get(), nullptr); 102 Env::GetInstance()->SetActiveFocusClient(focus_client_.get(), nullptr);
102 Env::GetInstance()->set_context_factory(context_factory); 103 Env::GetInstance()->set_context_factory(context_factory);
104 Env::GetInstance()->set_context_factory_private(context_factory_private);
103 // Unit tests generally don't want to query the system, rather use the state 105 // Unit tests generally don't want to query the system, rather use the state
104 // from RootWindow. 106 // from RootWindow.
105 env_helper.SetInputStateLookup(nullptr); 107 env_helper.SetInputStateLookup(nullptr);
106 env_helper.ResetEventState(); 108 env_helper.ResetEventState();
107 109
108 ui::InitializeInputMethodForTesting(); 110 ui::InitializeInputMethodForTesting();
109 111
110 display::Screen* screen = display::Screen::GetScreen(); 112 display::Screen* screen = display::Screen::GetScreen();
111 gfx::Size host_size(screen ? screen->GetPrimaryDisplay().GetSizeInPixel() 113 gfx::Size host_size(screen ? screen->GetPrimaryDisplay().GetSizeInPixel()
112 : gfx::Size(800, 600)); 114 : gfx::Size(800, 600));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 176
175 void AuraTestHelper::InitWindowTreeClient() { 177 void AuraTestHelper::InitWindowTreeClient() {
176 window_tree_client_setup_ = base::MakeUnique<TestWindowTreeClientSetup>(); 178 window_tree_client_setup_ = base::MakeUnique<TestWindowTreeClientSetup>();
177 window_tree_client_setup_->InitForWindowManager(window_tree_delegate_, 179 window_tree_client_setup_->InitForWindowManager(window_tree_delegate_,
178 window_manager_delegate_); 180 window_manager_delegate_);
179 window_tree_client_ = window_tree_client_setup_->window_tree_client(); 181 window_tree_client_ = window_tree_client_setup_->window_tree_client();
180 } 182 }
181 183
182 } // namespace test 184 } // namespace test
183 } // namespace aura 185 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/test/aura_test_helper.h ('k') | ui/aura/window_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698