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

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: 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
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" 22 #include "ui/base/ui_base_switches_util.h"
24 #include "ui/compositor/compositor.h" 23 #include "ui/compositor/compositor.h"
25 #include "ui/compositor/layer_type.h" 24 #include "ui/compositor/layer_type.h"
26 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 25 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
27 #include "ui/compositor/test/context_factories_for_test.h" 26 #include "ui/compositor/test/context_factories_for_test.h"
28 #include "ui/compositor/test/layer_animator_test_controller.h" 27 #include "ui/compositor/test/layer_animator_test_controller.h"
29 #include "ui/events/event_utils.h" 28 #include "ui/events/event_utils.h"
30 #include "ui/events/test/event_generator.h" 29 #include "ui/events/test/event_generator.h"
31 #include "ui/gfx/geometry/rect.h" 30 #include "ui/gfx/geometry/rect.h"
32 #include "ui/keyboard/keyboard_controller_observer.h" 31 #include "ui/keyboard/keyboard_controller_observer.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 void SetUp() override { 177 void SetUp() override {
179 // The ContextFactory must exist before any Compositors are created. 178 // The ContextFactory must exist before any Compositors are created.
180 bool enable_pixel_output = false; 179 bool enable_pixel_output = false;
181 ui::ContextFactory* context_factory = 180 ui::ContextFactory* context_factory =
182 ui::InitializeContextFactoryForTests(enable_pixel_output); 181 ui::InitializeContextFactoryForTests(enable_pixel_output);
183 182
184 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); 183 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_));
185 aura_test_helper_->SetUp(context_factory); 184 aura_test_helper_->SetUp(context_factory);
186 new wm::DefaultActivationClient(aura_test_helper_->root_window()); 185 new wm::DefaultActivationClient(aura_test_helper_->root_window());
187 ui::SetUpInputMethodFactoryForTesting(); 186 ui::SetUpInputMethodFactoryForTesting();
188 if (::switches::IsTextInputFocusManagerEnabled())
189 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL);
190 focus_controller_.reset(new TestFocusController(root_window())); 187 focus_controller_.reset(new TestFocusController(root_window()));
191 proxy_ = new TestKeyboardControllerProxy(); 188 proxy_ = new TestKeyboardControllerProxy();
192 controller_.reset(new KeyboardController(proxy_)); 189 controller_.reset(new KeyboardController(proxy_));
193 controller()->AddObserver(this); 190 controller()->AddObserver(this);
194 } 191 }
195 192
196 void TearDown() override { 193 void TearDown() override {
197 controller()->RemoveObserver(this); 194 controller()->RemoveObserver(this);
198 controller_.reset(); 195 controller_.reset();
199 focus_controller_.reset(); 196 focus_controller_.reset();
200 if (::switches::IsTextInputFocusManagerEnabled())
201 ui::TextInputFocusManager::GetInstance()->FocusTextInputClient(NULL);
202 aura_test_helper_->TearDown(); 197 aura_test_helper_->TearDown();
203 ui::TerminateContextFactoryForTests(); 198 ui::TerminateContextFactoryForTests();
204 } 199 }
205 200
206 aura::Window* root_window() { return aura_test_helper_->root_window(); } 201 aura::Window* root_window() { return aura_test_helper_->root_window(); }
207 KeyboardControllerProxy* proxy() { return proxy_; } 202 KeyboardControllerProxy* proxy() { return proxy_; }
208 KeyboardController* controller() { return controller_.get(); } 203 KeyboardController* controller() { return controller_.get(); }
209 204
210 void ShowKeyboard() { 205 void ShowKeyboard() {
211 test_text_input_client_.reset( 206 test_text_input_client_.reset(
(...skipping 16 matching lines...) Expand all
228 notified_bounds_ = new_bounds; 223 notified_bounds_ = new_bounds;
229 number_of_calls_++; 224 number_of_calls_++;
230 } 225 }
231 226
232 int number_of_calls() const { return number_of_calls_; } 227 int number_of_calls() const { return number_of_calls_; }
233 228
234 const gfx::Rect& notified_bounds() { return notified_bounds_; } 229 const gfx::Rect& notified_bounds() { return notified_bounds_; }
235 230
236 void SetFocus(ui::TextInputClient* client) { 231 void SetFocus(ui::TextInputClient* client) {
237 ui::InputMethod* input_method = proxy()->GetInputMethod(); 232 ui::InputMethod* input_method = proxy()->GetInputMethod();
238 if (::switches::IsTextInputFocusManagerEnabled()) { 233 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) { 234 if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) {
245 input_method->ShowImeIfNeeded(); 235 input_method->ShowImeIfNeeded();
246 if (proxy_->GetKeyboardWindow()->bounds().height() == 0) { 236 if (proxy_->GetKeyboardWindow()->bounds().height() == 0) {
247 // Set initial bounds for test keyboard window. 237 // Set initial bounds for test keyboard window.
248 proxy_->GetKeyboardWindow()->SetBounds( 238 proxy_->GetKeyboardWindow()->SetBounds(
249 FullWidthKeyboardBoundsFromRootBounds( 239 FullWidthKeyboardBoundsFromRootBounds(
250 root_window()->bounds(), kDefaultVirtualKeyboardHeight)); 240 root_window()->bounds(), kDefaultVirtualKeyboardHeight));
251 } 241 }
252 } 242 }
253 } 243 }
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 // Before hide animation finishes, show keyboard again. 605 // Before hide animation finishes, show keyboard again.
616 ShowKeyboard(); 606 ShowKeyboard();
617 RunAnimationForLayer(layer); 607 RunAnimationForLayer(layer);
618 EXPECT_TRUE(keyboard_container()->IsVisible()); 608 EXPECT_TRUE(keyboard_container()->IsVisible());
619 EXPECT_TRUE(keyboard_window()->IsVisible()); 609 EXPECT_TRUE(keyboard_window()->IsVisible());
620 EXPECT_EQ(1.0, layer->opacity()); 610 EXPECT_EQ(1.0, layer->opacity());
621 EXPECT_EQ(gfx::Transform(), layer->transform()); 611 EXPECT_EQ(gfx::Transform(), layer->transform());
622 } 612 }
623 613
624 } // namespace keyboard 614 } // namespace keyboard
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698