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

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

Issue 2714763002: Change FocusSynchronizer to maintain active focus client and window. (Closed)
Patch Set: switch back to use FocusSynchronizerObserver Created 3 years, 9 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/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"
11 #include "ui/aura/client/focus_client.h" 11 #include "ui/aura/client/focus_client.h"
12 #include "ui/aura/env.h" 12 #include "ui/aura/env.h"
13 #include "ui/aura/input_state_lookup.h" 13 #include "ui/aura/input_state_lookup.h"
14 #include "ui/aura/mus/capture_synchronizer.h" 14 #include "ui/aura/mus/capture_synchronizer.h"
15 #include "ui/aura/mus/focus_synchronizer.h"
15 #include "ui/aura/mus/window_port_mus.h" 16 #include "ui/aura/mus/window_port_mus.h"
16 #include "ui/aura/mus/window_tree_client.h" 17 #include "ui/aura/mus/window_tree_client.h"
17 #include "ui/aura/test/env_test_helper.h" 18 #include "ui/aura/test/env_test_helper.h"
18 #include "ui/aura/test/event_generator_delegate_aura.h" 19 #include "ui/aura/test/event_generator_delegate_aura.h"
19 #include "ui/aura/test/mus/test_window_tree.h" 20 #include "ui/aura/test/mus/test_window_tree.h"
20 #include "ui/aura/test/mus/test_window_tree_client_setup.h" 21 #include "ui/aura/test/mus/test_window_tree_client_setup.h"
21 #include "ui/aura/test/test_focus_client.h" 22 #include "ui/aura/test/test_focus_client.h"
22 #include "ui/aura/test/test_screen.h" 23 #include "ui/aura/test/test_screen.h"
23 #include "ui/aura/test/test_window_parenting_client.h" 24 #include "ui/aura/test/test_window_parenting_client.h"
24 #include "ui/aura/window.h" 25 #include "ui/aura/window.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 if (!Env::GetInstanceDontCreate()) 106 if (!Env::GetInstanceDontCreate())
106 env_ = Env::CreateInstance(env_mode); 107 env_ = Env::CreateInstance(env_mode);
107 EnvTestHelper env_helper; 108 EnvTestHelper env_helper;
108 // Always reset the mode. This really only matters for if Env was created 109 // Always reset the mode. This really only matters for if Env was created
109 // above. 110 // above.
110 env_helper.SetMode(env_mode); 111 env_helper.SetMode(env_mode);
111 env_helper.SetWindowTreeClient(window_tree_client_); 112 env_helper.SetWindowTreeClient(window_tree_client_);
112 // Tests assume they can set the mouse location on Env() and have it reflected 113 // Tests assume they can set the mouse location on Env() and have it reflected
113 // in tests. 114 // in tests.
114 env_helper.SetAlwaysUseLastMouseLocation(true); 115 env_helper.SetAlwaysUseLastMouseLocation(true);
115 Env::GetInstance()->SetActiveFocusClient(focus_client_.get(), nullptr);
116 Env::GetInstance()->set_context_factory(context_factory); 116 Env::GetInstance()->set_context_factory(context_factory);
117 Env::GetInstance()->set_context_factory_private(context_factory_private); 117 Env::GetInstance()->set_context_factory_private(context_factory_private);
118 // Unit tests generally don't want to query the system, rather use the state 118 // Unit tests generally don't want to query the system, rather use the state
119 // from RootWindow. 119 // from RootWindow.
120 env_helper.SetInputStateLookup(nullptr); 120 env_helper.SetInputStateLookup(nullptr);
121 env_helper.ResetEventState(); 121 env_helper.ResetEventState();
122 122
123 ui::InitializeInputMethodForTesting(); 123 ui::InitializeInputMethodForTesting();
124 124
125 display::Screen* screen = display::Screen::GetScreen(); 125 display::Screen* screen = display::Screen::GetScreen();
(...skipping 26 matching lines...) Expand all
152 teardown_called_ = true; 152 teardown_called_ = true;
153 parenting_client_.reset(); 153 parenting_client_.reset();
154 client::SetFocusClient(root_window(), nullptr); 154 client::SetFocusClient(root_window(), nullptr);
155 client::SetCaptureClient(root_window(), nullptr); 155 client::SetCaptureClient(root_window(), nullptr);
156 host_.reset(); 156 host_.reset();
157 ui::GestureRecognizer::Reset(); 157 ui::GestureRecognizer::Reset();
158 if (display::Screen::GetScreen() == test_screen_.get()) 158 if (display::Screen::GetScreen() == test_screen_.get())
159 display::Screen::SetScreenInstance(nullptr); 159 display::Screen::SetScreenInstance(nullptr);
160 test_screen_.reset(); 160 test_screen_.reset();
161 161
162 Env::GetInstance()->SetActiveFocusClient(nullptr, nullptr);
163 window_tree_client_setup_.reset(); 162 window_tree_client_setup_.reset();
164 focus_client_.reset(); 163 focus_client_.reset();
165 capture_client_.reset(); 164 capture_client_.reset();
166 165
167 ui::ShutdownInputMethodForTesting(); 166 ui::ShutdownInputMethodForTesting();
168 167
169 if (env_) 168 if (env_)
170 env_.reset(); 169 env_.reset();
171 else 170 else
172 EnvTestHelper().SetWindowTreeClient(nullptr); 171 EnvTestHelper().SetWindowTreeClient(nullptr);
(...skipping 17 matching lines...) Expand all
190 189
191 client::CaptureClient* AuraTestHelper::capture_client() { 190 client::CaptureClient* AuraTestHelper::capture_client() {
192 return capture_client_.get(); 191 return capture_client_.get();
193 } 192 }
194 193
195 void AuraTestHelper::InitWindowTreeClient() { 194 void AuraTestHelper::InitWindowTreeClient() {
196 window_tree_client_setup_ = base::MakeUnique<TestWindowTreeClientSetup>(); 195 window_tree_client_setup_ = base::MakeUnique<TestWindowTreeClientSetup>();
197 window_tree_client_setup_->InitForWindowManager(window_tree_delegate_, 196 window_tree_client_setup_->InitForWindowManager(window_tree_delegate_,
198 window_manager_delegate_); 197 window_manager_delegate_);
199 window_tree_client_ = window_tree_client_setup_->window_tree_client(); 198 window_tree_client_ = window_tree_client_setup_->window_tree_client();
199 window_tree_client_->focus_synchronizer()->SetActiveFocusClient(
200 focus_client_.get(), nullptr);
200 window_tree_client_->capture_synchronizer()->AttachToCaptureClient( 201 window_tree_client_->capture_synchronizer()->AttachToCaptureClient(
201 capture_client_.get()); 202 capture_client_.get());
202 } 203 }
203 204
204 } // namespace test 205 } // namespace test
205 } // namespace aura 206 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698