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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/aura/client/focus_client.h" | 8 #include "ui/aura/client/focus_client.h" |
9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
10 #include "ui/aura/test/aura_test_helper.h" | 10 #include "ui/aura/test/aura_test_helper.h" |
11 #include "ui/aura/test/event_generator.h" | 11 #include "ui/aura/test/event_generator.h" |
12 #include "ui/aura/test/test_window_delegate.h" | 12 #include "ui/aura/test/test_window_delegate.h" |
13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/base/ime/input_method.h" | 14 #include "ui/base/ime/input_method.h" |
15 #include "ui/base/ime/mock_input_method.h" | 15 #include "ui/base/ime/input_method_factory.h" |
16 #include "ui/base/ime/text_input_client.h" | 16 #include "ui/base/ime/text_input_client.h" |
17 #include "ui/compositor/layer_type.h" | 17 #include "ui/compositor/layer_type.h" |
18 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
19 #include "ui/keyboard/keyboard_controller.h" | 19 #include "ui/keyboard/keyboard_controller.h" |
20 #include "ui/keyboard/keyboard_controller_proxy.h" | 20 #include "ui/keyboard/keyboard_controller_proxy.h" |
21 | 21 |
22 namespace keyboard { | 22 namespace keyboard { |
23 namespace { | 23 namespace { |
24 | 24 |
25 // An event handler that focuses a window when it is clicked/touched on. This is | 25 // An event handler that focuses a window when it is clicked/touched on. This is |
(...skipping 24 matching lines...) Expand all Loading... |
50 }; | 50 }; |
51 | 51 |
52 class KeyboardControllerTest : public testing::Test { | 52 class KeyboardControllerTest : public testing::Test { |
53 public: | 53 public: |
54 KeyboardControllerTest() {} | 54 KeyboardControllerTest() {} |
55 virtual ~KeyboardControllerTest() {} | 55 virtual ~KeyboardControllerTest() {} |
56 | 56 |
57 virtual void SetUp() OVERRIDE { | 57 virtual void SetUp() OVERRIDE { |
58 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); | 58 aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); |
59 aura_test_helper_->SetUp(); | 59 aura_test_helper_->SetUp(); |
| 60 ui::SetUpInputMethodFactoryForTesting(); |
60 focus_controller_.reset(new TestFocusController(root_window())); | 61 focus_controller_.reset(new TestFocusController(root_window())); |
61 } | 62 } |
62 | 63 |
63 virtual void TearDown() OVERRIDE { | 64 virtual void TearDown() OVERRIDE { |
64 aura_test_helper_->TearDown(); | 65 aura_test_helper_->TearDown(); |
65 } | 66 } |
66 | 67 |
67 aura::RootWindow* root_window() { return aura_test_helper_->root_window(); } | 68 aura::RootWindow* root_window() { return aura_test_helper_->root_window(); } |
68 | 69 |
69 protected: | 70 protected: |
70 base::MessageLoopForUI message_loop_; | 71 base::MessageLoopForUI message_loop_; |
71 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; | 72 scoped_ptr<aura::test::AuraTestHelper> aura_test_helper_; |
72 scoped_ptr<TestFocusController> focus_controller_; | 73 scoped_ptr<TestFocusController> focus_controller_; |
73 | 74 |
74 private: | 75 private: |
75 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest); | 76 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerTest); |
76 }; | 77 }; |
77 | 78 |
78 class TestKeyboardControllerProxy : public KeyboardControllerProxy { | 79 class TestKeyboardControllerProxy : public KeyboardControllerProxy { |
79 public: | 80 public: |
80 TestKeyboardControllerProxy() | 81 TestKeyboardControllerProxy() |
81 : window_(new aura::Window(&delegate_)), | 82 : window_(new aura::Window(&delegate_)), |
82 input_method_(new ui::MockInputMethod(NULL)) { | 83 input_method_(ui::CreateInputMethod(NULL, |
| 84 gfx::kNullAcceleratedWidget)) { |
83 window_->Init(ui::LAYER_NOT_DRAWN); | 85 window_->Init(ui::LAYER_NOT_DRAWN); |
84 window_->set_owned_by_parent(false); | 86 window_->set_owned_by_parent(false); |
85 } | 87 } |
86 | 88 |
87 virtual ~TestKeyboardControllerProxy() { | 89 virtual ~TestKeyboardControllerProxy() { |
88 // Destroy the window before the delegate. | 90 // Destroy the window before the delegate. |
89 window_.reset(); | 91 window_.reset(); |
90 } | 92 } |
91 | 93 |
92 // Overridden from KeyboardControllerProxy: | 94 // Overridden from KeyboardControllerProxy: |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 EXPECT_TRUE(keyboard_container->IsVisible()); | 265 EXPECT_TRUE(keyboard_container->IsVisible()); |
264 | 266 |
265 input_method->SetFocusedTextInputClient(&no_input_client); | 267 input_method->SetFocusedTextInputClient(&no_input_client); |
266 EXPECT_FALSE(keyboard_container->IsVisible()); | 268 EXPECT_FALSE(keyboard_container->IsVisible()); |
267 | 269 |
268 input_method->SetFocusedTextInputClient(&input_client); | 270 input_method->SetFocusedTextInputClient(&input_client); |
269 EXPECT_TRUE(keyboard_container->IsVisible()); | 271 EXPECT_TRUE(keyboard_container->IsVisible()); |
270 } | 272 } |
271 | 273 |
272 } // namespace keyboard | 274 } // namespace keyboard |
OLD | NEW |