| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/aura/client/focus_client.h" | 10 #include "ui/aura/client/focus_client.h" |
| 11 #include "ui/aura/layout_manager.h" | 11 #include "ui/aura/layout_manager.h" |
| 12 #include "ui/aura/test/aura_test_helper.h" | |
| 13 #include "ui/aura/test/event_generator.h" | 12 #include "ui/aura/test/event_generator.h" |
| 14 #include "ui/aura/test/test_window_delegate.h" | 13 #include "ui/aura/test/test_window_delegate.h" |
| 15 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_event_dispatcher.h" | 15 #include "ui/aura/window_event_dispatcher.h" |
| 17 #include "ui/base/ime/dummy_text_input_client.h" | 16 #include "ui/base/ime/dummy_text_input_client.h" |
| 18 #include "ui/base/ime/input_method.h" | 17 #include "ui/base/ime/input_method.h" |
| 19 #include "ui/base/ime/input_method_factory.h" | 18 #include "ui/base/ime/input_method_factory.h" |
| 20 #include "ui/base/ime/text_input_client.h" | 19 #include "ui/base/ime/text_input_client.h" |
| 21 #include "ui/compositor/layer_type.h" | 20 #include "ui/compositor/layer_type.h" |
| 22 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 21 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 23 #include "ui/compositor/test/context_factories_for_test.h" | 22 #include "ui/compositor/test/context_factories_for_test.h" |
| 24 #include "ui/compositor/test/layer_animator_test_controller.h" | 23 #include "ui/compositor/test/layer_animator_test_controller.h" |
| 25 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
| 26 #include "ui/keyboard/keyboard_controller.h" | 25 #include "ui/keyboard/keyboard_controller.h" |
| 27 #include "ui/keyboard/keyboard_controller_observer.h" | 26 #include "ui/keyboard/keyboard_controller_observer.h" |
| 28 #include "ui/keyboard/keyboard_controller_proxy.h" | 27 #include "ui/keyboard/keyboard_controller_proxy.h" |
| 29 #include "ui/keyboard/keyboard_switches.h" | 28 #include "ui/keyboard/keyboard_switches.h" |
| 29 #include "ui/wm/test/wm_test_helper.h" |
| 30 | 30 |
| 31 namespace keyboard { | 31 namespace keyboard { |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 // Steps a layer animation until it is completed. Animations must be enabled. | 34 // Steps a layer animation until it is completed. Animations must be enabled. |
| 35 void RunAnimationForLayer(ui::Layer* layer) { | 35 void RunAnimationForLayer(ui::Layer* layer) { |
| 36 // Animations must be enabled for stepping to work. | 36 // Animations must be enabled for stepping to work. |
| 37 ASSERT_NE(ui::ScopedAnimationDurationScaleMode::duration_scale_mode(), | 37 ASSERT_NE(ui::ScopedAnimationDurationScaleMode::duration_scale_mode(), |
| 38 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); | 38 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); |
| 39 | 39 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 class KeyboardControllerTest : public testing::Test { | 158 class KeyboardControllerTest : public testing::Test { |
| 159 public: | 159 public: |
| 160 KeyboardControllerTest() {} | 160 KeyboardControllerTest() {} |
| 161 virtual ~KeyboardControllerTest() {} | 161 virtual ~KeyboardControllerTest() {} |
| 162 | 162 |
| 163 virtual void SetUp() OVERRIDE { | 163 virtual void SetUp() OVERRIDE { |
| 164 // The ContextFactory must exist before any Compositors are created. | 164 // The ContextFactory must exist before any Compositors are created. |
| 165 bool enable_pixel_output = false; | 165 bool enable_pixel_output = false; |
| 166 ui::InitializeContextFactoryForTests(enable_pixel_output); | 166 ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 167 | 167 |
| 168 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); | 168 wm_test_helper_.reset(new wm::WMTestHelper); |
| 169 aura_test_helper_->SetUp(); | 169 wm_test_helper_->SetUp(); |
| 170 ui::SetUpInputMethodFactoryForTesting(); | 170 ui::SetUpInputMethodFactoryForTesting(); |
| 171 focus_controller_.reset(new TestFocusController(root_window())); | 171 focus_controller_.reset(new TestFocusController(root_window())); |
| 172 proxy_ = new TestKeyboardControllerProxy(); | 172 proxy_ = new TestKeyboardControllerProxy(); |
| 173 controller_.reset(new KeyboardController(proxy_)); | 173 controller_.reset(new KeyboardController(proxy_)); |
| 174 } | 174 } |
| 175 | 175 |
| 176 virtual void TearDown() OVERRIDE { | 176 virtual void TearDown() OVERRIDE { |
| 177 controller_.reset(); | 177 controller_.reset(); |
| 178 focus_controller_.reset(); | 178 focus_controller_.reset(); |
| 179 aura_test_helper_->TearDown(); | 179 wm_test_helper_->TearDown(); |
| 180 ui::TerminateContextFactoryForTests(); | 180 ui::TerminateContextFactoryForTests(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 aura::Window* root_window() { return aura_test_helper_->root_window(); } | 183 aura::Window* root_window() { return wm_test_helper_->root_window(); } |
| 184 KeyboardControllerProxy* proxy() { return proxy_; } | 184 KeyboardControllerProxy* proxy() { return proxy_; } |
| 185 KeyboardController* controller() { return controller_.get(); } | 185 KeyboardController* controller() { return controller_.get(); } |
| 186 | 186 |
| 187 void ShowKeyboard() { | 187 void ShowKeyboard() { |
| 188 ui::DummyTextInputClient test_text_input_client(ui::TEXT_INPUT_TYPE_TEXT); | 188 ui::DummyTextInputClient test_text_input_client(ui::TEXT_INPUT_TYPE_TEXT); |
| 189 SetFocus(&test_text_input_client); | 189 SetFocus(&test_text_input_client); |
| 190 } | 190 } |
| 191 | 191 |
| 192 protected: | 192 protected: |
| 193 void SetFocus(ui::TextInputClient* client) { | 193 void SetFocus(ui::TextInputClient* client) { |
| 194 ui::InputMethod* input_method = proxy()->GetInputMethod(); | 194 ui::InputMethod* input_method = proxy()->GetInputMethod(); |
| 195 input_method->SetFocusedTextInputClient(client); | 195 input_method->SetFocusedTextInputClient(client); |
| 196 if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) | 196 if (client && client->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) |
| 197 input_method->ShowImeIfNeeded(); | 197 input_method->ShowImeIfNeeded(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 bool WillHideKeyboard() { | 200 bool WillHideKeyboard() { |
| 201 return controller_->WillHideKeyboard(); | 201 return controller_->WillHideKeyboard(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 base::MessageLoopForUI message_loop_; | 204 base::MessageLoopForUI message_loop_; |
| 205 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; | 205 scoped_ptr<aura::test::AuraTestHelper> wm_test_helper_; |
| 206 scoped_ptr<TestFocusController> focus_controller_; | 206 scoped_ptr<TestFocusController> focus_controller_; |
| 207 | 207 |
| 208 private: | 208 private: |
| 209 KeyboardControllerProxy* proxy_; | 209 KeyboardControllerProxy* proxy_; |
| 210 scoped_ptr<KeyboardController> controller_; | 210 scoped_ptr<KeyboardController> controller_; |
| 211 | 211 |
| 212 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest); | 212 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest); |
| 213 }; | 213 }; |
| 214 | 214 |
| 215 TEST_F(KeyboardControllerTest, KeyboardSize) { | 215 TEST_F(KeyboardControllerTest, KeyboardSize) { |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 SetFocus(&input_client); | 558 SetFocus(&input_client); |
| 559 EXPECT_TRUE(keyboard_container->IsVisible()); | 559 EXPECT_TRUE(keyboard_container->IsVisible()); |
| 560 | 560 |
| 561 SetFocus(&no_input_client); | 561 SetFocus(&no_input_client); |
| 562 // Keyboard should not hide itself after lost focus. | 562 // Keyboard should not hide itself after lost focus. |
| 563 EXPECT_TRUE(keyboard_container->IsVisible()); | 563 EXPECT_TRUE(keyboard_container->IsVisible()); |
| 564 EXPECT_FALSE(WillHideKeyboard()); | 564 EXPECT_FALSE(WillHideKeyboard()); |
| 565 } | 565 } |
| 566 | 566 |
| 567 } // namespace keyboard | 567 } // namespace keyboard |
| OLD | NEW |