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

Side by Side Diff: ash/wm/workspace/workspace_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/workspace/workspace_window_resizer.cc ('k') | ash/wm/workspace_controller.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/workspace/workspace_window_resizer.h" 5 #include "ash/wm/workspace/workspace_window_resizer.h"
6 6
7 #include "ash/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 touch_resize_delegate_.set_window_component(window_component); 187 touch_resize_delegate_.set_window_component(window_component);
188 touch_resize_window_.reset( 188 touch_resize_window_.reset(
189 CreateTestWindowInShellWithDelegate(&touch_resize_delegate_, 0, 189 CreateTestWindowInShellWithDelegate(&touch_resize_delegate_, 0,
190 bounds)); 190 bounds));
191 } 191 }
192 192
193 TestWindowDelegate delegate_; 193 TestWindowDelegate delegate_;
194 TestWindowDelegate delegate2_; 194 TestWindowDelegate delegate2_;
195 TestWindowDelegate delegate3_; 195 TestWindowDelegate delegate3_;
196 TestWindowDelegate delegate4_; 196 TestWindowDelegate delegate4_;
197 scoped_ptr<aura::Window> window_; 197 std::unique_ptr<aura::Window> window_;
198 scoped_ptr<aura::Window> window2_; 198 std::unique_ptr<aura::Window> window2_;
199 scoped_ptr<aura::Window> window3_; 199 std::unique_ptr<aura::Window> window3_;
200 scoped_ptr<aura::Window> window4_; 200 std::unique_ptr<aura::Window> window4_;
201 201
202 TestWindowDelegate touch_resize_delegate_; 202 TestWindowDelegate touch_resize_delegate_;
203 scoped_ptr<aura::Window> touch_resize_window_; 203 std::unique_ptr<aura::Window> touch_resize_window_;
204 WorkspaceWindowResizer* workspace_resizer_; 204 WorkspaceWindowResizer* workspace_resizer_;
205 205
206 private: 206 private:
207 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTest); 207 DISALLOW_COPY_AND_ASSIGN(WorkspaceWindowResizerTest);
208 }; 208 };
209 209
210 // Assertions around attached window resize dragging from the right with 2 210 // Assertions around attached window resize dragging from the right with 2
211 // windows. 211 // windows.
212 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) { 212 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) {
213 window_->SetBounds(gfx::Rect(0, 300, 400, 300)); 213 window_->SetBounds(gfx::Rect(0, 300, 400, 300));
214 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); 214 window2_->SetBounds(gfx::Rect(400, 200, 100, 200));
215 215
216 std::vector<aura::Window*> windows; 216 std::vector<aura::Window*> windows;
217 windows.push_back(window2_.get()); 217 windows.push_back(window2_.get());
218 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 218 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
219 window_.get(), gfx::Point(), HTRIGHT, 219 window_.get(), gfx::Point(), HTRIGHT,
220 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 220 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
221 ASSERT_TRUE(resizer.get()); 221 ASSERT_TRUE(resizer.get());
222 // Move it 100 to the right, which should expand w1 and push w2. 222 // Move it 100 to the right, which should expand w1 and push w2.
223 resizer->Drag(CalculateDragPoint(*resizer, 100, 10), 0); 223 resizer->Drag(CalculateDragPoint(*resizer, 100, 10), 0);
224 EXPECT_EQ("0,300 500x300", window_->bounds().ToString()); 224 EXPECT_EQ("0,300 500x300", window_->bounds().ToString());
225 EXPECT_EQ("500,200 100x200", window2_->bounds().ToString()); 225 EXPECT_EQ("500,200 100x200", window2_->bounds().ToString());
226 226
227 // Push off the screen, w2 should be resized to its min. 227 // Push off the screen, w2 should be resized to its min.
228 delegate2_.set_min_size(gfx::Size(20, 20)); 228 delegate2_.set_min_size(gfx::Size(20, 20));
(...skipping 13 matching lines...) Expand all
242 EXPECT_EQ("400,200 100x200", window2_->bounds().ToString()); 242 EXPECT_EQ("400,200 100x200", window2_->bounds().ToString());
243 } 243 }
244 244
245 // Assertions around collapsing and expanding. 245 // Assertions around collapsing and expanding.
246 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_Compress) { 246 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_Compress) {
247 window_->SetBounds(gfx::Rect( 0, 300, 400, 300)); 247 window_->SetBounds(gfx::Rect( 0, 300, 400, 300));
248 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); 248 window2_->SetBounds(gfx::Rect(400, 200, 100, 200));
249 249
250 std::vector<aura::Window*> windows; 250 std::vector<aura::Window*> windows;
251 windows.push_back(window2_.get()); 251 windows.push_back(window2_.get());
252 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 252 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
253 window_.get(), gfx::Point(), HTRIGHT, 253 window_.get(), gfx::Point(), HTRIGHT,
254 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 254 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
255 ASSERT_TRUE(resizer.get()); 255 ASSERT_TRUE(resizer.get());
256 // Move it 100 to the left, which should expand w2 and collapse w1. 256 // Move it 100 to the left, which should expand w2 and collapse w1.
257 resizer->Drag(CalculateDragPoint(*resizer, -100, 10), 0); 257 resizer->Drag(CalculateDragPoint(*resizer, -100, 10), 0);
258 EXPECT_EQ("0,300 300x300", window_->bounds().ToString()); 258 EXPECT_EQ("0,300 300x300", window_->bounds().ToString());
259 EXPECT_EQ("300,200 200x200", window2_->bounds().ToString()); 259 EXPECT_EQ("300,200 200x200", window2_->bounds().ToString());
260 260
261 // Collapse all the way to w1's min. 261 // Collapse all the way to w1's min.
262 delegate_.set_min_size(gfx::Size(25, 25)); 262 delegate_.set_min_size(gfx::Size(25, 25));
(...skipping 22 matching lines...) Expand all
285 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3) { 285 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3) {
286 window_->SetBounds(gfx::Rect( 100, 300, 200, 300)); 286 window_->SetBounds(gfx::Rect( 100, 300, 200, 300));
287 window2_->SetBounds(gfx::Rect(300, 300, 150, 200)); 287 window2_->SetBounds(gfx::Rect(300, 300, 150, 200));
288 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); 288 window3_->SetBounds(gfx::Rect(450, 300, 100, 200));
289 delegate2_.set_min_size(gfx::Size(52, 50)); 289 delegate2_.set_min_size(gfx::Size(52, 50));
290 delegate3_.set_min_size(gfx::Size(38, 50)); 290 delegate3_.set_min_size(gfx::Size(38, 50));
291 291
292 std::vector<aura::Window*> windows; 292 std::vector<aura::Window*> windows;
293 windows.push_back(window2_.get()); 293 windows.push_back(window2_.get());
294 windows.push_back(window3_.get()); 294 windows.push_back(window3_.get());
295 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 295 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
296 window_.get(), gfx::Point(), HTRIGHT, 296 window_.get(), gfx::Point(), HTRIGHT,
297 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 297 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
298 ASSERT_TRUE(resizer.get()); 298 ASSERT_TRUE(resizer.get());
299 // Move it 100 to the right, which should expand w1 and push w2 and w3. 299 // Move it 100 to the right, which should expand w1 and push w2 and w3.
300 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); 300 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0);
301 EXPECT_EQ("100,300 300x300", window_->bounds().ToString()); 301 EXPECT_EQ("100,300 300x300", window_->bounds().ToString());
302 EXPECT_EQ("400,300 150x200", window2_->bounds().ToString()); 302 EXPECT_EQ("400,300 150x200", window2_->bounds().ToString());
303 EXPECT_EQ("550,300 100x200", window3_->bounds().ToString()); 303 EXPECT_EQ("550,300 100x200", window3_->bounds().ToString());
304 304
305 // Move it 300, things should compress. 305 // Move it 300, things should compress.
(...skipping 20 matching lines...) Expand all
326 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3_Compress) { 326 TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_3_Compress) {
327 window_->SetBounds(gfx::Rect( 100, 300, 200, 300)); 327 window_->SetBounds(gfx::Rect( 100, 300, 200, 300));
328 window2_->SetBounds(gfx::Rect(300, 300, 200, 200)); 328 window2_->SetBounds(gfx::Rect(300, 300, 200, 200));
329 window3_->SetBounds(gfx::Rect(450, 300, 100, 200)); 329 window3_->SetBounds(gfx::Rect(450, 300, 100, 200));
330 delegate2_.set_min_size(gfx::Size(52, 50)); 330 delegate2_.set_min_size(gfx::Size(52, 50));
331 delegate3_.set_min_size(gfx::Size(38, 50)); 331 delegate3_.set_min_size(gfx::Size(38, 50));
332 332
333 std::vector<aura::Window*> windows; 333 std::vector<aura::Window*> windows;
334 windows.push_back(window2_.get()); 334 windows.push_back(window2_.get());
335 windows.push_back(window3_.get()); 335 windows.push_back(window3_.get());
336 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 336 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
337 window_.get(), gfx::Point(), HTRIGHT, 337 window_.get(), gfx::Point(), HTRIGHT,
338 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 338 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
339 ASSERT_TRUE(resizer.get()); 339 ASSERT_TRUE(resizer.get());
340 // Move it -100 to the right, which should collapse w1 and expand w2 and w3. 340 // Move it -100 to the right, which should collapse w1 and expand w2 and w3.
341 resizer->Drag(CalculateDragPoint(*resizer, -100, -10), 0); 341 resizer->Drag(CalculateDragPoint(*resizer, -100, -10), 0);
342 EXPECT_EQ("100,300 100x300", window_->bounds().ToString()); 342 EXPECT_EQ("100,300 100x300", window_->bounds().ToString());
343 EXPECT_EQ("200,300 266x200", window2_->bounds().ToString()); 343 EXPECT_EQ("200,300 266x200", window2_->bounds().ToString());
344 EXPECT_EQ("466,300 134x200", window3_->bounds().ToString()); 344 EXPECT_EQ("466,300 134x200", window3_->bounds().ToString());
345 345
346 // Move it 100 to the right. 346 // Move it 100 to the right.
347 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); 347 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0);
348 EXPECT_EQ("100,300 300x300", window_->bounds().ToString()); 348 EXPECT_EQ("100,300 300x300", window_->bounds().ToString());
349 EXPECT_EQ("400,300 200x200", window2_->bounds().ToString()); 349 EXPECT_EQ("400,300 200x200", window2_->bounds().ToString());
350 EXPECT_EQ("600,300 100x200", window3_->bounds().ToString()); 350 EXPECT_EQ("600,300 100x200", window3_->bounds().ToString());
351 351
352 // 100 to the left again. 352 // 100 to the left again.
353 resizer->Drag(CalculateDragPoint(*resizer, -100, -10), 0); 353 resizer->Drag(CalculateDragPoint(*resizer, -100, -10), 0);
354 EXPECT_EQ("100,300 100x300", window_->bounds().ToString()); 354 EXPECT_EQ("100,300 100x300", window_->bounds().ToString());
355 EXPECT_EQ("200,300 266x200", window2_->bounds().ToString()); 355 EXPECT_EQ("200,300 266x200", window2_->bounds().ToString());
356 EXPECT_EQ("466,300 134x200", window3_->bounds().ToString()); 356 EXPECT_EQ("466,300 134x200", window3_->bounds().ToString());
357 } 357 }
358 358
359 // Assertions around collapsing and expanding from the bottom. 359 // Assertions around collapsing and expanding from the bottom.
360 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_Compress) { 360 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_Compress) {
361 window_->SetBounds(gfx::Rect( 0, 100, 400, 300)); 361 window_->SetBounds(gfx::Rect( 0, 100, 400, 300));
362 window2_->SetBounds(gfx::Rect(400, 400, 100, 200)); 362 window2_->SetBounds(gfx::Rect(400, 400, 100, 200));
363 363
364 std::vector<aura::Window*> windows; 364 std::vector<aura::Window*> windows;
365 windows.push_back(window2_.get()); 365 windows.push_back(window2_.get());
366 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 366 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
367 window_.get(), gfx::Point(), HTBOTTOM, 367 window_.get(), gfx::Point(), HTBOTTOM,
368 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 368 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
369 ASSERT_TRUE(resizer.get()); 369 ASSERT_TRUE(resizer.get());
370 // Move it up 100, which should expand w2 and collapse w1. 370 // Move it up 100, which should expand w2 and collapse w1.
371 resizer->Drag(CalculateDragPoint(*resizer, 10, -100), 0); 371 resizer->Drag(CalculateDragPoint(*resizer, 10, -100), 0);
372 EXPECT_EQ("0,100 400x200", window_->bounds().ToString()); 372 EXPECT_EQ("0,100 400x200", window_->bounds().ToString());
373 EXPECT_EQ("400,300 100x300", window2_->bounds().ToString()); 373 EXPECT_EQ("400,300 100x300", window2_->bounds().ToString());
374 374
375 // Collapse all the way to w1's min. 375 // Collapse all the way to w1's min.
376 delegate_.set_min_size(gfx::Size(20, 20)); 376 delegate_.set_min_size(gfx::Size(20, 20));
(...skipping 13 matching lines...) Expand all
390 } 390 }
391 391
392 // Assertions around attached window resize dragging from the bottom with 2 392 // Assertions around attached window resize dragging from the bottom with 2
393 // windows. 393 // windows.
394 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2) { 394 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2) {
395 window_->SetBounds(gfx::Rect( 0, 50, 400, 200)); 395 window_->SetBounds(gfx::Rect( 0, 50, 400, 200));
396 window2_->SetBounds(gfx::Rect(0, 250, 200, 100)); 396 window2_->SetBounds(gfx::Rect(0, 250, 200, 100));
397 397
398 std::vector<aura::Window*> windows; 398 std::vector<aura::Window*> windows;
399 windows.push_back(window2_.get()); 399 windows.push_back(window2_.get());
400 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 400 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
401 window_.get(), gfx::Point(), HTBOTTOM, 401 window_.get(), gfx::Point(), HTBOTTOM,
402 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 402 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
403 ASSERT_TRUE(resizer.get()); 403 ASSERT_TRUE(resizer.get());
404 // Move it 100 to the bottom, which should expand w1 and push w2. 404 // Move it 100 to the bottom, which should expand w1 and push w2.
405 resizer->Drag(CalculateDragPoint(*resizer, 10, 100), 0); 405 resizer->Drag(CalculateDragPoint(*resizer, 10, 100), 0);
406 EXPECT_EQ("0,50 400x300", window_->bounds().ToString()); 406 EXPECT_EQ("0,50 400x300", window_->bounds().ToString());
407 EXPECT_EQ("0,350 200x100", window2_->bounds().ToString()); 407 EXPECT_EQ("0,350 200x100", window2_->bounds().ToString());
408 408
409 // Push off the screen, w2 should be resized to its min. 409 // Push off the screen, w2 should be resized to its min.
410 delegate2_.set_min_size(gfx::Size(20, 20)); 410 delegate2_.set_min_size(gfx::Size(20, 20));
(...skipping 29 matching lines...) Expand all
440 440
441 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); 441 window_->SetBounds(gfx::Rect( 300, 100, 300, 200));
442 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); 442 window2_->SetBounds(gfx::Rect(300, 300, 200, 150));
443 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); 443 window3_->SetBounds(gfx::Rect(300, 450, 200, 100));
444 delegate2_.set_min_size(gfx::Size(50, 52)); 444 delegate2_.set_min_size(gfx::Size(50, 52));
445 delegate3_.set_min_size(gfx::Size(50, 38)); 445 delegate3_.set_min_size(gfx::Size(50, 38));
446 446
447 std::vector<aura::Window*> windows; 447 std::vector<aura::Window*> windows;
448 windows.push_back(window2_.get()); 448 windows.push_back(window2_.get());
449 windows.push_back(window3_.get()); 449 windows.push_back(window3_.get());
450 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 450 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
451 window_.get(), gfx::Point(), HTBOTTOM, 451 window_.get(), gfx::Point(), HTBOTTOM,
452 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 452 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
453 ASSERT_TRUE(resizer.get()); 453 ASSERT_TRUE(resizer.get());
454 // Move it 100 down, which should expand w1 and push w2 and w3. 454 // Move it 100 down, which should expand w1 and push w2 and w3.
455 resizer->Drag(CalculateDragPoint(*resizer, -10, 100), 0); 455 resizer->Drag(CalculateDragPoint(*resizer, -10, 100), 0);
456 EXPECT_EQ("300,100 300x300", window_->bounds().ToString()); 456 EXPECT_EQ("300,100 300x300", window_->bounds().ToString());
457 EXPECT_EQ("300,400 200x150", window2_->bounds().ToString()); 457 EXPECT_EQ("300,400 200x150", window2_->bounds().ToString());
458 EXPECT_EQ("300,550 200x100", window3_->bounds().ToString()); 458 EXPECT_EQ("300,550 200x100", window3_->bounds().ToString());
459 459
460 // Move it 296 things should compress. 460 // Move it 296 things should compress.
(...skipping 20 matching lines...) Expand all
481 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3_Compress) { 481 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3_Compress) {
482 window_->SetBounds(gfx::Rect( 0, 0, 200, 200)); 482 window_->SetBounds(gfx::Rect( 0, 0, 200, 200));
483 window2_->SetBounds(gfx::Rect(10, 200, 200, 200)); 483 window2_->SetBounds(gfx::Rect(10, 200, 200, 200));
484 window3_->SetBounds(gfx::Rect(20, 400, 100, 100)); 484 window3_->SetBounds(gfx::Rect(20, 400, 100, 100));
485 delegate2_.set_min_size(gfx::Size(52, 50)); 485 delegate2_.set_min_size(gfx::Size(52, 50));
486 delegate3_.set_min_size(gfx::Size(38, 50)); 486 delegate3_.set_min_size(gfx::Size(38, 50));
487 487
488 std::vector<aura::Window*> windows; 488 std::vector<aura::Window*> windows;
489 windows.push_back(window2_.get()); 489 windows.push_back(window2_.get());
490 windows.push_back(window3_.get()); 490 windows.push_back(window3_.get());
491 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 491 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
492 window_.get(), gfx::Point(), HTBOTTOM, 492 window_.get(), gfx::Point(), HTBOTTOM,
493 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 493 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
494 ASSERT_TRUE(resizer.get()); 494 ASSERT_TRUE(resizer.get());
495 // Move it 100 up, which should collapse w1 and expand w2 and w3. 495 // Move it 100 up, which should collapse w1 and expand w2 and w3.
496 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0); 496 resizer->Drag(CalculateDragPoint(*resizer, -10, -100), 0);
497 EXPECT_EQ("0,0 200x100", window_->bounds().ToString()); 497 EXPECT_EQ("0,0 200x100", window_->bounds().ToString());
498 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString()); 498 EXPECT_EQ("10,100 200x266", window2_->bounds().ToString());
499 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString()); 499 EXPECT_EQ("20,366 100x134", window3_->bounds().ToString());
500 500
501 // Move it 100 down. 501 // Move it 100 down.
(...skipping 16 matching lines...) Expand all
518 window2_->SetBounds(gfx::Rect(400, 200, 100, 200)); 518 window2_->SetBounds(gfx::Rect(400, 200, 100, 200));
519 519
520 Shell* shell = Shell::GetInstance(); 520 Shell* shell = Shell::GetInstance();
521 ui::test::EventGenerator generator(window_->GetRootWindow()); 521 ui::test::EventGenerator generator(window_->GetRootWindow());
522 522
523 // The cursor should not be locked initially. 523 // The cursor should not be locked initially.
524 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked()); 524 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked());
525 525
526 std::vector<aura::Window*> windows; 526 std::vector<aura::Window*> windows;
527 windows.push_back(window2_.get()); 527 windows.push_back(window2_.get());
528 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 528 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
529 window_.get(), gfx::Point(), HTRIGHT, 529 window_.get(), gfx::Point(), HTRIGHT,
530 aura::client::WINDOW_MOVE_SOURCE_TOUCH, windows)); 530 aura::client::WINDOW_MOVE_SOURCE_TOUCH, windows));
531 ASSERT_TRUE(resizer.get()); 531 ASSERT_TRUE(resizer.get());
532 532
533 // Creating a WorkspaceWindowResizer should not lock the cursor. 533 // Creating a WorkspaceWindowResizer should not lock the cursor.
534 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked()); 534 EXPECT_FALSE(shell->cursor_manager()->IsCursorLocked());
535 535
536 // The cursor should be hidden after touching the screen and 536 // The cursor should be hidden after touching the screen and
537 // starting a drag. 537 // starting a drag.
538 EXPECT_TRUE(shell->cursor_manager()->IsCursorVisible()); 538 EXPECT_TRUE(shell->cursor_manager()->IsCursorVisible());
(...skipping 21 matching lines...) Expand all
560 // http://crbug.com/292238. 560 // http://crbug.com/292238.
561 // Window is wide enough not to get docked right away. 561 // Window is wide enough not to get docked right away.
562 window_->SetBounds(gfx::Rect(20, 30, 400, 60)); 562 window_->SetBounds(gfx::Rect(20, 30, 400, 60));
563 window_->SetProperty(aura::client::kCanMaximizeKey, true); 563 window_->SetProperty(aura::client::kCanMaximizeKey, true);
564 wm::WindowState* window_state = wm::GetWindowState(window_.get()); 564 wm::WindowState* window_state = wm::GetWindowState(window_.get());
565 565
566 { 566 {
567 gfx::Rect expected_bounds_in_parent( 567 gfx::Rect expected_bounds_in_parent(
568 wm::GetDefaultLeftSnappedWindowBoundsInParent(window_.get())); 568 wm::GetDefaultLeftSnappedWindowBoundsInParent(window_.get()));
569 569
570 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 570 std::unique_ptr<WindowResizer> resizer(
571 window_.get(), gfx::Point(), HTCAPTION)); 571 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
572 ASSERT_TRUE(resizer.get()); 572 ASSERT_TRUE(resizer.get());
573 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0); 573 resizer->Drag(CalculateDragPoint(*resizer, 0, 10), 0);
574 resizer->CompleteDrag(); 574 resizer->CompleteDrag();
575 575
576 EXPECT_EQ(expected_bounds_in_parent.ToString(), 576 EXPECT_EQ(expected_bounds_in_parent.ToString(),
577 window_->bounds().ToString()); 577 window_->bounds().ToString());
578 ASSERT_TRUE(window_state->HasRestoreBounds()); 578 ASSERT_TRUE(window_state->HasRestoreBounds());
579 EXPECT_EQ("20,30 400x60", 579 EXPECT_EQ("20,30 400x60",
580 window_state->GetRestoreBoundsInScreen().ToString()); 580 window_state->GetRestoreBoundsInScreen().ToString());
581 } 581 }
582 // Try the same with the right side. 582 // Try the same with the right side.
583 { 583 {
584 gfx::Rect expected_bounds_in_parent( 584 gfx::Rect expected_bounds_in_parent(
585 wm::GetDefaultRightSnappedWindowBoundsInParent(window_.get())); 585 wm::GetDefaultRightSnappedWindowBoundsInParent(window_.get()));
586 586
587 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 587 std::unique_ptr<WindowResizer> resizer(
588 window_.get(), gfx::Point(), HTCAPTION)); 588 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
589 ASSERT_TRUE(resizer.get()); 589 ASSERT_TRUE(resizer.get());
590 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0); 590 resizer->Drag(CalculateDragPoint(*resizer, 800, 10), 0);
591 resizer->CompleteDrag(); 591 resizer->CompleteDrag();
592 EXPECT_EQ(expected_bounds_in_parent.ToString(), 592 EXPECT_EQ(expected_bounds_in_parent.ToString(),
593 window_->bounds().ToString()); 593 window_->bounds().ToString());
594 ASSERT_TRUE(window_state->HasRestoreBounds()); 594 ASSERT_TRUE(window_state->HasRestoreBounds());
595 EXPECT_EQ("20,30 400x60", 595 EXPECT_EQ("20,30 400x60",
596 window_state->GetRestoreBoundsInScreen().ToString()); 596 window_state->GetRestoreBoundsInScreen().ToString());
597 } 597 }
598 598
599 // Test if the restore bounds is correct in multiple displays. 599 // Test if the restore bounds is correct in multiple displays.
600 if (!SupportsMultipleDisplays()) 600 if (!SupportsMultipleDisplays())
601 return; 601 return;
602 602
603 // Restore the window to clear snapped state. 603 // Restore the window to clear snapped state.
604 window_state->Restore(); 604 window_state->Restore();
605 605
606 UpdateDisplay("800x600,500x600"); 606 UpdateDisplay("800x600,500x600");
607 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 607 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
608 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 608 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
609 // Window is wide enough not to get docked right away. 609 // Window is wide enough not to get docked right away.
610 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), 610 window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60),
611 ScreenUtil::GetSecondaryDisplay()); 611 ScreenUtil::GetSecondaryDisplay());
612 EXPECT_EQ(root_windows[1], window_->GetRootWindow()); 612 EXPECT_EQ(root_windows[1], window_->GetRootWindow());
613 { 613 {
614 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); 614 EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString());
615 615
616 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 616 std::unique_ptr<WindowResizer> resizer(
617 window_.get(), gfx::Point(), HTCAPTION)); 617 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
618 ASSERT_TRUE(resizer.get()); 618 ASSERT_TRUE(resizer.get());
619 resizer->Drag(CalculateDragPoint(*resizer, 499, 0), 0); 619 resizer->Drag(CalculateDragPoint(*resizer, 499, 0), 0);
620 int bottom = 620 int bottom =
621 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); 621 ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom();
622 resizer->CompleteDrag(); 622 resizer->CompleteDrag();
623 // With the resolution of 500x600 we will hit in this case the 50% screen 623 // With the resolution of 500x600 we will hit in this case the 50% screen
624 // size setting. 624 // size setting.
625 // TODO(varkha): Insets are updated because of http://crbug.com/292238 625 // TODO(varkha): Insets are updated because of http://crbug.com/292238
626 EXPECT_EQ("250,0 250x" + base::IntToString(bottom), 626 EXPECT_EQ("250,0 250x" + base::IntToString(bottom),
627 window_->bounds().ToString()); 627 window_->bounds().ToString());
628 EXPECT_EQ("800,10 400x60", 628 EXPECT_EQ("800,10 400x60",
629 window_state->GetRestoreBoundsInScreen().ToString()); 629 window_state->GetRestoreBoundsInScreen().ToString());
630 } 630 }
631 } 631 }
632 632
633 // Check that non resizable windows will not get resized. 633 // Check that non resizable windows will not get resized.
634 TEST_F(WorkspaceWindowResizerTest, NonResizableWindows) { 634 TEST_F(WorkspaceWindowResizerTest, NonResizableWindows) {
635 window_->SetBounds(gfx::Rect(20, 30, 50, 60)); 635 window_->SetBounds(gfx::Rect(20, 30, 50, 60));
636 window_->SetProperty(aura::client::kCanResizeKey, false); 636 window_->SetProperty(aura::client::kCanResizeKey, false);
637 637
638 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 638 std::unique_ptr<WindowResizer> resizer(
639 window_.get(), gfx::Point(), HTCAPTION)); 639 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
640 ASSERT_TRUE(resizer.get()); 640 ASSERT_TRUE(resizer.get());
641 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0); 641 resizer->Drag(CalculateDragPoint(*resizer, -20, 0), 0);
642 resizer->CompleteDrag(); 642 resizer->CompleteDrag();
643 EXPECT_EQ("0,30 50x60", window_->bounds().ToString()); 643 EXPECT_EQ("0,30 50x60", window_->bounds().ToString());
644 } 644 }
645 645
646 TEST_F(WorkspaceWindowResizerTest, CancelSnapPhantom) { 646 TEST_F(WorkspaceWindowResizerTest, CancelSnapPhantom) {
647 if (!SupportsMultipleDisplays()) 647 if (!SupportsMultipleDisplays())
648 return; 648 return;
649 649
650 UpdateDisplay("800x600,800x600"); 650 UpdateDisplay("800x600,800x600");
651 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 651 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
652 ASSERT_EQ(2U, root_windows.size()); 652 ASSERT_EQ(2U, root_windows.size());
653 653
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 EXPECT_EQ(root_windows[0], window_->GetRootWindow()); 656 EXPECT_EQ(root_windows[0], window_->GetRootWindow());
657 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity()); 657 EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
658 { 658 {
659 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 659 std::unique_ptr<WindowResizer> resizer(
660 window_.get(), gfx::Point(), HTCAPTION)); 660 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
661 ASSERT_TRUE(resizer.get()); 661 ASSERT_TRUE(resizer.get());
662 EXPECT_FALSE(snap_phantom_window_controller()); 662 EXPECT_FALSE(snap_phantom_window_controller());
663 663
664 // The pointer is on the edge but not shared. The snap phantom window 664 // The pointer is on the edge but not shared. The snap phantom window
665 // controller should be non-NULL. 665 // controller should be non-NULL.
666 resizer->Drag(CalculateDragPoint(*resizer, 799, 0), 0); 666 resizer->Drag(CalculateDragPoint(*resizer, 799, 0), 0);
667 EXPECT_TRUE(snap_phantom_window_controller()); 667 EXPECT_TRUE(snap_phantom_window_controller());
668 668
669 // Move the cursor across the edge. Now the snap phantom window controller 669 // Move the cursor across the edge. Now the snap phantom window controller
670 // should be canceled. 670 // should be canceled.
(...skipping 11 matching lines...) Expand all
682 window_->Show(); 682 window_->Show();
683 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT); 683 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT);
684 window_state->OnWMEvent(&snap_event); 684 window_state->OnWMEvent(&snap_event);
685 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); 685 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType());
686 gfx::Rect snapped_bounds = window_->bounds(); 686 gfx::Rect snapped_bounds = window_->bounds();
687 EXPECT_NE(snapped_bounds.ToString(), kInitialBounds.ToString()); 687 EXPECT_NE(snapped_bounds.ToString(), kInitialBounds.ToString());
688 EXPECT_EQ(window_state->GetRestoreBoundsInParent().ToString(), 688 EXPECT_EQ(window_state->GetRestoreBoundsInParent().ToString(),
689 kInitialBounds.ToString()); 689 kInitialBounds.ToString());
690 690
691 // Dragging a side snapped window should unsnap it. 691 // Dragging a side snapped window should unsnap it.
692 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 692 std::unique_ptr<WindowResizer> resizer(
693 window_.get(), gfx::Point(), HTCAPTION)); 693 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
694 resizer->Drag(CalculateDragPoint(*resizer, 10, 0), 0); 694 resizer->Drag(CalculateDragPoint(*resizer, 10, 0), 0);
695 resizer->CompleteDrag(); 695 resizer->CompleteDrag();
696 EXPECT_EQ(wm::WINDOW_STATE_TYPE_NORMAL, window_state->GetStateType()); 696 EXPECT_EQ(wm::WINDOW_STATE_TYPE_NORMAL, window_state->GetStateType());
697 EXPECT_EQ("10,0 100x100", window_->bounds().ToString()); 697 EXPECT_EQ("10,0 100x100", window_->bounds().ToString());
698 EXPECT_FALSE(window_state->HasRestoreBounds()); 698 EXPECT_FALSE(window_state->HasRestoreBounds());
699 } 699 }
700 700
701 // Verifies the behavior of resizing a side snapped window. 701 // Verifies the behavior of resizing a side snapped window.
702 TEST_F(WorkspaceWindowResizerTest, ResizeSnapped) { 702 TEST_F(WorkspaceWindowResizerTest, ResizeSnapped) {
703 wm::WindowState* window_state = ash::wm::GetWindowState(window_.get()); 703 wm::WindowState* window_state = ash::wm::GetWindowState(window_.get());
704 704
705 const gfx::Rect kInitialBounds(100, 100, 100, 100); 705 const gfx::Rect kInitialBounds(100, 100, 100, 100);
706 window_->SetBounds(kInitialBounds); 706 window_->SetBounds(kInitialBounds);
707 window_->Show(); 707 window_->Show();
708 708
709 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT); 709 const wm::WMEvent snap_event(wm::WM_EVENT_SNAP_LEFT);
710 window_state->OnWMEvent(&snap_event); 710 window_state->OnWMEvent(&snap_event);
711 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); 711 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType());
712 gfx::Rect snapped_bounds = window_->bounds(); 712 gfx::Rect snapped_bounds = window_->bounds();
713 EXPECT_NE(snapped_bounds.ToString(), kInitialBounds.ToString()); 713 EXPECT_NE(snapped_bounds.ToString(), kInitialBounds.ToString());
714 EXPECT_EQ(window_state->GetRestoreBoundsInParent().ToString(), 714 EXPECT_EQ(window_state->GetRestoreBoundsInParent().ToString(),
715 kInitialBounds.ToString()); 715 kInitialBounds.ToString());
716 716
717 { 717 {
718 // 1) Resizing a side snapped window to make it wider should not unsnap the 718 // 1) Resizing a side snapped window to make it wider should not unsnap the
719 // window. 719 // window.
720 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 720 std::unique_ptr<WindowResizer> resizer(
721 window_.get(), gfx::Point(), HTRIGHT)); 721 CreateResizerForTest(window_.get(), gfx::Point(), HTRIGHT));
722 resizer->Drag(CalculateDragPoint(*resizer, 10, 0), 0); 722 resizer->Drag(CalculateDragPoint(*resizer, 10, 0), 0);
723 resizer->CompleteDrag(); 723 resizer->CompleteDrag();
724 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); 724 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType());
725 snapped_bounds.Inset(0, 0, -10, 0); 725 snapped_bounds.Inset(0, 0, -10, 0);
726 EXPECT_EQ(snapped_bounds.ToString(), window_->bounds().ToString()); 726 EXPECT_EQ(snapped_bounds.ToString(), window_->bounds().ToString());
727 EXPECT_EQ(window_state->GetRestoreBoundsInParent().ToString(), 727 EXPECT_EQ(window_state->GetRestoreBoundsInParent().ToString(),
728 kInitialBounds.ToString()); 728 kInitialBounds.ToString());
729 } 729 }
730 730
731 { 731 {
732 // 2) Resizing a side snapped window vertically and then undoing the change 732 // 2) Resizing a side snapped window vertically and then undoing the change
733 // should not unsnap. 733 // should not unsnap.
734 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 734 std::unique_ptr<WindowResizer> resizer(
735 window_.get(), gfx::Point(), HTBOTTOM)); 735 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOM));
736 resizer->Drag(CalculateDragPoint(*resizer, 0, -30), 0); 736 resizer->Drag(CalculateDragPoint(*resizer, 0, -30), 0);
737 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 737 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
738 resizer->CompleteDrag(); 738 resizer->CompleteDrag();
739 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType()); 739 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED, window_state->GetStateType());
740 EXPECT_EQ(snapped_bounds.ToString(), window_->bounds().ToString()); 740 EXPECT_EQ(snapped_bounds.ToString(), window_->bounds().ToString());
741 EXPECT_EQ(window_state->GetRestoreBoundsInParent().ToString(), 741 EXPECT_EQ(window_state->GetRestoreBoundsInParent().ToString(),
742 kInitialBounds.ToString()); 742 kInitialBounds.ToString());
743 } 743 }
744 744
745 { 745 {
746 // 3) Resizing a side snapped window vertically and then not undoing the 746 // 3) Resizing a side snapped window vertically and then not undoing the
747 // change should unsnap. 747 // change should unsnap.
748 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 748 std::unique_ptr<WindowResizer> resizer(
749 window_.get(), gfx::Point(), HTBOTTOM)); 749 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOM));
750 resizer->Drag(CalculateDragPoint(*resizer, 0, -10), 0); 750 resizer->Drag(CalculateDragPoint(*resizer, 0, -10), 0);
751 resizer->CompleteDrag(); 751 resizer->CompleteDrag();
752 EXPECT_EQ(wm::WINDOW_STATE_TYPE_NORMAL, window_state->GetStateType()); 752 EXPECT_EQ(wm::WINDOW_STATE_TYPE_NORMAL, window_state->GetStateType());
753 gfx::Rect expected_bounds(snapped_bounds); 753 gfx::Rect expected_bounds(snapped_bounds);
754 expected_bounds.Inset(0, 0, 0, 10); 754 expected_bounds.Inset(0, 0, 0, 10);
755 EXPECT_EQ(expected_bounds.ToString(), window_->bounds().ToString()); 755 EXPECT_EQ(expected_bounds.ToString(), window_->bounds().ToString());
756 EXPECT_FALSE(window_state->HasRestoreBounds()); 756 EXPECT_FALSE(window_state->HasRestoreBounds());
757 } 757 }
758 } 758 }
759 759
760 // Verifies windows are correctly restacked when reordering multiple windows. 760 // Verifies windows are correctly restacked when reordering multiple windows.
761 TEST_F(WorkspaceWindowResizerTest, RestackAttached) { 761 TEST_F(WorkspaceWindowResizerTest, RestackAttached) {
762 window_->SetBounds(gfx::Rect( 0, 0, 200, 300)); 762 window_->SetBounds(gfx::Rect( 0, 0, 200, 300));
763 window2_->SetBounds(gfx::Rect(200, 0, 100, 200)); 763 window2_->SetBounds(gfx::Rect(200, 0, 100, 200));
764 window3_->SetBounds(gfx::Rect(300, 0, 100, 100)); 764 window3_->SetBounds(gfx::Rect(300, 0, 100, 100));
765 765
766 { 766 {
767 std::vector<aura::Window*> windows; 767 std::vector<aura::Window*> windows;
768 windows.push_back(window2_.get()); 768 windows.push_back(window2_.get());
769 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 769 std::unique_ptr<WorkspaceWindowResizer> resizer(
770 window_.get(), gfx::Point(), HTRIGHT, 770 CreateWorkspaceResizerForTest(window_.get(), gfx::Point(), HTRIGHT,
771 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 771 aura::client::WINDOW_MOVE_SOURCE_MOUSE,
772 windows));
772 ASSERT_TRUE(resizer.get()); 773 ASSERT_TRUE(resizer.get());
773 // Move it 100 to the right, which should expand w1 and push w2 and w3. 774 // Move it 100 to the right, which should expand w1 and push w2 and w3.
774 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); 775 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0);
775 776
776 // 2 should be topmost since it's initially the highest in the stack. 777 // 2 should be topmost since it's initially the highest in the stack.
777 EXPECT_EQ("2 1 3", WindowOrderAsString(window_->parent())); 778 EXPECT_EQ("2 1 3", WindowOrderAsString(window_->parent()));
778 } 779 }
779 780
780 { 781 {
781 std::vector<aura::Window*> windows; 782 std::vector<aura::Window*> windows;
782 windows.push_back(window3_.get()); 783 windows.push_back(window3_.get());
783 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 784 std::unique_ptr<WorkspaceWindowResizer> resizer(
784 window2_.get(), gfx::Point(), HTRIGHT, 785 CreateWorkspaceResizerForTest(window2_.get(), gfx::Point(), HTRIGHT,
785 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 786 aura::client::WINDOW_MOVE_SOURCE_MOUSE,
787 windows));
786 ASSERT_TRUE(resizer.get()); 788 ASSERT_TRUE(resizer.get());
787 // Move it 100 to the right, which should expand w1 and push w2 and w3. 789 // Move it 100 to the right, which should expand w1 and push w2 and w3.
788 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); 790 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0);
789 791
790 // 2 should be topmost since it's initially the highest in the stack. 792 // 2 should be topmost since it's initially the highest in the stack.
791 EXPECT_EQ("2 3 1", WindowOrderAsString(window_->parent())); 793 EXPECT_EQ("2 3 1", WindowOrderAsString(window_->parent()));
792 } 794 }
793 } 795 }
794 796
795 // Makes sure we don't allow dragging below the work area. 797 // Makes sure we don't allow dragging below the work area.
796 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) { 798 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) {
797 Shell::GetInstance()->SetDisplayWorkAreaInsets( 799 Shell::GetInstance()->SetDisplayWorkAreaInsets(
798 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); 800 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0));
799 801
800 ASSERT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); 802 ASSERT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays());
801 803
802 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); 804 window_->SetBounds(gfx::Rect(100, 200, 300, 400));
803 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 805 std::unique_ptr<WindowResizer> resizer(
804 window_.get(), gfx::Point(), HTCAPTION)); 806 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
805 ASSERT_TRUE(resizer.get()); 807 ASSERT_TRUE(resizer.get());
806 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); 808 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0);
807 int expected_y = 809 int expected_y =
808 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; 810 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10;
809 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", 811 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400",
810 window_->bounds().ToString()); 812 window_->bounds().ToString());
811 } 813 }
812 814
813 // Makes sure we don't allow dragging on the work area with multidisplay. 815 // Makes sure we don't allow dragging on the work area with multidisplay.
814 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) { 816 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottomWithMultiDisplay) {
815 if (!SupportsMultipleDisplays()) 817 if (!SupportsMultipleDisplays())
816 return; 818 return;
817 819
818 UpdateDisplay("800x600,800x600"); 820 UpdateDisplay("800x600,800x600");
819 ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); 821 ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays());
820 822
821 Shell::GetInstance()->SetDisplayWorkAreaInsets( 823 Shell::GetInstance()->SetDisplayWorkAreaInsets(
822 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); 824 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0));
823 825
824 // Positions the secondary display at the bottom the primary display. 826 // Positions the secondary display at the bottom the primary display.
825 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( 827 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
826 test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 0)); 828 test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 0));
827 829
828 { 830 {
829 window_->SetBounds(gfx::Rect(100, 200, 300, 20)); 831 window_->SetBounds(gfx::Rect(100, 200, 300, 20));
830 DCHECK_LT(window_->bounds().height(), 832 DCHECK_LT(window_->bounds().height(),
831 WorkspaceWindowResizer::kMinOnscreenHeight); 833 WorkspaceWindowResizer::kMinOnscreenHeight);
832 // Drag down avoiding dragging along the edge as that would side-snap. 834 // Drag down avoiding dragging along the edge as that would side-snap.
833 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 835 std::unique_ptr<WindowResizer> resizer(
834 window_.get(), gfx::Point(10, 0), HTCAPTION)); 836 CreateResizerForTest(window_.get(), gfx::Point(10, 0), HTCAPTION));
835 ASSERT_TRUE(resizer.get()); 837 ASSERT_TRUE(resizer.get());
836 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); 838 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0);
837 int expected_y = kRootHeight - window_->bounds().height() - 10; 839 int expected_y = kRootHeight - window_->bounds().height() - 10;
838 // When the mouse cursor is in the primary display, the window cannot move 840 // When the mouse cursor is in the primary display, the window cannot move
839 // on non-work area but can get all the way towards the bottom, 841 // on non-work area but can get all the way towards the bottom,
840 // restricted only by the window height. 842 // restricted only by the window height.
841 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20", 843 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x20",
842 window_->bounds().ToString()); 844 window_->bounds().ToString());
843 // Revert the drag in order to not remember the restore bounds. 845 // Revert the drag in order to not remember the restore bounds.
844 resizer->RevertDrag(); 846 resizer->RevertDrag();
845 } 847 }
846 848
847 Shell::GetInstance()->SetDisplayWorkAreaInsets( 849 Shell::GetInstance()->SetDisplayWorkAreaInsets(
848 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); 850 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0));
849 { 851 {
850 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); 852 window_->SetBounds(gfx::Rect(100, 200, 300, 400));
851 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 853 std::unique_ptr<WindowResizer> resizer(
852 window_.get(), gfx::Point(10, 0), HTCAPTION)); 854 CreateResizerForTest(window_.get(), gfx::Point(10, 0), HTCAPTION));
853 ASSERT_TRUE(resizer.get()); 855 ASSERT_TRUE(resizer.get());
854 // Drag down avoiding dragging along the edge as that would side-snap. 856 // Drag down avoiding dragging along the edge as that would side-snap.
855 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0); 857 resizer->Drag(CalculateDragPoint(*resizer, 0, 400), 0);
856 int expected_y = 858 int expected_y =
857 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; 859 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10;
858 // When the mouse cursor is in the primary display, the window cannot move 860 // When the mouse cursor is in the primary display, the window cannot move
859 // on non-work area with kMinOnscreenHeight margin. 861 // on non-work area with kMinOnscreenHeight margin.
860 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", 862 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400",
861 window_->bounds().ToString()); 863 window_->bounds().ToString());
862 resizer->CompleteDrag(); 864 resizer->CompleteDrag();
863 } 865 }
864 866
865 { 867 {
866 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); 868 window_->SetBounds(gfx::Rect(100, 200, 300, 400));
867 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 869 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest(
868 window_.get(), window_->bounds().origin(), HTCAPTION)); 870 window_.get(), window_->bounds().origin(), HTCAPTION));
869 ASSERT_TRUE(resizer.get()); 871 ASSERT_TRUE(resizer.get());
870 // Drag down avoiding getting stuck against the shelf on the bottom screen. 872 // Drag down avoiding getting stuck against the shelf on the bottom screen.
871 resizer->Drag(CalculateDragPoint(*resizer, 0, 500), 0); 873 resizer->Drag(CalculateDragPoint(*resizer, 0, 500), 0);
872 // The window can move to the secondary display beyond non-work area of 874 // The window can move to the secondary display beyond non-work area of
873 // the primary display. 875 // the primary display.
874 EXPECT_EQ("100,700 300x400", window_->bounds().ToString()); 876 EXPECT_EQ("100,700 300x400", window_->bounds().ToString());
875 resizer->CompleteDrag(); 877 resizer->CompleteDrag();
876 } 878 }
877 } 879 }
878 880
879 // Makes sure we don't allow dragging off the top of the work area. 881 // Makes sure we don't allow dragging off the top of the work area.
880 TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) { 882 TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) {
881 Shell::GetInstance()->SetDisplayWorkAreaInsets( 883 Shell::GetInstance()->SetDisplayWorkAreaInsets(
882 Shell::GetPrimaryRootWindow(), gfx::Insets(10, 0, 0, 0)); 884 Shell::GetPrimaryRootWindow(), gfx::Insets(10, 0, 0, 0));
883 885
884 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); 886 window_->SetBounds(gfx::Rect(100, 200, 300, 400));
885 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 887 std::unique_ptr<WindowResizer> resizer(
886 window_.get(), gfx::Point(), HTCAPTION)); 888 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
887 ASSERT_TRUE(resizer.get()); 889 ASSERT_TRUE(resizer.get());
888 resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0); 890 resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0);
889 EXPECT_EQ("100,10 300x400", window_->bounds().ToString()); 891 EXPECT_EQ("100,10 300x400", window_->bounds().ToString());
890 } 892 }
891 893
892 TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) { 894 TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) {
893 Shell::GetInstance()->SetDisplayWorkAreaInsets( 895 Shell::GetInstance()->SetDisplayWorkAreaInsets(
894 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); 896 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
895 897
896 window_->SetBounds(gfx::Rect(100, 200, 300, 380)); 898 window_->SetBounds(gfx::Rect(100, 200, 300, 380));
897 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 899 std::unique_ptr<WindowResizer> resizer(
898 window_.get(), gfx::Point(), HTTOP)); 900 CreateResizerForTest(window_.get(), gfx::Point(), HTTOP));
899 ASSERT_TRUE(resizer.get()); 901 ASSERT_TRUE(resizer.get());
900 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); 902 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0);
901 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); 903 EXPECT_EQ("100,200 300x380", window_->bounds().ToString());
902 } 904 }
903 905
904 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { 906 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) {
905 Shell::GetInstance()->SetDisplayWorkAreaInsets( 907 Shell::GetInstance()->SetDisplayWorkAreaInsets(
906 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); 908 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
907 int left = ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); 909 int left = ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).x();
908 int pixels_to_left_border = 50; 910 int pixels_to_left_border = 50;
909 int window_width = 300; 911 int window_width = 300;
910 int window_x = left - window_width + pixels_to_left_border; 912 int window_x = left - window_width + pixels_to_left_border;
911 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); 913 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
912 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 914 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest(
913 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT)); 915 window_.get(), gfx::Point(pixels_to_left_border, 0), HTRIGHT));
914 ASSERT_TRUE(resizer.get()); 916 ASSERT_TRUE(resizer.get());
915 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0); 917 resizer->Drag(CalculateDragPoint(*resizer, -window_width, 0), 0);
916 EXPECT_EQ(base::IntToString(window_x) + ",100 " + 918 EXPECT_EQ(base::IntToString(window_x) + ",100 " +
917 base::IntToString(kMinimumOnScreenArea - window_x) + 919 base::IntToString(kMinimumOnScreenArea - window_x) +
918 "x380", window_->bounds().ToString()); 920 "x380", window_->bounds().ToString());
919 } 921 }
920 922
921 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { 923 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) {
922 Shell::GetInstance()->SetDisplayWorkAreaInsets( 924 Shell::GetInstance()->SetDisplayWorkAreaInsets(
923 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); 925 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
924 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 926 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
925 window_.get()).right(); 927 window_.get()).right();
926 int pixels_to_right_border = 50; 928 int pixels_to_right_border = 50;
927 int window_width = 300; 929 int window_width = 300;
928 int window_x = right - pixels_to_right_border; 930 int window_x = right - pixels_to_right_border;
929 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); 931 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
930 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 932 std::unique_ptr<WindowResizer> resizer(
931 window_.get(), gfx::Point(window_x, 0), HTLEFT)); 933 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTLEFT));
932 ASSERT_TRUE(resizer.get()); 934 ASSERT_TRUE(resizer.get());
933 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); 935 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0);
934 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + 936 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) +
935 ",100 " + 937 ",100 " +
936 base::IntToString(window_width - pixels_to_right_border + 938 base::IntToString(window_width - pixels_to_right_border +
937 kMinimumOnScreenArea) + 939 kMinimumOnScreenArea) +
938 "x380", window_->bounds().ToString()); 940 "x380", window_->bounds().ToString());
939 } 941 }
940 942
941 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { 943 TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) {
942 Shell::GetInstance()->SetDisplayWorkAreaInsets( 944 Shell::GetInstance()->SetDisplayWorkAreaInsets(
943 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); 945 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
944 int bottom = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 946 int bottom = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
945 window_.get()).bottom(); 947 window_.get()).bottom();
946 int delta_to_bottom = 50; 948 int delta_to_bottom = 50;
947 int height = 380; 949 int height = 380;
948 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height)); 950 window_->SetBounds(gfx::Rect(100, bottom - delta_to_bottom, 300, height));
949 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 951 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest(
950 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP)); 952 window_.get(), gfx::Point(0, bottom - delta_to_bottom), HTTOP));
951 ASSERT_TRUE(resizer.get()); 953 ASSERT_TRUE(resizer.get());
952 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0); 954 resizer->Drag(CalculateDragPoint(*resizer, 0, bottom), 0);
953 EXPECT_EQ("100," + 955 EXPECT_EQ("100," +
954 base::IntToString(bottom - kMinimumOnScreenArea) + 956 base::IntToString(bottom - kMinimumOnScreenArea) +
955 " 300x" + 957 " 300x" +
956 base::IntToString(height - (delta_to_bottom - 958 base::IntToString(height - (delta_to_bottom -
957 kMinimumOnScreenArea)), 959 kMinimumOnScreenArea)),
958 window_->bounds().ToString()); 960 window_->bounds().ToString());
959 } 961 }
960 962
961 // Verifies that 'outside' check of the resizer take into account the extended 963 // Verifies that 'outside' check of the resizer take into account the extended
962 // desktop in case of repositions. 964 // desktop in case of repositions.
963 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { 965 TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) {
964 // Only primary display. Changes the window position to fit within the 966 // Only primary display. Changes the window position to fit within the
965 // display. 967 // display.
966 Shell::GetInstance()->SetDisplayWorkAreaInsets( 968 Shell::GetInstance()->SetDisplayWorkAreaInsets(
967 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); 969 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
968 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( 970 int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent(
969 window_.get()).right(); 971 window_.get()).right();
970 int pixels_to_right_border = 50; 972 int pixels_to_right_border = 50;
971 int window_width = 300; 973 int window_width = 300;
972 int window_x = right - pixels_to_right_border; 974 int window_x = right - pixels_to_right_border;
973 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380)); 975 window_->SetBounds(gfx::Rect(window_x, 100, window_width, 380));
974 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 976 std::unique_ptr<WindowResizer> resizer(
975 window_.get(), gfx::Point(window_x, 0), HTCAPTION)); 977 CreateResizerForTest(window_.get(), gfx::Point(window_x, 0), HTCAPTION));
976 ASSERT_TRUE(resizer.get()); 978 ASSERT_TRUE(resizer.get());
977 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0); 979 resizer->Drag(CalculateDragPoint(*resizer, window_width, 0), 0);
978 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) + 980 EXPECT_EQ(base::IntToString(right - kMinimumOnScreenArea) +
979 ",100 " + 981 ",100 " +
980 base::IntToString(window_width) + 982 base::IntToString(window_width) +
981 "x380", window_->bounds().ToString()); 983 "x380", window_->bounds().ToString());
982 984
983 if (!SupportsMultipleDisplays()) 985 if (!SupportsMultipleDisplays())
984 return; 986 return;
985 987
(...skipping 10 matching lines...) Expand all
996 "x380", window_->bounds().ToString()); 998 "x380", window_->bounds().ToString());
997 } 999 }
998 1000
999 // Verifies snapping to edges works. 1001 // Verifies snapping to edges works.
1000 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) { 1002 TEST_F(WorkspaceWindowResizerTest, SnapToEdge) {
1001 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()-> 1003 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()->
1002 SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1004 SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1003 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); 1005 window_->SetBounds(gfx::Rect(96, 112, 320, 160));
1004 // Click 50px to the right so that the mouse pointer does not leave the 1006 // Click 50px to the right so that the mouse pointer does not leave the
1005 // workspace ensuring sticky behavior. 1007 // workspace ensuring sticky behavior.
1006 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1008 std::unique_ptr<WindowResizer> resizer(CreateResizerForTest(
1007 window_.get(), 1009 window_.get(), window_->bounds().origin() + gfx::Vector2d(50, 0),
1008 window_->bounds().origin() + gfx::Vector2d(50, 0),
1009 HTCAPTION)); 1010 HTCAPTION));
1010 ASSERT_TRUE(resizer.get()); 1011 ASSERT_TRUE(resizer.get());
1011 // Move to an x-coordinate of 15, which should not snap. 1012 // Move to an x-coordinate of 15, which should not snap.
1012 resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0); 1013 resizer->Drag(CalculateDragPoint(*resizer, 15 - 96, 0), 0);
1013 // An x-coordinate of 7 should snap. 1014 // An x-coordinate of 7 should snap.
1014 resizer->Drag(CalculateDragPoint(*resizer, 7 - 96, 0), 0); 1015 resizer->Drag(CalculateDragPoint(*resizer, 7 - 96, 0), 0);
1015 EXPECT_EQ("0,112 320x160", window_->bounds().ToString()); 1016 EXPECT_EQ("0,112 320x160", window_->bounds().ToString());
1016 // Move to -15, should still snap to 0. 1017 // Move to -15, should still snap to 0.
1017 resizer->Drag(CalculateDragPoint(*resizer, -15 - 96, 0), 0); 1018 resizer->Drag(CalculateDragPoint(*resizer, -15 - 96, 0), 0);
1018 EXPECT_EQ("0,112 320x160", window_->bounds().ToString()); 1019 EXPECT_EQ("0,112 320x160", window_->bounds().ToString());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 resizer->Drag( 1065 resizer->Drag(
1065 CalculateDragPoint(*resizer, -33 - 96, 600 - 160 - 112 - 2 + 33), 0); 1066 CalculateDragPoint(*resizer, -33 - 96, 600 - 160 - 112 - 2 + 33), 0);
1066 EXPECT_EQ("-33,471 320x160", window_->bounds().ToString()); 1067 EXPECT_EQ("-33,471 320x160", window_->bounds().ToString());
1067 1068
1068 // No need to test dragging < 0 as we force that to 0. 1069 // No need to test dragging < 0 as we force that to 0.
1069 } 1070 }
1070 1071
1071 // Verifies a resize snap when dragging TOPLEFT. 1072 // Verifies a resize snap when dragging TOPLEFT.
1072 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPLEFT) { 1073 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPLEFT) {
1073 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1074 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1074 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1075 std::unique_ptr<WindowResizer> resizer(
1075 window_.get(), gfx::Point(), HTTOPLEFT)); 1076 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPLEFT));
1076 ASSERT_TRUE(resizer.get()); 1077 ASSERT_TRUE(resizer.get());
1077 resizer->Drag(CalculateDragPoint(*resizer, -98, -199), 0); 1078 resizer->Drag(CalculateDragPoint(*resizer, -98, -199), 0);
1078 EXPECT_EQ("0,0 120x230", window_->bounds().ToString()); 1079 EXPECT_EQ("0,0 120x230", window_->bounds().ToString());
1079 } 1080 }
1080 1081
1081 // Verifies a resize snap when dragging TOPRIGHT. 1082 // Verifies a resize snap when dragging TOPRIGHT.
1082 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) { 1083 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) {
1083 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1084 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1084 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( 1085 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(
1085 window_.get())); 1086 window_.get()));
1086 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1087 std::unique_ptr<WindowResizer> resizer(
1087 window_.get(), gfx::Point(), HTTOPRIGHT)); 1088 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPRIGHT));
1088 ASSERT_TRUE(resizer.get()); 1089 ASSERT_TRUE(resizer.get());
1089 resizer->Drag( 1090 resizer->Drag(
1090 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, -199), 0); 1091 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, -199), 0);
1091 EXPECT_EQ(100, window_->bounds().x()); 1092 EXPECT_EQ(100, window_->bounds().x());
1092 EXPECT_EQ(work_area.y(), window_->bounds().y()); 1093 EXPECT_EQ(work_area.y(), window_->bounds().y());
1093 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); 1094 EXPECT_EQ(work_area.right() - 100, window_->bounds().width());
1094 EXPECT_EQ(230, window_->bounds().height()); 1095 EXPECT_EQ(230, window_->bounds().height());
1095 } 1096 }
1096 1097
1097 // Verifies a resize snap when dragging BOTTOMRIGHT. 1098 // Verifies a resize snap when dragging BOTTOMRIGHT.
1098 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) { 1099 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) {
1099 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1100 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1100 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( 1101 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(
1101 window_.get())); 1102 window_.get()));
1102 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1103 std::unique_ptr<WindowResizer> resizer(
1103 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); 1104 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT));
1104 ASSERT_TRUE(resizer.get()); 1105 ASSERT_TRUE(resizer.get());
1105 resizer->Drag( 1106 resizer->Drag(
1106 CalculateDragPoint(*resizer, work_area.right() - 120 - 1, 1107 CalculateDragPoint(*resizer, work_area.right() - 120 - 1,
1107 work_area.bottom() - 220 - 2), 0); 1108 work_area.bottom() - 220 - 2), 0);
1108 EXPECT_EQ(100, window_->bounds().x()); 1109 EXPECT_EQ(100, window_->bounds().x());
1109 EXPECT_EQ(200, window_->bounds().y()); 1110 EXPECT_EQ(200, window_->bounds().y());
1110 EXPECT_EQ(work_area.right() - 100, window_->bounds().width()); 1111 EXPECT_EQ(work_area.right() - 100, window_->bounds().width());
1111 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); 1112 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height());
1112 } 1113 }
1113 1114
1114 // Verifies a resize snap when dragging BOTTOMLEFT. 1115 // Verifies a resize snap when dragging BOTTOMLEFT.
1115 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMLEFT) { 1116 TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMLEFT) {
1116 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1117 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1117 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( 1118 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(
1118 window_.get())); 1119 window_.get()));
1119 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1120 std::unique_ptr<WindowResizer> resizer(
1120 window_.get(), gfx::Point(), HTBOTTOMLEFT)); 1121 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMLEFT));
1121 ASSERT_TRUE(resizer.get()); 1122 ASSERT_TRUE(resizer.get());
1122 resizer->Drag( 1123 resizer->Drag(
1123 CalculateDragPoint(*resizer, -98, work_area.bottom() - 220 - 2), 0); 1124 CalculateDragPoint(*resizer, -98, work_area.bottom() - 220 - 2), 0);
1124 EXPECT_EQ(0, window_->bounds().x()); 1125 EXPECT_EQ(0, window_->bounds().x());
1125 EXPECT_EQ(200, window_->bounds().y()); 1126 EXPECT_EQ(200, window_->bounds().y());
1126 EXPECT_EQ(120, window_->bounds().width()); 1127 EXPECT_EQ(120, window_->bounds().width());
1127 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height()); 1128 EXPECT_EQ(work_area.bottom() - 200, window_->bounds().height());
1128 } 1129 }
1129 1130
1130 // Verifies window sticks to both window and work area. 1131 // Verifies window sticks to both window and work area.
1131 TEST_F(WorkspaceWindowResizerTest, StickToBothEdgeAndWindow) { 1132 TEST_F(WorkspaceWindowResizerTest, StickToBothEdgeAndWindow) {
1132 window_->SetBounds(gfx::Rect(10, 10, 20, 50)); 1133 window_->SetBounds(gfx::Rect(10, 10, 20, 50));
1133 window_->Show(); 1134 window_->Show();
1134 window2_->SetBounds(gfx::Rect(150, 160, 25, 1000)); 1135 window2_->SetBounds(gfx::Rect(150, 160, 25, 1000));
1135 window2_->Show(); 1136 window2_->Show();
1136 1137
1137 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1138 std::unique_ptr<WindowResizer> resizer(
1138 window_.get(), gfx::Point(10, 10), HTCAPTION)); 1139 CreateResizerForTest(window_.get(), gfx::Point(10, 10), HTCAPTION));
1139 ASSERT_TRUE(resizer.get()); 1140 ASSERT_TRUE(resizer.get());
1140 1141
1141 // Move |window| one pixel to the left of |window2|. Should snap to right. 1142 // Move |window| one pixel to the left of |window2|. Should snap to right.
1142 resizer->Drag(CalculateDragPoint(*resizer, 119, 145), 0); 1143 resizer->Drag(CalculateDragPoint(*resizer, 119, 145), 0);
1143 gfx::Rect expected(130, 160, 20, 50); 1144 gfx::Rect expected(130, 160, 20, 50);
1144 EXPECT_EQ(expected.ToString(), window_->bounds().ToString()); 1145 EXPECT_EQ(expected.ToString(), window_->bounds().ToString());
1145 1146
1146 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( 1147 gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(
1147 window_.get())); 1148 window_.get()));
1148 1149
(...skipping 21 matching lines...) Expand all
1170 EXPECT_EQ(expected.ToString(), window_->bounds().ToString()); 1171 EXPECT_EQ(expected.ToString(), window_->bounds().ToString());
1171 1172
1172 // Moving down further should move the window. 1173 // Moving down further should move the window.
1173 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y + 18), 0); 1174 resizer->Drag(CalculateDragPoint(*resizer, 119, attach_y + 18), 0);
1174 expected.set_y(attach_y + initial_y + 18); 1175 expected.set_y(attach_y + initial_y + 18);
1175 EXPECT_EQ(expected.ToString(), window_->bounds().ToString()); 1176 EXPECT_EQ(expected.ToString(), window_->bounds().ToString());
1176 } 1177 }
1177 1178
1178 TEST_F(WorkspaceWindowResizerTest, CtrlDragResizeToExactPosition) { 1179 TEST_F(WorkspaceWindowResizerTest, CtrlDragResizeToExactPosition) {
1179 window_->SetBounds(gfx::Rect(96, 112, 320, 160)); 1180 window_->SetBounds(gfx::Rect(96, 112, 320, 160));
1180 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1181 std::unique_ptr<WindowResizer> resizer(
1181 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); 1182 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT));
1182 ASSERT_TRUE(resizer.get()); 1183 ASSERT_TRUE(resizer.get());
1183 // Resize the right bottom to add 10 in width, 12 in height. 1184 // Resize the right bottom to add 10 in width, 12 in height.
1184 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), ui::EF_CONTROL_DOWN); 1185 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), ui::EF_CONTROL_DOWN);
1185 // Both bottom and right sides to resize to exact size requested. 1186 // Both bottom and right sides to resize to exact size requested.
1186 EXPECT_EQ("96,112 330x172", window_->bounds().ToString()); 1187 EXPECT_EQ("96,112 330x172", window_->bounds().ToString());
1187 } 1188 }
1188 1189
1189 // Verifies that a dragged, non-snapped window will clear restore bounds. 1190 // Verifies that a dragged, non-snapped window will clear restore bounds.
1190 TEST_F(WorkspaceWindowResizerTest, RestoreClearedOnResize) { 1191 TEST_F(WorkspaceWindowResizerTest, RestoreClearedOnResize) {
1191 window_->SetBounds(gfx::Rect(10, 10, 100, 100)); 1192 window_->SetBounds(gfx::Rect(10, 10, 100, 100));
1192 wm::WindowState* window_state = wm::GetWindowState(window_.get()); 1193 wm::WindowState* window_state = wm::GetWindowState(window_.get());
1193 window_state->SetRestoreBoundsInScreen(gfx::Rect(50, 50, 50, 50)); 1194 window_state->SetRestoreBoundsInScreen(gfx::Rect(50, 50, 50, 50));
1194 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1195 std::unique_ptr<WindowResizer> resizer(
1195 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); 1196 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT));
1196 ASSERT_TRUE(resizer.get()); 1197 ASSERT_TRUE(resizer.get());
1197 // Drag the window to new position by adding (20, 30) to original point, 1198 // Drag the window to new position by adding (20, 30) to original point,
1198 // the original restore bound should be cleared. 1199 // the original restore bound should be cleared.
1199 resizer->Drag(CalculateDragPoint(*resizer, 20, 30), 0); 1200 resizer->Drag(CalculateDragPoint(*resizer, 20, 30), 0);
1200 resizer->CompleteDrag(); 1201 resizer->CompleteDrag();
1201 EXPECT_EQ("10,10 120x130", window_->bounds().ToString()); 1202 EXPECT_EQ("10,10 120x130", window_->bounds().ToString());
1202 EXPECT_FALSE(window_state->HasRestoreBounds()); 1203 EXPECT_FALSE(window_state->HasRestoreBounds());
1203 } 1204 }
1204 1205
1205 // Verifies that a dragged window will restore to its pre-maximized size. 1206 // Verifies that a dragged window will restore to its pre-maximized size.
1206 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) { 1207 TEST_F(WorkspaceWindowResizerTest, RestoreToPreMaximizeCoordinates) {
1207 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000)); 1208 window_->SetBounds(gfx::Rect(0, 0, 1000, 1000));
1208 wm::WindowState* window_state = wm::GetWindowState(window_.get()); 1209 wm::WindowState* window_state = wm::GetWindowState(window_.get());
1209 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160)); 1210 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160));
1210 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1211 std::unique_ptr<WindowResizer> resizer(
1211 window_.get(), gfx::Point(), HTCAPTION)); 1212 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1212 ASSERT_TRUE(resizer.get()); 1213 ASSERT_TRUE(resizer.get());
1213 // Drag the window to new position by adding (10, 10) to original point, 1214 // Drag the window to new position by adding (10, 10) to original point,
1214 // the window should get restored. 1215 // the window should get restored.
1215 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0); 1216 resizer->Drag(CalculateDragPoint(*resizer, 10, 10), 0);
1216 resizer->CompleteDrag(); 1217 resizer->CompleteDrag();
1217 EXPECT_EQ("10,10 320x160", window_->bounds().ToString()); 1218 EXPECT_EQ("10,10 320x160", window_->bounds().ToString());
1218 // The restore rectangle should get cleared as well. 1219 // The restore rectangle should get cleared as well.
1219 EXPECT_FALSE(window_state->HasRestoreBounds()); 1220 EXPECT_FALSE(window_state->HasRestoreBounds());
1220 } 1221 }
1221 1222
1222 // Verifies that a dragged window will restore to its pre-maximized size. 1223 // Verifies that a dragged window will restore to its pre-maximized size.
1223 TEST_F(WorkspaceWindowResizerTest, RevertResizeOperation) { 1224 TEST_F(WorkspaceWindowResizerTest, RevertResizeOperation) {
1224 const gfx::Rect initial_bounds(0, 0, 200, 400); 1225 const gfx::Rect initial_bounds(0, 0, 200, 400);
1225 window_->SetBounds(initial_bounds); 1226 window_->SetBounds(initial_bounds);
1226 1227
1227 wm::WindowState* window_state = wm::GetWindowState(window_.get()); 1228 wm::WindowState* window_state = wm::GetWindowState(window_.get());
1228 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160)); 1229 window_state->SetRestoreBoundsInScreen(gfx::Rect(96, 112, 320, 160));
1229 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1230 std::unique_ptr<WindowResizer> resizer(
1230 window_.get(), gfx::Point(), HTCAPTION)); 1231 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1231 ASSERT_TRUE(resizer.get()); 1232 ASSERT_TRUE(resizer.get());
1232 // Drag the window to new poistion by adding (180, 16) to original point, 1233 // Drag the window to new poistion by adding (180, 16) to original point,
1233 // the window should get restored. 1234 // the window should get restored.
1234 resizer->Drag(CalculateDragPoint(*resizer, 180, 16), 0); 1235 resizer->Drag(CalculateDragPoint(*resizer, 180, 16), 0);
1235 resizer->RevertDrag(); 1236 resizer->RevertDrag();
1236 EXPECT_EQ(initial_bounds.ToString(), window_->bounds().ToString()); 1237 EXPECT_EQ(initial_bounds.ToString(), window_->bounds().ToString());
1237 EXPECT_EQ("96,112 320x160", 1238 EXPECT_EQ("96,112 320x160",
1238 window_state->GetRestoreBoundsInScreen().ToString()); 1239 window_state->GetRestoreBoundsInScreen().ToString());
1239 } 1240 }
1240 1241
1241 // Check that only usable sizes get returned by the resizer. 1242 // Check that only usable sizes get returned by the resizer.
1242 TEST_F(WorkspaceWindowResizerTest, MagneticallyAttach) { 1243 TEST_F(WorkspaceWindowResizerTest, MagneticallyAttach) {
1243 window_->SetBounds(gfx::Rect(10, 10, 20, 30)); 1244 window_->SetBounds(gfx::Rect(10, 10, 20, 30));
1244 window2_->SetBounds(gfx::Rect(150, 160, 25, 20)); 1245 window2_->SetBounds(gfx::Rect(150, 160, 25, 20));
1245 window2_->Show(); 1246 window2_->Show();
1246 1247
1247 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1248 std::unique_ptr<WindowResizer> resizer(
1248 window_.get(), gfx::Point(), HTCAPTION)); 1249 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1249 ASSERT_TRUE(resizer.get()); 1250 ASSERT_TRUE(resizer.get());
1250 // Move |window| one pixel to the left of |window2|. Should snap to right and 1251 // Move |window| one pixel to the left of |window2|. Should snap to right and
1251 // top. 1252 // top.
1252 resizer->Drag(CalculateDragPoint(*resizer, 119, 145), 0); 1253 resizer->Drag(CalculateDragPoint(*resizer, 119, 145), 0);
1253 EXPECT_EQ("130,160 20x30", window_->bounds().ToString()); 1254 EXPECT_EQ("130,160 20x30", window_->bounds().ToString());
1254 1255
1255 // Move |window| one pixel to the right of |window2|. Should snap to left and 1256 // Move |window| one pixel to the right of |window2|. Should snap to left and
1256 // top. 1257 // top.
1257 resizer->Drag(CalculateDragPoint(*resizer, 164, 145), 0); 1258 resizer->Drag(CalculateDragPoint(*resizer, 164, 145), 0);
1258 EXPECT_EQ("175,160 20x30", window_->bounds().ToString()); 1259 EXPECT_EQ("175,160 20x30", window_->bounds().ToString());
1259 1260
1260 // Move |window| one pixel above |window2|. Should snap to top and left. 1261 // Move |window| one pixel above |window2|. Should snap to top and left.
1261 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0); 1262 resizer->Drag(CalculateDragPoint(*resizer, 142, 119), 0);
1262 EXPECT_EQ("150,130 20x30", window_->bounds().ToString()); 1263 EXPECT_EQ("150,130 20x30", window_->bounds().ToString());
1263 1264
1264 // Move |window| one pixel above the bottom of |window2|. Should snap to 1265 // Move |window| one pixel above the bottom of |window2|. Should snap to
1265 // bottom and left. 1266 // bottom and left.
1266 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0); 1267 resizer->Drag(CalculateDragPoint(*resizer, 142, 169), 0);
1267 EXPECT_EQ("150,180 20x30", window_->bounds().ToString()); 1268 EXPECT_EQ("150,180 20x30", window_->bounds().ToString());
1268 } 1269 }
1269 1270
1270 // The following variants verify magnetic snapping during resize when dragging a 1271 // The following variants verify magnetic snapping during resize when dragging a
1271 // particular edge. 1272 // particular edge.
1272 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOP) { 1273 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOP) {
1273 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1274 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1274 window2_->SetBounds(gfx::Rect(99, 179, 10, 20)); 1275 window2_->SetBounds(gfx::Rect(99, 179, 10, 20));
1275 window2_->Show(); 1276 window2_->Show();
1276 1277
1277 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1278 std::unique_ptr<WindowResizer> resizer(
1278 window_.get(), gfx::Point(), HTTOP)); 1279 CreateResizerForTest(window_.get(), gfx::Point(), HTTOP));
1279 ASSERT_TRUE(resizer.get()); 1280 ASSERT_TRUE(resizer.get());
1280 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1281 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1281 EXPECT_EQ("100,199 20x31", window_->bounds().ToString()); 1282 EXPECT_EQ("100,199 20x31", window_->bounds().ToString());
1282 } 1283 }
1283 1284
1284 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPLEFT) { 1285 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPLEFT) {
1285 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1286 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1286 window2_->SetBounds(gfx::Rect(99, 179, 10, 20)); 1287 window2_->SetBounds(gfx::Rect(99, 179, 10, 20));
1287 window2_->Show(); 1288 window2_->Show();
1288 1289
1289 { 1290 {
1290 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1291 std::unique_ptr<WindowResizer> resizer(
1291 window_.get(), gfx::Point(), HTTOPLEFT)); 1292 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPLEFT));
1292 ASSERT_TRUE(resizer.get()); 1293 ASSERT_TRUE(resizer.get());
1293 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1294 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1294 EXPECT_EQ("99,199 21x31", window_->bounds().ToString()); 1295 EXPECT_EQ("99,199 21x31", window_->bounds().ToString());
1295 resizer->RevertDrag(); 1296 resizer->RevertDrag();
1296 } 1297 }
1297 1298
1298 { 1299 {
1299 window2_->SetBounds(gfx::Rect(88, 201, 10, 20)); 1300 window2_->SetBounds(gfx::Rect(88, 201, 10, 20));
1300 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1301 std::unique_ptr<WindowResizer> resizer(
1301 window_.get(), gfx::Point(), HTTOPLEFT)); 1302 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPLEFT));
1302 ASSERT_TRUE(resizer.get()); 1303 ASSERT_TRUE(resizer.get());
1303 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1304 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1304 EXPECT_EQ("98,201 22x29", window_->bounds().ToString()); 1305 EXPECT_EQ("98,201 22x29", window_->bounds().ToString());
1305 resizer->RevertDrag(); 1306 resizer->RevertDrag();
1306 } 1307 }
1307 } 1308 }
1308 1309
1309 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPRIGHT) { 1310 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_TOPRIGHT) {
1310 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1311 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1311 window2_->Show(); 1312 window2_->Show();
1312 1313
1313 { 1314 {
1314 window2_->SetBounds(gfx::Rect(111, 179, 10, 20)); 1315 window2_->SetBounds(gfx::Rect(111, 179, 10, 20));
1315 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1316 std::unique_ptr<WindowResizer> resizer(
1316 window_.get(), gfx::Point(), HTTOPRIGHT)); 1317 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPRIGHT));
1317 ASSERT_TRUE(resizer.get()); 1318 ASSERT_TRUE(resizer.get());
1318 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1319 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1319 EXPECT_EQ("100,199 21x31", window_->bounds().ToString()); 1320 EXPECT_EQ("100,199 21x31", window_->bounds().ToString());
1320 resizer->RevertDrag(); 1321 resizer->RevertDrag();
1321 } 1322 }
1322 1323
1323 { 1324 {
1324 window2_->SetBounds(gfx::Rect(121, 199, 10, 20)); 1325 window2_->SetBounds(gfx::Rect(121, 199, 10, 20));
1325 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1326 std::unique_ptr<WindowResizer> resizer(
1326 window_.get(), gfx::Point(), HTTOPRIGHT)); 1327 CreateResizerForTest(window_.get(), gfx::Point(), HTTOPRIGHT));
1327 ASSERT_TRUE(resizer.get()); 1328 ASSERT_TRUE(resizer.get());
1328 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1329 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1329 EXPECT_EQ("100,199 21x31", window_->bounds().ToString()); 1330 EXPECT_EQ("100,199 21x31", window_->bounds().ToString());
1330 resizer->RevertDrag(); 1331 resizer->RevertDrag();
1331 } 1332 }
1332 } 1333 }
1333 1334
1334 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_RIGHT) { 1335 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_RIGHT) {
1335 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1336 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1336 window2_->SetBounds(gfx::Rect(121, 199, 10, 20)); 1337 window2_->SetBounds(gfx::Rect(121, 199, 10, 20));
1337 window2_->Show(); 1338 window2_->Show();
1338 1339
1339 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1340 std::unique_ptr<WindowResizer> resizer(
1340 window_.get(), gfx::Point(), HTRIGHT)); 1341 CreateResizerForTest(window_.get(), gfx::Point(), HTRIGHT));
1341 ASSERT_TRUE(resizer.get()); 1342 ASSERT_TRUE(resizer.get());
1342 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1343 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1343 EXPECT_EQ("100,200 21x30", window_->bounds().ToString()); 1344 EXPECT_EQ("100,200 21x30", window_->bounds().ToString());
1344 } 1345 }
1345 1346
1346 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMRIGHT) { 1347 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMRIGHT) {
1347 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1348 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1348 window2_->Show(); 1349 window2_->Show();
1349 1350
1350 { 1351 {
1351 window2_->SetBounds(gfx::Rect(122, 212, 10, 20)); 1352 window2_->SetBounds(gfx::Rect(122, 212, 10, 20));
1352 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1353 std::unique_ptr<WindowResizer> resizer(
1353 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); 1354 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT));
1354 ASSERT_TRUE(resizer.get()); 1355 ASSERT_TRUE(resizer.get());
1355 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1356 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1356 EXPECT_EQ("100,200 22x32", window_->bounds().ToString()); 1357 EXPECT_EQ("100,200 22x32", window_->bounds().ToString());
1357 resizer->RevertDrag(); 1358 resizer->RevertDrag();
1358 } 1359 }
1359 1360
1360 { 1361 {
1361 window2_->SetBounds(gfx::Rect(111, 233, 10, 20)); 1362 window2_->SetBounds(gfx::Rect(111, 233, 10, 20));
1362 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1363 std::unique_ptr<WindowResizer> resizer(
1363 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); 1364 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT));
1364 ASSERT_TRUE(resizer.get()); 1365 ASSERT_TRUE(resizer.get());
1365 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1366 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1366 EXPECT_EQ("100,200 21x33", window_->bounds().ToString()); 1367 EXPECT_EQ("100,200 21x33", window_->bounds().ToString());
1367 resizer->RevertDrag(); 1368 resizer->RevertDrag();
1368 } 1369 }
1369 } 1370 }
1370 1371
1371 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOM) { 1372 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOM) {
1372 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1373 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1373 window2_->SetBounds(gfx::Rect(111, 233, 10, 20)); 1374 window2_->SetBounds(gfx::Rect(111, 233, 10, 20));
1374 window2_->Show(); 1375 window2_->Show();
1375 1376
1376 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1377 std::unique_ptr<WindowResizer> resizer(
1377 window_.get(), gfx::Point(), HTBOTTOM)); 1378 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOM));
1378 ASSERT_TRUE(resizer.get()); 1379 ASSERT_TRUE(resizer.get());
1379 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1380 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1380 EXPECT_EQ("100,200 20x33", window_->bounds().ToString()); 1381 EXPECT_EQ("100,200 20x33", window_->bounds().ToString());
1381 } 1382 }
1382 1383
1383 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMLEFT) { 1384 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_BOTTOMLEFT) {
1384 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1385 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1385 window2_->Show(); 1386 window2_->Show();
1386 1387
1387 { 1388 {
1388 window2_->SetBounds(gfx::Rect(99, 231, 10, 20)); 1389 window2_->SetBounds(gfx::Rect(99, 231, 10, 20));
1389 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1390 std::unique_ptr<WindowResizer> resizer(
1390 window_.get(), gfx::Point(), HTBOTTOMLEFT)); 1391 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMLEFT));
1391 ASSERT_TRUE(resizer.get()); 1392 ASSERT_TRUE(resizer.get());
1392 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1393 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1393 EXPECT_EQ("99,200 21x31", window_->bounds().ToString()); 1394 EXPECT_EQ("99,200 21x31", window_->bounds().ToString());
1394 resizer->RevertDrag(); 1395 resizer->RevertDrag();
1395 } 1396 }
1396 1397
1397 { 1398 {
1398 window2_->SetBounds(gfx::Rect(89, 209, 10, 20)); 1399 window2_->SetBounds(gfx::Rect(89, 209, 10, 20));
1399 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1400 std::unique_ptr<WindowResizer> resizer(
1400 window_.get(), gfx::Point(), HTBOTTOMLEFT)); 1401 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMLEFT));
1401 ASSERT_TRUE(resizer.get()); 1402 ASSERT_TRUE(resizer.get());
1402 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1403 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1403 EXPECT_EQ("99,200 21x29", window_->bounds().ToString()); 1404 EXPECT_EQ("99,200 21x29", window_->bounds().ToString());
1404 resizer->RevertDrag(); 1405 resizer->RevertDrag();
1405 } 1406 }
1406 } 1407 }
1407 1408
1408 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_LEFT) { 1409 TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_LEFT) {
1409 window2_->SetBounds(gfx::Rect(89, 209, 10, 20)); 1410 window2_->SetBounds(gfx::Rect(89, 209, 10, 20));
1410 window_->SetBounds(gfx::Rect(100, 200, 20, 30)); 1411 window_->SetBounds(gfx::Rect(100, 200, 20, 30));
1411 window2_->Show(); 1412 window2_->Show();
1412 1413
1413 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1414 std::unique_ptr<WindowResizer> resizer(
1414 window_.get(), gfx::Point(), HTLEFT)); 1415 CreateResizerForTest(window_.get(), gfx::Point(), HTLEFT));
1415 ASSERT_TRUE(resizer.get()); 1416 ASSERT_TRUE(resizer.get());
1416 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0); 1417 resizer->Drag(CalculateDragPoint(*resizer, 0, 0), 0);
1417 EXPECT_EQ("99,200 21x30", window_->bounds().ToString()); 1418 EXPECT_EQ("99,200 21x30", window_->bounds().ToString());
1418 } 1419 }
1419 1420
1420 // Test that the user user moved window flag is getting properly set. 1421 // Test that the user user moved window flag is getting properly set.
1421 TEST_F(WorkspaceWindowResizerTest, CheckUserWindowManagedFlags) { 1422 TEST_F(WorkspaceWindowResizerTest, CheckUserWindowManagedFlags) {
1422 window_->SetBounds(gfx::Rect( 0, 50, 400, 200)); 1423 window_->SetBounds(gfx::Rect( 0, 50, 400, 200));
1423 window_->SetProperty(aura::client::kCanMaximizeKey, true); 1424 window_->SetProperty(aura::client::kCanMaximizeKey, true);
1424 1425
1425 std::vector<aura::Window*> no_attached_windows; 1426 std::vector<aura::Window*> no_attached_windows;
1426 // Check that an abort doesn't change anything. 1427 // Check that an abort doesn't change anything.
1427 { 1428 {
1428 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1429 std::unique_ptr<WindowResizer> resizer(
1429 window_.get(), gfx::Point(), HTCAPTION)); 1430 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1430 ASSERT_TRUE(resizer.get()); 1431 ASSERT_TRUE(resizer.get());
1431 // Move it 100 to the bottom. 1432 // Move it 100 to the bottom.
1432 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); 1433 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0);
1433 EXPECT_EQ("0,150 400x200", window_->bounds().ToString()); 1434 EXPECT_EQ("0,150 400x200", window_->bounds().ToString());
1434 resizer->RevertDrag(); 1435 resizer->RevertDrag();
1435 1436
1436 EXPECT_FALSE(wm::GetWindowState(window_.get())->bounds_changed_by_user()); 1437 EXPECT_FALSE(wm::GetWindowState(window_.get())->bounds_changed_by_user());
1437 } 1438 }
1438 1439
1439 // Check that a completed move / size does change the user coordinates. 1440 // Check that a completed move / size does change the user coordinates.
1440 { 1441 {
1441 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1442 std::unique_ptr<WindowResizer> resizer(
1442 window_.get(), gfx::Point(), HTCAPTION)); 1443 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1443 ASSERT_TRUE(resizer.get()); 1444 ASSERT_TRUE(resizer.get());
1444 // Move it 100 to the bottom. 1445 // Move it 100 to the bottom.
1445 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); 1446 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0);
1446 EXPECT_EQ("0,150 400x200", window_->bounds().ToString()); 1447 EXPECT_EQ("0,150 400x200", window_->bounds().ToString());
1447 resizer->CompleteDrag(); 1448 resizer->CompleteDrag();
1448 EXPECT_TRUE(wm::GetWindowState(window_.get())->bounds_changed_by_user()); 1449 EXPECT_TRUE(wm::GetWindowState(window_.get())->bounds_changed_by_user());
1449 } 1450 }
1450 } 1451 }
1451 1452
1452 // Test that a window with a specified max size doesn't exceed it when dragged. 1453 // Test that a window with a specified max size doesn't exceed it when dragged.
1453 TEST_F(WorkspaceWindowResizerTest, TestMaxSizeEnforced) { 1454 TEST_F(WorkspaceWindowResizerTest, TestMaxSizeEnforced) {
1454 window_->SetBounds(gfx::Rect(0, 0, 400, 300)); 1455 window_->SetBounds(gfx::Rect(0, 0, 400, 300));
1455 delegate_.set_max_size(gfx::Size(401, 301)); 1456 delegate_.set_max_size(gfx::Size(401, 301));
1456 1457
1457 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1458 std::unique_ptr<WindowResizer> resizer(
1458 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); 1459 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT));
1459 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0); 1460 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0);
1460 EXPECT_EQ(401, window_->bounds().width()); 1461 EXPECT_EQ(401, window_->bounds().width());
1461 EXPECT_EQ(301, window_->bounds().height()); 1462 EXPECT_EQ(301, window_->bounds().height());
1462 } 1463 }
1463 1464
1464 // Test that a window with a specified max width doesn't restrict its height. 1465 // Test that a window with a specified max width doesn't restrict its height.
1465 TEST_F(WorkspaceWindowResizerTest, TestPartialMaxSizeEnforced) { 1466 TEST_F(WorkspaceWindowResizerTest, TestPartialMaxSizeEnforced) {
1466 window_->SetBounds(gfx::Rect(0, 0, 400, 300)); 1467 window_->SetBounds(gfx::Rect(0, 0, 400, 300));
1467 delegate_.set_max_size(gfx::Size(401, 0)); 1468 delegate_.set_max_size(gfx::Size(401, 0));
1468 1469
1469 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1470 std::unique_ptr<WindowResizer> resizer(
1470 window_.get(), gfx::Point(), HTBOTTOMRIGHT)); 1471 CreateResizerForTest(window_.get(), gfx::Point(), HTBOTTOMRIGHT));
1471 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0); 1472 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0);
1472 EXPECT_EQ(401, window_->bounds().width()); 1473 EXPECT_EQ(401, window_->bounds().width());
1473 EXPECT_EQ(302, window_->bounds().height()); 1474 EXPECT_EQ(302, window_->bounds().height());
1474 } 1475 }
1475 1476
1476 // Test that a window with a specified max size can't be snapped. 1477 // Test that a window with a specified max size can't be snapped.
1477 TEST_F(WorkspaceWindowResizerTest, PhantomSnapMaxSize) { 1478 TEST_F(WorkspaceWindowResizerTest, PhantomSnapMaxSize) {
1478 { 1479 {
1479 // With max size not set we get a phantom window controller for dragging off 1480 // With max size not set we get a phantom window controller for dragging off
1480 // the right hand side. 1481 // the right hand side.
1481 // Make the window wider than maximum docked width. 1482 // Make the window wider than maximum docked width.
1482 window_->SetBounds(gfx::Rect(0, 0, 400, 200)); 1483 window_->SetBounds(gfx::Rect(0, 0, 400, 200));
1483 1484
1484 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1485 std::unique_ptr<WindowResizer> resizer(
1485 window_.get(), gfx::Point(), HTCAPTION)); 1486 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1486 EXPECT_FALSE(snap_phantom_window_controller()); 1487 EXPECT_FALSE(snap_phantom_window_controller());
1487 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); 1488 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
1488 EXPECT_TRUE(snap_phantom_window_controller()); 1489 EXPECT_TRUE(snap_phantom_window_controller());
1489 resizer->RevertDrag(); 1490 resizer->RevertDrag();
1490 } 1491 }
1491 { 1492 {
1492 // With max size defined, we get no phantom window for snapping but we still 1493 // With max size defined, we get no phantom window for snapping but we still
1493 // get a phantom window (docking guide). 1494 // get a phantom window (docking guide).
1494 window_->SetBounds(gfx::Rect(0, 0, 400, 200)); 1495 window_->SetBounds(gfx::Rect(0, 0, 400, 200));
1495 delegate_.set_max_size(gfx::Size(400, 200)); 1496 delegate_.set_max_size(gfx::Size(400, 200));
1496 1497
1497 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1498 std::unique_ptr<WindowResizer> resizer(
1498 window_.get(), gfx::Point(), HTCAPTION)); 1499 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1499 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); 1500 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
1500 EXPECT_TRUE(snap_phantom_window_controller()); 1501 EXPECT_TRUE(snap_phantom_window_controller());
1501 resizer->RevertDrag(); 1502 resizer->RevertDrag();
1502 } 1503 }
1503 { 1504 {
1504 // With max size defined, we get no phantom window for snapping. 1505 // With max size defined, we get no phantom window for snapping.
1505 window_->SetBounds(gfx::Rect(0, 0, 400, 200)); 1506 window_->SetBounds(gfx::Rect(0, 0, 400, 200));
1506 delegate_.set_max_size(gfx::Size(400, 200)); 1507 delegate_.set_max_size(gfx::Size(400, 200));
1507 // With min size defined, we get no phantom window for docking. 1508 // With min size defined, we get no phantom window for docking.
1508 delegate_.set_min_size(gfx::Size(400, 200)); 1509 delegate_.set_min_size(gfx::Size(400, 200));
1509 1510
1510 scoped_ptr<WindowResizer> resizer(CreateResizerForTest( 1511 std::unique_ptr<WindowResizer> resizer(
1511 window_.get(), gfx::Point(), HTCAPTION)); 1512 CreateResizerForTest(window_.get(), gfx::Point(), HTCAPTION));
1512 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0); 1513 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
1513 EXPECT_FALSE(snap_phantom_window_controller()); 1514 EXPECT_FALSE(snap_phantom_window_controller());
1514 resizer->RevertDrag(); 1515 resizer->RevertDrag();
1515 } 1516 }
1516 } 1517 }
1517 1518
1518 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) { 1519 TEST_F(WorkspaceWindowResizerTest, DontRewardRightmostWindowForOverflows) {
1519 UpdateDisplay("600x800"); 1520 UpdateDisplay("600x800");
1520 aura::Window* root = Shell::GetPrimaryRootWindow(); 1521 aura::Window* root = Shell::GetPrimaryRootWindow();
1521 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); 1522 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
1522 1523
1523 // Four 100x100 windows flush against eachother, starting at 100,100. 1524 // Four 100x100 windows flush against eachother, starting at 100,100.
1524 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); 1525 window_->SetBounds(gfx::Rect( 100, 100, 100, 100));
1525 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); 1526 window2_->SetBounds(gfx::Rect(200, 100, 100, 100));
1526 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); 1527 window3_->SetBounds(gfx::Rect(300, 100, 100, 100));
1527 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); 1528 window4_->SetBounds(gfx::Rect(400, 100, 100, 100));
1528 delegate2_.set_max_size(gfx::Size(101, 0)); 1529 delegate2_.set_max_size(gfx::Size(101, 0));
1529 1530
1530 std::vector<aura::Window*> windows; 1531 std::vector<aura::Window*> windows;
1531 windows.push_back(window2_.get()); 1532 windows.push_back(window2_.get());
1532 windows.push_back(window3_.get()); 1533 windows.push_back(window3_.get());
1533 windows.push_back(window4_.get()); 1534 windows.push_back(window4_.get());
1534 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 1535 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
1535 window_.get(), gfx::Point(), HTRIGHT, 1536 window_.get(), gfx::Point(), HTRIGHT,
1536 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 1537 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
1537 ASSERT_TRUE(resizer.get()); 1538 ASSERT_TRUE(resizer.get());
1538 // Move it 51 to the left, which should contract w1 and expand w2-4. 1539 // Move it 51 to the left, which should contract w1 and expand w2-4.
1539 // w2 will hit its max size straight away, and in doing so will leave extra 1540 // w2 will hit its max size straight away, and in doing so will leave extra
1540 // pixels that a naive implementation may award to the rightmost window. A 1541 // pixels that a naive implementation may award to the rightmost window. A
1541 // fair implementation will give 25 pixels to each of the other windows. 1542 // fair implementation will give 25 pixels to each of the other windows.
1542 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); 1543 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0);
1543 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); 1544 EXPECT_EQ("100,100 49x100", window_->bounds().ToString());
1544 EXPECT_EQ("149,100 101x100", window2_->bounds().ToString()); 1545 EXPECT_EQ("149,100 101x100", window2_->bounds().ToString());
(...skipping 11 matching lines...) Expand all
1556 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); 1557 window2_->SetBounds(gfx::Rect(200, 100, 100, 100));
1557 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); 1558 window3_->SetBounds(gfx::Rect(300, 100, 100, 100));
1558 window4_->SetBounds(gfx::Rect(400, 100, 100, 100)); 1559 window4_->SetBounds(gfx::Rect(400, 100, 100, 100));
1559 delegate2_.set_max_size(gfx::Size(101, 0)); 1560 delegate2_.set_max_size(gfx::Size(101, 0));
1560 delegate3_.set_max_size(gfx::Size(101, 0)); 1561 delegate3_.set_max_size(gfx::Size(101, 0));
1561 1562
1562 std::vector<aura::Window*> windows; 1563 std::vector<aura::Window*> windows;
1563 windows.push_back(window2_.get()); 1564 windows.push_back(window2_.get());
1564 windows.push_back(window3_.get()); 1565 windows.push_back(window3_.get());
1565 windows.push_back(window4_.get()); 1566 windows.push_back(window4_.get());
1566 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 1567 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
1567 window_.get(), gfx::Point(), HTRIGHT, 1568 window_.get(), gfx::Point(), HTRIGHT,
1568 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 1569 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
1569 ASSERT_TRUE(resizer.get()); 1570 ASSERT_TRUE(resizer.get());
1570 // Move it 52 to the left, which should contract w1 and expand w2-4. 1571 // Move it 52 to the left, which should contract w1 and expand w2-4.
1571 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); 1572 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0);
1572 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); 1573 EXPECT_EQ("100,100 48x100", window_->bounds().ToString());
1573 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); 1574 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString());
1574 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); 1575 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString());
1575 EXPECT_EQ("350,100 150x100", window4_->bounds().ToString()); 1576 EXPECT_EQ("350,100 150x100", window4_->bounds().ToString());
1576 } 1577 }
1577 1578
1578 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxHeight) { 1579 TEST_F(WorkspaceWindowResizerTest, DontExceedMaxHeight) {
1579 UpdateDisplay("600x800"); 1580 UpdateDisplay("600x800");
1580 aura::Window* root = Shell::GetPrimaryRootWindow(); 1581 aura::Window* root = Shell::GetPrimaryRootWindow();
1581 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); 1582 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
1582 1583
1583 // Four 100x100 windows flush against eachother, starting at 100,100. 1584 // Four 100x100 windows flush against eachother, starting at 100,100.
1584 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); 1585 window_->SetBounds(gfx::Rect( 100, 100, 100, 100));
1585 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); 1586 window2_->SetBounds(gfx::Rect(100, 200, 100, 100));
1586 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); 1587 window3_->SetBounds(gfx::Rect(100, 300, 100, 100));
1587 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); 1588 window4_->SetBounds(gfx::Rect(100, 400, 100, 100));
1588 delegate2_.set_max_size(gfx::Size(0, 101)); 1589 delegate2_.set_max_size(gfx::Size(0, 101));
1589 delegate3_.set_max_size(gfx::Size(0, 101)); 1590 delegate3_.set_max_size(gfx::Size(0, 101));
1590 1591
1591 std::vector<aura::Window*> windows; 1592 std::vector<aura::Window*> windows;
1592 windows.push_back(window2_.get()); 1593 windows.push_back(window2_.get());
1593 windows.push_back(window3_.get()); 1594 windows.push_back(window3_.get());
1594 windows.push_back(window4_.get()); 1595 windows.push_back(window4_.get());
1595 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 1596 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
1596 window_.get(), gfx::Point(), HTBOTTOM, 1597 window_.get(), gfx::Point(), HTBOTTOM,
1597 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 1598 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
1598 ASSERT_TRUE(resizer.get()); 1599 ASSERT_TRUE(resizer.get());
1599 // Move it 52 up, which should contract w1 and expand w2-4. 1600 // Move it 52 up, which should contract w1 and expand w2-4.
1600 resizer->Drag(CalculateDragPoint(*resizer, 0, -52), 0); 1601 resizer->Drag(CalculateDragPoint(*resizer, 0, -52), 0);
1601 EXPECT_EQ("100,100 100x48", window_->bounds().ToString()); 1602 EXPECT_EQ("100,100 100x48", window_->bounds().ToString());
1602 EXPECT_EQ("100,148 100x101", window2_->bounds().ToString()); 1603 EXPECT_EQ("100,148 100x101", window2_->bounds().ToString());
1603 EXPECT_EQ("100,249 100x101", window3_->bounds().ToString()); 1604 EXPECT_EQ("100,249 100x101", window3_->bounds().ToString());
1604 EXPECT_EQ("100,350 100x150", window4_->bounds().ToString()); 1605 EXPECT_EQ("100,350 100x150", window4_->bounds().ToString());
1605 } 1606 }
(...skipping 15 matching lines...) Expand all
1621 window2_->SetBounds(gfx::Rect(100, 200, 100, 100)); 1622 window2_->SetBounds(gfx::Rect(100, 200, 100, 100));
1622 window3_->SetBounds(gfx::Rect(100, 300, 100, 100)); 1623 window3_->SetBounds(gfx::Rect(100, 300, 100, 100));
1623 window4_->SetBounds(gfx::Rect(100, 400, 100, 100)); 1624 window4_->SetBounds(gfx::Rect(100, 400, 100, 100));
1624 delegate2_.set_min_size(gfx::Size(0, 99)); 1625 delegate2_.set_min_size(gfx::Size(0, 99));
1625 delegate3_.set_min_size(gfx::Size(0, 99)); 1626 delegate3_.set_min_size(gfx::Size(0, 99));
1626 1627
1627 std::vector<aura::Window*> windows; 1628 std::vector<aura::Window*> windows;
1628 windows.push_back(window2_.get()); 1629 windows.push_back(window2_.get());
1629 windows.push_back(window3_.get()); 1630 windows.push_back(window3_.get());
1630 windows.push_back(window4_.get()); 1631 windows.push_back(window4_.get());
1631 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 1632 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
1632 window_.get(), gfx::Point(), HTBOTTOM, 1633 window_.get(), gfx::Point(), HTBOTTOM,
1633 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 1634 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
1634 ASSERT_TRUE(resizer.get()); 1635 ASSERT_TRUE(resizer.get());
1635 // Move it 52 down, which should expand w1 and contract w2-4. 1636 // Move it 52 down, which should expand w1 and contract w2-4.
1636 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0); 1637 resizer->Drag(CalculateDragPoint(*resizer, 0, 52), 0);
1637 EXPECT_EQ("100,100 100x152", window_->bounds().ToString()); 1638 EXPECT_EQ("100,100 100x152", window_->bounds().ToString());
1638 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString()); 1639 EXPECT_EQ("100,252 100x99", window2_->bounds().ToString());
1639 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString()); 1640 EXPECT_EQ("100,351 100x99", window3_->bounds().ToString());
1640 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString()); 1641 EXPECT_EQ("100,450 100x50", window4_->bounds().ToString());
1641 } 1642 }
1642 1643
1643 TEST_F(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) { 1644 TEST_F(WorkspaceWindowResizerTest, DontExpandRightmostPastMaxWidth) {
1644 UpdateDisplay("600x800"); 1645 UpdateDisplay("600x800");
1645 aura::Window* root = Shell::GetPrimaryRootWindow(); 1646 aura::Window* root = Shell::GetPrimaryRootWindow();
1646 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); 1647 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
1647 1648
1648 // Three 100x100 windows flush against eachother, starting at 100,100. 1649 // Three 100x100 windows flush against eachother, starting at 100,100.
1649 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); 1650 window_->SetBounds(gfx::Rect( 100, 100, 100, 100));
1650 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); 1651 window2_->SetBounds(gfx::Rect(200, 100, 100, 100));
1651 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); 1652 window3_->SetBounds(gfx::Rect(300, 100, 100, 100));
1652 delegate3_.set_max_size(gfx::Size(101, 0)); 1653 delegate3_.set_max_size(gfx::Size(101, 0));
1653 1654
1654 std::vector<aura::Window*> windows; 1655 std::vector<aura::Window*> windows;
1655 windows.push_back(window2_.get()); 1656 windows.push_back(window2_.get());
1656 windows.push_back(window3_.get()); 1657 windows.push_back(window3_.get());
1657 windows.push_back(window4_.get()); 1658 windows.push_back(window4_.get());
1658 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 1659 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
1659 window_.get(), gfx::Point(), HTRIGHT, 1660 window_.get(), gfx::Point(), HTRIGHT,
1660 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 1661 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
1661 ASSERT_TRUE(resizer.get()); 1662 ASSERT_TRUE(resizer.get());
1662 // Move it 51 to the left, which should contract w1 and expand w2-3. 1663 // Move it 51 to the left, which should contract w1 and expand w2-3.
1663 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0); 1664 resizer->Drag(CalculateDragPoint(*resizer, -51, 0), 0);
1664 EXPECT_EQ("100,100 49x100", window_->bounds().ToString()); 1665 EXPECT_EQ("100,100 49x100", window_->bounds().ToString());
1665 EXPECT_EQ("149,100 150x100", window2_->bounds().ToString()); 1666 EXPECT_EQ("149,100 150x100", window2_->bounds().ToString());
1666 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); 1667 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString());
1667 } 1668 }
1668 1669
1669 TEST_F(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) { 1670 TEST_F(WorkspaceWindowResizerTest, MoveAttachedWhenGrownToMaxSize) {
1670 UpdateDisplay("600x800"); 1671 UpdateDisplay("600x800");
1671 aura::Window* root = Shell::GetPrimaryRootWindow(); 1672 aura::Window* root = Shell::GetPrimaryRootWindow();
1672 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); 1673 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
1673 1674
1674 // Three 100x100 windows flush against eachother, starting at 100,100. 1675 // Three 100x100 windows flush against eachother, starting at 100,100.
1675 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); 1676 window_->SetBounds(gfx::Rect( 100, 100, 100, 100));
1676 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); 1677 window2_->SetBounds(gfx::Rect(200, 100, 100, 100));
1677 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); 1678 window3_->SetBounds(gfx::Rect(300, 100, 100, 100));
1678 delegate2_.set_max_size(gfx::Size(101, 0)); 1679 delegate2_.set_max_size(gfx::Size(101, 0));
1679 delegate3_.set_max_size(gfx::Size(101, 0)); 1680 delegate3_.set_max_size(gfx::Size(101, 0));
1680 1681
1681 std::vector<aura::Window*> windows; 1682 std::vector<aura::Window*> windows;
1682 windows.push_back(window2_.get()); 1683 windows.push_back(window2_.get());
1683 windows.push_back(window3_.get()); 1684 windows.push_back(window3_.get());
1684 windows.push_back(window4_.get()); 1685 windows.push_back(window4_.get());
1685 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 1686 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
1686 window_.get(), gfx::Point(), HTRIGHT, 1687 window_.get(), gfx::Point(), HTRIGHT,
1687 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 1688 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
1688 ASSERT_TRUE(resizer.get()); 1689 ASSERT_TRUE(resizer.get());
1689 // Move it 52 to the left, which should contract w1 and expand and move w2-3. 1690 // Move it 52 to the left, which should contract w1 and expand and move w2-3.
1690 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0); 1691 resizer->Drag(CalculateDragPoint(*resizer, -52, 0), 0);
1691 EXPECT_EQ("100,100 48x100", window_->bounds().ToString()); 1692 EXPECT_EQ("100,100 48x100", window_->bounds().ToString());
1692 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString()); 1693 EXPECT_EQ("148,100 101x100", window2_->bounds().ToString());
1693 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString()); 1694 EXPECT_EQ("249,100 101x100", window3_->bounds().ToString());
1694 } 1695 }
1695 1696
(...skipping 12 matching lines...) Expand all
1708 // Three 100x100 windows flush against eachother, starting at 100,100. 1709 // Three 100x100 windows flush against eachother, starting at 100,100.
1709 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); 1710 window_->SetBounds(gfx::Rect( 100, 100, 100, 100));
1710 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); 1711 window2_->SetBounds(gfx::Rect(200, 100, 100, 100));
1711 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); 1712 window3_->SetBounds(gfx::Rect(300, 100, 100, 100));
1712 delegate_.set_max_size(gfx::Size(102, 0)); 1713 delegate_.set_max_size(gfx::Size(102, 0));
1713 1714
1714 std::vector<aura::Window*> windows; 1715 std::vector<aura::Window*> windows;
1715 windows.push_back(window2_.get()); 1716 windows.push_back(window2_.get());
1716 windows.push_back(window3_.get()); 1717 windows.push_back(window3_.get());
1717 windows.push_back(window4_.get()); 1718 windows.push_back(window4_.get());
1718 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 1719 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
1719 window_.get(), gfx::Point(), HTRIGHT, 1720 window_.get(), gfx::Point(), HTRIGHT,
1720 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 1721 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
1721 ASSERT_TRUE(resizer.get()); 1722 ASSERT_TRUE(resizer.get());
1722 // Move it 50 to the right, which should expand w1 and contract w2-3, as they 1723 // Move it 50 to the right, which should expand w1 and contract w2-3, as they
1723 // won't fit in the root window in their original sizes. 1724 // won't fit in the root window in their original sizes.
1724 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0); 1725 resizer->Drag(CalculateDragPoint(*resizer, 50, 0), 0);
1725 EXPECT_EQ("100,100 102x100", window_->bounds().ToString()); 1726 EXPECT_EQ("100,100 102x100", window_->bounds().ToString());
1726 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString()); 1727 EXPECT_EQ("202,100 99x100", window2_->bounds().ToString());
1727 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString()); 1728 EXPECT_EQ("301,100 99x100", window3_->bounds().ToString());
1728 } 1729 }
1729 1730
1730 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) { 1731 TEST_F(WorkspaceWindowResizerTest, MainWindowHonoursMinWidth) {
1731 UpdateDisplay("400x800"); 1732 UpdateDisplay("400x800");
1732 aura::Window* root = Shell::GetPrimaryRootWindow(); 1733 aura::Window* root = Shell::GetPrimaryRootWindow();
1733 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); 1734 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
1734 1735
1735 // Three 100x100 windows flush against eachother, starting at 100,100. 1736 // Three 100x100 windows flush against eachother, starting at 100,100.
1736 window_->SetBounds(gfx::Rect( 100, 100, 100, 100)); 1737 window_->SetBounds(gfx::Rect( 100, 100, 100, 100));
1737 window2_->SetBounds(gfx::Rect(200, 100, 100, 100)); 1738 window2_->SetBounds(gfx::Rect(200, 100, 100, 100));
1738 window3_->SetBounds(gfx::Rect(300, 100, 100, 100)); 1739 window3_->SetBounds(gfx::Rect(300, 100, 100, 100));
1739 delegate_.set_min_size(gfx::Size(98, 0)); 1740 delegate_.set_min_size(gfx::Size(98, 0));
1740 1741
1741 std::vector<aura::Window*> windows; 1742 std::vector<aura::Window*> windows;
1742 windows.push_back(window2_.get()); 1743 windows.push_back(window2_.get());
1743 windows.push_back(window3_.get()); 1744 windows.push_back(window3_.get());
1744 scoped_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest( 1745 std::unique_ptr<WorkspaceWindowResizer> resizer(CreateWorkspaceResizerForTest(
1745 window_.get(), gfx::Point(), HTRIGHT, 1746 window_.get(), gfx::Point(), HTRIGHT,
1746 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows)); 1747 aura::client::WINDOW_MOVE_SOURCE_MOUSE, windows));
1747 ASSERT_TRUE(resizer.get()); 1748 ASSERT_TRUE(resizer.get());
1748 // Move it 50 to the left, which should contract w1 and expand w2-3. 1749 // Move it 50 to the left, which should contract w1 and expand w2-3.
1749 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0); 1750 resizer->Drag(CalculateDragPoint(*resizer, -50, 0), 0);
1750 EXPECT_EQ("100,100 98x100", window_->bounds().ToString()); 1751 EXPECT_EQ("100,100 98x100", window_->bounds().ToString());
1751 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString()); 1752 EXPECT_EQ("198,100 101x100", window2_->bounds().ToString());
1752 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString()); 1753 EXPECT_EQ("299,100 101x100", window3_->bounds().ToString());
1753 } 1754 }
1754 1755
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 // Drag even more to snap to the edge. 1885 // Drag even more to snap to the edge.
1885 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40), 1886 generator.GestureScrollSequence(gfx::Point(400, kRootHeight - 40),
1886 gfx::Point(400, kRootHeight - 25), 1887 gfx::Point(400, kRootHeight - 25),
1887 base::TimeDelta::FromMilliseconds(10), 1888 base::TimeDelta::FromMilliseconds(10),
1888 5); 1889 5);
1889 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(), 1890 EXPECT_EQ(gfx::Rect(100, 100, 600, kRootHeight - 100).ToString(),
1890 touch_resize_window_->bounds().ToString()); 1891 touch_resize_window_->bounds().ToString());
1891 } 1892 }
1892 1893
1893 } // namespace ash 1894 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer.cc ('k') | ash/wm/workspace_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698