| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // Disabled right now as this won't work on BuildBots right now as this test | 5 // Disabled right now as this won't work on BuildBots right now as this test |
| 6 // require the box it runs on to be unlocked (and no screen-savers). | 6 // require the box it runs on to be unlocked (and no screen-savers). |
| 7 // The test actually simulates mouse and key events, so if the screen is locked, | 7 // The test actually simulates mouse and key events, so if the screen is locked, |
| 8 // the events don't go to the Chrome window. | 8 // the events don't go to the Chrome window. |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 } | 885 } |
| 886 } | 886 } |
| 887 | 887 |
| 888 // Focus the 1st item. | 888 // Focus the 1st item. |
| 889 GetFocusManager()->SetFocusedView( | 889 GetFocusManager()->SetFocusedView( |
| 890 content_view_->GetViewByID(kTraversalIDs[0])); | 890 content_view_->GetViewByID(kTraversalIDs[0])); |
| 891 | 891 |
| 892 // Let's traverse in reverse order. | 892 // Let's traverse in reverse order. |
| 893 for (int i = 0; i < 3; ++i) { | 893 for (int i = 0; i < 3; ++i) { |
| 894 for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) { | 894 for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) { |
| 895 // TODO(jcampan): Remove this hack. The reverse order of traversal in | |
| 896 // Tabbed Panes is broken (we go to the tab before going to the content). | |
| 897 if (kTraversalIDs[j] == kStyleContainerID) | |
| 898 j--; // Ignore the tab. | |
| 899 | |
| 900 GetFocusManager()->AdvanceFocus(true); | 895 GetFocusManager()->AdvanceFocus(true); |
| 901 View* focused_view = GetFocusManager()->GetFocusedView(); | 896 View* focused_view = GetFocusManager()->GetFocusedView(); |
| 902 EXPECT_TRUE(focused_view != NULL); | 897 EXPECT_TRUE(focused_view != NULL); |
| 903 | |
| 904 // TODO(jcampan): Remove this hack, same as above. | |
| 905 if (focused_view->GetID() == kStyleContainerID) { | |
| 906 j++; // Ignore the tab. | |
| 907 continue; | |
| 908 } | |
| 909 | |
| 910 if (focused_view) | 898 if (focused_view) |
| 911 EXPECT_EQ(kTraversalIDs[j], focused_view->GetID()); | 899 EXPECT_EQ(kTraversalIDs[j], focused_view->GetID()); |
| 912 } | 900 } |
| 913 } | 901 } |
| 914 } | 902 } |
| 915 | 903 |
| 916 TEST_F(FocusTraversalTest, TraversalWithNonEnabledViews) { | 904 TEST_F(FocusTraversalTest, TraversalWithNonEnabledViews) { |
| 917 const int kDisabledIDs[] = { | 905 const int kDisabledIDs[] = { |
| 918 kBananaTextfieldID, kFruitCheckBoxID, kComboboxID, kAsparagusButtonID, | 906 kBananaTextfieldID, kFruitCheckBoxID, kComboboxID, kAsparagusButtonID, |
| 919 kCauliflowerButtonID, kClosetLinkID, kVisitingLinkID, kBriceDeNiceLinkID, | 907 kCauliflowerButtonID, kClosetLinkID, kVisitingLinkID, kBriceDeNiceLinkID, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 // Focus the 1st item. | 944 // Focus the 1st item. |
| 957 GetFocusManager()->AdvanceFocus(false); | 945 GetFocusManager()->AdvanceFocus(false); |
| 958 focused_view = GetFocusManager()->GetFocusedView(); | 946 focused_view = GetFocusManager()->GetFocusedView(); |
| 959 EXPECT_TRUE(focused_view != NULL); | 947 EXPECT_TRUE(focused_view != NULL); |
| 960 if (focused_view) | 948 if (focused_view) |
| 961 EXPECT_EQ(kTraversalIDs[0], focused_view->GetID()); | 949 EXPECT_EQ(kTraversalIDs[0], focused_view->GetID()); |
| 962 | 950 |
| 963 // Same thing in reverse. | 951 // Same thing in reverse. |
| 964 for (int i = 0; i < 3; ++i) { | 952 for (int i = 0; i < 3; ++i) { |
| 965 for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) { | 953 for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) { |
| 966 // TODO(jcampan): Remove this hack. The reverse order of traversal in | |
| 967 // Tabbed Panes is broken (we go to the tab before going to the content). | |
| 968 if (kTraversalIDs[j] == kStyleContainerID) | |
| 969 j--; // Ignore the tab. | |
| 970 | |
| 971 GetFocusManager()->AdvanceFocus(true); | 954 GetFocusManager()->AdvanceFocus(true); |
| 972 focused_view = GetFocusManager()->GetFocusedView(); | 955 focused_view = GetFocusManager()->GetFocusedView(); |
| 973 EXPECT_TRUE(focused_view != NULL); | 956 EXPECT_TRUE(focused_view != NULL); |
| 974 | |
| 975 // TODO(jcampan): Remove this hack, same as above. | |
| 976 if (focused_view->GetID() == kStyleContainerID) { | |
| 977 j++; // Ignore the tab. | |
| 978 continue; | |
| 979 } | |
| 980 | |
| 981 if (focused_view) | 957 if (focused_view) |
| 982 EXPECT_EQ(kTraversalIDs[j], focused_view->GetID()); | 958 EXPECT_EQ(kTraversalIDs[j], focused_view->GetID()); |
| 983 } | 959 } |
| 984 } | 960 } |
| 985 } | 961 } |
| 986 | 962 |
| 987 // Counts accelerator calls. | 963 // Counts accelerator calls. |
| 988 class TestAcceleratorTarget : public AcceleratorTarget { | 964 class TestAcceleratorTarget : public AcceleratorTarget { |
| 989 public: | 965 public: |
| 990 explicit TestAcceleratorTarget(bool process_accelerator) | 966 explicit TestAcceleratorTarget(bool process_accelerator) |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 EXPECT_EQ(target.accelerator_count(), 1); | 1116 EXPECT_EQ(target.accelerator_count(), 1); |
| 1141 EXPECT_EQ(NULL, | 1117 EXPECT_EQ(NULL, |
| 1142 focus_manager->GetCurrentTargetForAccelerator(return_accelerator)); | 1118 focus_manager->GetCurrentTargetForAccelerator(return_accelerator)); |
| 1143 | 1119 |
| 1144 // Hitting the return key again; nothing should happen. | 1120 // Hitting the return key again; nothing should happen. |
| 1145 EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator)); | 1121 EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator)); |
| 1146 EXPECT_EQ(target.accelerator_count(), 1); | 1122 EXPECT_EQ(target.accelerator_count(), 1); |
| 1147 } | 1123 } |
| 1148 | 1124 |
| 1149 } // namespace views | 1125 } // namespace views |
| OLD | NEW |