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

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

Issue 2694623016: chromeos: Makes AshTestBase/Helper target mash when appropriate (Closed)
Patch Set: feedback Created 3 years, 10 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
« no previous file with comments | « ash/BUILD.gn ('k') | ash/common/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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/ash_switches.h" 10 #include "ash/common/ash_switches.h"
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 660 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
661 window3_state->Unminimize(); 661 window3_state->Unminimize();
662 EXPECT_FALSE(window1_state->IsDocked()); 662 EXPECT_FALSE(window1_state->IsDocked());
663 EXPECT_FALSE(window2_state->IsDocked()); 663 EXPECT_FALSE(window2_state->IsDocked());
664 EXPECT_TRUE(window3_state->IsDocked()); 664 EXPECT_TRUE(window3_state->IsDocked());
665 EXPECT_EQ(window3_docked_bounds.ToString(), window3->bounds().ToString()); 665 EXPECT_EQ(window3_docked_bounds.ToString(), window3->bounds().ToString());
666 } 666 }
667 667
668 TEST_F(EnabledDockedWindowsAcceleratorControllerTest, 668 TEST_F(EnabledDockedWindowsAcceleratorControllerTest,
669 WindowPanelDockLeftDockRightRestore) { 669 WindowPanelDockLeftDockRightRestore) {
670 // TODO: http://crbug.com/632209.
671 if (WmShell::Get()->IsRunningInMash())
672 return;
670 std::unique_ptr<aura::Window> window0( 673 std::unique_ptr<aura::Window> window0(
671 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 674 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
672 675
673 std::unique_ptr<aura::Window> window(CreatePanel()); 676 std::unique_ptr<aura::Window> window(CreatePanel());
674 wm::WindowState* window_state = wm::GetWindowState(window.get()); 677 wm::WindowState* window_state = wm::GetWindowState(window.get());
675 window_state->Activate(); 678 window_state->Activate();
676 679
677 gfx::Rect window_restore_bounds2 = window->bounds(); 680 gfx::Rect window_restore_bounds2 = window->bounds();
678 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 681 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
679 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent( 682 gfx::Rect expected_bounds = wm::GetDefaultLeftSnappedWindowBoundsInParent(
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 844
842 key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0); 845 key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0);
843 ui::KeyEvent key_event3(key_event); 846 ui::KeyEvent key_event3(key_event);
844 details = dispatcher->OnEventFromSource(&key_event3); 847 details = dispatcher->OnEventFromSource(&key_event3);
845 EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed); 848 EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed);
846 EXPECT_EQ(1, target.accelerator_pressed_count()); 849 EXPECT_EQ(1, target.accelerator_pressed_count());
847 } 850 }
848 #endif 851 #endif
849 852
850 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { 853 TEST_F(AcceleratorControllerTest, GlobalAccelerators) {
854 // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111.
855 if (WmShell::Get()->IsRunningInMash())
856 return;
857
851 // CycleBackward 858 // CycleBackward
852 EXPECT_TRUE(ProcessInController( 859 EXPECT_TRUE(ProcessInController(
853 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); 860 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN)));
854 // CycleForward 861 // CycleForward
855 EXPECT_TRUE( 862 EXPECT_TRUE(
856 ProcessInController(ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN))); 863 ProcessInController(ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN)));
857 // CycleLinear 864 // CycleLinear
858 EXPECT_TRUE(ProcessInController( 865 EXPECT_TRUE(ProcessInController(
859 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_NONE))); 866 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_NONE)));
860 867
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 new test::TestSessionStateAnimator); 1223 new test::TestSessionStateAnimator);
1217 } 1224 }
1218 1225
1219 private: 1226 private:
1220 DISALLOW_COPY_AND_ASSIGN(PreferredReservedAcceleratorsTest); 1227 DISALLOW_COPY_AND_ASSIGN(PreferredReservedAcceleratorsTest);
1221 }; 1228 };
1222 1229
1223 } // namespace 1230 } // namespace
1224 1231
1225 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithFullscreen) { 1232 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithFullscreen) {
1233 // TODO: needs LockStateController ported: http://crbug.com/632189.
1234 if (WmShell::Get()->IsRunningInMash())
1235 return;
1236
1226 aura::Window* w1 = CreateTestWindowInShellWithId(0); 1237 aura::Window* w1 = CreateTestWindowInShellWithId(0);
1227 aura::Window* w2 = CreateTestWindowInShellWithId(1); 1238 aura::Window* w2 = CreateTestWindowInShellWithId(1);
1228 wm::ActivateWindow(w1); 1239 wm::ActivateWindow(w1);
1229 1240
1230 wm::WMEvent fullscreen(wm::WM_EVENT_FULLSCREEN); 1241 wm::WMEvent fullscreen(wm::WM_EVENT_FULLSCREEN);
1231 wm::WindowState* w1_state = wm::GetWindowState(w1); 1242 wm::WindowState* w1_state = wm::GetWindowState(w1);
1232 w1_state->OnWMEvent(&fullscreen); 1243 w1_state->OnWMEvent(&fullscreen);
1233 ASSERT_TRUE(w1_state->IsFullscreen()); 1244 ASSERT_TRUE(w1_state->IsFullscreen());
1234 1245
1235 ui::test::EventGenerator& generator = GetEventGenerator(); 1246 ui::test::EventGenerator& generator = GetEventGenerator();
(...skipping 27 matching lines...) Expand all
1263 w1_state->OnWMEvent(&normal); 1274 w1_state->OnWMEvent(&normal);
1264 ASSERT_FALSE(w1_state->IsFullscreen()); 1275 ASSERT_FALSE(w1_state->IsFullscreen());
1265 1276
1266 EXPECT_EQ(w1, wm::GetActiveWindow()); 1277 EXPECT_EQ(w1, wm::GetActiveWindow());
1267 press_and_release_alt_tab(); 1278 press_and_release_alt_tab();
1268 ASSERT_NE(w1, wm::GetActiveWindow()); 1279 ASSERT_NE(w1, wm::GetActiveWindow());
1269 ASSERT_EQ(w2, wm::GetActiveWindow()); 1280 ASSERT_EQ(w2, wm::GetActiveWindow());
1270 } 1281 }
1271 1282
1272 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithPinned) { 1283 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithPinned) {
1284 // TODO: needs LockStateController ported: http://crbug.com/632189.
1285 if (WmShell::Get()->IsRunningInMash())
1286 return;
1273 aura::Window* w1 = CreateTestWindowInShellWithId(0); 1287 aura::Window* w1 = CreateTestWindowInShellWithId(0);
1274 aura::Window* w2 = CreateTestWindowInShellWithId(1); 1288 aura::Window* w2 = CreateTestWindowInShellWithId(1);
1275 wm::ActivateWindow(w1); 1289 wm::ActivateWindow(w1);
1276 1290
1277 { 1291 {
1278 wm::WMEvent pin_event(wm::WM_EVENT_PIN); 1292 wm::WMEvent pin_event(wm::WM_EVENT_PIN);
1279 wm::WindowState* w1_state = wm::GetWindowState(w1); 1293 wm::WindowState* w1_state = wm::GetWindowState(w1);
1280 w1_state->OnWMEvent(&pin_event); 1294 w1_state->OnWMEvent(&pin_event);
1281 ASSERT_TRUE(w1_state->IsPinned()); 1295 ASSERT_TRUE(w1_state->IsPinned());
1282 } 1296 }
1283 1297
1284 ui::test::EventGenerator& generator = GetEventGenerator(); 1298 ui::test::EventGenerator& generator = GetEventGenerator();
1285 1299
1286 // Power key (reserved) should always be handled. 1300 // Power key (reserved) should always be handled.
1287 test::LockStateControllerTestApi test_api( 1301 test::LockStateControllerTestApi test_api(
1288 Shell::GetInstance()->lock_state_controller()); 1302 Shell::GetInstance()->lock_state_controller());
1289 EXPECT_FALSE(test_api.is_animating_lock()); 1303 EXPECT_FALSE(test_api.is_animating_lock());
1290 generator.PressKey(ui::VKEY_POWER, ui::EF_NONE); 1304 generator.PressKey(ui::VKEY_POWER, ui::EF_NONE);
1291 EXPECT_TRUE(test_api.is_animating_lock()); 1305 EXPECT_TRUE(test_api.is_animating_lock());
1292 1306
1293 // A pinned window can consume ALT-TAB (preferred), but no side effect. 1307 // A pinned window can consume ALT-TAB (preferred), but no side effect.
1294 ASSERT_EQ(w1, wm::GetActiveWindow()); 1308 ASSERT_EQ(w1, wm::GetActiveWindow());
1295 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 1309 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
1296 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 1310 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
1297 ASSERT_EQ(w1, wm::GetActiveWindow()); 1311 ASSERT_EQ(w1, wm::GetActiveWindow());
1298 ASSERT_NE(w2, wm::GetActiveWindow()); 1312 ASSERT_NE(w2, wm::GetActiveWindow());
1299 } 1313 }
1300 1314
1301 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { 1315 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) {
1316 // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111.
1317 if (WmShell::Get()->IsRunningInMash())
1318 return;
1319
1302 std::set<AcceleratorAction> all_actions; 1320 std::set<AcceleratorAction> all_actions;
1303 for (size_t i = 0; i < kAcceleratorDataLength; ++i) 1321 for (size_t i = 0; i < kAcceleratorDataLength; ++i)
1304 all_actions.insert(kAcceleratorData[i].action); 1322 all_actions.insert(kAcceleratorData[i].action);
1305 std::set<AcceleratorAction> all_debug_actions; 1323 std::set<AcceleratorAction> all_debug_actions;
1306 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) 1324 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i)
1307 all_debug_actions.insert(kDebugAcceleratorData[i].action); 1325 all_debug_actions.insert(kDebugAcceleratorData[i].action);
1308 std::set<AcceleratorAction> all_dev_actions; 1326 std::set<AcceleratorAction> all_dev_actions;
1309 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i) 1327 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i)
1310 all_dev_actions.insert(kDeveloperAcceleratorData[i].action); 1328 all_dev_actions.insert(kDeveloperAcceleratorData[i].action);
1311 1329
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 return message_center::MessageCenter::Get(); 1495 return message_center::MessageCenter::Get();
1478 } 1496 }
1479 1497
1480 private: 1498 private:
1481 DISALLOW_COPY_AND_ASSIGN(DeprecatedAcceleratorTester); 1499 DISALLOW_COPY_AND_ASSIGN(DeprecatedAcceleratorTester);
1482 }; 1500 };
1483 1501
1484 } // namespace 1502 } // namespace
1485 1503
1486 TEST_F(DeprecatedAcceleratorTester, TestDeprecatedAcceleratorsBehavior) { 1504 TEST_F(DeprecatedAcceleratorTester, TestDeprecatedAcceleratorsBehavior) {
1505 // TODO: disabled because of UnblockUserSession() not working:
1506 // http://crbug.com/632201.
1507 if (WmShell::Get()->IsRunningInMash())
1508 return;
1487 for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) { 1509 for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) {
1488 const AcceleratorData& entry = kDeprecatedAccelerators[i]; 1510 const AcceleratorData& entry = kDeprecatedAccelerators[i];
1489 1511
1490 auto itr = GetController()->actions_with_deprecations_.find(entry.action); 1512 auto itr = GetController()->actions_with_deprecations_.find(entry.action);
1491 ASSERT_TRUE(itr != GetController()->actions_with_deprecations_.end()); 1513 ASSERT_TRUE(itr != GetController()->actions_with_deprecations_.end());
1492 const DeprecatedAcceleratorData* data = itr->second; 1514 const DeprecatedAcceleratorData* data = itr->second;
1493 1515
1494 EXPECT_TRUE(IsMessageCenterEmpty()); 1516 EXPECT_TRUE(IsMessageCenterEmpty());
1495 ui::Accelerator deprecated_accelerator = CreateAccelerator(entry); 1517 ui::Accelerator deprecated_accelerator = CreateAccelerator(entry);
1496 if (data->deprecated_enabled) 1518 if (data->deprecated_enabled)
(...skipping 28 matching lines...) Expand all
1525 // Expect no notifications from the new accelerators. 1547 // Expect no notifications from the new accelerators.
1526 EXPECT_TRUE(IsMessageCenterEmpty()); 1548 EXPECT_TRUE(IsMessageCenterEmpty());
1527 1549
1528 // If the action is LOCK_SCREEN, we must reset the state by unlocking the 1550 // If the action is LOCK_SCREEN, we must reset the state by unlocking the
1529 // screen before we proceed testing the rest of accelerators. 1551 // screen before we proceed testing the rest of accelerators.
1530 ResetStateIfNeeded(); 1552 ResetStateIfNeeded();
1531 } 1553 }
1532 } 1554 }
1533 1555
1534 } // namespace ash 1556 } // namespace ash
OLDNEW
« no previous file with comments | « ash/BUILD.gn ('k') | ash/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698