| 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 12 matching lines...) Expand all Loading... |
| 23 #include "ui/base/ui_base_switches_util.h" | 23 #include "ui/base/ui_base_switches_util.h" |
| 24 #include "ui/compositor/compositor.h" | 24 #include "ui/compositor/compositor.h" |
| 25 #include "ui/compositor/layer_type.h" | 25 #include "ui/compositor/layer_type.h" |
| 26 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 26 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 27 #include "ui/compositor/test/context_factories_for_test.h" | 27 #include "ui/compositor/test/context_factories_for_test.h" |
| 28 #include "ui/compositor/test/layer_animator_test_controller.h" | 28 #include "ui/compositor/test/layer_animator_test_controller.h" |
| 29 #include "ui/events/test/event_generator.h" | 29 #include "ui/events/test/event_generator.h" |
| 30 #include "ui/gfx/geometry/rect.h" | 30 #include "ui/gfx/geometry/rect.h" |
| 31 #include "ui/keyboard/keyboard_controller_observer.h" | 31 #include "ui/keyboard/keyboard_controller_observer.h" |
| 32 #include "ui/keyboard/keyboard_controller_proxy.h" | 32 #include "ui/keyboard/keyboard_controller_proxy.h" |
| 33 #include "ui/keyboard/keyboard_switches.h" | |
| 34 #include "ui/keyboard/keyboard_util.h" | 33 #include "ui/keyboard/keyboard_util.h" |
| 35 #include "ui/wm/core/default_activation_client.h" | 34 #include "ui/wm/core/default_activation_client.h" |
| 36 | 35 |
| 37 namespace keyboard { | 36 namespace keyboard { |
| 38 namespace { | 37 namespace { |
| 39 | 38 |
| 40 // Steps a layer animation until it is completed. Animations must be enabled. | 39 // Steps a layer animation until it is completed. Animations must be enabled. |
| 41 void RunAnimationForLayer(ui::Layer* layer) { | 40 void RunAnimationForLayer(ui::Layer* layer) { |
| 42 // Animations must be enabled for stepping to work. | 41 // Animations must be enabled for stepping to work. |
| 43 ASSERT_NE(ui::ScopedAnimationDurationScaleMode::duration_scale_mode(), | 42 ASSERT_NE(ui::ScopedAnimationDurationScaleMode::duration_scale_mode(), |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 controller()->HideKeyboard(KeyboardController::HIDE_REASON_AUTOMATIC); | 564 controller()->HideKeyboard(KeyboardController::HIDE_REASON_AUTOMATIC); |
| 566 // Before hide animation finishes, show keyboard again. | 565 // Before hide animation finishes, show keyboard again. |
| 567 ShowKeyboard(); | 566 ShowKeyboard(); |
| 568 RunAnimationForLayer(layer); | 567 RunAnimationForLayer(layer); |
| 569 EXPECT_TRUE(keyboard_container()->IsVisible()); | 568 EXPECT_TRUE(keyboard_container()->IsVisible()); |
| 570 EXPECT_TRUE(keyboard_window()->IsVisible()); | 569 EXPECT_TRUE(keyboard_window()->IsVisible()); |
| 571 EXPECT_EQ(1.0, layer->opacity()); | 570 EXPECT_EQ(1.0, layer->opacity()); |
| 572 EXPECT_EQ(gfx::Transform(), layer->transform()); | 571 EXPECT_EQ(gfx::Transform(), layer->transform()); |
| 573 } | 572 } |
| 574 | 573 |
| 575 class KeyboardControllerUsabilityTest : public KeyboardControllerTest { | |
| 576 public: | |
| 577 KeyboardControllerUsabilityTest() {} | |
| 578 virtual ~KeyboardControllerUsabilityTest() {} | |
| 579 | |
| 580 virtual void SetUp() OVERRIDE { | |
| 581 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 582 switches::kKeyboardUsabilityExperiment); | |
| 583 KeyboardControllerTest::SetUp(); | |
| 584 } | |
| 585 | |
| 586 private: | |
| 587 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerUsabilityTest); | |
| 588 }; | |
| 589 | |
| 590 TEST_F(KeyboardControllerUsabilityTest, KeyboardAlwaysVisibleInUsabilityTest) { | |
| 591 const gfx::Rect& root_bounds = root_window()->bounds(); | |
| 592 | |
| 593 ui::DummyTextInputClient input_client(ui::TEXT_INPUT_TYPE_TEXT); | |
| 594 ui::DummyTextInputClient no_input_client(ui::TEXT_INPUT_TYPE_NONE); | |
| 595 | |
| 596 aura::Window* keyboard_container(controller()->GetContainerWindow()); | |
| 597 keyboard_container->SetBounds(root_bounds); | |
| 598 root_window()->AddChild(keyboard_container); | |
| 599 | |
| 600 SetFocus(&input_client); | |
| 601 EXPECT_TRUE(keyboard_container->IsVisible()); | |
| 602 | |
| 603 SetFocus(&no_input_client); | |
| 604 // Keyboard should not hide itself after lost focus. | |
| 605 EXPECT_TRUE(keyboard_container->IsVisible()); | |
| 606 EXPECT_FALSE(WillHideKeyboard()); | |
| 607 } | |
| 608 | |
| 609 } // namespace keyboard | 574 } // namespace keyboard |
| OLD | NEW |