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/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/accelerators/accelerator_table.h" | 8 #include "ash/common/accelerators/accelerator_table.h" |
9 #include "ash/common/accessibility_delegate.h" | 9 #include "ash/common/accessibility_delegate.h" |
10 #include "ash/common/accessibility_types.h" | 10 #include "ash/common/accessibility_types.h" |
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 } | 1183 } |
1184 | 1184 |
1185 #if defined(OS_CHROMEOS) | 1185 #if defined(OS_CHROMEOS) |
1186 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { | 1186 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { |
1187 std::set<AcceleratorAction> all_actions; | 1187 std::set<AcceleratorAction> all_actions; |
1188 for (size_t i = 0; i < kAcceleratorDataLength; ++i) | 1188 for (size_t i = 0; i < kAcceleratorDataLength; ++i) |
1189 all_actions.insert(kAcceleratorData[i].action); | 1189 all_actions.insert(kAcceleratorData[i].action); |
1190 std::set<AcceleratorAction> all_debug_actions; | 1190 std::set<AcceleratorAction> all_debug_actions; |
1191 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) | 1191 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) |
1192 all_debug_actions.insert(kDebugAcceleratorData[i].action); | 1192 all_debug_actions.insert(kDebugAcceleratorData[i].action); |
| 1193 std::set<AcceleratorAction> all_dev_actions; |
| 1194 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i) |
| 1195 all_dev_actions.insert(kDeveloperAcceleratorData[i].action); |
1193 | 1196 |
1194 std::set<AcceleratorAction> actionsAllowedAtModalWindow; | 1197 std::set<AcceleratorAction> actionsAllowedAtModalWindow; |
1195 for (size_t k = 0; k < kActionsAllowedAtModalWindowLength; ++k) | 1198 for (size_t k = 0; k < kActionsAllowedAtModalWindowLength; ++k) |
1196 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); | 1199 actionsAllowedAtModalWindow.insert(kActionsAllowedAtModalWindow[k]); |
1197 for (std::set<AcceleratorAction>::const_iterator it = | 1200 for (const auto& action : actionsAllowedAtModalWindow) { |
1198 actionsAllowedAtModalWindow.begin(); | 1201 EXPECT_TRUE(all_actions.find(action) != all_actions.end() || |
1199 it != actionsAllowedAtModalWindow.end(); ++it) { | 1202 all_debug_actions.find(action) != all_debug_actions.end() || |
1200 EXPECT_TRUE(all_actions.find(*it) != all_actions.end() || | 1203 all_dev_actions.find(action) != all_dev_actions.end()) |
1201 all_debug_actions.find(*it) != all_debug_actions.end()) | |
1202 << " action from kActionsAllowedAtModalWindow" | 1204 << " action from kActionsAllowedAtModalWindow" |
1203 << " not found in kAcceleratorData or kDebugAcceleratorData. " | 1205 << " not found in kAcceleratorData, kDebugAcceleratorData or" |
1204 << "action: " << *it; | 1206 << " kDeveloperAcceleratorData action: " << action; |
1205 } | 1207 } |
1206 std::unique_ptr<aura::Window> window( | 1208 std::unique_ptr<aura::Window> window( |
1207 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 1209 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
1208 wm::ActivateWindow(window.get()); | 1210 wm::ActivateWindow(window.get()); |
1209 WmShell::Get()->SimulateModalWindowOpenForTesting(true); | 1211 WmShell::Get()->SimulateModalWindowOpenForTesting(true); |
1210 for (std::set<AcceleratorAction>::const_iterator it = all_actions.begin(); | 1212 for (const auto& action : all_actions) { |
1211 it != all_actions.end(); ++it) { | 1213 if (actionsAllowedAtModalWindow.find(action) == |
1212 if (actionsAllowedAtModalWindow.find(*it) == | |
1213 actionsAllowedAtModalWindow.end()) { | 1214 actionsAllowedAtModalWindow.end()) { |
1214 EXPECT_TRUE(GetController()->PerformActionIfEnabled(*it)) | 1215 EXPECT_TRUE(GetController()->PerformActionIfEnabled(action)) |
1215 << " for action (disallowed at modal window): " << *it; | 1216 << " for action (disallowed at modal window): " << action; |
1216 } | 1217 } |
1217 } | 1218 } |
1218 // Testing of top row (F5-F10) accelerators that should still work | 1219 // Testing of top row (F5-F10) accelerators that should still work |
1219 // when a modal window is open | 1220 // when a modal window is open |
1220 // | 1221 // |
1221 // Screenshot | 1222 // Screenshot |
1222 { | 1223 { |
1223 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); | 1224 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); |
1224 delegate->set_can_take_screenshot(false); | 1225 delegate->set_can_take_screenshot(false); |
1225 EXPECT_TRUE(ProcessInController( | 1226 EXPECT_TRUE(ProcessInController( |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 EXPECT_TRUE(IsMessageCenterEmpty()); | 1414 EXPECT_TRUE(IsMessageCenterEmpty()); |
1414 | 1415 |
1415 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1416 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
1416 // screen before we proceed testing the rest of accelerators. | 1417 // screen before we proceed testing the rest of accelerators. |
1417 ResetStateIfNeeded(); | 1418 ResetStateIfNeeded(); |
1418 } | 1419 } |
1419 } | 1420 } |
1420 #endif // defined(OS_CHROMEOS) | 1421 #endif // defined(OS_CHROMEOS) |
1421 | 1422 |
1422 } // namespace ash | 1423 } // namespace ash |
OLD | NEW |