Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(729)

Side by Side Diff: ash/accelerators/accelerator_controller_unittest.cc

Issue 2072853002: Implement "pinned" mode in ash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/aura/wm_window_aura.h" 9 #include "ash/aura/wm_window_aura.h"
10 #include "ash/common/accessibility_delegate.h" 10 #include "ash/common/accessibility_delegate.h"
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 wm::WMEvent normal(wm::WM_EVENT_NORMAL); 1334 wm::WMEvent normal(wm::WM_EVENT_NORMAL);
1335 w1_state->OnWMEvent(&normal); 1335 w1_state->OnWMEvent(&normal);
1336 ASSERT_FALSE(w1_state->IsFullscreen()); 1336 ASSERT_FALSE(w1_state->IsFullscreen());
1337 1337
1338 EXPECT_EQ(w1, wm::GetActiveWindow()); 1338 EXPECT_EQ(w1, wm::GetActiveWindow());
1339 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 1339 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
1340 ASSERT_NE(w1, wm::GetActiveWindow()); 1340 ASSERT_NE(w1, wm::GetActiveWindow());
1341 ASSERT_EQ(w2, wm::GetActiveWindow()); 1341 ASSERT_EQ(w2, wm::GetActiveWindow());
1342 } 1342 }
1343 1343
1344 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithPinned) {
1345 aura::Window* w1 = CreateTestWindowInShellWithId(0);
1346 aura::Window* w2 = CreateTestWindowInShellWithId(1);
1347 wm::ActivateWindow(w1);
1348
1349 {
1350 wm::WMEvent pin_event(wm::WM_EVENT_PIN);
1351 wm::WindowState* w1_state = wm::GetWindowState(w1);
1352 w1_state->OnWMEvent(&pin_event);
1353 ASSERT_TRUE(w1_state->IsPinned());
1354 }
1355
1356 ui::test::EventGenerator& generator = GetEventGenerator();
1357 #if defined(OS_CHROMEOS)
1358 // Power key (reserved) should always be handled.
1359 LockStateController::TestApi test_api(
1360 Shell::GetInstance()->lock_state_controller());
1361 EXPECT_FALSE(test_api.is_animating_lock());
1362 generator.PressKey(ui::VKEY_POWER, ui::EF_NONE);
1363 EXPECT_TRUE(test_api.is_animating_lock());
1364 #endif
1365
1366 // A pinned window can consume ALT-TAB (preferred), but no side effect.
1367 ASSERT_EQ(w1, wm::GetActiveWindow());
1368 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
1369 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
1370 ASSERT_EQ(w1, wm::GetActiveWindow());
1371 ASSERT_NE(w2, wm::GetActiveWindow());
1372 }
1373
1344 #if defined(OS_CHROMEOS) 1374 #if defined(OS_CHROMEOS)
1345 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { 1375 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) {
1346 std::set<AcceleratorAction> all_actions; 1376 std::set<AcceleratorAction> all_actions;
1347 for (size_t i = 0 ; i < kAcceleratorDataLength; ++i) 1377 for (size_t i = 0 ; i < kAcceleratorDataLength; ++i)
1348 all_actions.insert(kAcceleratorData[i].action); 1378 all_actions.insert(kAcceleratorData[i].action);
1349 std::set<AcceleratorAction> all_debug_actions; 1379 std::set<AcceleratorAction> all_debug_actions;
1350 for (size_t i = 0 ; i < kDebugAcceleratorDataLength; ++i) 1380 for (size_t i = 0 ; i < kDebugAcceleratorDataLength; ++i)
1351 all_debug_actions.insert(kDebugAcceleratorData[i].action); 1381 all_debug_actions.insert(kDebugAcceleratorData[i].action);
1352 1382
1353 std::set<AcceleratorAction> actionsAllowedAtModalWindow; 1383 std::set<AcceleratorAction> actionsAllowedAtModalWindow;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 EXPECT_TRUE(IsMessageCenterEmpty()); 1609 EXPECT_TRUE(IsMessageCenterEmpty());
1580 1610
1581 // If the action is LOCK_SCREEN, we must reset the state by unlocking the 1611 // If the action is LOCK_SCREEN, we must reset the state by unlocking the
1582 // screen before we proceed testing the rest of accelerators. 1612 // screen before we proceed testing the rest of accelerators.
1583 ResetStateIfNeeded(); 1613 ResetStateIfNeeded();
1584 } 1614 }
1585 } 1615 }
1586 #endif // defined(OS_CHROMEOS) 1616 #endif // defined(OS_CHROMEOS)
1587 1617
1588 } // namespace ash 1618 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698