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/common/accelerators/accelerator_controller.h" | 5 #include "ash/common/accelerators/accelerator_controller.h" |
6 | 6 |
7 #include "ash/common/accelerators/accelerator_table.h" | 7 #include "ash/common/accelerators/accelerator_table.h" |
8 #include "ash/common/accessibility_delegate.h" | 8 #include "ash/common/accessibility_delegate.h" |
9 #include "ash/common/accessibility_types.h" | 9 #include "ash/common/accessibility_types.h" |
10 #include "ash/common/ime_control_delegate.h" | 10 #include "ash/common/ime_control_delegate.h" |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 */ | 1148 */ |
1149 | 1149 |
1150 #if defined(OS_CHROMEOS) | 1150 #if defined(OS_CHROMEOS) |
1151 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { | 1151 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { |
1152 std::set<AcceleratorAction> all_actions; | 1152 std::set<AcceleratorAction> all_actions; |
1153 for (size_t i = 0; i < kAcceleratorDataLength; ++i) | 1153 for (size_t i = 0; i < kAcceleratorDataLength; ++i) |
1154 all_actions.insert(kAcceleratorData[i].action); | 1154 all_actions.insert(kAcceleratorData[i].action); |
1155 std::set<AcceleratorAction> all_debug_actions; | 1155 std::set<AcceleratorAction> all_debug_actions; |
1156 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) | 1156 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) |
1157 all_debug_actions.insert(kDebugAcceleratorData[i].action); | 1157 all_debug_actions.insert(kDebugAcceleratorData[i].action); |
| 1158 std::set<AcceleratorAction> all_dev_actions; |
| 1159 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i) |
| 1160 all_dev_actions.insert(kDeveloperAcceleratorData[i].action); |
1158 | 1161 |
1159 std::set<AcceleratorAction> actionsAllowedAtModalWindow; | 1162 std::set<AcceleratorAction> actionsAllowedAtModalWindow; |
1160 for (size_t k = 0; k < kActionsAllowedAtModalWindowLength; ++k) | 1163 for (size_t k = 0; k < kActionsAllowedAtModalWindowLength; ++k) |
1161 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); | 1164 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); |
1162 for (std::set<AcceleratorAction>::const_iterator it = | 1165 for (const auto& action : actionsAllowedAtModalWindow) { |
1163 actionsAllowedAtModalWindow.begin(); | 1166 EXPECT_TRUE(all_actions.find(action) != all_actions.end() || |
1164 it != actionsAllowedAtModalWindow.end(); ++it) { | 1167 all_debug_actions.find(action) != all_debug_actions.end() || |
1165 EXPECT_TRUE(all_actions.find(*it) != all_actions.end() || | 1168 all_dev_actions.find(action) != all_dev_actions.end()) |
1166 all_debug_actions.find(*it) != all_debug_actions.end()) | |
1167 << " action from kActionsAllowedAtModalWindow" | 1169 << " action from kActionsAllowedAtModalWindow" |
1168 << " not found in kAcceleratorData or kDebugAcceleratorData. " | 1170 << " not found in kAcceleratorData, kDebugAcceleratorData or" |
1169 << "action: " << *it; | 1171 << " kDeveloperAcceleratorData action: " << action; |
1170 } | 1172 } |
1171 WmWindow* window = | 1173 WmWindow* window = |
1172 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); | 1174 mus::WmWindowMus::Get(CreateTestWindow(gfx::Rect(5, 5, 20, 20))); |
1173 window->Activate(); | 1175 window->Activate(); |
1174 WmShell::Get()->SimulateModalWindowOpenForTesting(true); | 1176 WmShell::Get()->SimulateModalWindowOpenForTesting(true); |
1175 for (std::set<AcceleratorAction>::const_iterator it = all_actions.begin(); | 1177 for (const auto& action : all_actions) { |
1176 it != all_actions.end(); ++it) { | 1178 if (actionsAllowedAtModalWindow.find(action) == |
1177 if (actionsAllowedAtModalWindow.find(*it) == | |
1178 actionsAllowedAtModalWindow.end()) { | 1179 actionsAllowedAtModalWindow.end()) { |
1179 EXPECT_TRUE(GetController()->PerformActionIfEnabled(*it)) | 1180 EXPECT_TRUE(GetController()->PerformActionIfEnabled(action)) |
1180 << " for action (disallowed at modal window): " << *it; | 1181 << " for action (disallowed at modal window): " << action; |
1181 } | 1182 } |
1182 } | 1183 } |
1183 // Testing of top row (F5-F10) accelerators that should still work | 1184 // Testing of top row (F5-F10) accelerators that should still work |
1184 // when a modal window is open | 1185 // when a modal window is open |
1185 // | 1186 // |
1186 // Screenshot | 1187 // Screenshot |
1187 // TODO: needs ScreenShotDelegate converted: http://crbug.com/612331. | 1188 // TODO: needs ScreenShotDelegate converted: http://crbug.com/612331. |
1188 /* | 1189 /* |
1189 { | 1190 { |
1190 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); | 1191 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 EXPECT_TRUE(IsMessageCenterEmpty()); | 1396 EXPECT_TRUE(IsMessageCenterEmpty()); |
1396 | 1397 |
1397 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1398 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
1398 // screen before we proceed testing the rest of accelerators. | 1399 // screen before we proceed testing the rest of accelerators. |
1399 ResetStateIfNeeded(); | 1400 ResetStateIfNeeded(); |
1400 } | 1401 } |
1401 } | 1402 } |
1402 #endif // defined(OS_CHROMEOS) | 1403 #endif // defined(OS_CHROMEOS) |
1403 | 1404 |
1404 } // namespace ash | 1405 } // namespace ash |
OLD | NEW |