Commit 72f479bb authored by oshima's avatar oshima Committed by Commit bot

Always update cursor visibility

otherwise the visibility state gets out of sync

BUG=471670
TEST=CursorWindowControllerTest.VisibilityTest

Review URL: https://codereview.chromium.org/1137303004

Cr-Commit-Position: refs/heads/master@{#329881}
parent c762a67b
...@@ -181,8 +181,6 @@ void CursorWindowController::SetCursorSet(ui::CursorSetType cursor_set) { ...@@ -181,8 +181,6 @@ void CursorWindowController::SetCursorSet(ui::CursorSetType cursor_set) {
} }
void CursorWindowController::SetVisibility(bool visible) { void CursorWindowController::SetVisibility(bool visible) {
if (!cursor_window_)
return;
visible_ = visible; visible_ = visible;
UpdateCursorVisibility(); UpdateCursorVisibility();
} }
......
...@@ -25,9 +25,7 @@ class CursorWindowControllerTest : public test::AshTestBase { ...@@ -25,9 +25,7 @@ class CursorWindowControllerTest : public test::AshTestBase {
// test::AshTestBase: // test::AshTestBase:
void SetUp() override { void SetUp() override {
AshTestBase::SetUp(); AshTestBase::SetUp();
cursor_window_controller_ = SetCursorCompositionEnabled(true);
Shell::GetInstance()->display_controller()->cursor_window_controller();
cursor_window_controller_->SetCursorCompositingEnabled(true);
} }
int GetCursorType() const { return cursor_window_controller_->cursor_type_; } int GetCursorType() const { return cursor_window_controller_->cursor_type_; }
...@@ -44,6 +42,12 @@ class CursorWindowControllerTest : public test::AshTestBase { ...@@ -44,6 +42,12 @@ class CursorWindowControllerTest : public test::AshTestBase {
return cursor_window_controller_->display_.id(); return cursor_window_controller_->display_.id();
} }
void SetCursorCompositionEnabled(bool enabled) {
cursor_window_controller_ =
Shell::GetInstance()->display_controller()->cursor_window_controller();
cursor_window_controller_->SetCursorCompositingEnabled(enabled);
}
private: private:
// Not owned. // Not owned.
CursorWindowController* cursor_window_controller_; CursorWindowController* cursor_window_controller_;
...@@ -105,4 +109,39 @@ TEST_F(CursorWindowControllerTest, MoveToDifferentDisplay) { ...@@ -105,4 +109,39 @@ TEST_F(CursorWindowControllerTest, MoveToDifferentDisplay) {
EXPECT_EQ(50, cursor_bounds.y() + hot_point.y()); EXPECT_EQ(50, cursor_bounds.y() + hot_point.y());
} }
// Windows doesn't support compositor based cursor.
#if !defined(OS_WIN)
// Make sure that composition cursor inherits the visibility state.
TEST_F(CursorWindowControllerTest, VisibilityTest) {
ASSERT_TRUE(GetCursorWindow());
EXPECT_TRUE(GetCursorWindow()->IsVisible());
aura::client::CursorClient* client = Shell::GetInstance()->cursor_manager();
client->HideCursor();
ASSERT_TRUE(GetCursorWindow());
EXPECT_FALSE(GetCursorWindow()->IsVisible());
// Normal cursor should be in the correct state.
SetCursorCompositionEnabled(false);
ASSERT_FALSE(GetCursorWindow());
ASSERT_FALSE(client->IsCursorVisible());
// Cursor was hidden.
SetCursorCompositionEnabled(true);
ASSERT_TRUE(GetCursorWindow());
EXPECT_FALSE(GetCursorWindow()->IsVisible());
// Goback to normal cursor and show the cursor.
SetCursorCompositionEnabled(false);
ASSERT_FALSE(GetCursorWindow());
ASSERT_FALSE(client->IsCursorVisible());
client->ShowCursor();
ASSERT_TRUE(client->IsCursorVisible());
// Cursor was shown.
SetCursorCompositionEnabled(true);
ASSERT_TRUE(GetCursorWindow());
EXPECT_TRUE(GetCursorWindow()->IsVisible());
}
#endif
} // 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