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

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

Issue 2815043002: Removes ShellPort::IsRunningInMash() (Closed)
Patch Set: dont set instance_ in constructor Created 3 years, 8 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 | « no previous file | ash/accelerators/accelerator_filter_unittest.cc » ('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/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/accessibility_delegate.h" 8 #include "ash/accessibility_delegate.h"
9 #include "ash/accessibility_types.h" 9 #include "ash/accessibility_types.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/ime_control_delegate.h" 11 #include "ash/ime_control_delegate.h"
12 #include "ash/public/cpp/config.h"
12 #include "ash/public/cpp/shell_window_ids.h" 13 #include "ash/public/cpp/shell_window_ids.h"
13 #include "ash/session/session_controller.h" 14 #include "ash/session/session_controller.h"
14 #include "ash/shell.h" 15 #include "ash/shell.h"
15 #include "ash/shell_port.h" 16 #include "ash/shell_port.h"
16 #include "ash/system/brightness_control_delegate.h" 17 #include "ash/system/brightness_control_delegate.h"
17 #include "ash/system/keyboard_brightness_control_delegate.h" 18 #include "ash/system/keyboard_brightness_control_delegate.h"
18 #include "ash/system/tray/system_tray_delegate.h" 19 #include "ash/system/tray/system_tray_delegate.h"
19 #include "ash/test/ash_test_base.h" 20 #include "ash/test/ash_test_base.h"
20 #include "ash/test/lock_state_controller_test_api.h" 21 #include "ash/test/lock_state_controller_test_api.h"
21 #include "ash/test/test_screenshot_delegate.h" 22 #include "ash/test/test_screenshot_delegate.h"
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 WmWindow::Get(window.get())); 517 WmWindow::Get(window.get()));
517 EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString()); 518 EXPECT_EQ(expected_bounds.ToString(), window->bounds().ToString());
518 // Snap left again ->> becomes normal. 519 // Snap left again ->> becomes normal.
519 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_LEFT); 520 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_LEFT);
520 EXPECT_TRUE(window_state->IsNormalStateType()); 521 EXPECT_TRUE(window_state->IsNormalStateType());
521 EXPECT_EQ(normal_bounds.ToString(), window->bounds().ToString()); 522 EXPECT_EQ(normal_bounds.ToString(), window->bounds().ToString());
522 } 523 }
523 524
524 TEST_F(AcceleratorControllerTest, RotateScreen) { 525 TEST_F(AcceleratorControllerTest, RotateScreen) {
525 // TODO: needs GetDisplayInfo http://crbug.com/622480. 526 // TODO: needs GetDisplayInfo http://crbug.com/622480.
526 if (ShellPort::Get()->IsRunningInMash()) 527 if (Shell::GetAshConfig() == Config::MASH)
527 return; 528 return;
528 529
529 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); 530 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
530 display::Display::Rotation initial_rotation = 531 display::Display::Rotation initial_rotation =
531 GetActiveDisplayRotation(display.id()); 532 GetActiveDisplayRotation(display.id());
532 ui::test::EventGenerator& generator = GetEventGenerator(); 533 ui::test::EventGenerator& generator = GetEventGenerator();
533 generator.PressKey(ui::VKEY_BROWSER_REFRESH, 534 generator.PressKey(ui::VKEY_BROWSER_REFRESH,
534 ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN); 535 ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN);
535 generator.ReleaseKey(ui::VKEY_BROWSER_REFRESH, 536 generator.ReleaseKey(ui::VKEY_BROWSER_REFRESH,
536 ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN); 537 ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0); 657 key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0);
657 ui::KeyEvent key_event3(key_event); 658 ui::KeyEvent key_event3(key_event);
658 details = sink->OnEventFromSource(&key_event3); 659 details = sink->OnEventFromSource(&key_event3);
659 EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed); 660 EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed);
660 EXPECT_EQ(1, target.accelerator_pressed_count()); 661 EXPECT_EQ(1, target.accelerator_pressed_count());
661 } 662 }
662 #endif 663 #endif
663 664
664 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { 665 TEST_F(AcceleratorControllerTest, GlobalAccelerators) {
665 // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111. 666 // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111.
666 if (ShellPort::Get()->IsRunningInMash()) 667 if (Shell::GetAshConfig() == Config::MASH)
667 return; 668 return;
668 669
669 // CycleBackward 670 // CycleBackward
670 EXPECT_TRUE(ProcessInController( 671 EXPECT_TRUE(ProcessInController(
671 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); 672 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN)));
672 // CycleForward 673 // CycleForward
673 EXPECT_TRUE( 674 EXPECT_TRUE(
674 ProcessInController(ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN))); 675 ProcessInController(ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN)));
675 // CycleLinear 676 // CycleLinear
676 EXPECT_TRUE(ProcessInController( 677 EXPECT_TRUE(ProcessInController(
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 } 1035 }
1035 1036
1036 private: 1037 private:
1037 DISALLOW_COPY_AND_ASSIGN(PreferredReservedAcceleratorsTest); 1038 DISALLOW_COPY_AND_ASSIGN(PreferredReservedAcceleratorsTest);
1038 }; 1039 };
1039 1040
1040 } // namespace 1041 } // namespace
1041 1042
1042 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithFullscreen) { 1043 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithFullscreen) {
1043 // TODO: needs LockStateController ported: http://crbug.com/632189. 1044 // TODO: needs LockStateController ported: http://crbug.com/632189.
1044 if (ShellPort::Get()->IsRunningInMash()) 1045 if (Shell::GetAshConfig() == Config::MASH)
1045 return; 1046 return;
1046 1047
1047 aura::Window* w1 = CreateTestWindowInShellWithId(0); 1048 aura::Window* w1 = CreateTestWindowInShellWithId(0);
1048 aura::Window* w2 = CreateTestWindowInShellWithId(1); 1049 aura::Window* w2 = CreateTestWindowInShellWithId(1);
1049 wm::ActivateWindow(w1); 1050 wm::ActivateWindow(w1);
1050 1051
1051 wm::WMEvent fullscreen(wm::WM_EVENT_FULLSCREEN); 1052 wm::WMEvent fullscreen(wm::WM_EVENT_FULLSCREEN);
1052 wm::WindowState* w1_state = wm::GetWindowState(w1); 1053 wm::WindowState* w1_state = wm::GetWindowState(w1);
1053 w1_state->OnWMEvent(&fullscreen); 1054 w1_state->OnWMEvent(&fullscreen);
1054 ASSERT_TRUE(w1_state->IsFullscreen()); 1055 ASSERT_TRUE(w1_state->IsFullscreen());
(...skipping 30 matching lines...) Expand all
1085 ASSERT_FALSE(w1_state->IsFullscreen()); 1086 ASSERT_FALSE(w1_state->IsFullscreen());
1086 1087
1087 EXPECT_EQ(w1, wm::GetActiveWindow()); 1088 EXPECT_EQ(w1, wm::GetActiveWindow());
1088 press_and_release_alt_tab(); 1089 press_and_release_alt_tab();
1089 ASSERT_NE(w1, wm::GetActiveWindow()); 1090 ASSERT_NE(w1, wm::GetActiveWindow());
1090 ASSERT_EQ(w2, wm::GetActiveWindow()); 1091 ASSERT_EQ(w2, wm::GetActiveWindow());
1091 } 1092 }
1092 1093
1093 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithPinned) { 1094 TEST_F(PreferredReservedAcceleratorsTest, AcceleratorsWithPinned) {
1094 // TODO: needs LockStateController ported: http://crbug.com/632189. 1095 // TODO: needs LockStateController ported: http://crbug.com/632189.
1095 if (ShellPort::Get()->IsRunningInMash()) 1096 if (Shell::GetAshConfig() == Config::MASH)
1096 return; 1097 return;
1097 aura::Window* w1 = CreateTestWindowInShellWithId(0); 1098 aura::Window* w1 = CreateTestWindowInShellWithId(0);
1098 aura::Window* w2 = CreateTestWindowInShellWithId(1); 1099 aura::Window* w2 = CreateTestWindowInShellWithId(1);
1099 wm::ActivateWindow(w1); 1100 wm::ActivateWindow(w1);
1100 1101
1101 { 1102 {
1102 wm::WMEvent pin_event(wm::WM_EVENT_PIN); 1103 wm::WMEvent pin_event(wm::WM_EVENT_PIN);
1103 wm::WindowState* w1_state = wm::GetWindowState(w1); 1104 wm::WindowState* w1_state = wm::GetWindowState(w1);
1104 w1_state->OnWMEvent(&pin_event); 1105 w1_state->OnWMEvent(&pin_event);
1105 ASSERT_TRUE(w1_state->IsPinned()); 1106 ASSERT_TRUE(w1_state->IsPinned());
(...skipping 11 matching lines...) Expand all
1117 // A pinned window can consume ALT-TAB (preferred), but no side effect. 1118 // A pinned window can consume ALT-TAB (preferred), but no side effect.
1118 ASSERT_EQ(w1, wm::GetActiveWindow()); 1119 ASSERT_EQ(w1, wm::GetActiveWindow());
1119 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 1120 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
1120 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 1121 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
1121 ASSERT_EQ(w1, wm::GetActiveWindow()); 1122 ASSERT_EQ(w1, wm::GetActiveWindow());
1122 ASSERT_NE(w2, wm::GetActiveWindow()); 1123 ASSERT_NE(w2, wm::GetActiveWindow());
1123 } 1124 }
1124 1125
1125 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { 1126 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) {
1126 // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111. 1127 // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111.
1127 if (ShellPort::Get()->IsRunningInMash()) 1128 if (Shell::GetAshConfig() == Config::MASH)
1128 return; 1129 return;
1129 1130
1130 std::set<AcceleratorAction> all_actions; 1131 std::set<AcceleratorAction> all_actions;
1131 for (size_t i = 0; i < kAcceleratorDataLength; ++i) 1132 for (size_t i = 0; i < kAcceleratorDataLength; ++i)
1132 all_actions.insert(kAcceleratorData[i].action); 1133 all_actions.insert(kAcceleratorData[i].action);
1133 std::set<AcceleratorAction> all_debug_actions; 1134 std::set<AcceleratorAction> all_debug_actions;
1134 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) 1135 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i)
1135 all_debug_actions.insert(kDebugAcceleratorData[i].action); 1136 all_debug_actions.insert(kDebugAcceleratorData[i].action);
1136 std::set<AcceleratorAction> all_dev_actions; 1137 std::set<AcceleratorAction> all_dev_actions;
1137 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i) 1138 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i)
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 1309
1309 private: 1310 private:
1310 DISALLOW_COPY_AND_ASSIGN(DeprecatedAcceleratorTester); 1311 DISALLOW_COPY_AND_ASSIGN(DeprecatedAcceleratorTester);
1311 }; 1312 };
1312 1313
1313 } // namespace 1314 } // namespace
1314 1315
1315 TEST_F(DeprecatedAcceleratorTester, TestDeprecatedAcceleratorsBehavior) { 1316 TEST_F(DeprecatedAcceleratorTester, TestDeprecatedAcceleratorsBehavior) {
1316 // TODO: disabled because of UnblockUserSession() not working: 1317 // TODO: disabled because of UnblockUserSession() not working:
1317 // http://crbug.com/632201. 1318 // http://crbug.com/632201.
1318 if (ShellPort::Get()->IsRunningInMash()) 1319 if (Shell::GetAshConfig() == Config::MASH)
1319 return; 1320 return;
1320 for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) { 1321 for (size_t i = 0; i < kDeprecatedAcceleratorsLength; ++i) {
1321 const AcceleratorData& entry = kDeprecatedAccelerators[i]; 1322 const AcceleratorData& entry = kDeprecatedAccelerators[i];
1322 1323
1323 auto itr = GetController()->actions_with_deprecations_.find(entry.action); 1324 auto itr = GetController()->actions_with_deprecations_.find(entry.action);
1324 ASSERT_TRUE(itr != GetController()->actions_with_deprecations_.end()); 1325 ASSERT_TRUE(itr != GetController()->actions_with_deprecations_.end());
1325 const DeprecatedAcceleratorData* data = itr->second; 1326 const DeprecatedAcceleratorData* data = itr->second;
1326 1327
1327 EXPECT_TRUE(IsMessageCenterEmpty()); 1328 EXPECT_TRUE(IsMessageCenterEmpty());
1328 ui::Accelerator deprecated_accelerator = CreateAccelerator(entry); 1329 ui::Accelerator deprecated_accelerator = CreateAccelerator(entry);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 // Expect no notifications from the new accelerators. 1361 // Expect no notifications from the new accelerators.
1361 EXPECT_TRUE(IsMessageCenterEmpty()); 1362 EXPECT_TRUE(IsMessageCenterEmpty());
1362 1363
1363 // If the action is LOCK_SCREEN, we must reset the state by unlocking the 1364 // If the action is LOCK_SCREEN, we must reset the state by unlocking the
1364 // screen before we proceed testing the rest of accelerators. 1365 // screen before we proceed testing the rest of accelerators.
1365 ResetStateIfNeeded(); 1366 ResetStateIfNeeded();
1366 } 1367 }
1367 } 1368 }
1368 1369
1369 } // namespace ash 1370 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/accelerators/accelerator_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698