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/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
6 #include "ash/accelerators/accelerator_table.h" | 6 #include "ash/accelerators/accelerator_table.h" |
7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
8 #include "ash/ash_switches.h" | 8 #include "ash/ash_switches.h" |
9 #include "ash/caps_lock_delegate.h" | 9 #include "ash/caps_lock_delegate.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 EXPECT_EQ(1, delegate->handle_volume_down_count()); | 1323 EXPECT_EQ(1, delegate->handle_volume_down_count()); |
1324 EXPECT_EQ(volume_down, delegate->last_accelerator()); | 1324 EXPECT_EQ(volume_down, delegate->last_accelerator()); |
1325 EXPECT_EQ(0, delegate->handle_volume_up_count()); | 1325 EXPECT_EQ(0, delegate->handle_volume_up_count()); |
1326 EXPECT_TRUE(ProcessWithContext(volume_up)); | 1326 EXPECT_TRUE(ProcessWithContext(volume_up)); |
1327 EXPECT_EQ(1, delegate->handle_volume_up_count()); | 1327 EXPECT_EQ(1, delegate->handle_volume_up_count()); |
1328 EXPECT_EQ(volume_up, delegate->last_accelerator()); | 1328 EXPECT_EQ(volume_up, delegate->last_accelerator()); |
1329 } | 1329 } |
1330 } | 1330 } |
1331 #endif | 1331 #endif |
1332 | 1332 |
| 1333 TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { |
| 1334 const ui::Accelerator dummy; |
| 1335 AccessibilityDelegate* delegate = |
| 1336 ash::Shell::GetInstance()->accessibility_delegate(); |
| 1337 |
| 1338 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
| 1339 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
| 1340 EXPECT_TRUE( |
| 1341 GetController()->PerformAction(kActionsNeedingWindow[i], dummy)); |
| 1342 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
| 1343 } |
| 1344 |
| 1345 // Make sure we don't alert if we do have a window. |
| 1346 scoped_ptr<aura::Window> window( |
| 1347 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| 1348 wm::ActivateWindow(window.get()); |
| 1349 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
| 1350 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
| 1351 GetController()->PerformAction(kActionsNeedingWindow[i], dummy); |
| 1352 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_NONE); |
| 1353 } |
| 1354 |
| 1355 // Don't alert if we have a minimized window either. |
| 1356 GetController()->PerformAction(WINDOW_MINIMIZE, dummy); |
| 1357 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
| 1358 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
| 1359 GetController()->PerformAction(kActionsNeedingWindow[i], dummy); |
| 1360 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_NONE); |
| 1361 } |
| 1362 } |
| 1363 |
1333 } // namespace ash | 1364 } // namespace ash |
OLD | NEW |