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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/aura/client/focus_client.h" | 10 #include "ui/aura/client/focus_client.h" |
10 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
11 #include "ui/aura/test/aura_test_helper.h" | 12 #include "ui/aura/test/aura_test_helper.h" |
12 #include "ui/aura/test/event_generator.h" | 13 #include "ui/aura/test/event_generator.h" |
13 #include "ui/aura/test/test_window_delegate.h" | 14 #include "ui/aura/test/test_window_delegate.h" |
14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
15 #include "ui/base/ime/input_method.h" | 16 #include "ui/base/ime/input_method.h" |
16 #include "ui/base/ime/input_method_factory.h" | 17 #include "ui/base/ime/input_method_factory.h" |
17 #include "ui/base/ime/text_input_client.h" | 18 #include "ui/base/ime/text_input_client.h" |
18 #include "ui/compositor/layer_type.h" | 19 #include "ui/compositor/layer_type.h" |
19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
20 #include "ui/keyboard/keyboard_controller.h" | 21 #include "ui/keyboard/keyboard_controller.h" |
21 #include "ui/keyboard/keyboard_controller_proxy.h" | 22 #include "ui/keyboard/keyboard_controller_proxy.h" |
23 #include "ui/keyboard/keyboard_switches.h" | |
22 | 24 |
23 namespace keyboard { | 25 namespace keyboard { |
24 namespace { | 26 namespace { |
25 | 27 |
26 // An event handler that focuses a window when it is clicked/touched on. This is | 28 // An event handler that focuses a window when it is clicked/touched on. This is |
27 // used to match the focus manger behaviour in ash and views. | 29 // used to match the focus manger behaviour in ash and views. |
28 class TestFocusController : public ui::EventHandler { | 30 class TestFocusController : public ui::EventHandler { |
29 public: | 31 public: |
30 explicit TestFocusController(aura::RootWindow* root) | 32 explicit TestFocusController(aura::RootWindow* root) |
31 : root_(root) { | 33 : root_(root) { |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 // Schedule to hide keyboard. | 324 // Schedule to hide keyboard. |
323 input_method->SetFocusedTextInputClient(&no_input_client_1); | 325 input_method->SetFocusedTextInputClient(&no_input_client_1); |
324 EXPECT_TRUE(WillHideKeyboard()); | 326 EXPECT_TRUE(WillHideKeyboard()); |
325 // Cancel keyboard hide. | 327 // Cancel keyboard hide. |
326 input_method->SetFocusedTextInputClient(&input_client_2); | 328 input_method->SetFocusedTextInputClient(&input_client_2); |
327 | 329 |
328 EXPECT_FALSE(WillHideKeyboard()); | 330 EXPECT_FALSE(WillHideKeyboard()); |
329 EXPECT_TRUE(keyboard_container->IsVisible()); | 331 EXPECT_TRUE(keyboard_container->IsVisible()); |
330 } | 332 } |
331 | 333 |
334 class KeyboardControllerUsabilityTest : public KeyboardControllerTest { | |
335 public: | |
336 KeyboardControllerUsabilityTest() {} | |
337 virtual ~KeyboardControllerUsabilityTest() {} | |
338 | |
339 virtual void SetUp() OVERRIDE { | |
340 CommandLine::ForCurrentProcess()->AppendSwitch( | |
341 switches::kKeyboardUsabilityTest); | |
342 KeyboardControllerTest::SetUp(); | |
343 } | |
344 | |
345 private: | |
346 DISALLOW_COPY_AND_ASSIGN(KeyboardControllerUsabilityTest); | |
347 }; | |
348 | |
349 TEST_F(KeyboardControllerUsabilityTest, KeyboardAlwaysVisibleInUsabilityTest) { | |
350 const gfx::Rect& root_bounds = root_window()->bounds(); | |
351 | |
352 ui::InputMethod* input_method = proxy()->GetInputMethod(); | |
353 TestTextInputClient input_client(ui::TEXT_INPUT_TYPE_TEXT); | |
354 TestTextInputClient no_input_client(ui::TEXT_INPUT_TYPE_NONE); | |
355 input_method->SetFocusedTextInputClient(&input_client); | |
356 | |
357 aura::Window* keyboard_container(controller()->GetContainerWindow()); | |
358 scoped_ptr<KeyboardContainerObserver> keyboard_container_observer( | |
359 new KeyboardContainerObserver(keyboard_container)); | |
sadrul
2013/10/24 06:09:56
I don't think you need this.
bshe
2013/10/24 13:25:20
Done.
| |
360 keyboard_container->SetBounds(root_bounds); | |
361 root_window()->AddChild(keyboard_container); | |
362 | |
363 EXPECT_TRUE(keyboard_container->IsVisible()); | |
364 | |
365 input_method->SetFocusedTextInputClient(&no_input_client); | |
366 // Keyboard should not hide itself after lost focus. | |
367 EXPECT_TRUE(keyboard_container->IsVisible()); | |
368 EXPECT_FALSE(WillHideKeyboard()); | |
369 } | |
370 | |
332 } // namespace keyboard | 371 } // namespace keyboard |
OLD | NEW |