Commit 74c92298 authored by wutao's avatar wutao Committed by Commit Bot

ambient: Hide cursor when entering ambient mode

Bug: b/167462026
Test: added new test
Change-Id: I8397cf381dffc8c7698f987a79f5b7edae5f3b2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410802Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: Tao Wu <wutao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806736}
parent 4d6dc631
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "ui/base/ui_base_types.h" #include "ui/base/ui_base_types.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h" #include "ui/views/widget/widget_delegate.h"
#include "ui/wm/core/cursor_manager.h"
#include "ui/wm/core/visibility_controller.h" #include "ui/wm/core/visibility_controller.h"
#include "ui/wm/core/window_animations.h" #include "ui/wm/core/window_animations.h"
...@@ -549,6 +550,9 @@ void AmbientController::CreateAndShowWidget() { ...@@ -549,6 +550,9 @@ void AmbientController::CreateAndShowWidget() {
widget->Show(); widget->Show();
// Hide cursor.
Shell::Get()->cursor_manager()->HideCursor();
// Requests keyboard focus for |container_view_| to receive keyboard events. // Requests keyboard focus for |container_view_| to receive keyboard events.
container_view_->RequestFocus(); container_view_->RequestFocus();
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ash/ambient/test/ambient_ash_test_base.h" #include "ash/ambient/test/ambient_ash_test_base.h"
#include "ash/ambient/ui/ambient_container_view.h" #include "ash/ambient/ui/ambient_container_view.h"
#include "ash/public/cpp/ambient/ambient_ui_model.h" #include "ash/public/cpp/ambient/ambient_ui_model.h"
#include "ash/shell.h"
#include "ash/system/power/power_status.h" #include "ash/system/power/power_status.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
...@@ -474,4 +475,25 @@ TEST_F(AmbientControllerTest, ...@@ -474,4 +475,25 @@ TEST_F(AmbientControllerTest,
EXPECT_TRUE(ambient_controller()->IsShown()); EXPECT_TRUE(ambient_controller()->IsShown());
} }
TEST_F(AmbientControllerTest, HideCursor) {
auto* cursor_manager = Shell::Get()->cursor_manager();
LockScreen();
cursor_manager->ShowCursor();
EXPECT_TRUE(cursor_manager->IsCursorVisible());
FastForwardToInactivity();
FastForwardToNextImage();
EXPECT_TRUE(container_view());
EXPECT_EQ(AmbientUiModel::Get()->ui_visibility(),
AmbientUiVisibility::kShown);
EXPECT_TRUE(ambient_controller()->IsShown());
EXPECT_FALSE(cursor_manager->IsCursorVisible());
// Clean up.
UnlockScreen();
EXPECT_FALSE(ambient_controller()->IsShown());
}
} // namespace ash } // namespace ash
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