| 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 class CursorTest : public testing::Test { | 38 class CursorTest : public testing::Test { |
| 39 public: | 39 public: |
| 40 CursorTest() {} | 40 CursorTest() {} |
| 41 ~CursorTest() override {} | 41 ~CursorTest() override {} |
| 42 | 42 |
| 43 WindowServer* window_server() { return ws_test_helper_.window_server(); } | 43 WindowServer* window_server() { return ws_test_helper_.window_server(); } |
| 44 TestWindowServerDelegate* window_server_delegate() { | 44 TestWindowServerDelegate* window_server_delegate() { |
| 45 return ws_test_helper_.window_server_delegate(); | 45 return ws_test_helper_.window_server_delegate(); |
| 46 } | 46 } |
| 47 int32_t cursor_id() const { return ws_test_helper_.cursor_id(); } | 47 mojom::Cursor cursor() const { return ws_test_helper_.cursor(); } |
| 48 | 48 |
| 49 protected: | 49 protected: |
| 50 // testing::Test: | 50 // testing::Test: |
| 51 void SetUp() override { | 51 void SetUp() override { |
| 52 window_server_delegate()->set_num_displays_to_create(1); | 52 window_server_delegate()->set_num_displays_to_create(1); |
| 53 | 53 |
| 54 // As a side effect, this allocates Displays. | 54 // As a side effect, this allocates Displays. |
| 55 WindowManagerWindowTreeFactorySetTestApi( | 55 WindowManagerWindowTreeFactorySetTestApi( |
| 56 window_server()->window_manager_window_tree_factory_set()) | 56 window_server()->window_manager_window_tree_factory_set()) |
| 57 .Add(kTestId1); | 57 .Add(kTestId1); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 103 } |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 WindowServerTestHelper ws_test_helper_; | 106 WindowServerTestHelper ws_test_helper_; |
| 107 DISALLOW_COPY_AND_ASSIGN(CursorTest); | 107 DISALLOW_COPY_AND_ASSIGN(CursorTest); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 TEST_F(CursorTest, ChangeByMouseMove) { | 110 TEST_F(CursorTest, ChangeByMouseMove) { |
| 111 ServerWindow* win = BuildServerWindow(); | 111 ServerWindow* win = BuildServerWindow(); |
| 112 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 112 win->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 113 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(win->cursor())); | 113 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); |
| 114 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 114 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); |
| 115 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, | 115 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); |
| 116 mojom::Cursor(win->non_client_cursor())); | |
| 117 | 116 |
| 118 // Non client area | 117 // Non client area |
| 119 MoveCursorTo(gfx::Point(15, 15)); | 118 MoveCursorTo(gfx::Point(15, 15)); |
| 120 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id())); | 119 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); |
| 121 | 120 |
| 122 // Client area | 121 // Client area |
| 123 MoveCursorTo(gfx::Point(25, 25)); | 122 MoveCursorTo(gfx::Point(25, 25)); |
| 124 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(cursor_id())); | 123 EXPECT_EQ(mojom::Cursor::IBEAM, cursor()); |
| 125 } | 124 } |
| 126 | 125 |
| 127 TEST_F(CursorTest, ChangeByClientAreaChange) { | 126 TEST_F(CursorTest, ChangeByClientAreaChange) { |
| 128 ServerWindow* win = BuildServerWindow(); | 127 ServerWindow* win = BuildServerWindow(); |
| 129 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 128 win->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 130 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(win->cursor())); | 129 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(win->cursor())); |
| 131 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 130 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); |
| 132 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, | 131 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); |
| 133 mojom::Cursor(win->non_client_cursor())); | |
| 134 | 132 |
| 135 // Non client area before we move. | 133 // Non client area before we move. |
| 136 MoveCursorTo(gfx::Point(15, 15)); | 134 MoveCursorTo(gfx::Point(15, 15)); |
| 137 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id())); | 135 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); |
| 138 | 136 |
| 139 // Changing the client area should cause a change. | 137 // Changing the client area should cause a change. |
| 140 win->SetClientArea(gfx::Insets(1, 1), std::vector<gfx::Rect>()); | 138 win->SetClientArea(gfx::Insets(1, 1), std::vector<gfx::Rect>()); |
| 141 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(cursor_id())); | 139 EXPECT_EQ(mojom::Cursor::IBEAM, cursor()); |
| 142 } | 140 } |
| 143 | 141 |
| 144 TEST_F(CursorTest, NonClientCursorChange) { | 142 TEST_F(CursorTest, NonClientCursorChange) { |
| 145 ServerWindow* win = BuildServerWindow(); | 143 ServerWindow* win = BuildServerWindow(); |
| 146 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 144 win->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 147 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(win->cursor())); | 145 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); |
| 148 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 146 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); |
| 149 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, | 147 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); |
| 150 mojom::Cursor(win->non_client_cursor())); | |
| 151 | 148 |
| 152 MoveCursorTo(gfx::Point(15, 15)); | 149 MoveCursorTo(gfx::Point(15, 15)); |
| 153 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id())); | 150 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); |
| 154 | 151 |
| 155 win->SetNonClientCursor(mojom::Cursor::WEST_RESIZE); | 152 win->SetNonClientCursor(mojom::Cursor::WEST_RESIZE); |
| 156 EXPECT_EQ(mojom::Cursor::WEST_RESIZE, mojom::Cursor(cursor_id())); | 153 EXPECT_EQ(mojom::Cursor::WEST_RESIZE, cursor()); |
| 157 } | 154 } |
| 158 | 155 |
| 159 TEST_F(CursorTest, IgnoreClientCursorChangeInNonClientArea) { | 156 TEST_F(CursorTest, IgnoreClientCursorChangeInNonClientArea) { |
| 160 ServerWindow* win = BuildServerWindow(); | 157 ServerWindow* win = BuildServerWindow(); |
| 161 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 158 win->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 162 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(win->cursor())); | 159 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); |
| 163 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 160 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); |
| 164 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, | 161 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); |
| 165 mojom::Cursor(win->non_client_cursor())); | |
| 166 | 162 |
| 167 MoveCursorTo(gfx::Point(15, 15)); | 163 MoveCursorTo(gfx::Point(15, 15)); |
| 168 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id())); | 164 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); |
| 169 | 165 |
| 170 win->SetPredefinedCursor(mojom::Cursor::HELP); | 166 win->SetPredefinedCursor(mojom::Cursor::HELP); |
| 171 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id())); | 167 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); |
| 172 } | 168 } |
| 173 | 169 |
| 174 TEST_F(CursorTest, NonClientToClientByBoundsChange) { | 170 TEST_F(CursorTest, NonClientToClientByBoundsChange) { |
| 175 ServerWindow* win = BuildServerWindow(); | 171 ServerWindow* win = BuildServerWindow(); |
| 176 win->SetPredefinedCursor(mojom::Cursor::IBEAM); | 172 win->SetPredefinedCursor(mojom::Cursor::IBEAM); |
| 177 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(win->cursor())); | 173 EXPECT_EQ(mojom::Cursor::IBEAM, win->cursor()); |
| 178 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); | 174 win->SetNonClientCursor(mojom::Cursor::EAST_RESIZE); |
| 179 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, | 175 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, win->non_client_cursor()); |
| 180 mojom::Cursor(win->non_client_cursor())); | |
| 181 | 176 |
| 182 // Non client area before we move. | 177 // Non client area before we move. |
| 183 MoveCursorTo(gfx::Point(15, 15)); | 178 MoveCursorTo(gfx::Point(15, 15)); |
| 184 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id())); | 179 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, cursor()); |
| 185 | 180 |
| 186 win->SetBounds(gfx::Rect(0, 0, 30, 30)); | 181 win->SetBounds(gfx::Rect(0, 0, 30, 30)); |
| 187 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(cursor_id())); | 182 EXPECT_EQ(mojom::Cursor::IBEAM, cursor()); |
| 188 } | 183 } |
| 189 | 184 |
| 190 } // namespace test | 185 } // namespace test |
| 191 } // namespace ws | 186 } // namespace ws |
| 192 } // namespace ui | 187 } // namespace ui |
| OLD | NEW |