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

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

Issue 2807833002: [views-mus] Prevent creating a native OzonePlatform in mus tests. (Closed)
Patch Set: sky comments Created 3 years, 8 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 (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/command_line.h"
7 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
8 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 10 #include "base/run_loop.h"
10 #include "ui/aura/client/default_capture_client.h" 11 #include "ui/aura/client/default_capture_client.h"
11 #include "ui/aura/client/focus_client.h" 12 #include "ui/aura/client/focus_client.h"
12 #include "ui/aura/env.h" 13 #include "ui/aura/env.h"
13 #include "ui/aura/input_state_lookup.h" 14 #include "ui/aura/input_state_lookup.h"
14 #include "ui/aura/mus/capture_synchronizer.h" 15 #include "ui/aura/mus/capture_synchronizer.h"
15 #include "ui/aura/mus/focus_synchronizer.h" 16 #include "ui/aura/mus/focus_synchronizer.h"
16 #include "ui/aura/mus/window_port_mus.h" 17 #include "ui/aura/mus/window_port_mus.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 env_helper.SetAlwaysUseLastMouseLocation(true); 116 env_helper.SetAlwaysUseLastMouseLocation(true);
116 Env::GetInstance()->set_context_factory(context_factory); 117 Env::GetInstance()->set_context_factory(context_factory);
117 Env::GetInstance()->set_context_factory_private(context_factory_private); 118 Env::GetInstance()->set_context_factory_private(context_factory_private);
118 // Unit tests generally don't want to query the system, rather use the state 119 // Unit tests generally don't want to query the system, rather use the state
119 // from RootWindow. 120 // from RootWindow.
120 env_helper.SetInputStateLookup(nullptr); 121 env_helper.SetInputStateLookup(nullptr);
121 env_helper.ResetEventState(); 122 env_helper.ResetEventState();
122 123
123 ui::InitializeInputMethodForTesting(); 124 ui::InitializeInputMethodForTesting();
124 125
125 display::Screen* screen = display::Screen::GetScreen(); 126 if (mode_ != Mode::MUS) {
126 gfx::Size host_size(screen ? screen->GetPrimaryDisplay().GetSizeInPixel() 127 display::Screen* screen = display::Screen::GetScreen();
127 : gfx::Size(800, 600)); 128 gfx::Size host_size(screen ? screen->GetPrimaryDisplay().GetSizeInPixel()
128 // TODO(sky): creating the screen and host should not happen for mus. 129 : gfx::Size(800, 600));
129 test_screen_.reset(TestScreen::Create(host_size)); 130 test_screen_.reset(TestScreen::Create(host_size));
130 if (!screen) 131 if (!screen)
131 display::Screen::SetScreenInstance(test_screen_.get()); 132 display::Screen::SetScreenInstance(test_screen_.get());
132 host_.reset(test_screen_->CreateHostForPrimaryDisplay()); 133 host_.reset(test_screen_->CreateHostForPrimaryDisplay());
133 host_->window()->SetEventTargeter( 134 host_->window()->SetEventTargeter(
134 std::unique_ptr<ui::EventTargeter>(new WindowTargeter())); 135 std::unique_ptr<ui::EventTargeter>(new WindowTargeter()));
135 136
136 client::SetFocusClient(root_window(), focus_client_.get()); 137 client::SetFocusClient(root_window(), focus_client_.get());
137 client::SetCaptureClient(root_window(), capture_client()); 138 client::SetCaptureClient(root_window(), capture_client());
138 parenting_client_.reset(new TestWindowParentingClient(root_window())); 139 parenting_client_.reset(new TestWindowParentingClient(root_window()));
139 140
140 root_window()->Show(); 141 root_window()->Show();
141 // Ensure width != height so tests won't confuse them. 142 // Ensure width != height so tests won't confuse them.
142 host()->SetBoundsInPixels(gfx::Rect(host_size)); 143 host()->SetBoundsInPixels(gfx::Rect(host_size));
144 }
143 145
144 if (mode_ == Mode::MUS_CREATE_WINDOW_TREE_CLIENT) { 146 if (mode_ == Mode::MUS_CREATE_WINDOW_TREE_CLIENT) {
145 window_tree_client_->focus_synchronizer()->SetActiveFocusClient( 147 window_tree_client_->focus_synchronizer()->SetActiveFocusClient(
146 focus_client_.get(), root_window()); 148 focus_client_.get(), root_window());
147 window_tree()->AckAllChanges(); 149 window_tree()->AckAllChanges();
148 } 150 }
149 151
150 g_instance = this; 152 g_instance = this;
151 } 153 }
152 154
153 void AuraTestHelper::TearDown() { 155 void AuraTestHelper::TearDown() {
154 g_instance = nullptr; 156 g_instance = nullptr;
155 teardown_called_ = true; 157 teardown_called_ = true;
156 parenting_client_.reset(); 158 parenting_client_.reset();
157 client::SetFocusClient(root_window(), nullptr); 159 if (mode_ != Mode::MUS) {
158 client::SetCaptureClient(root_window(), nullptr); 160 client::SetFocusClient(root_window(), nullptr);
159 host_.reset(); 161 client::SetCaptureClient(root_window(), nullptr);
162 host_.reset();
163
164 if (display::Screen::GetScreen() == test_screen_.get())
165 display::Screen::SetScreenInstance(nullptr);
166 test_screen_.reset();
167
168 window_tree_client_setup_.reset();
169 focus_client_.reset();
170 capture_client_.reset();
171 }
160 ui::GestureRecognizer::Reset(); 172 ui::GestureRecognizer::Reset();
161 if (display::Screen::GetScreen() == test_screen_.get())
162 display::Screen::SetScreenInstance(nullptr);
163 test_screen_.reset();
164
165 window_tree_client_setup_.reset();
166 focus_client_.reset();
167 capture_client_.reset();
168
169 ui::ShutdownInputMethodForTesting(); 173 ui::ShutdownInputMethodForTesting();
170 174
171 if (env_) 175 if (env_)
172 env_.reset(); 176 env_.reset();
173 else 177 else
174 EnvTestHelper().SetWindowTreeClient(nullptr); 178 EnvTestHelper().SetWindowTreeClient(nullptr);
175 wm_state_.reset(); 179 wm_state_.reset();
176 } 180 }
177 181
178 void AuraTestHelper::RunAllPendingInMessageLoop() { 182 void AuraTestHelper::RunAllPendingInMessageLoop() {
(...skipping 19 matching lines...) Expand all
198 window_tree_client_setup_ = base::MakeUnique<TestWindowTreeClientSetup>(); 202 window_tree_client_setup_ = base::MakeUnique<TestWindowTreeClientSetup>();
199 window_tree_client_setup_->InitForWindowManager(window_tree_delegate_, 203 window_tree_client_setup_->InitForWindowManager(window_tree_delegate_,
200 window_manager_delegate_); 204 window_manager_delegate_);
201 window_tree_client_ = window_tree_client_setup_->window_tree_client(); 205 window_tree_client_ = window_tree_client_setup_->window_tree_client();
202 window_tree_client_->capture_synchronizer()->AttachToCaptureClient( 206 window_tree_client_->capture_synchronizer()->AttachToCaptureClient(
203 capture_client_.get()); 207 capture_client_.get());
204 } 208 }
205 209
206 } // namespace test 210 } // namespace test
207 } // namespace aura 211 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698