Commit 5693d3c3 authored by MinChen's avatar MinChen Committed by Commit Bot

Create default inactivated power button menu and hide cursor

if menu animation started.


Bug: 799524
Change-Id: I1d87a7944a8f98f9617ccb071ffae1adef491605
Reviewed-on: https://chromium-review.googlesource.com/953823
Commit-Queue: min c <minch@chromium.org>
Reviewed-by: default avatarQiang Xu <warx@google.com>
Reviewed-by: default avatarDan Erat <derat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541984}
parent 1825db4a
...@@ -44,6 +44,8 @@ std::unique_ptr<views::Widget> CreateMenuWidget() { ...@@ -44,6 +44,8 @@ std::unique_ptr<views::Widget> CreateMenuWidget() {
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
params.keep_on_top = true; params.keep_on_top = true;
params.accept_events = true;
params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.name = "PowerButtonMenuWindow"; params.name = "PowerButtonMenuWindow";
params.layer_type = ui::LAYER_SOLID_COLOR; params.layer_type = ui::LAYER_SOLID_COLOR;
...@@ -332,6 +334,11 @@ void PowerButtonController::OnPowerButtonMenuTimeout() { ...@@ -332,6 +334,11 @@ void PowerButtonController::OnPowerButtonMenuTimeout() {
menu_widget_->SetContentsView(new PowerButtonMenuScreenView()); menu_widget_->SetContentsView(new PowerButtonMenuScreenView());
menu_widget_->Show(); menu_widget_->Show();
// Hide cursor, but let it reappear if the mouse moves.
Shell* shell = Shell::Get();
if (shell->cursor_manager())
shell->cursor_manager()->HideCursor();
static_cast<PowerButtonMenuScreenView*>(menu_widget_->GetContentsView()) static_cast<PowerButtonMenuScreenView*>(menu_widget_->GetContentsView())
->ScheduleShowHideAnimation(true); ->ScheduleShowHideAnimation(true);
} }
......
...@@ -8,14 +8,17 @@ ...@@ -8,14 +8,17 @@
#include "ash/accessibility/test_accessibility_controller_client.h" #include "ash/accessibility/test_accessibility_controller_client.h"
#include "ash/media_controller.h" #include "ash/media_controller.h"
#include "ash/public/cpp/ash_switches.h" #include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/config.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/power/power_button_controller_test_api.h" #include "ash/system/power/power_button_controller_test_api.h"
#include "ash/system/power/power_button_menu_view.h"
#include "ash/system/power/power_button_test_base.h" #include "ash/system/power/power_button_test_base.h"
#include "ash/test_media_client.h" #include "ash/test_media_client.h"
#include "ash/touch/touch_devices_controller.h" #include "ash/touch/touch_devices_controller.h"
#include "ash/wm/lock_state_controller_test_api.h" #include "ash/wm/lock_state_controller_test_api.h"
#include "ash/wm/test_session_state_animator.h" #include "ash/wm/test_session_state_animator.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/test/simple_test_tick_clock.h" #include "base/test/simple_test_tick_clock.h"
...@@ -24,6 +27,7 @@ ...@@ -24,6 +27,7 @@
#include "chromeos/dbus/power_manager/suspend.pb.h" #include "chromeos/dbus/power_manager/suspend.pb.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/events/test/event_generator.h" #include "ui/events/test/event_generator.h"
#include "ui/views/widget/widget.h"
using PowerManagerClient = chromeos::PowerManagerClient; using PowerManagerClient = chromeos::PowerManagerClient;
...@@ -815,4 +819,38 @@ TEST_F(PowerButtonControllerTest, SuspendWithMenuOn) { ...@@ -815,4 +819,38 @@ TEST_F(PowerButtonControllerTest, SuspendWithMenuOn) {
EXPECT_FALSE(power_button_test_api_->IsMenuOpened()); EXPECT_FALSE(power_button_test_api_->IsMenuOpened());
} }
// Tests that the menu is inactive by default.
TEST_F(PowerButtonControllerTest, InactivePowerMenuByDefault) {
aura::Window* window = CreateTestWindowInShellWithId(0);
wm::ActivateWindow(window);
ASSERT_EQ(window, wm::GetActiveWindow());
PressPowerButton();
EXPECT_TRUE(power_button_test_api_->TriggerPowerButtonMenuTimeout());
ReleasePowerButton();
EXPECT_TRUE(power_button_test_api_->IsMenuOpened());
EXPECT_EQ(window, wm::GetActiveWindow());
EXPECT_FALSE(
wm::IsActiveWindow(power_button_test_api_->GetPowerButtonMenuView()
->GetWidget()
->GetNativeWindow()));
}
// Tests that cursor is hidden after show the menu and should reappear if mouse
// moves.
TEST_F(PowerButtonControllerTest, HideCursorAfterShowMenu) {
// Cursor is hidden after show the menu.
::wm::CursorManager* cursor_manager = Shell::Get()->cursor_manager();
EXPECT_TRUE(cursor_manager->IsCursorVisible());
PressPowerButton();
EXPECT_TRUE(power_button_test_api_->TriggerPowerButtonMenuTimeout());
ReleasePowerButton();
EXPECT_TRUE(power_button_test_api_->IsMenuOpened());
EXPECT_FALSE(cursor_manager->IsCursorVisible());
// Cursor reappears if mouse moves.
GenerateMouseMoveEvent();
EXPECT_TRUE(cursor_manager->IsCursorVisible());
}
} // namespace ash } // namespace ash
...@@ -181,6 +181,7 @@ ...@@ -181,6 +181,7 @@
# TODO: Needs cursor manager support. http://crbug.com/698033 # TODO: Needs cursor manager support. http://crbug.com/698033
-PartialScreenshotControllerTest.CursorVisibilityTest -PartialScreenshotControllerTest.CursorVisibilityTest
-PartialScreenshotControllerTest.LargeCursor -PartialScreenshotControllerTest.LargeCursor
-PowerButtonControllerTest.HideCursorAfterShowMenu
# TODO: Needs LockStateController. http://crbug.com/632189. # TODO: Needs LockStateController. http://crbug.com/632189.
-PreferredReservedAcceleratorsTest.AcceleratorsWithFullscreen -PreferredReservedAcceleratorsTest.AcceleratorsWithFullscreen
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment