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

Side by Side Diff: ui/keyboard/keyboard_controller_unittest.cc

Issue 1182523003: Removes TextInputFocusManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit per comment. Created 5 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
« no previous file with comments | « ui/base/ui_base_switches_util.cc ('k') | ui/views/cocoa/bridged_native_widget.mm » ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/keyboard/keyboard_controller.h" 5 #include "ui/keyboard/keyboard_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/aura/client/focus_client.h" 12 #include "ui/aura/client/focus_client.h"
13 #include "ui/aura/layout_manager.h" 13 #include "ui/aura/layout_manager.h"
14 #include "ui/aura/test/aura_test_helper.h" 14 #include "ui/aura/test/aura_test_helper.h"
15 #include "ui/aura/test/test_window_delegate.h" 15 #include "ui/aura/test/test_window_delegate.h"
16 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
17 #include "ui/aura/window_event_dispatcher.h" 17 #include "ui/aura/window_event_dispatcher.h"
18 #include "ui/base/ime/dummy_text_input_client.h" 18 #include "ui/base/ime/dummy_text_input_client.h"
19 #include "ui/base/ime/input_method.h" 19 #include "ui/base/ime/input_method.h"
20 #include "ui/base/ime/input_method_factory.h" 20 #include "ui/base/ime/input_method_factory.h"
21 #include "ui/base/ime/text_input_client.h" 21 #include "ui/base/ime/text_input_client.h"
22 #include "ui/base/ime/text_input_focus_manager.h"
23 #include "ui/base/ui_base_switches_util.h"
24 #include "ui/compositor/compositor.h" 22 #include "ui/compositor/compositor.h"
25 #include "ui/compositor/layer_type.h" 23 #include "ui/compositor/layer_type.h"
26 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 24 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
27 #include "ui/compositor/test/context_factories_for_test.h" 25 #include "ui/compositor/test/context_factories_for_test.h"
28 #include "ui/compositor/test/layer_animator_test_controller.h" 26 #include "ui/compositor/test/layer_animator_test_controller.h"
29 #include "ui/events/event_utils.h" 27 #include "ui/events/event_utils.h"
30 #include "ui/events/test/event_generator.h" 28 #include "ui/events/test/event_generator.h"
31 #include "ui/gfx/geometry/rect.h" 29 #include "ui/gfx/geometry/rect.h"
32 #include "ui/keyboard/keyboard_controller_observer.h" 30 #include "ui/keyboard/keyboard_controller_observer.h"
33 #include "ui/keyboard/keyboard_controller_proxy.h" 31 #include "ui/keyboard/keyboard_controller_proxy.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 void SetUp() override { 176 void SetUp() override {
179 // The ContextFactory must exist before any Compositors are created. 177 // The ContextFactory must exist before any Compositors are created.
180 bool enable_pixel_output = false; 178 bool enable_pixel_output = false;
181 ui::ContextFactory* context_factory = 179 ui::ContextFactory* context_factory =
182 ui::InitializeContextFactoryForTests(enable_pixel_output); 180 ui::InitializeContextFactoryForTests(enable_pixel_output);
183 181
184 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); 182 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
185 aura_test_helper_->SetUp(context_factory); 183 aura_test_helper_->SetUp(context_factory);
186 new wm::DefaultActivationClient(aura_test_helper_->root_window()); 184 new wm::DefaultActivationClient(aura_test_helper_->root_window());
187 ui::SetUpInputMethodFactoryForTesting(); 185 ui::SetUpInputMethodFactoryForTesting();
188 if (::switches::IsTextInputFocusManagerEnabled())
189 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL);
190 focus_controller_.reset(new TestFocusController(root_window())); 186 focus_controller_.reset(new TestFocusController(root_window()));
191 proxy_ = new TestKeyboardControllerProxy(); 187 proxy_ = new TestKeyboardControllerProxy();
192 controller_.reset(new KeyboardController(proxy_)); 188 controller_.reset(new KeyboardController(proxy_));
193 controller()->AddObserver(this); 189 controller()->AddObserver(this);
194 } 190 }
195 191
196 void TearDown() override { 192 void TearDown() override {
197 controller()->RemoveObserver(this); 193 controller()->RemoveObserver(this);
198 controller_.reset(); 194 controller_.reset();
199 focus_controller_.reset(); 195 focus_controller_.reset();
200 if (::switches::IsTextInputFocusManagerEnabled())
201 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL);
202 aura_test_helper_->TearDown(); 196 aura_test_helper_->TearDown();
203 ui::TerminateContextFactoryForTests(); 197 ui::TerminateContextFactoryForTests();
204 } 198 }
205 199
206 aura::Window* root_window() { return aura_test_helper_->root_window(); } 200 aura::Window* root_window() { return aura_test_helper_->root_window(); }
207 KeyboardControllerProxy* proxy() { return proxy_; } 201 KeyboardControllerProxy* proxy() { return proxy_; }
208 KeyboardController* controller() { return controller_.get(); } 202 KeyboardController* controller() { return controller_.get(); }
209 203
210 void ShowKeyboard() { 204 void ShowKeyboard() {
211 test_text_input_client_.reset( 205 test_text_input_client_.reset(
(...skipping 16 matching lines...) Expand all
228 notified_bounds_ = new_bounds; 222 notified_bounds_ = new_bounds;
229 number_of_calls_++; 223 number_of_calls_++;
230 } 224 }
231 225
232 int number_of_calls() const { return number_of_calls_; } 226 int number_of_calls() const { return number_of_calls_; }
233 227
234 const gfx::Rect& notified_bounds() { return notified_bounds_; } 228 const gfx::Rect& notified_bounds() { return notified_bounds_; }
235 229
236 void SetFocus(ui::TextInputClient* client) { 230 void SetFocus(ui::TextInputClient* client) {
237 ui::InputMethod* input_method = proxy()->GetInputMethod(); 231 ui::InputMethod* input_method = proxy()->GetInputMethod();
238 if (::switches::IsTextInputFocusManagerEnabled()) { 232 input_method->SetFocusedTextInputClient(client);
239 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(client);
240 input_method->OnTextInputTypeChanged(client);
241 } else {
242 input_method->SetFocusedTextInputClient(client);
243 }
244 if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) { 233 if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) {
245 input_method->ShowImeIfNeeded(); 234 input_method->ShowImeIfNeeded();
246 if (proxy_->GetKeyboardWindow()->bounds().height() == 0) { 235 if (proxy_->GetKeyboardWindow()->bounds().height() == 0) {
247 // Set initial bounds for test keyboard window. 236 // Set initial bounds for test keyboard window.
248 proxy_->GetKeyboardWindow()->SetBounds( 237 proxy_->GetKeyboardWindow()->SetBounds(
249 FullWidthKeyboardBoundsFromRootBounds( 238 FullWidthKeyboardBoundsFromRootBounds(
250 root_window()->bounds(), kDefaultVirtualKeyboardHeight)); 239 root_window()->bounds(), kDefaultVirtualKeyboardHeight));
251 } 240 }
252 } 241 }
253 } 242 }
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 // Before hide animation finishes, show keyboard again. 604 // Before hide animation finishes, show keyboard again.
616 ShowKeyboard(); 605 ShowKeyboard();
617 RunAnimationForLayer(layer); 606 RunAnimationForLayer(layer);
618 EXPECT_TRUE(keyboard_container()->IsVisible()); 607 EXPECT_TRUE(keyboard_container()->IsVisible());
619 EXPECT_TRUE(keyboard_window()->IsVisible()); 608 EXPECT_TRUE(keyboard_window()->IsVisible());
620 EXPECT_EQ(1.0, layer->opacity()); 609 EXPECT_EQ(1.0, layer->opacity());
621 EXPECT_EQ(gfx::Transform(), layer->transform()); 610 EXPECT_EQ(gfx::Transform(), layer->transform());
622 } 611 }
623 612
624 } // namespace keyboard 613 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/base/ui_base_switches_util.cc ('k') | ui/views/cocoa/bridged_native_widget.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698