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 "ui/views/focus/focus_manager.h" | 5 #include "ui/views/focus/focus_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 private: | 721 private: |
722 bool previous_arrow_key_traversal_enabled_; | 722 bool previous_arrow_key_traversal_enabled_; |
723 | 723 |
724 DISALLOW_COPY_AND_ASSIGN(FocusManagerArrowKeyTraversalTest); | 724 DISALLOW_COPY_AND_ASSIGN(FocusManagerArrowKeyTraversalTest); |
725 }; | 725 }; |
726 | 726 |
727 } // namespace | 727 } // namespace |
728 | 728 |
729 TEST_F(FocusManagerArrowKeyTraversalTest, ArrowKeyTraversal) { | 729 TEST_F(FocusManagerArrowKeyTraversalTest, ArrowKeyTraversal) { |
730 FocusManager* focus_manager = GetFocusManager(); | 730 FocusManager* focus_manager = GetFocusManager(); |
731 const ui::KeyEvent left_key( | 731 const ui::KeyEvent left_key(ui::ET_KEY_PRESSED, ui::VKEY_LEFT, ui::EF_NONE); |
732 ui::ET_KEY_PRESSED, ui::VKEY_LEFT, ui::EF_NONE, false); | 732 const ui::KeyEvent right_key(ui::ET_KEY_PRESSED, ui::VKEY_RIGHT, ui::EF_NONE); |
733 const ui::KeyEvent right_key( | 733 const ui::KeyEvent up_key(ui::ET_KEY_PRESSED, ui::VKEY_UP, ui::EF_NONE); |
734 ui::ET_KEY_PRESSED, ui::VKEY_RIGHT, ui::EF_NONE, false); | 734 const ui::KeyEvent down_key(ui::ET_KEY_PRESSED, ui::VKEY_DOWN, ui::EF_NONE); |
735 const ui::KeyEvent up_key( | |
736 ui::ET_KEY_PRESSED, ui::VKEY_UP, ui::EF_NONE, false); | |
737 const ui::KeyEvent down_key( | |
738 ui::ET_KEY_PRESSED, ui::VKEY_DOWN, ui::EF_NONE, false); | |
739 | 735 |
740 std::vector<views::View*> v; | 736 std::vector<views::View*> v; |
741 for (size_t i = 0; i < 2; ++i) { | 737 for (size_t i = 0; i < 2; ++i) { |
742 views::View* view = new View; | 738 views::View* view = new View; |
743 view->SetFocusable(true); | 739 view->SetFocusable(true); |
744 GetContentsView()->AddChildView(view); | 740 GetContentsView()->AddChildView(view); |
745 v.push_back(view); | 741 v.push_back(view); |
746 } | 742 } |
747 | 743 |
748 // Arrow key traversal is off and arrow key does not change focus. | 744 // Arrow key traversal is off and arrow key does not change focus. |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView()); | 911 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView()); |
916 | 912 |
917 // Allow focus to go to the parent, and focus backwards which should now move | 913 // Allow focus to go to the parent, and focus backwards which should now move |
918 // up |widget_view| (in the parent). | 914 // up |widget_view| (in the parent). |
919 delegate->set_should_advance_focus_to_parent(true); | 915 delegate->set_should_advance_focus_to_parent(true); |
920 GetFocusManager()->AdvanceFocus(true); | 916 GetFocusManager()->AdvanceFocus(true); |
921 EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView()); | 917 EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView()); |
922 } | 918 } |
923 | 919 |
924 } // namespace views | 920 } // namespace views |
OLD | NEW |