| Index: services/ui/ws/display_unittest.cc
|
| diff --git a/services/ui/ws/display_unittest.cc b/services/ui/ws/display_unittest.cc
|
| index 8a832269a63d3828dcbd5abdb1673d86fbcba2c8..26ecb2fd827c538c54b7ec9a738d4eb601321e6f 100644
|
| --- a/services/ui/ws/display_unittest.cc
|
| +++ b/services/ui/ws/display_unittest.cc
|
| @@ -25,6 +25,7 @@
|
| #include "services/ui/ws/window_tree.h"
|
| #include "services/ui/ws/window_tree_binding.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/base/cursor/cursor.h"
|
| #include "ui/display/display.h"
|
| #include "ui/events/event.h"
|
| #include "ui/gfx/geometry/rect.h"
|
| @@ -103,6 +104,7 @@ class DisplayTest : public testing::Test {
|
| return ws_test_helper_.window_server_delegate();
|
| }
|
| TestScreenManager& screen_manager() { return screen_manager_; }
|
| + const ui::CursorData& cursor() { return ws_test_helper_.cursor(); }
|
|
|
| protected:
|
| // testing::Test:
|
| @@ -428,6 +430,115 @@ TEST_F(DisplayTest, DestroyingDisplayDoesntDelete) {
|
| EXPECT_TRUE(secondary_root_destroyed);
|
| }
|
|
|
| +TEST_F(DisplayTest, CursorLockTest) {
|
| + AddWindowManager(window_server(), kTestId1);
|
| + const int64_t display_id =
|
| + screen_manager().AddDisplay(MakeDisplay(0, 0, 1024, 768, 1.0f));
|
| +
|
| + ASSERT_EQ(1u, display_manager()->displays().size());
|
| + Display* display = display_manager()->GetDisplayById(display_id);
|
| +
|
| + display->UpdateNativeCursor(ui::CursorData(ui::CursorType::kWait));
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kWait));
|
| +
|
| + display->LockCursor();
|
| +
|
| + display->UpdateNativeCursor(ui::CursorData(ui::CursorType::kCell));
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kWait));
|
| +
|
| + display->UnlockCursor();
|
| +
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kCell));
|
| +}
|
| +
|
| +TEST_F(DisplayTest, CursorVisibilityTest) {
|
| + AddWindowManager(window_server(), kTestId1);
|
| + const int64_t display_id =
|
| + screen_manager().AddDisplay(MakeDisplay(0, 0, 1024, 768, 1.0f));
|
| +
|
| + ASSERT_EQ(1u, display_manager()->displays().size());
|
| + Display* display = display_manager()->GetDisplayById(display_id);
|
| +
|
| + display->UpdateNativeCursor(ui::CursorData(ui::CursorType::kWait));
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kWait));
|
| +
|
| + display->HideCursor();
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kNone));
|
| +
|
| + display->ShowCursor();
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kWait));
|
| +
|
| + display->HideCursor();
|
| + display->UpdateNativeCursor(ui::CursorData(ui::CursorType::kCell));
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kNone));
|
| +
|
| + display->ShowCursor();
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kCell));
|
| +}
|
| +
|
| +TEST_F(DisplayTest, CursorOverrideTest) {
|
| + AddWindowManager(window_server(), kTestId1);
|
| + const int64_t display_id =
|
| + screen_manager().AddDisplay(MakeDisplay(0, 0, 1024, 768, 1.0f));
|
| +
|
| + ASSERT_EQ(1u, display_manager()->displays().size());
|
| + Display* display = display_manager()->GetDisplayById(display_id);
|
| +
|
| + display->UpdateNativeCursor(ui::CursorData(ui::CursorType::kWait));
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kWait));
|
| +
|
| + display->SetGlobalOverrideCursor(ui::CursorData(ui::CursorType::kCell));
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kCell));
|
| +
|
| + display->SetGlobalOverrideCursor(base::nullopt);
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kWait));
|
| +}
|
| +
|
| +TEST_F(DisplayTest, CursorOverrideLockTest) {
|
| + // This test is meant to mimic the calls in ScreenshotController when it sets
|
| + // a cursor.
|
| + AddWindowManager(window_server(), kTestId1);
|
| + const int64_t display_id =
|
| + screen_manager().AddDisplay(MakeDisplay(0, 0, 1024, 768, 1.0f));
|
| +
|
| + ASSERT_EQ(1u, display_manager()->displays().size());
|
| + Display* display = display_manager()->GetDisplayById(display_id);
|
| +
|
| + display->UpdateNativeCursor(ui::CursorData(ui::CursorType::kWait));
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kWait));
|
| +
|
| + display->SetGlobalOverrideCursor(ui::CursorData(ui::CursorType::kCross));
|
| + display->LockCursor();
|
| + display->SetGlobalOverrideCursor(base::nullopt);
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kCross));
|
| +
|
| + display->UnlockCursor();
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kWait));
|
| +}
|
| +
|
| +TEST_F(DisplayTest, CursorOverrideVisibilityTest) {
|
| + // This test is meant to mimic the calls in ScreenshotController when it
|
| + // hides the cursor.
|
| + AddWindowManager(window_server(), kTestId1);
|
| + const int64_t display_id =
|
| + screen_manager().AddDisplay(MakeDisplay(0, 0, 1024, 768, 1.0f));
|
| +
|
| + ASSERT_EQ(1u, display_manager()->displays().size());
|
| + Display* display = display_manager()->GetDisplayById(display_id);
|
| +
|
| + display->UpdateNativeCursor(ui::CursorData(ui::CursorType::kWait));
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kWait));
|
| +
|
| + display->HideCursor();
|
| + display->LockCursor();
|
| + display->SetGlobalOverrideCursor(base::nullopt);
|
| + display->ShowCursor();
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kNone));
|
| +
|
| + display->UnlockCursor();
|
| + EXPECT_TRUE(cursor().IsType(ui::CursorType::kWait));
|
| +}
|
| +
|
| } // namespace test
|
| } // namespace ws
|
| } // namespace ui
|
|
|