| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 class CursorTest : public testing::Test { | 36 class CursorTest : public testing::Test { |
| 37 public: | 37 public: |
| 38 CursorTest() {} | 38 CursorTest() {} |
| 39 ~CursorTest() override {} | 39 ~CursorTest() override {} |
| 40 | 40 |
| 41 WindowServer* window_server() { return ws_test_helper_.window_server(); } | 41 WindowServer* window_server() { return ws_test_helper_.window_server(); } |
| 42 TestWindowServerDelegate* window_server_delegate() { | 42 TestWindowServerDelegate* window_server_delegate() { |
| 43 return ws_test_helper_.window_server_delegate(); | 43 return ws_test_helper_.window_server_delegate(); |
| 44 } | 44 } |
| 45 mojom::Cursor cursor() const { return ws_test_helper_.cursor(); } | 45 mojom::CursorType cursor() const { return ws_test_helper_.cursor(); } |
| 46 | 46 |
| 47 protected: | 47 protected: |
| 48 // testing::Test: | 48 // testing::Test: |
| 49 void SetUp() override { | 49 void SetUp() override { |
| 50 screen_manager_.Init(window_server()->display_manager()); | 50 screen_manager_.Init(window_server()->display_manager()); |
| 51 screen_manager_.AddDisplay(); | 51 screen_manager_.AddDisplay(); |
| 52 | 52 |
| 53 // As a side effect, this allocates Displays. | 53 // As a side effect, this allocates Displays. |
| 54 AddWindowManager(window_server(), kTestId1); | 54 AddWindowManager(window_server(), kTestId1); |
| 55 window_server()->user_id_tracker()->AddUserId(kTestId1); | 55 window_server()->user_id_tracker()->AddUserId(kTestId1); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 WindowServerTestHelper ws_test_helper_; | 103 WindowServerTestHelper ws_test_helper_; |
| 104 TestScreenManager screen_manager_; | 104 TestScreenManager screen_manager_; |
| 105 DISALLOW_COPY_AND_ASSIGN(CursorTest); | 105 DISALLOW_COPY_AND_ASSIGN(CursorTest); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 TEST_F(CursorTest, ChangeByMouseMove) { | 108 TEST_F(CursorTest, ChangeByMouseMove) { |
| 109 ServerWindow* win = BuildServerWindow(); | 109 ServerWindow* win = BuildServerWindow(); |
| 110 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 110 win->SetPredefinedCursor(mojom::CursorType::IBEAM); |
| 111 win->parent()->SetPredefinedCursor(mojom::Cursor::CELL); | 111 win->parent()->SetPredefinedCursor(mojom::CursorType::CELL); |
| 112 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); | 112 EXPECT_EQ(mojom::CursorType::IBEAM, win->cursor()); |
| 113 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 113 win->SetNonClientCursor(mojom::CursorType::EAST_RESIZE); |
| 114 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); | 114 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, win->non_client_cursor()); |
| 115 | 115 |
| 116 // Non client area | 116 // Non client area |
| 117 MoveCursorTo(gfx::Point(15, 15)); | 117 MoveCursorTo(gfx::Point(15, 15)); |
| 118 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); | 118 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, cursor()); |
| 119 | 119 |
| 120 // Client area, which comes from win->parent(). | 120 // Client area, which comes from win->parent(). |
| 121 MoveCursorTo(gfx::Point(25, 25)); | 121 MoveCursorTo(gfx::Point(25, 25)); |
| 122 EXPECT_EQ(mojom::Cursor::CELL, cursor()); | 122 EXPECT_EQ(mojom::CursorType::CELL, cursor()); |
| 123 } | 123 } |
| 124 | 124 |
| 125 TEST_F(CursorTest, ChangeByClientAreaChange) { | 125 TEST_F(CursorTest, ChangeByClientAreaChange) { |
| 126 ServerWindow* win = BuildServerWindow(); | 126 ServerWindow* win = BuildServerWindow(); |
| 127 win->parent()->SetPredefinedCursor(mojom::Cursor::CROSS); | 127 win->parent()->SetPredefinedCursor(mojom::CursorType::CROSS); |
| 128 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 128 win->SetPredefinedCursor(mojom::CursorType::IBEAM); |
| 129 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(win->cursor())); | 129 EXPECT_EQ(mojom::CursorType::IBEAM, mojom::CursorType(win->cursor())); |
| 130 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 130 win->SetNonClientCursor(mojom::CursorType::EAST_RESIZE); |
| 131 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); | 131 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, win->non_client_cursor()); |
| 132 | 132 |
| 133 // Non client area before we move. | 133 // Non client area before we move. |
| 134 MoveCursorTo(gfx::Point(15, 15)); | 134 MoveCursorTo(gfx::Point(15, 15)); |
| 135 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); | 135 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, cursor()); |
| 136 | 136 |
| 137 // Changing the client area should cause a change. The cursor for the client | 137 // Changing the client area should cause a change. The cursor for the client |
| 138 // area comes from root ancestor, which is win->parent(). | 138 // area comes from root ancestor, which is win->parent(). |
| 139 win->SetClientArea(gfx::Insets(1, 1), std::vector<gfx::Rect>()); | 139 win->SetClientArea(gfx::Insets(1, 1), std::vector<gfx::Rect>()); |
| 140 EXPECT_EQ(mojom::Cursor::CROSS, cursor()); | 140 EXPECT_EQ(mojom::CursorType::CROSS, cursor()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 TEST_F(CursorTest, NonClientCursorChange) { | 143 TEST_F(CursorTest, NonClientCursorChange) { |
| 144 ServerWindow* win = BuildServerWindow(); | 144 ServerWindow* win = BuildServerWindow(); |
| 145 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 145 win->SetPredefinedCursor(mojom::CursorType::IBEAM); |
| 146 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); | 146 EXPECT_EQ(mojom::CursorType::IBEAM, win->cursor()); |
| 147 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 147 win->SetNonClientCursor(mojom::CursorType::EAST_RESIZE); |
| 148 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); | 148 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, win->non_client_cursor()); |
| 149 | 149 |
| 150 MoveCursorTo(gfx::Point(15, 15)); | 150 MoveCursorTo(gfx::Point(15, 15)); |
| 151 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); | 151 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, cursor()); |
| 152 | 152 |
| 153 win->SetNonClientCursor(mojom::Cursor::WEST_RESIZE); | 153 win->SetNonClientCursor(mojom::CursorType::WEST_RESIZE); |
| 154 EXPECT_EQ(mojom::Cursor::WEST_RESIZE, cursor()); | 154 EXPECT_EQ(mojom::CursorType::WEST_RESIZE, cursor()); |
| 155 } | 155 } |
| 156 | 156 |
| 157 TEST_F(CursorTest, IgnoreClientCursorChangeInNonClientArea) { | 157 TEST_F(CursorTest, IgnoreClientCursorChangeInNonClientArea) { |
| 158 ServerWindow* win = BuildServerWindow(); | 158 ServerWindow* win = BuildServerWindow(); |
| 159 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 159 win->SetPredefinedCursor(mojom::CursorType::IBEAM); |
| 160 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); | 160 EXPECT_EQ(mojom::CursorType::IBEAM, win->cursor()); |
| 161 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 161 win->SetNonClientCursor(mojom::CursorType::EAST_RESIZE); |
| 162 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); | 162 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, win->non_client_cursor()); |
| 163 | 163 |
| 164 MoveCursorTo(gfx::Point(15, 15)); | 164 MoveCursorTo(gfx::Point(15, 15)); |
| 165 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); | 165 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, cursor()); |
| 166 | 166 |
| 167 win->SetPredefinedCursor(mojom::Cursor::HELP); | 167 win->SetPredefinedCursor(mojom::CursorType::HELP); |
| 168 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); | 168 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, cursor()); |
| 169 } | 169 } |
| 170 | 170 |
| 171 TEST_F(CursorTest, NonClientToClientByBoundsChange) { | 171 TEST_F(CursorTest, NonClientToClientByBoundsChange) { |
| 172 ServerWindow* win = BuildServerWindow(); | 172 ServerWindow* win = BuildServerWindow(); |
| 173 win->parent()->SetPredefinedCursor(mojom::Cursor::COPY); | 173 win->parent()->SetPredefinedCursor(mojom::CursorType::COPY); |
| 174 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 174 win->SetPredefinedCursor(mojom::CursorType::IBEAM); |
| 175 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); | 175 EXPECT_EQ(mojom::CursorType::IBEAM, win->cursor()); |
| 176 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 176 win->SetNonClientCursor(mojom::CursorType::EAST_RESIZE); |
| 177 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); | 177 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, win->non_client_cursor()); |
| 178 | 178 |
| 179 // Non client area before we move. | 179 // Non client area before we move. |
| 180 MoveCursorTo(gfx::Point(15, 15)); | 180 MoveCursorTo(gfx::Point(15, 15)); |
| 181 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); | 181 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, cursor()); |
| 182 | 182 |
| 183 win->SetBounds(gfx::Rect(0, 0, 30, 30)); | 183 win->SetBounds(gfx::Rect(0, 0, 30, 30)); |
| 184 EXPECT_EQ(mojom::Cursor::COPY, cursor()); | 184 EXPECT_EQ(mojom::CursorType::COPY, cursor()); |
| 185 } | 185 } |
| 186 | 186 |
| 187 } // namespace test | 187 } // namespace test |
| 188 } // namespace ws | 188 } // namespace ws |
| 189 } // namespace ui | 189 } // namespace ui |
| OLD | NEW |