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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 101 } |
102 | 102 |
103 private: | 103 private: |
104 WindowServerTestHelper ws_test_helper_; | 104 WindowServerTestHelper ws_test_helper_; |
105 TestScreenManager screen_manager_; | 105 TestScreenManager screen_manager_; |
106 DISALLOW_COPY_AND_ASSIGN(CursorTest); | 106 DISALLOW_COPY_AND_ASSIGN(CursorTest); |
107 }; | 107 }; |
108 | 108 |
109 TEST_F(CursorTest, ChangeByMouseMove) { | 109 TEST_F(CursorTest, ChangeByMouseMove) { |
110 ServerWindow* win = BuildServerWindow(); | 110 ServerWindow* win = BuildServerWindow(); |
111 win->SetPredefinedCursor(mojom::CursorType::IBEAM); | 111 win->SetPredefinedCursor(mojom::CursorType::kIBeam); |
112 win->parent()->SetPredefinedCursor(mojom::CursorType::CELL); | 112 win->parent()->SetPredefinedCursor(mojom::CursorType::kCell); |
113 EXPECT_EQ(mojom::CursorType::IBEAM, win->cursor()); | 113 EXPECT_EQ(mojom::CursorType::kIBeam, win->cursor()); |
114 win->SetNonClientCursor(mojom::CursorType::EAST_RESIZE); | 114 win->SetNonClientCursor(mojom::CursorType::kEastResize); |
115 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, win->non_client_cursor()); | 115 EXPECT_EQ(mojom::CursorType::kEastResize, win->non_client_cursor()); |
116 | 116 |
117 // Non client area | 117 // Non client area |
118 MoveCursorTo(gfx::Point(15, 15)); | 118 MoveCursorTo(gfx::Point(15, 15)); |
119 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, cursor()); | 119 EXPECT_EQ(mojom::CursorType::kEastResize, cursor()); |
120 | 120 |
121 // Client area, which comes from win->parent(). | 121 // Client area, which comes from win->parent(). |
122 MoveCursorTo(gfx::Point(25, 25)); | 122 MoveCursorTo(gfx::Point(25, 25)); |
123 EXPECT_EQ(mojom::CursorType::CELL, cursor()); | 123 EXPECT_EQ(mojom::CursorType::kCell, cursor()); |
124 } | 124 } |
125 | 125 |
126 TEST_F(CursorTest, ChangeByClientAreaChange) { | 126 TEST_F(CursorTest, ChangeByClientAreaChange) { |
127 ServerWindow* win = BuildServerWindow(); | 127 ServerWindow* win = BuildServerWindow(); |
128 win->parent()->SetPredefinedCursor(mojom::CursorType::CROSS); | 128 win->parent()->SetPredefinedCursor(mojom::CursorType::kCross); |
129 win->SetPredefinedCursor(mojom::CursorType::IBEAM); | 129 win->SetPredefinedCursor(mojom::CursorType::kIBeam); |
130 EXPECT_EQ(mojom::CursorType::IBEAM, mojom::CursorType(win->cursor())); | 130 EXPECT_EQ(mojom::CursorType::kIBeam, mojom::CursorType(win->cursor())); |
131 win->SetNonClientCursor(mojom::CursorType::EAST_RESIZE); | 131 win->SetNonClientCursor(mojom::CursorType::kEastResize); |
132 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, win->non_client_cursor()); | 132 EXPECT_EQ(mojom::CursorType::kEastResize, win->non_client_cursor()); |
133 | 133 |
134 // Non client area before we move. | 134 // Non client area before we move. |
135 MoveCursorTo(gfx::Point(15, 15)); | 135 MoveCursorTo(gfx::Point(15, 15)); |
136 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, cursor()); | 136 EXPECT_EQ(mojom::CursorType::kEastResize, cursor()); |
137 | 137 |
138 // Changing the client area should cause a change. The cursor for the client | 138 // Changing the client area should cause a change. The cursor for the client |
139 // area comes from root ancestor, which is win->parent(). | 139 // area comes from root ancestor, which is win->parent(). |
140 win->SetClientArea(gfx::Insets(1, 1), std::vector<gfx::Rect>()); | 140 win->SetClientArea(gfx::Insets(1, 1), std::vector<gfx::Rect>()); |
141 EXPECT_EQ(mojom::CursorType::CROSS, cursor()); | 141 EXPECT_EQ(mojom::CursorType::kCross, cursor()); |
142 } | 142 } |
143 | 143 |
144 TEST_F(CursorTest, NonClientCursorChange) { | 144 TEST_F(CursorTest, NonClientCursorChange) { |
145 ServerWindow* win = BuildServerWindow(); | 145 ServerWindow* win = BuildServerWindow(); |
146 win->SetPredefinedCursor(mojom::CursorType::IBEAM); | 146 win->SetPredefinedCursor(mojom::CursorType::kIBeam); |
147 EXPECT_EQ(mojom::CursorType::IBEAM, win->cursor()); | 147 EXPECT_EQ(mojom::CursorType::kIBeam, win->cursor()); |
148 win->SetNonClientCursor(mojom::CursorType::EAST_RESIZE); | 148 win->SetNonClientCursor(mojom::CursorType::kEastResize); |
149 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, win->non_client_cursor()); | 149 EXPECT_EQ(mojom::CursorType::kEastResize, win->non_client_cursor()); |
150 | 150 |
151 MoveCursorTo(gfx::Point(15, 15)); | 151 MoveCursorTo(gfx::Point(15, 15)); |
152 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, cursor()); | 152 EXPECT_EQ(mojom::CursorType::kEastResize, cursor()); |
153 | 153 |
154 win->SetNonClientCursor(mojom::CursorType::WEST_RESIZE); | 154 win->SetNonClientCursor(mojom::CursorType::kWestResize); |
155 EXPECT_EQ(mojom::CursorType::WEST_RESIZE, cursor()); | 155 EXPECT_EQ(mojom::CursorType::kWestResize, cursor()); |
156 } | 156 } |
157 | 157 |
158 TEST_F(CursorTest, IgnoreClientCursorChangeInNonClientArea) { | 158 TEST_F(CursorTest, IgnoreClientCursorChangeInNonClientArea) { |
159 ServerWindow* win = BuildServerWindow(); | 159 ServerWindow* win = BuildServerWindow(); |
160 win->SetPredefinedCursor(mojom::CursorType::IBEAM); | 160 win->SetPredefinedCursor(mojom::CursorType::kIBeam); |
161 EXPECT_EQ(mojom::CursorType::IBEAM, win->cursor()); | 161 EXPECT_EQ(mojom::CursorType::kIBeam, win->cursor()); |
162 win->SetNonClientCursor(mojom::CursorType::EAST_RESIZE); | 162 win->SetNonClientCursor(mojom::CursorType::kEastResize); |
163 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, win->non_client_cursor()); | 163 EXPECT_EQ(mojom::CursorType::kEastResize, win->non_client_cursor()); |
164 | 164 |
165 MoveCursorTo(gfx::Point(15, 15)); | 165 MoveCursorTo(gfx::Point(15, 15)); |
166 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, cursor()); | 166 EXPECT_EQ(mojom::CursorType::kEastResize, cursor()); |
167 | 167 |
168 win->SetPredefinedCursor(mojom::CursorType::HELP); | 168 win->SetPredefinedCursor(mojom::CursorType::kHelp); |
169 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, cursor()); | 169 EXPECT_EQ(mojom::CursorType::kEastResize, cursor()); |
170 } | 170 } |
171 | 171 |
172 TEST_F(CursorTest, NonClientToClientByBoundsChange) { | 172 TEST_F(CursorTest, NonClientToClientByBoundsChange) { |
173 ServerWindow* win = BuildServerWindow(); | 173 ServerWindow* win = BuildServerWindow(); |
174 win->parent()->SetPredefinedCursor(mojom::CursorType::COPY); | 174 win->parent()->SetPredefinedCursor(mojom::CursorType::kCopy); |
175 win->SetPredefinedCursor(mojom::CursorType::IBEAM); | 175 win->SetPredefinedCursor(mojom::CursorType::kIBeam); |
176 EXPECT_EQ(mojom::CursorType::IBEAM, win->cursor()); | 176 EXPECT_EQ(mojom::CursorType::kIBeam, win->cursor()); |
177 win->SetNonClientCursor(mojom::CursorType::EAST_RESIZE); | 177 win->SetNonClientCursor(mojom::CursorType::kEastResize); |
178 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, win->non_client_cursor()); | 178 EXPECT_EQ(mojom::CursorType::kEastResize, win->non_client_cursor()); |
179 | 179 |
180 // Non client area before we move. | 180 // Non client area before we move. |
181 MoveCursorTo(gfx::Point(15, 15)); | 181 MoveCursorTo(gfx::Point(15, 15)); |
182 EXPECT_EQ(mojom::CursorType::EAST_RESIZE, cursor()); | 182 EXPECT_EQ(mojom::CursorType::kEastResize, cursor()); |
183 | 183 |
184 win->SetBounds(gfx::Rect(0, 0, 30, 30)); | 184 win->SetBounds(gfx::Rect(0, 0, 30, 30)); |
185 EXPECT_EQ(mojom::CursorType::COPY, cursor()); | 185 EXPECT_EQ(mojom::CursorType::kCopy, cursor()); |
186 } | 186 } |
187 | 187 |
188 } // namespace test | 188 } // namespace test |
189 } // namespace ws | 189 } // namespace ws |
190 } // namespace ui | 190 } // namespace ui |
OLD | NEW |