| Index: services/ui/ws/cursor_unittest.cc
|
| diff --git a/services/ui/ws/cursor_unittest.cc b/services/ui/ws/cursor_unittest.cc
|
| index fea988b7a5e7bda06727a32ea3b1890295848aa1..2d8935f1cc1f121edf0bf8b46f84022d83281e77 100644
|
| --- a/services/ui/ws/cursor_unittest.cc
|
| +++ b/services/ui/ws/cursor_unittest.cc
|
| @@ -37,28 +37,30 @@ const UserId kTestId1 = "20";
|
|
|
| class CursorTest : public testing::Test {
|
| public:
|
| - CursorTest() : cursor_id_(-1), platform_display_factory_(&cursor_id_) {}
|
| + CursorTest() {}
|
| ~CursorTest() override {}
|
|
|
| + WindowServer* window_server() { return ws_test_helper_.window_server(); }
|
| + TestWindowServerDelegate* window_server_delegate() {
|
| + return ws_test_helper_.window_server_delegate();
|
| + }
|
| + int32_t cursor_id() const { return ws_test_helper_.cursor_id(); }
|
| +
|
| protected:
|
| // testing::Test:
|
| void SetUp() override {
|
| - PlatformDisplay::set_factory_for_testing(&platform_display_factory_);
|
| - window_server_.reset(new WindowServer(&window_server_delegate_));
|
| - window_server_delegate_.set_window_server(window_server_.get());
|
| -
|
| - window_server_delegate_.set_num_displays_to_create(1);
|
| + window_server_delegate()->set_num_displays_to_create(1);
|
|
|
| // As a side effect, this allocates Displays.
|
| WindowManagerWindowTreeFactorySetTestApi(
|
| - window_server_->window_manager_window_tree_factory_set())
|
| + window_server()->window_manager_window_tree_factory_set())
|
| .Add(kTestId1);
|
| - window_server_->user_id_tracker()->AddUserId(kTestId1);
|
| - window_server_->user_id_tracker()->SetActiveUserId(kTestId1);
|
| + window_server()->user_id_tracker()->AddUserId(kTestId1);
|
| + window_server()->user_id_tracker()->SetActiveUserId(kTestId1);
|
| }
|
|
|
| ServerWindow* GetRoot() {
|
| - DisplayManager* display_manager = window_server_->display_manager();
|
| + DisplayManager* display_manager = window_server()->display_manager();
|
| // ASSERT_EQ(1u, display_manager->displays().size());
|
| Display* display = *display_manager->displays().begin();
|
| return display->GetWindowManagerDisplayRootForUser(kTestId1)->root();
|
| @@ -66,7 +68,7 @@ class CursorTest : public testing::Test {
|
|
|
| // Create a 30x30 window where the outer 10 pixels is non-client.
|
| ServerWindow* BuildServerWindow() {
|
| - DisplayManager* display_manager = window_server_->display_manager();
|
| + DisplayManager* display_manager = window_server()->display_manager();
|
| Display* display = *display_manager->displays().begin();
|
| WindowManagerDisplayRoot* active_display_root =
|
| display->GetActiveWindowManagerDisplayRoot();
|
| @@ -88,7 +90,7 @@ class CursorTest : public testing::Test {
|
| }
|
|
|
| void MoveCursorTo(const gfx::Point& p) {
|
| - DisplayManager* display_manager = window_server_->display_manager();
|
| + DisplayManager* display_manager = window_server()->display_manager();
|
| ASSERT_EQ(1u, display_manager->displays().size());
|
| Display* display = *display_manager->displays().begin();
|
| WindowManagerDisplayRoot* active_display_root =
|
| @@ -100,14 +102,8 @@ class CursorTest : public testing::Test {
|
| wms->OnEventAck(wms->window_tree(), mojom::EventResult::HANDLED);
|
| }
|
|
|
| - protected:
|
| - int32_t cursor_id_;
|
| - TestPlatformDisplayFactory platform_display_factory_;
|
| - TestWindowServerDelegate window_server_delegate_;
|
| - std::unique_ptr<WindowServer> window_server_;
|
| - base::MessageLoop message_loop_;
|
| -
|
| private:
|
| + WindowServerTestHelper ws_test_helper_;
|
| DISALLOW_COPY_AND_ASSIGN(CursorTest);
|
| };
|
|
|
| @@ -121,11 +117,11 @@ TEST_F(CursorTest, ChangeByMouseMove) {
|
|
|
| // Non client area
|
| MoveCursorTo(gfx::Point(15, 15));
|
| - EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id_));
|
| + EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id()));
|
|
|
| // Client area
|
| MoveCursorTo(gfx::Point(25, 25));
|
| - EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(cursor_id_));
|
| + EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(cursor_id()));
|
| }
|
|
|
| TEST_F(CursorTest, ChangeByClientAreaChange) {
|
| @@ -138,11 +134,11 @@ TEST_F(CursorTest, ChangeByClientAreaChange) {
|
|
|
| // Non client area before we move.
|
| MoveCursorTo(gfx::Point(15, 15));
|
| - EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id_));
|
| + EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id()));
|
|
|
| // Changing the client area should cause a change.
|
| win->SetClientArea(gfx::Insets(1, 1), std::vector<gfx::Rect>());
|
| - EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(cursor_id_));
|
| + EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(cursor_id()));
|
| }
|
|
|
| TEST_F(CursorTest, NonClientCursorChange) {
|
| @@ -154,10 +150,10 @@ TEST_F(CursorTest, NonClientCursorChange) {
|
| mojom::Cursor(win->non_client_cursor()));
|
|
|
| MoveCursorTo(gfx::Point(15, 15));
|
| - EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id_));
|
| + EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id()));
|
|
|
| win->SetNonClientCursor(mojom::Cursor::WEST_RESIZE);
|
| - EXPECT_EQ(mojom::Cursor::WEST_RESIZE, mojom::Cursor(cursor_id_));
|
| + EXPECT_EQ(mojom::Cursor::WEST_RESIZE, mojom::Cursor(cursor_id()));
|
| }
|
|
|
| TEST_F(CursorTest, IgnoreClientCursorChangeInNonClientArea) {
|
| @@ -169,10 +165,10 @@ TEST_F(CursorTest, IgnoreClientCursorChangeInNonClientArea) {
|
| mojom::Cursor(win->non_client_cursor()));
|
|
|
| MoveCursorTo(gfx::Point(15, 15));
|
| - EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id_));
|
| + EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id()));
|
|
|
| win->SetPredefinedCursor(mojom::Cursor::HELP);
|
| - EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id_));
|
| + EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id()));
|
| }
|
|
|
| TEST_F(CursorTest, NonClientToClientByBoundsChange) {
|
| @@ -185,10 +181,10 @@ TEST_F(CursorTest, NonClientToClientByBoundsChange) {
|
|
|
| // Non client area before we move.
|
| MoveCursorTo(gfx::Point(15, 15));
|
| - EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id_));
|
| + EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id()));
|
|
|
| win->SetBounds(gfx::Rect(0, 0, 30, 30));
|
| - EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(cursor_id_));
|
| + EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(cursor_id()));
|
| }
|
|
|
| } // namespace test
|
|
|