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

Side by Side Diff: ash/wm/workspace/workspace_window_resizer_unittest.cc

Issue 10675011: Rename the remaining usage of Monitor to Display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 5 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 | Annotate | Revision Log
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/screen_ash.h" 7 #include "ash/screen_ash.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/property_util.h" 10 #include "ash/wm/property_util.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 WorkspaceWindowResizerTest() : window_(NULL) {} 48 WorkspaceWindowResizerTest() : window_(NULL) {}
49 virtual ~WorkspaceWindowResizerTest() {} 49 virtual ~WorkspaceWindowResizerTest() {}
50 50
51 virtual void SetUp() OVERRIDE { 51 virtual void SetUp() OVERRIDE {
52 AshTestBase::SetUp(); 52 AshTestBase::SetUp();
53 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); 53 aura::RootWindow* root = Shell::GetPrimaryRootWindow();
54 root->SetHostSize(gfx::Size(800, kRootHeight)); 54 root->SetHostSize(gfx::Size(800, kRootHeight));
55 55
56 gfx::Rect root_bounds(root->bounds()); 56 gfx::Rect root_bounds(root->bounds());
57 EXPECT_EQ(kRootHeight, root_bounds.height()); 57 EXPECT_EQ(kRootHeight, root_bounds.height());
58 Shell::GetInstance()->SetMonitorWorkAreaInsets(root, gfx::Insets()); 58 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
59 window_.reset(new aura::Window(&delegate_)); 59 window_.reset(new aura::Window(&delegate_));
60 window_->Init(ui::LAYER_NOT_DRAWN); 60 window_->Init(ui::LAYER_NOT_DRAWN);
61 window_->SetParent(root); 61 window_->SetParent(root);
62 window_->set_id(1); 62 window_->set_id(1);
63 63
64 window2_.reset(new aura::Window(&delegate2_)); 64 window2_.reset(new aura::Window(&delegate2_));
65 window2_->Init(ui::LAYER_NOT_DRAWN); 65 window2_->Init(ui::LAYER_NOT_DRAWN);
66 window2_->SetParent(root); 66 window2_->SetParent(root);
67 window2_->set_id(2); 67 window2_->set_id(2);
68 68
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // Revert and make sure everything moves back. 340 // Revert and make sure everything moves back.
341 resizer->Drag(CalculateDragPoint(*resizer, 800, 20), 0); 341 resizer->Drag(CalculateDragPoint(*resizer, 800, 20), 0);
342 resizer->RevertDrag(); 342 resizer->RevertDrag();
343 EXPECT_EQ("0,50 400x200", window_->bounds().ToString()); 343 EXPECT_EQ("0,50 400x200", window_->bounds().ToString());
344 EXPECT_EQ("0,250 200x100", window2_->bounds().ToString()); 344 EXPECT_EQ("0,250 200x100", window2_->bounds().ToString());
345 } 345 }
346 346
347 // Assertions around attached window resize dragging from the bottom with 3 347 // Assertions around attached window resize dragging from the bottom with 3
348 // windows. 348 // windows.
349 // TODO(oshima): Host window doesn't get a resize event after 349 // TODO(oshima): Host window doesn't get a resize event after
350 // SetHostSize on Windows trybot, which gives wrong work/monitor area. 350 // SetHostSize on Windows trybot, which gives wrong work/display area.
351 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3) { 351 TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3) {
352 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); 352 aura::RootWindow* root = Shell::GetPrimaryRootWindow();
353 root->SetHostSize(gfx::Size(600, 800)); 353 root->SetHostSize(gfx::Size(600, 800));
354 LOG(ERROR) << "=== Calling OnHostResized, 600x800"; 354 LOG(ERROR) << "=== Calling OnHostResized, 600x800";
355 355
356 Shell::GetInstance()->SetMonitorWorkAreaInsets(root, gfx::Insets()); 356 Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets());
357 357
358 window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); 358 window_->SetBounds(gfx::Rect( 300, 100, 300, 200));
359 window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); 359 window2_->SetBounds(gfx::Rect(300, 300, 200, 150));
360 window3_->SetBounds(gfx::Rect(300, 450, 200, 100)); 360 window3_->SetBounds(gfx::Rect(300, 450, 200, 100));
361 delegate2_.set_min_size(gfx::Size(50, 52)); 361 delegate2_.set_min_size(gfx::Size(50, 52));
362 delegate3_.set_min_size(gfx::Size(50, 38)); 362 delegate3_.set_min_size(gfx::Size(50, 38));
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 windows.push_back(window3_.get()); 366 windows.push_back(window3_.get());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 // Move it 100 to the right, which should expand w1 and push w2 and w3. 489 // Move it 100 to the right, which should expand w1 and push w2 and w3.
490 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0); 490 resizer->Drag(CalculateDragPoint(*resizer, 100, -10), 0);
491 491
492 // 2 should be topmost since it's initially the highest in the stack. 492 // 2 should be topmost since it's initially the highest in the stack.
493 EXPECT_EQ("2 3 1", WindowOrderAsString()); 493 EXPECT_EQ("2 3 1", WindowOrderAsString());
494 } 494 }
495 } 495 }
496 496
497 // Makes sure we don't allow dragging below the work area. 497 // Makes sure we don't allow dragging below the work area.
498 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) { 498 TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) {
499 Shell::GetInstance()->SetMonitorWorkAreaInsets( 499 Shell::GetInstance()->SetDisplayWorkAreaInsets(
500 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); 500 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0));
501 501
502 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); 502 window_->SetBounds(gfx::Rect(100, 200, 300, 400));
503 SetGridSize(0); 503 SetGridSize(0);
504 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 504 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
505 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); 505 window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
506 ASSERT_TRUE(resizer.get()); 506 ASSERT_TRUE(resizer.get());
507 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0); 507 resizer->Drag(CalculateDragPoint(*resizer, 0, 600), 0);
508 int expected_y = 508 int expected_y =
509 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10; 509 kRootHeight - WorkspaceWindowResizer::kMinOnscreenHeight - 10;
510 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400", 510 EXPECT_EQ("100," + base::IntToString(expected_y) + " 300x400",
511 window_->bounds().ToString()); 511 window_->bounds().ToString());
512 } 512 }
513 513
514 // Makes sure we don't allow dragging off the top of the work area. 514 // Makes sure we don't allow dragging off the top of the work area.
515 TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) { 515 TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) {
516 Shell::GetInstance()->SetMonitorWorkAreaInsets( 516 Shell::GetInstance()->SetDisplayWorkAreaInsets(
517 Shell::GetPrimaryRootWindow(), gfx::Insets(10, 0, 0, 0)); 517 Shell::GetPrimaryRootWindow(), gfx::Insets(10, 0, 0, 0));
518 518
519 window_->SetBounds(gfx::Rect(100, 200, 300, 400)); 519 window_->SetBounds(gfx::Rect(100, 200, 300, 400));
520 SetGridSize(0); 520 SetGridSize(0);
521 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 521 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
522 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); 522 window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
523 ASSERT_TRUE(resizer.get()); 523 ASSERT_TRUE(resizer.get());
524 resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0); 524 resizer->Drag(CalculateDragPoint(*resizer, 0, -600), 0);
525 EXPECT_EQ("100,10 300x400", window_->bounds().ToString()); 525 EXPECT_EQ("100,10 300x400", window_->bounds().ToString());
526 } 526 }
527 527
528 TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) { 528 TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) {
529 Shell::GetInstance()->SetMonitorWorkAreaInsets( 529 Shell::GetInstance()->SetDisplayWorkAreaInsets(
530 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); 530 Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0));
531 531
532 window_->SetBounds(gfx::Rect(100, 200, 300, 380)); 532 window_->SetBounds(gfx::Rect(100, 200, 300, 380));
533 SetGridSize(10); 533 SetGridSize(10);
534 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 534 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
535 window_.get(), gfx::Point(), HTTOP, empty_windows())); 535 window_.get(), gfx::Point(), HTTOP, empty_windows()));
536 ASSERT_TRUE(resizer.get()); 536 ASSERT_TRUE(resizer.get());
537 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0); 537 resizer->Drag(CalculateDragPoint(*resizer, 8, 0), 0);
538 EXPECT_EQ("100,200 300x380", window_->bounds().ToString()); 538 EXPECT_EQ("100,200 300x380", window_->bounds().ToString());
539 } 539 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 EXPECT_EQ("96,20 320x160", window_->bounds().ToString()); 588 EXPECT_EQ("96,20 320x160", window_->bounds().ToString());
589 resizer->Drag(CalculateDragPoint(*resizer, 0, -112 + 7), 0); 589 resizer->Drag(CalculateDragPoint(*resizer, 0, -112 + 7), 0);
590 EXPECT_EQ("96,0 320x160", window_->bounds().ToString()); 590 EXPECT_EQ("96,0 320x160", window_->bounds().ToString());
591 // No need to test dragging < 0 as we force that to 0. 591 // No need to test dragging < 0 as we force that to 0.
592 } 592 }
593 593
594 // Verifies a window taller than work area height doesn't snap above the top of 594 // Verifies a window taller than work area height doesn't snap above the top of
595 // the work area. 595 // the work area.
596 TEST_F(WorkspaceWindowResizerTest, TallWindow) { 596 TEST_F(WorkspaceWindowResizerTest, TallWindow) {
597 aura::RootWindow* root = Shell::GetPrimaryRootWindow(); 597 aura::RootWindow* root = Shell::GetPrimaryRootWindow();
598 Shell::GetInstance()->SetMonitorWorkAreaInsets( 598 Shell::GetInstance()->SetDisplayWorkAreaInsets(
599 root, gfx::Insets(0, 0, 50, 0)); 599 root, gfx::Insets(0, 0, 50, 0));
600 window_->SetBounds(gfx::Rect(0, 0, 320, 560)); 600 window_->SetBounds(gfx::Rect(0, 0, 320, 560));
601 SetGridSize(16); 601 SetGridSize(16);
602 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create( 602 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
603 window_.get(), gfx::Point(), HTCAPTION, empty_windows())); 603 window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
604 resizer->Drag(CalculateDragPoint(*resizer, 0, 9), 0); 604 resizer->Drag(CalculateDragPoint(*resizer, 0, 9), 0);
605 EXPECT_EQ("0,9 320x560", window_->bounds().ToString()); 605 EXPECT_EQ("0,9 320x560", window_->bounds().ToString());
606 } 606 }
607 607
608 TEST_F(WorkspaceWindowResizerTest, DragResizeSnapToGrid) { 608 TEST_F(WorkspaceWindowResizerTest, DragResizeSnapToGrid) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), 0); 653 resizer->Drag(CalculateDragPoint(*resizer, 10, 12), 0);
654 resizer->CompleteDrag(ui::EF_CONTROL_DOWN); 654 resizer->CompleteDrag(ui::EF_CONTROL_DOWN);
655 EXPECT_EQ("106,124 320x160", window_->bounds().ToString()); 655 EXPECT_EQ("106,124 320x160", window_->bounds().ToString());
656 } 656 }
657 657
658 #endif 658 #endif
659 659
660 } // namespace 660 } // namespace
661 } // namespace test 661 } // namespace test
662 } // namespace ash 662 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer.cc ('k') | chrome/browser/chromeos/power/output_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698