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

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

Issue 11366215: Prevents windows in chromeos from resizing bigger than their maximum size. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 8 years, 1 month 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/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/display/mouse_cursor_event_filter.h" 8 #include "ash/display/mouse_cursor_event_filter.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/screen_ash.h" 10 #include "ash/screen_ash.h"
(...skipping 28 matching lines...) Expand all
39 class TestWindowDelegate : public aura::test::TestWindowDelegate { 39 class TestWindowDelegate : public aura::test::TestWindowDelegate {
40 public: 40 public:
41 TestWindowDelegate() { 41 TestWindowDelegate() {
42 } 42 }
43 virtual ~TestWindowDelegate() {} 43 virtual ~TestWindowDelegate() {}
44 44
45 void set_min_size(const gfx::Size& size) { 45 void set_min_size(const gfx::Size& size) {
46 min_size_ = size; 46 min_size_ = size;
47 } 47 }
48 48
49 void set_max_size(const gfx::Size& size) {
50 max_size_ = size;
51 }
52
49 private: 53 private:
50 // Overridden from aura::Test::TestWindowDelegate: 54 // Overridden from aura::Test::TestWindowDelegate:
51 virtual gfx::Size GetMinimumSize() const OVERRIDE { 55 virtual gfx::Size GetMinimumSize() const OVERRIDE {
52 return min_size_; 56 return min_size_;
53 } 57 }
54 58
59 virtual gfx::Size GetMaximumSize() const OVERRIDE {
60 return max_size_;
61 }
62
55 gfx::Size min_size_; 63 gfx::Size min_size_;
64 gfx::Size max_size_;
56 65
57 DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate); 66 DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate);
58 }; 67 };
59 68
60 class WorkspaceWindowResizerTest : public test::AshTestBase { 69 class WorkspaceWindowResizerTest : public test::AshTestBase {
61 public: 70 public:
62 WorkspaceWindowResizerTest() : window_(NULL) {} 71 WorkspaceWindowResizerTest() : window_(NULL) {}
63 virtual ~WorkspaceWindowResizerTest() {} 72 virtual ~WorkspaceWindowResizerTest() {}
64 73
65 virtual void SetUp() OVERRIDE { 74 virtual void SetUp() OVERRIDE {
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 window_.get(), gfx::Point(), HTCAPTION, no_attached_windows)); 1467 window_.get(), gfx::Point(), HTCAPTION, no_attached_windows));
1459 ASSERT_TRUE(resizer.get()); 1468 ASSERT_TRUE(resizer.get());
1460 // Move it 100 to the bottom. 1469 // Move it 100 to the bottom.
1461 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0); 1470 resizer->Drag(CalculateDragPoint(*resizer, 0, 100), 0);
1462 EXPECT_EQ("0,150 400x200", window_->bounds().ToString()); 1471 EXPECT_EQ("0,150 400x200", window_->bounds().ToString());
1463 resizer->CompleteDrag(0); 1472 resizer->CompleteDrag(0);
1464 EXPECT_TRUE(ash::wm::HasUserChangedWindowPositionOrSize(window_.get())); 1473 EXPECT_TRUE(ash::wm::HasUserChangedWindowPositionOrSize(window_.get()));
1465 } 1474 }
1466 } 1475 }
1467 1476
1477 // Test that a window with a specified max size doesn't exceed it when dragged.
1478 TEST_F(WorkspaceWindowResizerTest, TestMaxSizeEnforced) {
1479 window_->SetBounds(gfx::Rect(0, 0, 400, 300));
1480 delegate_.set_max_size(gfx::Size(401, 301));
1481
1482 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
1483 window_.get(), gfx::Point(), HTBOTTOMRIGHT, empty_windows()));
1484 resizer->Drag(CalculateDragPoint(*resizer, 2, 2), 0);
1485 EXPECT_EQ(401, window_->bounds().width());
1486 EXPECT_EQ(301, window_->bounds().height());
1487 }
1488
1489 // Test that a window with a specified max size can't be snapped.
1490 TEST_F(WorkspaceWindowResizerTest, PhantomSnapMaxSize) {
1491 {
1492 // With max size not set we get a phantom window controller for dragging off
1493 // the right hand side.
1494 window_->SetBounds(gfx::Rect(0, 0, 300, 200));
1495
1496 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
1497 window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
1498 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get());
1499 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
1500 EXPECT_TRUE(resizer->snap_phantom_window_controller_.get());
1501 }
1502 {
1503 // With max size defined, we get no phantom window.
1504 window_->SetBounds(gfx::Rect(0, 0, 300, 200));
1505 delegate_.set_max_size(gfx::Size(300, 200));
1506
1507 scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
1508 window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
1509 resizer->Drag(CalculateDragPoint(*resizer, 801, 0), 0);
1510 EXPECT_FALSE(resizer->snap_phantom_window_controller_.get());
1511 }
1512 }
1513
1468 } // namespace internal 1514 } // namespace internal
1469 } // namespace ash 1515 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698