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" | 12 #include "ui/aura/test/aura_test_helper.h" |
13 #include "ui/aura/test/event_generator.h" | 13 #include "ui/aura/test/event_generator.h" |
14 #include "ui/aura/test/test_window_delegate.h" | 14 #include "ui/aura/test/test_window_delegate.h" |
15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
16 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.h" |
17 #include "ui/base/ime/dummy_text_input_client.h" | 17 #include "ui/base/ime/dummy_text_input_client.h" |
18 #include "ui/base/ime/input_method.h" | 18 #include "ui/base/ime/input_method.h" |
19 #include "ui/base/ime/input_method_factory.h" | 19 #include "ui/base/ime/input_method_factory.h" |
20 #include "ui/base/ime/text_input_client.h" | 20 #include "ui/base/ime/text_input_client.h" |
| 21 #include "ui/compositor/compositor.h" |
21 #include "ui/compositor/layer_type.h" | 22 #include "ui/compositor/layer_type.h" |
22 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 23 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
23 #include "ui/compositor/test/context_factories_for_test.h" | 24 #include "ui/compositor/test/context_factories_for_test.h" |
24 #include "ui/compositor/test/layer_animator_test_controller.h" | 25 #include "ui/compositor/test/layer_animator_test_controller.h" |
25 #include "ui/gfx/rect.h" | 26 #include "ui/gfx/rect.h" |
26 #include "ui/keyboard/keyboard_controller.h" | 27 #include "ui/keyboard/keyboard_controller.h" |
27 #include "ui/keyboard/keyboard_controller_observer.h" | 28 #include "ui/keyboard/keyboard_controller_observer.h" |
28 #include "ui/keyboard/keyboard_controller_proxy.h" | 29 #include "ui/keyboard/keyboard_controller_proxy.h" |
29 #include "ui/keyboard/keyboard_switches.h" | 30 #include "ui/keyboard/keyboard_switches.h" |
30 #include "ui/keyboard/keyboard_util.h" | 31 #include "ui/keyboard/keyboard_util.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } // namespace | 159 } // namespace |
159 | 160 |
160 class KeyboardControllerTest : public testing::Test { | 161 class KeyboardControllerTest : public testing::Test { |
161 public: | 162 public: |
162 KeyboardControllerTest() {} | 163 KeyboardControllerTest() {} |
163 virtual ~KeyboardControllerTest() {} | 164 virtual ~KeyboardControllerTest() {} |
164 | 165 |
165 virtual void SetUp() OVERRIDE { | 166 virtual void SetUp() OVERRIDE { |
166 // The ContextFactory must exist before any Compositors are created. | 167 // The ContextFactory must exist before any Compositors are created. |
167 bool enable_pixel_output = false; | 168 bool enable_pixel_output = false; |
168 ui::InitializeContextFactoryForTests(enable_pixel_output); | 169 ui::ContextFactory* context_factory = |
| 170 ui::InitializeContextFactoryForTests(enable_pixel_output); |
169 | 171 |
170 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); | 172 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); |
171 aura_test_helper_->SetUp(); | 173 aura_test_helper_->SetUp(context_factory); |
172 new wm::DefaultActivationClient(aura_test_helper_->root_window()); | 174 new wm::DefaultActivationClient(aura_test_helper_->root_window()); |
173 ui::SetUpInputMethodFactoryForTesting(); | 175 ui::SetUpInputMethodFactoryForTesting(); |
174 focus_controller_.reset(new TestFocusController(root_window())); | 176 focus_controller_.reset(new TestFocusController(root_window())); |
175 proxy_ = new TestKeyboardControllerProxy(); | 177 proxy_ = new TestKeyboardControllerProxy(); |
176 controller_.reset(new KeyboardController(proxy_)); | 178 controller_.reset(new KeyboardController(proxy_)); |
177 } | 179 } |
178 | 180 |
179 virtual void TearDown() OVERRIDE { | 181 virtual void TearDown() OVERRIDE { |
180 controller_.reset(); | 182 controller_.reset(); |
181 focus_controller_.reset(); | 183 focus_controller_.reset(); |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 SetFocus(&input_client); | 553 SetFocus(&input_client); |
552 EXPECT_TRUE(keyboard_container->IsVisible()); | 554 EXPECT_TRUE(keyboard_container->IsVisible()); |
553 | 555 |
554 SetFocus(&no_input_client); | 556 SetFocus(&no_input_client); |
555 // Keyboard should not hide itself after lost focus. | 557 // Keyboard should not hide itself after lost focus. |
556 EXPECT_TRUE(keyboard_container->IsVisible()); | 558 EXPECT_TRUE(keyboard_container->IsVisible()); |
557 EXPECT_FALSE(WillHideKeyboard()); | 559 EXPECT_FALSE(WillHideKeyboard()); |
558 } | 560 } |
559 | 561 |
560 } // namespace keyboard | 562 } // namespace keyboard |
OLD | NEW |