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

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

Issue 2539363005: Converts ash to use aura-mus (Closed)
Patch Set: merge Created 4 years 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/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/ime_control_delegate.h" 10 #include "ash/common/ime_control_delegate.h"
11 #include "ash/common/session/session_state_delegate.h" 11 #include "ash/common/session/session_state_delegate.h"
12 #include "ash/common/system/brightness_control_delegate.h" 12 #include "ash/common/system/brightness_control_delegate.h"
13 #include "ash/common/system/keyboard_brightness_control_delegate.h" 13 #include "ash/common/system/keyboard_brightness_control_delegate.h"
14 #include "ash/common/system/tray/system_tray_delegate.h" 14 #include "ash/common/system/tray/system_tray_delegate.h"
15 #include "ash/common/test/ash_test.h" 15 #include "ash/common/test/ash_test.h"
16 #include "ash/common/wm/panels/panel_layout_manager.h" 16 #include "ash/common/wm/panels/panel_layout_manager.h"
17 #include "ash/common/wm/window_positioning_utils.h" 17 #include "ash/common/wm/window_positioning_utils.h"
18 #include "ash/common/wm/window_state.h" 18 #include "ash/common/wm/window_state.h"
19 #include "ash/common/wm/wm_event.h" 19 #include "ash/common/wm/wm_event.h"
20 #include "ash/common/wm_lookup.h" 20 #include "ash/common/wm_lookup.h"
21 #include "ash/common/wm_root_window_controller.h" 21 #include "ash/common/wm_root_window_controller.h"
22 #include "ash/common/wm_shell.h" 22 #include "ash/common/wm_shell.h"
23 #include "ash/mus/accelerators/accelerator_controller_registrar_test_api.h" 23 #include "ash/mus/accelerators/accelerator_controller_registrar_test_api.h"
24 #include "ash/mus/bridge/wm_shell_mus_test_api.h" 24 #include "ash/mus/bridge/wm_shell_mus_test_api.h"
25 #include "ash/mus/bridge/wm_window_mus.h" 25 #include "ash/mus/bridge/wm_window_mus.h"
26 #include "ash/mus/property_util.h" 26 #include "ash/mus/property_util.h"
27 #include "ash/mus/test/wm_test_base.h" 27 #include "ash/mus/test/wm_test_base.h"
28 #include "ash/public/cpp/shell_window_ids.h" 28 #include "ash/public/cpp/shell_window_ids.h"
29 #include "base/test/user_action_tester.cc" 29 #include "base/test/user_action_tester.cc"
30 #include "services/ui/public/interfaces/window_manager.mojom.h"
31 #include "ui/aura/client/aura_constants.h"
32 #include "ui/aura/window.h"
30 #include "ui/events/event.h" 33 #include "ui/events/event.h"
31 #include "ui/events/event_processor.h" 34 #include "ui/events/event_processor.h"
32 #include "ui/events/test/event_generator.h" 35 #include "ui/events/test/event_generator.h"
33 #include "ui/message_center/message_center.h" 36 #include "ui/message_center/message_center.h"
34 #include "ui/views/widget/widget.h" 37 #include "ui/views/widget/widget.h"
35 38
36 #if defined(USE_X11) 39 #if defined(USE_X11)
37 #include <X11/Xlib.h> 40 #include <X11/Xlib.h>
38 #include "ui/events/test/events_test_utils_x11.h" 41 #include "ui/events/test/events_test_utils_x11.h"
39 #endif 42 #endif
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 const ui::Accelerator accelerator_shift_a(ui::VKEY_A, ui::EF_SHIFT_DOWN); 425 const ui::Accelerator accelerator_shift_a(ui::VKEY_A, ui::EF_SHIFT_DOWN);
423 TestTarget target; 426 TestTarget target;
424 GetController()->Register(accelerator_a, &target); 427 GetController()->Register(accelerator_a, &target);
425 EXPECT_TRUE(GetController()->IsRegistered(accelerator_a)); 428 EXPECT_TRUE(GetController()->IsRegistered(accelerator_a));
426 EXPECT_FALSE(GetController()->IsRegistered(accelerator_shift_a)); 429 EXPECT_FALSE(GetController()->IsRegistered(accelerator_shift_a));
427 GetController()->UnregisterAll(&target); 430 GetController()->UnregisterAll(&target);
428 EXPECT_FALSE(GetController()->IsRegistered(accelerator_a)); 431 EXPECT_FALSE(GetController()->IsRegistered(accelerator_a));
429 } 432 }
430 433
431 TEST_F(AcceleratorControllerTest, WindowSnap) { 434 TEST_F(AcceleratorControllerTest, WindowSnap) {
432 ui::Window* ui_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); 435 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20));
433 WmWindow* window = mus::WmWindowMus::Get(ui_window); 436 WmWindow* window = mus::WmWindowMus::Get(aura_window);
434 wm::WindowState* window_state = window->GetWindowState(); 437 wm::WindowState* window_state = window->GetWindowState();
435 438
436 window_state->Activate(); 439 window_state->Activate();
437 440
438 { 441 {
439 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT); 442 GetController()->PerformActionIfEnabled(WINDOW_CYCLE_SNAP_DOCK_LEFT);
440 gfx::Rect expected_bounds = 443 gfx::Rect expected_bounds =
441 wm::GetDefaultLeftSnappedWindowBoundsInParent(window); 444 wm::GetDefaultLeftSnappedWindowBoundsInParent(window);
442 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString()); 445 EXPECT_EQ(expected_bounds.ToString(), window->GetBounds().ToString());
443 } 446 }
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 733
731 TEST_F(AcceleratorControllerTest, DontRepeatToggleFullscreen) { 734 TEST_F(AcceleratorControllerTest, DontRepeatToggleFullscreen) {
732 const AcceleratorData accelerators[] = { 735 const AcceleratorData accelerators[] = {
733 {true, ui::VKEY_J, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN}, 736 {true, ui::VKEY_J, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN},
734 {true, ui::VKEY_K, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN}, 737 {true, ui::VKEY_K, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN},
735 }; 738 };
736 GetController()->RegisterAccelerators(accelerators, arraysize(accelerators)); 739 GetController()->RegisterAccelerators(accelerators, arraysize(accelerators));
737 740
738 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 741 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
739 params.bounds = gfx::Rect(5, 5, 20, 20); 742 params.bounds = gfx::Rect(5, 5, 20, 20);
740 mus::SetResizeBehavior(
741 &params.mus_properties,
742 static_cast<uint32_t>(ui::mojom::kResizeBehaviorCanMaximize));
743 views::Widget* widget = new views::Widget; 743 views::Widget* widget = new views::Widget;
744 mus::WmWindowMus::Get(GetPrimaryRootWindow()) 744 mus::WmWindowMus::Get(GetPrimaryRootWindow())
745 ->GetRootWindowController() 745 ->GetRootWindowController()
746 ->ConfigureWidgetInitParamsForContainer( 746 ->ConfigureWidgetInitParamsForContainer(
747 widget, kShellWindowId_DefaultContainer, &params); 747 widget, kShellWindowId_DefaultContainer, &params);
748 widget->Init(params); 748 widget->Init(params);
749 widget->GetNativeView()->SetProperty(aura::client::kResizeBehaviorKey,
750 ui::mojom::kResizeBehaviorCanMaximize);
749 widget->Show(); 751 widget->Show();
750 widget->Activate(); 752 widget->Activate();
751 753
752 wm::WindowState* window_state = 754 wm::WindowState* window_state =
753 WmLookup::Get()->GetWindowForWidget(widget)->GetWindowState(); 755 WmLookup::Get()->GetWindowForWidget(widget)->GetWindowState();
754 756
755 // Toggling not suppressed. 757 // Toggling not suppressed.
756 ProcessAccelerator(ui::VKEY_J, ui::EF_ALT_DOWN); 758 ProcessAccelerator(ui::VKEY_J, ui::EF_ALT_DOWN);
757 EXPECT_TRUE(window_state->IsFullscreen()); 759 EXPECT_TRUE(window_state->IsFullscreen());
758 760
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 1270
1269 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { 1271 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) {
1270 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); 1272 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE);
1271 EXPECT_TRUE( 1273 EXPECT_TRUE(
1272 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); 1274 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]));
1273 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); 1275 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED);
1274 } 1276 }
1275 1277
1276 // Make sure we don't alert if we do have a window. 1278 // Make sure we don't alert if we do have a window.
1277 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { 1279 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) {
1278 ui::Window* ui_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); 1280 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20));
1279 mus::WmWindowMus::Get(ui_window)->Activate(); 1281 mus::WmWindowMus::Get(aura_window)->Activate();
1280 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); 1282 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE);
1281 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); 1283 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]);
1282 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); 1284 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED);
1283 ui_window->Destroy(); 1285 delete aura_window;
1284 } 1286 }
1285 1287
1286 // Don't alert if we have a minimized window either. 1288 // Don't alert if we have a minimized window either.
1287 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { 1289 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) {
1288 ui::Window* ui_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); 1290 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20));
1289 mus::WmWindowMus::Get(ui_window)->Activate(); 1291 mus::WmWindowMus::Get(aura_window)->Activate();
1290 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); 1292 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE);
1291 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); 1293 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE);
1292 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); 1294 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]);
1293 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); 1295 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED);
1294 ui_window->Destroy(); 1296 delete aura_window;
1295 } 1297 }
1296 } 1298 }
1297 1299
1298 #if defined(OS_CHROMEOS) 1300 #if defined(OS_CHROMEOS)
1299 namespace { 1301 namespace {
1300 1302
1301 // defines a class to test the behavior of deprecated accelerators. 1303 // defines a class to test the behavior of deprecated accelerators.
1302 class DeprecatedAcceleratorTester : public AcceleratorControllerTest { 1304 class DeprecatedAcceleratorTester : public AcceleratorControllerTest {
1303 public: 1305 public:
1304 DeprecatedAcceleratorTester() {} 1306 DeprecatedAcceleratorTester() {}
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 EXPECT_TRUE(IsMessageCenterEmpty()); 1404 EXPECT_TRUE(IsMessageCenterEmpty());
1403 1405
1404 // If the action is LOCK_SCREEN, we must reset the state by unlocking the 1406 // If the action is LOCK_SCREEN, we must reset the state by unlocking the
1405 // screen before we proceed testing the rest of accelerators. 1407 // screen before we proceed testing the rest of accelerators.
1406 ResetStateIfNeeded(); 1408 ResetStateIfNeeded();
1407 } 1409 }
1408 } 1410 }
1409 #endif // defined(OS_CHROMEOS) 1411 #endif // defined(OS_CHROMEOS)
1410 1412
1411 } // namespace ash 1413 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698