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 | 6 |
7 #include "ash/accelerators/accelerator_table.h" | 7 #include "ash/accelerators/accelerator_table.h" |
8 #include "ash/aura/wm_window_aura.h" | 8 #include "ash/aura/wm_window_aura.h" |
9 #include "ash/common/accessibility_delegate.h" | 9 #include "ash/common/accessibility_delegate.h" |
10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 wm::WMEvent normal(wm::WM_EVENT_NORMAL); | 1174 wm::WMEvent normal(wm::WM_EVENT_NORMAL); |
1175 w1_state->OnWMEvent(&normal); | 1175 w1_state->OnWMEvent(&normal); |
1176 ASSERT_FALSE(w1_state->IsFullscreen()); | 1176 ASSERT_FALSE(w1_state->IsFullscreen()); |
1177 | 1177 |
1178 EXPECT_EQ(w1, wm::GetActiveWindow()); | 1178 EXPECT_EQ(w1, wm::GetActiveWindow()); |
1179 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); | 1179 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
1180 ASSERT_NE(w1, wm::GetActiveWindow()); | 1180 ASSERT_NE(w1, wm::GetActiveWindow()); |
1181 ASSERT_EQ(w2, wm::GetActiveWindow()); | 1181 ASSERT_EQ(w2, wm::GetActiveWindow()); |
1182 } | 1182 } |
1183 | 1183 |
| 1184 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithPinned) { |
| 1185 aura::Window* w1 = CreateTestWindowInShellWithId(0); |
| 1186 aura::Window* w2 = CreateTestWindowInShellWithId(1); |
| 1187 wm::ActivateWindow(w1); |
| 1188 |
| 1189 { |
| 1190 wm::WMEvent pin_event(wm::WM_EVENT_PIN); |
| 1191 wm::WindowState* w1_state = wm::GetWindowState(w1); |
| 1192 w1_state->OnWMEvent(&pin_event); |
| 1193 ASSERT_TRUE(w1_state->IsPinned()); |
| 1194 } |
| 1195 |
| 1196 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 1197 #if defined(OS_CHROMEOS) |
| 1198 // Power key (reserved) should always be handled. |
| 1199 LockStateController::TestApi test_api( |
| 1200 Shell::GetInstance()->lock_state_controller()); |
| 1201 EXPECT_FALSE(test_api.is_animating_lock()); |
| 1202 generator.PressKey(ui::VKEY_POWER, ui::EF_NONE); |
| 1203 EXPECT_TRUE(test_api.is_animating_lock()); |
| 1204 #endif |
| 1205 |
| 1206 // A pinned window can consume ALT-TAB (preferred), but no side effect. |
| 1207 ASSERT_EQ(w1, wm::GetActiveWindow()); |
| 1208 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 1209 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 1210 ASSERT_EQ(w1, wm::GetActiveWindow()); |
| 1211 ASSERT_NE(w2, wm::GetActiveWindow()); |
| 1212 } |
| 1213 |
1184 #if defined(OS_CHROMEOS) | 1214 #if defined(OS_CHROMEOS) |
1185 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { | 1215 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { |
1186 std::set<AcceleratorAction> all_actions; | 1216 std::set<AcceleratorAction> all_actions; |
1187 for (size_t i = 0 ; i < kAcceleratorDataLength; ++i) | 1217 for (size_t i = 0 ; i < kAcceleratorDataLength; ++i) |
1188 all_actions.insert(kAcceleratorData[i].action); | 1218 all_actions.insert(kAcceleratorData[i].action); |
1189 std::set<AcceleratorAction> all_debug_actions; | 1219 std::set<AcceleratorAction> all_debug_actions; |
1190 for (size_t i = 0 ; i < kDebugAcceleratorDataLength; ++i) | 1220 for (size_t i = 0 ; i < kDebugAcceleratorDataLength; ++i) |
1191 all_debug_actions.insert(kDebugAcceleratorData[i].action); | 1221 all_debug_actions.insert(kDebugAcceleratorData[i].action); |
1192 | 1222 |
1193 std::set<AcceleratorAction> actionsAllowedAtModalWindow; | 1223 std::set<AcceleratorAction> actionsAllowedAtModalWindow; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 EXPECT_TRUE(IsMessageCenterEmpty()); | 1449 EXPECT_TRUE(IsMessageCenterEmpty()); |
1420 | 1450 |
1421 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1451 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
1422 // screen before we proceed testing the rest of accelerators. | 1452 // screen before we proceed testing the rest of accelerators. |
1423 ResetStateIfNeeded(); | 1453 ResetStateIfNeeded(); |
1424 } | 1454 } |
1425 } | 1455 } |
1426 #endif // defined(OS_CHROMEOS) | 1456 #endif // defined(OS_CHROMEOS) |
1427 | 1457 |
1428 } // namespace ash | 1458 } // namespace ash |
OLD | NEW |