OLD | NEW |
---|---|
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" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 KeyboardBoundsFromWindowBounds( | 221 KeyboardBoundsFromWindowBounds( |
222 controller()->GetContainerWindow()->bounds(), 100)); | 222 controller()->GetContainerWindow()->bounds(), 100)); |
223 } | 223 } |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 bool WillHideKeyboard() { | 227 bool WillHideKeyboard() { |
228 return controller_->WillHideKeyboard(); | 228 return controller_->WillHideKeyboard(); |
229 } | 229 } |
230 | 230 |
231 bool ShouldEnableInsets(aura::Window* window) { | |
232 return controller_->ShouldEnableInsets(window); | |
233 } | |
234 | |
231 base::MessageLoopForUI message_loop_; | 235 base::MessageLoopForUI message_loop_; |
232 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; | 236 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; |
233 scoped_ptr<TestFocusController> focus_controller_; | 237 scoped_ptr<TestFocusController> focus_controller_; |
234 | 238 |
235 private: | 239 private: |
236 KeyboardControllerProxy* proxy_; | 240 KeyboardControllerProxy* proxy_; |
237 scoped_ptr<KeyboardController> controller_; | 241 scoped_ptr<KeyboardController> controller_; |
238 scoped_ptr<ui::TextInputClient> test_text_input_client_; | 242 scoped_ptr<ui::TextInputClient> test_text_input_client_; |
239 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest); | 243 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest); |
240 }; | 244 }; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 | 417 |
414 // Schedule to hide keyboard. | 418 // Schedule to hide keyboard. |
415 SetFocus(&no_input_client_1); | 419 SetFocus(&no_input_client_1); |
416 EXPECT_TRUE(WillHideKeyboard()); | 420 EXPECT_TRUE(WillHideKeyboard()); |
417 // Cancel keyboard hide. | 421 // Cancel keyboard hide. |
418 SetFocus(&input_client_2); | 422 SetFocus(&input_client_2); |
419 | 423 |
420 EXPECT_FALSE(WillHideKeyboard()); | 424 EXPECT_FALSE(WillHideKeyboard()); |
421 EXPECT_TRUE(keyboard_container->IsVisible()); | 425 EXPECT_TRUE(keyboard_container->IsVisible()); |
422 } | 426 } |
423 | 427 |
bshe
2014/09/18 18:26:07
nit: Do you mind to add a link to the bug that you
Peter Wen
2014/09/18 18:41:47
Done.
| |
428 TEST_F(KeyboardControllerTest, CheckOverscrollInsetDuringVisibilityChange) { | |
429 const gfx::Rect& root_bounds = root_window()->bounds(); | |
430 | |
431 ui::DummyTextInputClient input_client(ui::TEXT_INPUT_TYPE_TEXT); | |
432 ui::DummyTextInputClient no_input_client(ui::TEXT_INPUT_TYPE_NONE); | |
433 | |
434 aura::Window* keyboard_container(controller()->GetContainerWindow()); | |
435 keyboard_container->SetBounds(root_bounds); | |
436 root_window()->AddChild(keyboard_container); | |
437 | |
438 // Enable touch keyboard / overscroll mode to test insets. | |
439 keyboard::SetTouchKeyboardEnabled(true); | |
440 EXPECT_TRUE(keyboard::IsKeyboardOverscrollEnabled()); | |
441 | |
442 SetFocus(&input_client); | |
443 SetFocus(&no_input_client); | |
444 // Insets should not be enabled for new windows while keyboard is in the | |
445 // process of hiding when overscroll is enabled. | |
446 EXPECT_FALSE(ShouldEnableInsets(proxy()->GetKeyboardWindow())); | |
447 // Cancel keyboard hide. | |
448 SetFocus(&input_client); | |
449 // Insets should be enabled for new windows as hide was cancelled. | |
450 EXPECT_TRUE(ShouldEnableInsets(proxy()->GetKeyboardWindow())); | |
451 } | |
452 | |
424 TEST_F(KeyboardControllerTest, AlwaysVisibleWhenLocked) { | 453 TEST_F(KeyboardControllerTest, AlwaysVisibleWhenLocked) { |
425 const gfx::Rect& root_bounds = root_window()->bounds(); | 454 const gfx::Rect& root_bounds = root_window()->bounds(); |
426 | 455 |
427 ui::DummyTextInputClient input_client_0(ui::TEXT_INPUT_TYPE_TEXT); | 456 ui::DummyTextInputClient input_client_0(ui::TEXT_INPUT_TYPE_TEXT); |
428 ui::DummyTextInputClient input_client_1(ui::TEXT_INPUT_TYPE_TEXT); | 457 ui::DummyTextInputClient input_client_1(ui::TEXT_INPUT_TYPE_TEXT); |
429 ui::DummyTextInputClient no_input_client_0(ui::TEXT_INPUT_TYPE_NONE); | 458 ui::DummyTextInputClient no_input_client_0(ui::TEXT_INPUT_TYPE_NONE); |
430 ui::DummyTextInputClient no_input_client_1(ui::TEXT_INPUT_TYPE_NONE); | 459 ui::DummyTextInputClient no_input_client_1(ui::TEXT_INPUT_TYPE_NONE); |
431 | 460 |
432 aura::Window* keyboard_container(controller()->GetContainerWindow()); | 461 aura::Window* keyboard_container(controller()->GetContainerWindow()); |
433 scoped_ptr<KeyboardContainerObserver> keyboard_container_observer( | 462 scoped_ptr<KeyboardContainerObserver> keyboard_container_observer( |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
565 // Before hide animation finishes, show keyboard again. | 594 // Before hide animation finishes, show keyboard again. |
566 ShowKeyboard(); | 595 ShowKeyboard(); |
567 RunAnimationForLayer(layer); | 596 RunAnimationForLayer(layer); |
568 EXPECT_TRUE(keyboard_container()->IsVisible()); | 597 EXPECT_TRUE(keyboard_container()->IsVisible()); |
569 EXPECT_TRUE(keyboard_window()->IsVisible()); | 598 EXPECT_TRUE(keyboard_window()->IsVisible()); |
570 EXPECT_EQ(1.0, layer->opacity()); | 599 EXPECT_EQ(1.0, layer->opacity()); |
571 EXPECT_EQ(gfx::Transform(), layer->transform()); | 600 EXPECT_EQ(gfx::Transform(), layer->transform()); |
572 } | 601 } |
573 | 602 |
574 } // namespace keyboard | 603 } // namespace keyboard |
OLD | NEW |