Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
| 6 | 6 |
| 7 #include "ash/session/session_state_delegate.h" | 7 #include "ash/session/session_state_delegate.h" |
| 8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 640 const gfx::Rect& visible_rect() const { | 640 const gfx::Rect& visible_rect() const { |
| 641 return visible_rect_; | 641 return visible_rect_; |
| 642 } | 642 } |
| 643 | 643 |
| 644 private: | 644 private: |
| 645 gfx::Rect visible_rect_; | 645 gfx::Rect visible_rect_; |
| 646 | 646 |
| 647 DISALLOW_COPY_AND_ASSIGN(MockTextInputClient); | 647 DISALLOW_COPY_AND_ASSIGN(MockTextInputClient); |
| 648 }; | 648 }; |
| 649 | 649 |
| 650 class TargetHitTestEventHandler : public ui::test::TestEventHandler { | |
| 651 public: | |
| 652 TargetHitTestEventHandler() : ui::test::TestEventHandler() {} | |
|
James Cook
2014/09/12 22:01:52
nit: "ui::test::TestEventHandler" not needed
kevers
2014/09/15 17:23:46
Done.
| |
| 653 | |
| 654 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | |
|
James Cook
2014/09/12 22:01:52
nit: "// ui::test::TestEventHandler overrides:" or
kevers
2014/09/15 17:23:45
Done.
| |
| 655 if (event->type() == ui::ET_MOUSE_PRESSED) | |
|
James Cook
2014/09/12 22:01:52
nit: one space after ==
kevers
2014/09/15 17:23:45
Done.
| |
| 656 ui::test::TestEventHandler::OnMouseEvent(event); | |
| 657 event->StopPropagation(); | |
| 658 } | |
| 659 | |
| 660 private: | |
| 661 DISALLOW_COPY_AND_ASSIGN(TargetHitTestEventHandler); | |
| 662 }; | |
| 663 | |
| 650 // Test for http://crbug.com/297858. Virtual keyboard container should only show | 664 // Test for http://crbug.com/297858. Virtual keyboard container should only show |
| 651 // on primary root window. | 665 // on primary root window. |
| 652 TEST_F(VirtualKeyboardRootWindowControllerTest, | 666 TEST_F(VirtualKeyboardRootWindowControllerTest, |
| 653 VirtualKeyboardOnPrimaryRootWindowOnly) { | 667 VirtualKeyboardOnPrimaryRootWindowOnly) { |
| 654 if (!SupportsMultipleDisplays()) | 668 if (!SupportsMultipleDisplays()) |
| 655 return; | 669 return; |
| 656 | 670 |
| 657 UpdateDisplay("500x500,500x500"); | 671 UpdateDisplay("500x500,500x500"); |
| 658 | 672 |
| 659 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 673 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 text_input_client.visible_rect().height()); | 848 text_input_client.visible_rect().height()); |
| 835 | 849 |
| 836 if (switches::IsTextInputFocusManagerEnabled()) { | 850 if (switches::IsTextInputFocusManagerEnabled()) { |
| 837 ui::TextInputFocusManager::GetInstance()->BlurTextInputClient( | 851 ui::TextInputFocusManager::GetInstance()->BlurTextInputClient( |
| 838 &text_input_client); | 852 &text_input_client); |
| 839 } else { | 853 } else { |
| 840 input_method->SetFocusedTextInputClient(NULL); | 854 input_method->SetFocusedTextInputClient(NULL); |
| 841 } | 855 } |
| 842 } | 856 } |
| 843 | 857 |
| 858 TEST_F(VirtualKeyboardRootWindowControllerTest, ZOrderTest) { | |
|
James Cook
2014/09/12 22:01:52
Add a brief comment about what this test is testin
kevers
2014/09/15 17:23:45
Done.
| |
| 859 UpdateDisplay("800x600"); | |
| 860 keyboard::KeyboardController* keyboard_controller = | |
| 861 keyboard::KeyboardController::GetInstance(); | |
| 862 keyboard::KeyboardControllerProxy* proxy = keyboard_controller->proxy(); | |
| 863 | |
| 864 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | |
| 865 aura::Window* keyboard_container = | |
| 866 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | |
| 867 ASSERT_TRUE(keyboard_container); | |
| 868 keyboard_container->Show(); | |
| 869 | |
| 870 const int keyboard_height = 200; | |
| 871 aura::Window* keyboard_window =proxy->GetKeyboardWindow(); | |
|
James Cook
2014/09/12 22:01:52
nit: space after =
Or just run "git cl format"
kevers
2014/09/15 17:23:45
Whoops...done.
| |
| 872 keyboard_container->AddChild(keyboard_window); | |
| 873 keyboard_window->set_owned_by_parent(false); | |
| 874 gfx::Rect keyboard_bounds = keyboard::KeyboardBoundsFromWindowBounds( | |
| 875 keyboard_container->bounds(), keyboard_height); | |
| 876 keyboard_window->SetBounds(keyboard_bounds); | |
| 877 keyboard_window->Show(); | |
| 878 | |
| 879 ui::test::EventGenerator generator(root_window); | |
| 880 | |
| 881 int window_height = keyboard_bounds.bottom(); | |
| 882 int window_width = keyboard_bounds.width() / 2; | |
| 883 | |
| 884 // Normal window is should be partially occluded by the virtual keyboard. | |
|
James Cook
2014/09/12 22:01:52
nit: "is should be"?
kevers
2014/09/15 17:23:45
Fixed wording.
| |
| 885 aura::test::TestWindowDelegate delegate; | |
| 886 aura::Window* normal = CreateTestWindowInShellWithDelegateAndType( | |
| 887 &delegate, ui::wm::WINDOW_TYPE_NORMAL, 0, | |
| 888 gfx::Rect(0, 0, window_width, window_height)); | |
| 889 normal->set_owned_by_parent(false); | |
| 890 normal->Show(); | |
| 891 TargetHitTestEventHandler normal_handler; | |
| 892 normal->AddPreTargetHandler(&normal_handler); | |
| 893 | |
| 894 // Menu overlaps virtual keyboard. | |
| 895 aura::test::TestWindowDelegate delegate2; | |
| 896 aura::Window* menu = CreateTestWindowInShellWithDelegateAndType( | |
| 897 &delegate2, ui::wm::WINDOW_TYPE_MENU, 0, | |
| 898 gfx::Rect(window_width, 0, window_width, window_height)); | |
| 899 menu->set_owned_by_parent(false); | |
| 900 menu->Show(); | |
| 901 TargetHitTestEventHandler menu_handler; | |
| 902 menu->AddPreTargetHandler(&menu_handler); | |
| 903 | |
| 904 int left = window_width / 2; | |
|
James Cook
2014/09/12 22:01:52
I'm having a hard time visualizing the coordinates
kevers
2014/09/15 17:23:45
Added comment block. I do feel that numbers are mo
| |
| 905 int right = 3 * window_width / 2; | |
| 906 int top = keyboard_bounds.y() / 2; | |
| 907 int bottom = window_height - keyboard_height / 2; | |
| 908 | |
| 909 // Test that only the click on the top portion of the window is pickd up. | |
|
James Cook
2014/09/12 22:01:52
This block might be clearer if it was moved up to
kevers
2014/09/15 17:23:45
Done.
| |
| 910 generator.MoveMouseTo(left, top); | |
| 911 generator.ClickLeftButton(); | |
| 912 EXPECT_EQ(1, normal_handler.num_mouse_events()); | |
| 913 generator.MoveMouseTo(left, bottom); | |
| 914 generator.ClickLeftButton(); | |
| 915 EXPECT_EQ(1, normal_handler.num_mouse_events()); | |
| 916 | |
| 917 // Test that both clicks register. | |
| 918 generator.MoveMouseTo(right, top); | |
| 919 generator.ClickLeftButton(); | |
| 920 EXPECT_EQ(1, menu_handler.num_mouse_events()); | |
| 921 generator.MoveMouseTo(right, bottom); | |
| 922 generator.ClickLeftButton(); | |
| 923 EXPECT_EQ(2, menu_handler.num_mouse_events()); | |
| 924 | |
| 925 delete normal; | |
|
James Cook
2014/09/12 22:01:53
Can you use scoped_ptr<> for these?
| |
| 926 delete menu; | |
| 927 } | |
|
James Cook
2014/09/12 22:01:53
Thanks for writing a nice test for this! It's alw
| |
| 928 | |
| 844 } // namespace test | 929 } // namespace test |
| 845 } // namespace ash | 930 } // namespace ash |
| OLD | NEW |