Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: ash/wm/drag_window_resizer_unittest.cc

Issue 1867223004: Convert //ash from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/drag_window_resizer.h ('k') | ash/wm/gestures/long_press_affordance_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/wm/drag_window_resizer.h" 5 #include "ash/wm/drag_window_resizer.h"
6 6
7 #include "ash/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/display/mouse_cursor_event_filter.h" 8 #include "ash/display/mouse_cursor_event_filter.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 point_in_screen); 129 point_in_screen);
130 } 130 }
131 131
132 aura::test::TestWindowDelegate delegate_; 132 aura::test::TestWindowDelegate delegate_;
133 aura::test::TestWindowDelegate delegate2_; 133 aura::test::TestWindowDelegate delegate2_;
134 aura::test::TestWindowDelegate delegate3_; 134 aura::test::TestWindowDelegate delegate3_;
135 aura::test::TestWindowDelegate delegate4_; 135 aura::test::TestWindowDelegate delegate4_;
136 aura::test::TestWindowDelegate delegate5_; 136 aura::test::TestWindowDelegate delegate5_;
137 aura::test::TestWindowDelegate delegate6_; 137 aura::test::TestWindowDelegate delegate6_;
138 138
139 scoped_ptr<aura::Window> window_; 139 std::unique_ptr<aura::Window> window_;
140 scoped_ptr<aura::Window> always_on_top_window_; 140 std::unique_ptr<aura::Window> always_on_top_window_;
141 scoped_ptr<aura::Window> system_modal_window_; 141 std::unique_ptr<aura::Window> system_modal_window_;
142 scoped_ptr<aura::Window> panel_window_; 142 std::unique_ptr<aura::Window> panel_window_;
143 aura::Window* transient_child_; 143 aura::Window* transient_child_;
144 scoped_ptr<aura::Window> transient_parent_; 144 std::unique_ptr<aura::Window> transient_parent_;
145 145
146 private: 146 private:
147 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest); 147 DISALLOW_COPY_AND_ASSIGN(DragWindowResizerTest);
148 }; 148 };
149 149
150 // Verifies a window can be moved from the primary display to another. 150 // Verifies a window can be moved from the primary display to another.
151 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplays) { 151 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplays) {
152 if (!SupportsMultipleDisplays()) 152 if (!SupportsMultipleDisplays())
153 return; 153 return;
154 154
155 // The secondary display is logically on the right, but on the system (e.g. X) 155 // The secondary display is logically on the right, but on the system (e.g. X)
156 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 156 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
157 UpdateDisplay("800x600,400x300"); 157 UpdateDisplay("800x600,400x300");
158 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 158 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
159 ASSERT_EQ(2U, root_windows.size()); 159 ASSERT_EQ(2U, root_windows.size());
160 160
161 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 161 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
162 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 162 gfx::Screen::GetScreen()->GetPrimaryDisplay());
163 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 163 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
164 { 164 {
165 // Grab (0, 0) of the window. 165 // Grab (0, 0) of the window.
166 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 166 std::unique_ptr<WindowResizer> resizer(
167 window_.get(), gfx::Point(), HTCAPTION)); 167 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
168 ASSERT_TRUE(resizer.get()); 168 ASSERT_TRUE(resizer.get());
169 // Drag the pointer to the right. Once it reaches the right edge of the 169 // Drag the pointer to the right. Once it reaches the right edge of the
170 // primary display, it warps to the secondary. 170 // primary display, it warps to the secondary.
171 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 171 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
172 resizer->CompleteDrag(); 172 resizer->CompleteDrag();
173 // The whole window is on the secondary display now. The parent should be 173 // The whole window is on the secondary display now. The parent should be
174 // changed. 174 // changed.
175 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 175 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
176 EXPECT_EQ("0,10 50x60", window_->bounds().ToString()); 176 EXPECT_EQ("0,10 50x60", window_->bounds().ToString());
177 } 177 }
178 178
179 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 179 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
180 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 180 gfx::Screen::GetScreen()->GetPrimaryDisplay());
181 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 181 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
182 { 182 {
183 // Grab (0, 0) of the window and move the pointer to (775, 10). 183 // Grab (0, 0) of the window and move the pointer to (775, 10).
184 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 184 std::unique_ptr<WindowResizer> resizer(
185 window_.get(), gfx::Point(), HTCAPTION)); 185 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
186 ASSERT_TRUE(resizer.get()); 186 ASSERT_TRUE(resizer.get());
187 resizer->Drag(CalculateDragPoint(*resizer, 795, 10), 0); 187 resizer->Drag(CalculateDragPoint(*resizer, 795, 10), 0);
188 // Window should be adjusted for minimum visibility (25px) during the drag. 188 // Window should be adjusted for minimum visibility (25px) during the drag.
189 EXPECT_EQ("775,10 50x60", window_->bounds().ToString()); 189 EXPECT_EQ("775,10 50x60", window_->bounds().ToString());
190 resizer->CompleteDrag(); 190 resizer->CompleteDrag();
191 // Since the pointer is still on the primary root window, the parent should 191 // Since the pointer is still on the primary root window, the parent should
192 // not be changed. 192 // not be changed.
193 // Window origin should be adjusted for minimum visibility (25px). 193 // Window origin should be adjusted for minimum visibility (25px).
194 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 194 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
195 EXPECT_EQ("775,10 50x60", window_->bounds().ToString()); 195 EXPECT_EQ("775,10 50x60", window_->bounds().ToString());
196 } 196 }
197 197
198 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 198 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
199 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 199 gfx::Screen::GetScreen()->GetPrimaryDisplay());
200 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 200 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
201 { 201 {
202 // Grab the top-right edge of the window and move the pointer to (0, 10) 202 // Grab the top-right edge of the window and move the pointer to (0, 10)
203 // in the secondary root window's coordinates. 203 // in the secondary root window's coordinates.
204 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 204 std::unique_ptr<WindowResizer> resizer(
205 window_.get(), gfx::Point(49, 0), HTCAPTION)); 205 CreateDragWindowResizer(window_.get(), gfx::Point(49, 0), HTCAPTION));
206 ASSERT_TRUE(resizer.get()); 206 ASSERT_TRUE(resizer.get());
207 resizer->Drag(CalculateDragPoint(*resizer, 751, 10), ui::EF_CONTROL_DOWN); 207 resizer->Drag(CalculateDragPoint(*resizer, 751, 10), ui::EF_CONTROL_DOWN);
208 resizer->CompleteDrag(); 208 resizer->CompleteDrag();
209 // Since the pointer is on the secondary, the parent should be changed 209 // Since the pointer is on the secondary, the parent should be changed
210 // even though only small fraction of the window is within the secondary 210 // even though only small fraction of the window is within the secondary
211 // root window's bounds. 211 // root window's bounds.
212 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 212 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
213 // Window origin should be adjusted for minimum visibility (25px). 213 // Window origin should be adjusted for minimum visibility (25px).
214 int expected_x = -50 + kMinimumOnScreenArea; 214 int expected_x = -50 + kMinimumOnScreenArea;
215 215
216 EXPECT_EQ(base::IntToString(expected_x) + ",10 50x60", 216 EXPECT_EQ(base::IntToString(expected_x) + ",10 50x60",
217 window_->bounds().ToString()); 217 window_->bounds().ToString());
218 } 218 }
219 // Dropping a window that is larger than the destination work area 219 // Dropping a window that is larger than the destination work area
220 // will shrink to fit to the work area. 220 // will shrink to fit to the work area.
221 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), 221 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500),
222 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 222 gfx::Screen::GetScreen()->GetPrimaryDisplay());
223 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 223 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
224 { 224 {
225 // Grab the top-right edge of the window and move the pointer to (0, 10) 225 // Grab the top-right edge of the window and move the pointer to (0, 10)
226 // in the secondary root window's coordinates. 226 // in the secondary root window's coordinates.
227 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 227 std::unique_ptr<WindowResizer> resizer(
228 window_.get(), gfx::Point(699, 0), HTCAPTION)); 228 CreateDragWindowResizer(window_.get(), gfx::Point(699, 0), HTCAPTION));
229 ASSERT_TRUE(resizer.get()); 229 ASSERT_TRUE(resizer.get());
230 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN); 230 resizer->Drag(CalculateDragPoint(*resizer, 101, 10), ui::EF_CONTROL_DOWN);
231 resizer->CompleteDrag(); 231 resizer->CompleteDrag();
232 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 232 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
233 // Window size should be adjusted to fit to the work area 233 // Window size should be adjusted to fit to the work area
234 EXPECT_EQ("400x253", window_->bounds().size().ToString()); 234 EXPECT_EQ("400x253", window_->bounds().size().ToString());
235 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); 235 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen();
236 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); 236 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen());
237 intersect.Intersect(window_bounds_in_screen); 237 intersect.Intersect(window_bounds_in_screen);
238 238
239 EXPECT_LE(10, intersect.width()); 239 EXPECT_LE(10, intersect.width());
240 EXPECT_LE(10, intersect.height()); 240 EXPECT_LE(10, intersect.height());
241 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10))); 241 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(800, 10)));
242 } 242 }
243 243
244 // Dropping a window that is larger than the destination work area 244 // Dropping a window that is larger than the destination work area
245 // will shrink to fit to the work area. 245 // will shrink to fit to the work area.
246 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500), 246 window_->SetBoundsInScreen(gfx::Rect(0, 0, 700, 500),
247 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 247 gfx::Screen::GetScreen()->GetPrimaryDisplay());
248 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 248 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
249 { 249 {
250 // Grab the top-left edge of the window and move the pointer to (150, 10) 250 // Grab the top-left edge of the window and move the pointer to (150, 10)
251 // in the secondary root window's coordinates. Make sure the window is 251 // in the secondary root window's coordinates. Make sure the window is
252 // shrink in such a way that it keeps the cursor within. 252 // shrink in such a way that it keeps the cursor within.
253 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 253 std::unique_ptr<WindowResizer> resizer(
254 window_.get(), gfx::Point(0, 0), HTCAPTION)); 254 CreateDragWindowResizer(window_.get(), gfx::Point(0, 0), HTCAPTION));
255 ASSERT_TRUE(resizer.get()); 255 ASSERT_TRUE(resizer.get());
256 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN); 256 resizer->Drag(CalculateDragPoint(*resizer, 799, 10), ui::EF_CONTROL_DOWN);
257 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN); 257 resizer->Drag(CalculateDragPoint(*resizer, 850, 10), ui::EF_CONTROL_DOWN);
258 resizer->CompleteDrag(); 258 resizer->CompleteDrag();
259 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 259 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
260 // Window size should be adjusted to fit to the work area 260 // Window size should be adjusted to fit to the work area
261 EXPECT_EQ("400x253", window_->bounds().size().ToString()); 261 EXPECT_EQ("400x253", window_->bounds().size().ToString());
262 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen(); 262 gfx::Rect window_bounds_in_screen = window_->GetBoundsInScreen();
263 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen()); 263 gfx::Rect intersect(window_->GetRootWindow()->GetBoundsInScreen());
264 intersect.Intersect(window_bounds_in_screen); 264 intersect.Intersect(window_bounds_in_screen);
265 EXPECT_LE(10, intersect.width()); 265 EXPECT_LE(10, intersect.width());
266 EXPECT_LE(10, intersect.height()); 266 EXPECT_LE(10, intersect.height());
267 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10))); 267 EXPECT_TRUE(window_bounds_in_screen.Contains(gfx::Point(850, 10)));
268 } 268 }
269 } 269 }
270 270
271 // Verifies that dragging the active window to another display makes the new 271 // Verifies that dragging the active window to another display makes the new
272 // root window the active root window. 272 // root window the active root window.
273 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) { 273 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysActiveRoot) {
274 if (!SupportsMultipleDisplays()) 274 if (!SupportsMultipleDisplays())
275 return; 275 return;
276 276
277 // The secondary display is logically on the right, but on the system (e.g. X) 277 // The secondary display is logically on the right, but on the system (e.g. X)
278 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 278 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
279 UpdateDisplay("800x600,800x600"); 279 UpdateDisplay("800x600,800x600");
280 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 280 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
281 ASSERT_EQ(2U, root_windows.size()); 281 ASSERT_EQ(2U, root_windows.size());
282 282
283 aura::test::TestWindowDelegate delegate; 283 aura::test::TestWindowDelegate delegate;
284 scoped_ptr<aura::Window> window(new aura::Window(&delegate)); 284 std::unique_ptr<aura::Window> window(new aura::Window(&delegate));
285 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 285 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
286 window->Init(ui::LAYER_TEXTURED); 286 window->Init(ui::LAYER_TEXTURED);
287 ParentWindowInPrimaryRootWindow(window.get()); 287 ParentWindowInPrimaryRootWindow(window.get());
288 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 288 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
289 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 289 gfx::Screen::GetScreen()->GetPrimaryDisplay());
290 window->Show(); 290 window->Show();
291 EXPECT_TRUE(ash::wm::CanActivateWindow(window.get())); 291 EXPECT_TRUE(ash::wm::CanActivateWindow(window.get()));
292 ash::wm::ActivateWindow(window.get()); 292 ash::wm::ActivateWindow(window.get());
293 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 293 EXPECT_EQ(root_windows[0], window->GetRootWindow());
294 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow()); 294 EXPECT_EQ(root_windows[0], ash::Shell::GetTargetRootWindow());
295 { 295 {
296 // Grab (0, 0) of the window. 296 // Grab (0, 0) of the window.
297 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 297 std::unique_ptr<WindowResizer> resizer(
298 window.get(), gfx::Point(), HTCAPTION)); 298 CreateDragWindowResizer(window.get(), gfx::Point(), HTCAPTION));
299 ASSERT_TRUE(resizer.get()); 299 ASSERT_TRUE(resizer.get());
300 // Drag the pointer to the right. Once it reaches the right edge of the 300 // Drag the pointer to the right. Once it reaches the right edge of the
301 // primary display, it warps to the secondary. 301 // primary display, it warps to the secondary.
302 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 302 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
303 resizer->CompleteDrag(); 303 resizer->CompleteDrag();
304 // The whole window is on the secondary display now. The parent should be 304 // The whole window is on the secondary display now. The parent should be
305 // changed. 305 // changed.
306 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 306 EXPECT_EQ(root_windows[1], window->GetRootWindow());
307 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow()); 307 EXPECT_EQ(root_windows[1], ash::Shell::GetTargetRootWindow());
308 } 308 }
309 } 309 }
310 310
311 // Verifies a window can be moved from the secondary display to primary. 311 // Verifies a window can be moved from the secondary display to primary.
312 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) { 312 TEST_F(DragWindowResizerTest, WindowDragWithMultiDisplaysRightToLeft) {
313 if (!SupportsMultipleDisplays()) 313 if (!SupportsMultipleDisplays())
314 return; 314 return;
315 315
316 UpdateDisplay("800x600,800x600"); 316 UpdateDisplay("800x600,800x600");
317 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 317 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
318 ASSERT_EQ(2U, root_windows.size()); 318 ASSERT_EQ(2U, root_windows.size());
319 319
320 window_->SetBoundsInScreen( 320 window_->SetBoundsInScreen(
321 gfx::Rect(800, 00, 50, 60), 321 gfx::Rect(800, 00, 50, 60),
322 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 322 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
323 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 323 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
324 { 324 {
325 // Grab (0, 0) of the window. 325 // Grab (0, 0) of the window.
326 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 326 std::unique_ptr<WindowResizer> resizer(
327 window_.get(), gfx::Point(), HTCAPTION)); 327 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
328 ASSERT_TRUE(resizer.get()); 328 ASSERT_TRUE(resizer.get());
329 // Move the mouse near the right edge, (798, 0), of the primary display. 329 // Move the mouse near the right edge, (798, 0), of the primary display.
330 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN); 330 resizer->Drag(CalculateDragPoint(*resizer, -2, 0), ui::EF_CONTROL_DOWN);
331 resizer->CompleteDrag(); 331 resizer->CompleteDrag();
332 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 332 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
333 // Window origin should be adjusted for minimum visibility (25px). 333 // Window origin should be adjusted for minimum visibility (25px).
334 EXPECT_EQ("775,0 50x60", window_->bounds().ToString()); 334 EXPECT_EQ("775,0 50x60", window_->bounds().ToString());
335 } 335 }
336 } 336 }
337 337
338 // Verifies the drag window is shown correctly. 338 // Verifies the drag window is shown correctly.
339 TEST_F(DragWindowResizerTest, DragWindowController) { 339 TEST_F(DragWindowResizerTest, DragWindowController) {
340 if (!SupportsMultipleDisplays()) 340 if (!SupportsMultipleDisplays())
341 return; 341 return;
342 342
343 UpdateDisplay("800x600,800x600"); 343 UpdateDisplay("800x600,800x600");
344 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 344 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
345 ASSERT_EQ(2U, root_windows.size()); 345 ASSERT_EQ(2U, root_windows.size());
346 346
347 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 347 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
348 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 348 gfx::Screen::GetScreen()->GetPrimaryDisplay());
349 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 349 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
350 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 350 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
351 { 351 {
352 // Hold the center of the window so that the window doesn't stick to the 352 // Hold the center of the window so that the window doesn't stick to the
353 // edge when dragging around the edge of the display. 353 // edge when dragging around the edge of the display.
354 scoped_ptr<WindowResizer> resizer( 354 std::unique_ptr<WindowResizer> resizer(
355 CreateDragWindowResizer(window_.get(), gfx::Point(25, 30), HTCAPTION)); 355 CreateDragWindowResizer(window_.get(), gfx::Point(25, 30), HTCAPTION));
356 ASSERT_TRUE(resizer.get()); 356 ASSERT_TRUE(resizer.get());
357 DragWindowResizer* drag_resizer = DragWindowResizer::instance_; 357 DragWindowResizer* drag_resizer = DragWindowResizer::instance_;
358 ASSERT_TRUE(drag_resizer); 358 ASSERT_TRUE(drag_resizer);
359 EXPECT_FALSE(drag_resizer->drag_window_controller_.get()); 359 EXPECT_FALSE(drag_resizer->drag_window_controller_.get());
360 360
361 // The pointer is inside the primary root. The drag window controller 361 // The pointer is inside the primary root. The drag window controller
362 // should be NULL. 362 // should be NULL.
363 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0); 363 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0);
364 DragWindowController* controller = 364 DragWindowController* controller =
(...skipping 29 matching lines...) Expand all
394 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 394 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
395 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 395 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
396 } 396 }
397 397
398 // Do the same test with RevertDrag(). 398 // Do the same test with RevertDrag().
399 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 399 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
400 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 400 gfx::Screen::GetScreen()->GetPrimaryDisplay());
401 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 401 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
402 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 402 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
403 { 403 {
404 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 404 std::unique_ptr<WindowResizer> resizer(
405 window_.get(), gfx::Point(), HTCAPTION)); 405 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
406 ASSERT_TRUE(resizer.get()); 406 ASSERT_TRUE(resizer.get());
407 DragWindowResizer* drag_resizer = DragWindowResizer::instance_; 407 DragWindowResizer* drag_resizer = DragWindowResizer::instance_;
408 DragWindowController* controller = 408 DragWindowController* controller =
409 drag_resizer->drag_window_controller_.get(); 409 drag_resizer->drag_window_controller_.get();
410 ASSERT_TRUE(drag_resizer); 410 ASSERT_TRUE(drag_resizer);
411 EXPECT_FALSE(controller); 411 EXPECT_FALSE(controller);
412 412
413 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0); 413 resizer->Drag(CalculateDragPoint(*resizer, 0, 610), 0);
414 resizer->RevertDrag(); 414 resizer->RevertDrag();
415 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 415 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
(...skipping 27 matching lines...) Expand all
443 ASSERT_EQ(gfx::Rect(0, 600, 800, 600), 443 ASSERT_EQ(gfx::Rect(0, 600, 800, 600),
444 display_manager->GetDisplayForId(list[2]).bounds()); 444 display_manager->GetDisplayForId(list[2]).bounds());
445 445
446 // Create a window on 2nd display. 446 // Create a window on 2nd display.
447 window_->SetBoundsInScreen(gfx::Rect(400, 0, 100, 100), 447 window_->SetBoundsInScreen(gfx::Rect(400, 0, 100, 100),
448 display_manager->GetDisplayForId(list[1])); 448 display_manager->GetDisplayForId(list[1]));
449 ASSERT_EQ(root_windows[1], window_->GetRootWindow()); 449 ASSERT_EQ(root_windows[1], window_->GetRootWindow());
450 450
451 // Hold the center of the window so that the window doesn't stick to the edge 451 // Hold the center of the window so that the window doesn't stick to the edge
452 // when dragging around the edge of the display. 452 // when dragging around the edge of the display.
453 scoped_ptr<WindowResizer> resizer( 453 std::unique_ptr<WindowResizer> resizer(
454 CreateDragWindowResizer(window_.get(), gfx::Point(50, 50), HTCAPTION)); 454 CreateDragWindowResizer(window_.get(), gfx::Point(50, 50), HTCAPTION));
455 ASSERT_TRUE(resizer.get()); 455 ASSERT_TRUE(resizer.get());
456 DragWindowResizer* drag_resizer = DragWindowResizer::instance_; 456 DragWindowResizer* drag_resizer = DragWindowResizer::instance_;
457 ASSERT_TRUE(drag_resizer); 457 ASSERT_TRUE(drag_resizer);
458 EXPECT_FALSE(drag_resizer->drag_window_controller_.get()); 458 EXPECT_FALSE(drag_resizer->drag_window_controller_.get());
459 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); 459 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0);
460 DragWindowController* controller = 460 DragWindowController* controller =
461 drag_resizer->drag_window_controller_.get(); 461 drag_resizer->drag_window_controller_.get();
462 ASSERT_TRUE(controller); 462 ASSERT_TRUE(controller);
463 ASSERT_EQ(1, controller->GetDragWindowsCountForTest()); 463 ASSERT_EQ(1, controller->GetDragWindowsCountForTest());
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 // Verifies if the resizer sets and resets 522 // Verifies if the resizer sets and resets
523 // MouseCursorEventFilter::mouse_warp_mode_ as expected. 523 // MouseCursorEventFilter::mouse_warp_mode_ as expected.
524 TEST_F(DragWindowResizerTest, WarpMousePointer) { 524 TEST_F(DragWindowResizerTest, WarpMousePointer) {
525 MouseCursorEventFilter* event_filter = 525 MouseCursorEventFilter* event_filter =
526 Shell::GetInstance()->mouse_cursor_filter(); 526 Shell::GetInstance()->mouse_cursor_filter();
527 ASSERT_TRUE(event_filter); 527 ASSERT_TRUE(event_filter);
528 window_->SetBounds(gfx::Rect(0, 0, 50, 60)); 528 window_->SetBounds(gfx::Rect(0, 0, 50, 60));
529 529
530 EXPECT_TRUE(event_filter->mouse_warp_enabled_); 530 EXPECT_TRUE(event_filter->mouse_warp_enabled_);
531 { 531 {
532 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 532 std::unique_ptr<WindowResizer> resizer(
533 window_.get(), gfx::Point(), HTCAPTION)); 533 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
534 // While dragging a window, warp should be allowed. 534 // While dragging a window, warp should be allowed.
535 EXPECT_TRUE(event_filter->mouse_warp_enabled_); 535 EXPECT_TRUE(event_filter->mouse_warp_enabled_);
536 resizer->CompleteDrag(); 536 resizer->CompleteDrag();
537 } 537 }
538 EXPECT_TRUE(event_filter->mouse_warp_enabled_); 538 EXPECT_TRUE(event_filter->mouse_warp_enabled_);
539 539
540 { 540 {
541 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 541 std::unique_ptr<WindowResizer> resizer(
542 window_.get(), gfx::Point(), HTCAPTION)); 542 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
543 EXPECT_TRUE(event_filter->mouse_warp_enabled_); 543 EXPECT_TRUE(event_filter->mouse_warp_enabled_);
544 resizer->RevertDrag(); 544 resizer->RevertDrag();
545 } 545 }
546 EXPECT_TRUE(event_filter->mouse_warp_enabled_); 546 EXPECT_TRUE(event_filter->mouse_warp_enabled_);
547 547
548 { 548 {
549 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 549 std::unique_ptr<WindowResizer> resizer(
550 window_.get(), gfx::Point(), HTRIGHT)); 550 CreateDragWindowResizer(window_.get(), gfx::Point(), HTRIGHT));
551 // While resizing a window, warp should NOT be allowed. 551 // While resizing a window, warp should NOT be allowed.
552 EXPECT_FALSE(event_filter->mouse_warp_enabled_); 552 EXPECT_FALSE(event_filter->mouse_warp_enabled_);
553 resizer->CompleteDrag(); 553 resizer->CompleteDrag();
554 } 554 }
555 EXPECT_TRUE(event_filter->mouse_warp_enabled_); 555 EXPECT_TRUE(event_filter->mouse_warp_enabled_);
556 556
557 { 557 {
558 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 558 std::unique_ptr<WindowResizer> resizer(
559 window_.get(), gfx::Point(), HTRIGHT)); 559 CreateDragWindowResizer(window_.get(), gfx::Point(), HTRIGHT));
560 EXPECT_FALSE(event_filter->mouse_warp_enabled_); 560 EXPECT_FALSE(event_filter->mouse_warp_enabled_);
561 resizer->RevertDrag(); 561 resizer->RevertDrag();
562 } 562 }
563 EXPECT_TRUE(event_filter->mouse_warp_enabled_); 563 EXPECT_TRUE(event_filter->mouse_warp_enabled_);
564 } 564 }
565 565
566 // Verifies cursor's device scale factor is updated whe a window is moved across 566 // Verifies cursor's device scale factor is updated whe a window is moved across
567 // root windows with different device scale factors (http://crbug.com/154183). 567 // root windows with different device scale factors (http://crbug.com/154183).
568 TEST_F(DragWindowResizerTest, CursorDeviceScaleFactor) { 568 TEST_F(DragWindowResizerTest, CursorDeviceScaleFactor) {
569 if (!SupportsMultipleDisplays()) 569 if (!SupportsMultipleDisplays())
570 return; 570 return;
571 571
572 // The secondary display is logically on the right, but on the system (e.g. X) 572 // The secondary display is logically on the right, but on the system (e.g. X)
573 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 573 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
574 UpdateDisplay("400x400,800x800*2"); 574 UpdateDisplay("400x400,800x800*2");
575 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 575 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
576 ASSERT_EQ(2U, root_windows.size()); 576 ASSERT_EQ(2U, root_windows.size());
577 577
578 test::CursorManagerTestApi cursor_test_api( 578 test::CursorManagerTestApi cursor_test_api(
579 Shell::GetInstance()->cursor_manager()); 579 Shell::GetInstance()->cursor_manager());
580 // Move window from the root window with 1.0 device scale factor to the root 580 // Move window from the root window with 1.0 device scale factor to the root
581 // window with 2.0 device scale factor. 581 // window with 2.0 device scale factor.
582 { 582 {
583 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 583 window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
584 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 584 gfx::Screen::GetScreen()->GetPrimaryDisplay());
585 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 585 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
586 // Grab (0, 0) of the window. 586 // Grab (0, 0) of the window.
587 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 587 std::unique_ptr<WindowResizer> resizer(
588 window_.get(), gfx::Point(), HTCAPTION)); 588 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
589 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 589 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
590 ASSERT_TRUE(resizer.get()); 590 ASSERT_TRUE(resizer.get());
591 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 591 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
592 TestIfMouseWarpsAt(gfx::Point(399, 200)); 592 TestIfMouseWarpsAt(gfx::Point(399, 200));
593 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 593 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
594 resizer->CompleteDrag(); 594 resizer->CompleteDrag();
595 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 595 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
596 } 596 }
597 597
598 // Move window from the root window with 2.0 device scale factor to the root 598 // Move window from the root window with 2.0 device scale factor to the root
599 // window with 1.0 device scale factor. 599 // window with 1.0 device scale factor.
600 { 600 {
601 // Make sure the window is on the default container first. 601 // Make sure the window is on the default container first.
602 aura::Window* default_container = 602 aura::Window* default_container =
603 GetRootWindowController(root_windows[1]) 603 GetRootWindowController(root_windows[1])
604 ->GetContainer(kShellWindowId_DefaultContainer); 604 ->GetContainer(kShellWindowId_DefaultContainer);
605 default_container->AddChild(window_.get()); 605 default_container->AddChild(window_.get());
606 window_->SetBoundsInScreen( 606 window_->SetBoundsInScreen(
607 gfx::Rect(600, 0, 50, 60), 607 gfx::Rect(600, 0, 50, 60),
608 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1])); 608 gfx::Screen::GetScreen()->GetDisplayNearestWindow(root_windows[1]));
609 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 609 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
610 // Grab (0, 0) of the window. 610 // Grab (0, 0) of the window.
611 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 611 std::unique_ptr<WindowResizer> resizer(
612 window_.get(), gfx::Point(), HTCAPTION)); 612 CreateDragWindowResizer(window_.get(), gfx::Point(), HTCAPTION));
613 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 613 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
614 ASSERT_TRUE(resizer.get()); 614 ASSERT_TRUE(resizer.get());
615 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0); 615 resizer->Drag(CalculateDragPoint(*resizer, -200, 200), 0);
616 TestIfMouseWarpsAt(gfx::Point(400, 200)); 616 TestIfMouseWarpsAt(gfx::Point(400, 200));
617 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 617 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
618 resizer->CompleteDrag(); 618 resizer->CompleteDrag();
619 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 619 EXPECT_EQ(1.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
620 } 620 }
621 } 621 }
622 622
623 // Verifies several kinds of windows can be moved across displays. 623 // Verifies several kinds of windows can be moved across displays.
624 TEST_F(DragWindowResizerTest, MoveWindowAcrossDisplays) { 624 TEST_F(DragWindowResizerTest, MoveWindowAcrossDisplays) {
625 if (!SupportsMultipleDisplays()) 625 if (!SupportsMultipleDisplays())
626 return; 626 return;
627 627
628 // The secondary display is logically on the right, but on the system (e.g. X) 628 // The secondary display is logically on the right, but on the system (e.g. X)
629 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc. 629 // layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
630 UpdateDisplay("400x400,400x400"); 630 UpdateDisplay("400x400,400x400");
631 631
632 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 632 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
633 ASSERT_EQ(2U, root_windows.size()); 633 ASSERT_EQ(2U, root_windows.size());
634 634
635 // Normal window can be moved across display. 635 // Normal window can be moved across display.
636 { 636 {
637 aura::Window* window = window_.get(); 637 aura::Window* window = window_.get();
638 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 638 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
639 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 639 gfx::Screen::GetScreen()->GetPrimaryDisplay());
640 // Grab (0, 0) of the window. 640 // Grab (0, 0) of the window.
641 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 641 std::unique_ptr<WindowResizer> resizer(
642 window, gfx::Point(), HTCAPTION)); 642 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION));
643 ASSERT_TRUE(resizer.get()); 643 ASSERT_TRUE(resizer.get());
644 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 644 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
645 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 645 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
646 EXPECT_EQ("401,200", 646 EXPECT_EQ("401,200",
647 aura::Env::GetInstance()->last_mouse_location().ToString()); 647 aura::Env::GetInstance()->last_mouse_location().ToString());
648 resizer->CompleteDrag(); 648 resizer->CompleteDrag();
649 } 649 }
650 650
651 // Always on top window can be moved across display. 651 // Always on top window can be moved across display.
652 { 652 {
653 aura::Window* window = always_on_top_window_.get(); 653 aura::Window* window = always_on_top_window_.get();
654 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 654 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
655 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 655 gfx::Screen::GetScreen()->GetPrimaryDisplay());
656 // Grab (0, 0) of the window. 656 // Grab (0, 0) of the window.
657 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 657 std::unique_ptr<WindowResizer> resizer(
658 window, gfx::Point(), HTCAPTION)); 658 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION));
659 ASSERT_TRUE(resizer.get()); 659 ASSERT_TRUE(resizer.get());
660 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 660 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
661 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 661 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
662 EXPECT_EQ("401,200", 662 EXPECT_EQ("401,200",
663 aura::Env::GetInstance()->last_mouse_location().ToString()); 663 aura::Env::GetInstance()->last_mouse_location().ToString());
664 resizer->CompleteDrag(); 664 resizer->CompleteDrag();
665 } 665 }
666 666
667 // System modal window can be moved across display. 667 // System modal window can be moved across display.
668 { 668 {
669 aura::Window* window = system_modal_window_.get(); 669 aura::Window* window = system_modal_window_.get();
670 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 670 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
671 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 671 gfx::Screen::GetScreen()->GetPrimaryDisplay());
672 aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(0, 0)); 672 aura::Env::GetInstance()->set_last_mouse_location(gfx::Point(0, 0));
673 // Grab (0, 0) of the window. 673 // Grab (0, 0) of the window.
674 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 674 std::unique_ptr<WindowResizer> resizer(
675 window, gfx::Point(), HTCAPTION)); 675 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION));
676 ASSERT_TRUE(resizer.get()); 676 ASSERT_TRUE(resizer.get());
677 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 677 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
678 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 678 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
679 EXPECT_EQ("401,200", 679 EXPECT_EQ("401,200",
680 aura::Env::GetInstance()->last_mouse_location().ToString()); 680 aura::Env::GetInstance()->last_mouse_location().ToString());
681 resizer->CompleteDrag(); 681 resizer->CompleteDrag();
682 } 682 }
683 683
684 // Transient window cannot be moved across display. 684 // Transient window cannot be moved across display.
685 { 685 {
686 aura::Window* window = transient_child_; 686 aura::Window* window = transient_child_;
687 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 687 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
688 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 688 gfx::Screen::GetScreen()->GetPrimaryDisplay());
689 // Grab (0, 0) of the window. 689 // Grab (0, 0) of the window.
690 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 690 std::unique_ptr<WindowResizer> resizer(
691 window, gfx::Point(), HTCAPTION)); 691 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION));
692 ASSERT_TRUE(resizer.get()); 692 ASSERT_TRUE(resizer.get());
693 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 693 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
694 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 694 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
695 EXPECT_EQ("399,200", 695 EXPECT_EQ("399,200",
696 aura::Env::GetInstance()->last_mouse_location().ToString()); 696 aura::Env::GetInstance()->last_mouse_location().ToString());
697 resizer->CompleteDrag(); 697 resizer->CompleteDrag();
698 } 698 }
699 699
700 // The parent of transient window can be moved across display. 700 // The parent of transient window can be moved across display.
701 { 701 {
702 aura::Window* window = transient_parent_.get(); 702 aura::Window* window = transient_parent_.get();
703 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 703 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
704 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 704 gfx::Screen::GetScreen()->GetPrimaryDisplay());
705 // Grab (0, 0) of the window. 705 // Grab (0, 0) of the window.
706 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 706 std::unique_ptr<WindowResizer> resizer(
707 window, gfx::Point(), HTCAPTION)); 707 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION));
708 ASSERT_TRUE(resizer.get()); 708 ASSERT_TRUE(resizer.get());
709 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 709 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
710 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 710 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
711 EXPECT_EQ("401,200", 711 EXPECT_EQ("401,200",
712 aura::Env::GetInstance()->last_mouse_location().ToString()); 712 aura::Env::GetInstance()->last_mouse_location().ToString());
713 resizer->CompleteDrag(); 713 resizer->CompleteDrag();
714 } 714 }
715 715
716 // Panel window can be moved across display. 716 // Panel window can be moved across display.
717 { 717 {
718 aura::Window* window = panel_window_.get(); 718 aura::Window* window = panel_window_.get();
719 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60), 719 window->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
720 gfx::Screen::GetScreen()->GetPrimaryDisplay()); 720 gfx::Screen::GetScreen()->GetPrimaryDisplay());
721 // Grab (0, 0) of the window. 721 // Grab (0, 0) of the window.
722 scoped_ptr<WindowResizer> resizer(CreateDragWindowResizer( 722 std::unique_ptr<WindowResizer> resizer(
723 window, gfx::Point(), HTCAPTION)); 723 CreateDragWindowResizer(window, gfx::Point(), HTCAPTION));
724 ASSERT_TRUE(resizer.get()); 724 ASSERT_TRUE(resizer.get());
725 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0); 725 resizer->Drag(CalculateDragPoint(*resizer, 399, 200), 0);
726 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200))); 726 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(399, 200)));
727 EXPECT_EQ("401,200", 727 EXPECT_EQ("401,200",
728 aura::Env::GetInstance()->last_mouse_location().ToString()); 728 aura::Env::GetInstance()->last_mouse_location().ToString());
729 resizer->CompleteDrag(); 729 resizer->CompleteDrag();
730 } 730 }
731 } 731 }
732 732
733 } // namespace ash 733 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/drag_window_resizer.h ('k') | ash/wm/gestures/long_press_affordance_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698