| 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" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/aura/client/focus_client.h" | 12 #include "ui/aura/client/focus_client.h" |
| 13 #include "ui/aura/layout_manager.h" | 13 #include "ui/aura/layout_manager.h" |
| 14 #include "ui/aura/test/aura_test_helper.h" | 14 #include "ui/aura/test/aura_test_helper.h" |
| 15 #include "ui/aura/test/event_generator.h" |
| 15 #include "ui/aura/test/test_window_delegate.h" | 16 #include "ui/aura/test/test_window_delegate.h" |
| 16 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 17 #include "ui/aura/window_event_dispatcher.h" | 18 #include "ui/aura/window_event_dispatcher.h" |
| 18 #include "ui/base/ime/dummy_text_input_client.h" | 19 #include "ui/base/ime/dummy_text_input_client.h" |
| 19 #include "ui/base/ime/input_method.h" | 20 #include "ui/base/ime/input_method.h" |
| 20 #include "ui/base/ime/input_method_factory.h" | 21 #include "ui/base/ime/input_method_factory.h" |
| 21 #include "ui/base/ime/text_input_client.h" | 22 #include "ui/base/ime/text_input_client.h" |
| 22 #include "ui/base/ime/text_input_focus_manager.h" | 23 #include "ui/base/ime/text_input_focus_manager.h" |
| 23 #include "ui/base/ui_base_switches_util.h" | 24 #include "ui/base/ui_base_switches_util.h" |
| 24 #include "ui/compositor/compositor.h" | 25 #include "ui/compositor/compositor.h" |
| 25 #include "ui/compositor/layer_type.h" | 26 #include "ui/compositor/layer_type.h" |
| 26 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 27 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 27 #include "ui/compositor/test/context_factories_for_test.h" | 28 #include "ui/compositor/test/context_factories_for_test.h" |
| 28 #include "ui/compositor/test/layer_animator_test_controller.h" | 29 #include "ui/compositor/test/layer_animator_test_controller.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" | 33 #include "ui/keyboard/keyboard_switches.h" |
| 34 #include "ui/keyboard/keyboard_util.h" | 34 #include "ui/keyboard/keyboard_util.h" |
| 35 #include "ui/wm/core/default_activation_client.h" | 35 #include "ui/wm/core/default_activation_client.h" |
| 36 | 36 |
| 37 namespace keyboard { | 37 namespace keyboard { |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 EXPECT_TRUE(window->IsVisible()); | 287 EXPECT_TRUE(window->IsVisible()); |
| 288 EXPECT_TRUE(keyboard_container->IsVisible()); | 288 EXPECT_TRUE(keyboard_container->IsVisible()); |
| 289 EXPECT_TRUE(window->HasFocus()); | 289 EXPECT_TRUE(window->HasFocus()); |
| 290 EXPECT_FALSE(keyboard_container->HasFocus()); | 290 EXPECT_FALSE(keyboard_container->HasFocus()); |
| 291 | 291 |
| 292 // Click on the keyboard. Make sure the keyboard receives the event, but does | 292 // Click on the keyboard. Make sure the keyboard receives the event, but does |
| 293 // not get focus. | 293 // not get focus. |
| 294 EventObserver observer; | 294 EventObserver observer; |
| 295 keyboard_container->AddPreTargetHandler(&observer); | 295 keyboard_container->AddPreTargetHandler(&observer); |
| 296 | 296 |
| 297 ui::test::EventGenerator generator(root_window()); | 297 aura::test::EventGenerator generator(root_window()); |
| 298 generator.MoveMouseTo(proxy()->GetKeyboardWindow()->bounds().CenterPoint()); | 298 generator.MoveMouseTo(proxy()->GetKeyboardWindow()->bounds().CenterPoint()); |
| 299 generator.ClickLeftButton(); | 299 generator.ClickLeftButton(); |
| 300 EXPECT_TRUE(window->HasFocus()); | 300 EXPECT_TRUE(window->HasFocus()); |
| 301 EXPECT_FALSE(keyboard_container->HasFocus()); | 301 EXPECT_FALSE(keyboard_container->HasFocus()); |
| 302 EXPECT_EQ("0 0", delegate.GetMouseButtonCountsAndReset()); | 302 EXPECT_EQ("0 0", delegate.GetMouseButtonCountsAndReset()); |
| 303 EXPECT_EQ(1, observer.GetEventCount(ui::ET_MOUSE_PRESSED)); | 303 EXPECT_EQ(1, observer.GetEventCount(ui::ET_MOUSE_PRESSED)); |
| 304 EXPECT_EQ(1, observer.GetEventCount(ui::ET_MOUSE_RELEASED)); | 304 EXPECT_EQ(1, observer.GetEventCount(ui::ET_MOUSE_RELEASED)); |
| 305 | 305 |
| 306 // Click outside of the keyboard. It should reach the window behind. | 306 // Click outside of the keyboard. It should reach the window behind. |
| 307 generator.MoveMouseTo(gfx::Point()); | 307 generator.MoveMouseTo(gfx::Point()); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 SetFocus(&input_client); | 600 SetFocus(&input_client); |
| 601 EXPECT_TRUE(keyboard_container->IsVisible()); | 601 EXPECT_TRUE(keyboard_container->IsVisible()); |
| 602 | 602 |
| 603 SetFocus(&no_input_client); | 603 SetFocus(&no_input_client); |
| 604 // Keyboard should not hide itself after lost focus. | 604 // Keyboard should not hide itself after lost focus. |
| 605 EXPECT_TRUE(keyboard_container->IsVisible()); | 605 EXPECT_TRUE(keyboard_container->IsVisible()); |
| 606 EXPECT_FALSE(WillHideKeyboard()); | 606 EXPECT_FALSE(WillHideKeyboard()); |
| 607 } | 607 } |
| 608 | 608 |
| 609 } // namespace keyboard | 609 } // namespace keyboard |
| OLD | NEW |