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

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

Issue 11293014: Renames Workspace*2 -> Workspace*. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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_layout_manager2.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.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"
11 #include "ash/wm/shelf_layout_manager.h" 11 #include "ash/wm/shelf_layout_manager.h"
12 #include "ash/wm/window_util.h" 12 #include "ash/wm/window_util.h"
13 #include "ui/aura/root_window.h" 13 #include "ui/aura/root_window.h"
14 #include "ui/aura/test/test_windows.h" 14 #include "ui/aura/test/test_windows.h"
15 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
16 #include "ui/gfx/insets.h" 16 #include "ui/gfx/insets.h"
17 17
18 namespace ash { 18 namespace ash {
19 19
20 namespace { 20 namespace {
21 21
22 class WorkspaceLayoutManager2Test : public test::AshTestBase { 22 class WorkspaceLayoutManagerTest : public test::AshTestBase {
23 public: 23 public:
24 WorkspaceLayoutManager2Test() {} 24 WorkspaceLayoutManagerTest() {}
25 virtual ~WorkspaceLayoutManager2Test() {} 25 virtual ~WorkspaceLayoutManagerTest() {}
26 26
27 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { 27 aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
28 return aura::test::CreateTestWindowWithBounds(bounds, NULL); 28 return aura::test::CreateTestWindowWithBounds(bounds, NULL);
29 } 29 }
30 30
31 private: 31 private:
32 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager2Test); 32 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerTest);
33 }; 33 };
34 34
35 // Verifies that a window containing a restore coordinate will be restored to 35 // Verifies that a window containing a restore coordinate will be restored to
36 // to the size prior to minimize, keeping the restore rectangle in tact (if 36 // to the size prior to minimize, keeping the restore rectangle in tact (if
37 // there is one). 37 // there is one).
38 TEST_F(WorkspaceLayoutManager2Test, RestoreFromMinimizeKeepsRestore) { 38 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) {
39 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4))); 39 scoped_ptr<aura::Window> window(CreateTestWindow(gfx::Rect(1, 2, 3, 4)));
40 gfx::Rect bounds(10, 15, 25, 35); 40 gfx::Rect bounds(10, 15, 25, 35);
41 window->SetBounds(bounds); 41 window->SetBounds(bounds);
42 SetRestoreBoundsInScreen(window.get(), gfx::Rect(0, 0, 100, 100)); 42 SetRestoreBoundsInScreen(window.get(), gfx::Rect(0, 0, 100, 100));
43 wm::MinimizeWindow(window.get()); 43 wm::MinimizeWindow(window.get());
44 wm::RestoreWindow(window.get()); 44 wm::RestoreWindow(window.get());
45 EXPECT_EQ("0,0 100x100", GetRestoreBoundsInScreen(window.get())->ToString()); 45 EXPECT_EQ("0,0 100x100", GetRestoreBoundsInScreen(window.get())->ToString());
46 EXPECT_EQ("10,15 25x35", window.get()->bounds().ToString()); 46 EXPECT_EQ("10,15 25x35", window.get()->bounds().ToString());
47 } 47 }
48 48
(...skipping 27 matching lines...) Expand all
76 76
77 private: 77 private:
78 aura::Window* window_; 78 aura::Window* window_;
79 79
80 DISALLOW_COPY_AND_ASSIGN(DontClobberRestoreBoundsWindowObserver); 80 DISALLOW_COPY_AND_ASSIGN(DontClobberRestoreBoundsWindowObserver);
81 }; 81 };
82 82
83 // Creates a window, maximized the window and from within the maximized 83 // Creates a window, maximized the window and from within the maximized
84 // notification sets the bounds of a window to overlap the shelf. Verifies this 84 // notification sets the bounds of a window to overlap the shelf. Verifies this
85 // doesn't effect the restore bounds. 85 // doesn't effect the restore bounds.
86 TEST_F(WorkspaceLayoutManager2Test, DontClobberRestoreBounds) { 86 TEST_F(WorkspaceLayoutManagerTest, DontClobberRestoreBounds) {
87 DontClobberRestoreBoundsWindowObserver window_observer; 87 DontClobberRestoreBoundsWindowObserver window_observer;
88 scoped_ptr<aura::Window> window(new aura::Window(NULL)); 88 scoped_ptr<aura::Window> window(new aura::Window(NULL));
89 window->SetType(aura::client::WINDOW_TYPE_NORMAL); 89 window->SetType(aura::client::WINDOW_TYPE_NORMAL);
90 window->Init(ui::LAYER_TEXTURED); 90 window->Init(ui::LAYER_TEXTURED);
91 window->SetBounds(gfx::Rect(10, 20, 30, 40)); 91 window->SetBounds(gfx::Rect(10, 20, 30, 40));
92 // NOTE: for this test to exercise the failure the observer needs to be added 92 // NOTE: for this test to exercise the failure the observer needs to be added
93 // before the parent set. This mimics what BrowserFrameAura does. 93 // before the parent set. This mimics what BrowserFrameAura does.
94 window->AddObserver(&window_observer); 94 window->AddObserver(&window_observer);
95 window->SetParent(NULL); 95 window->SetParent(NULL);
96 window->Show(); 96 window->Show();
97 ash::wm::ActivateWindow(window.get()); 97 ash::wm::ActivateWindow(window.get());
98 98
99 scoped_ptr<aura::Window> window2(CreateTestWindow(gfx::Rect(12, 20, 30, 40))); 99 scoped_ptr<aura::Window> window2(CreateTestWindow(gfx::Rect(12, 20, 30, 40)));
100 window->AddTransientChild(window2.get()); 100 window->AddTransientChild(window2.get());
101 window2->Show(); 101 window2->Show();
102 102
103 window_observer.set_window(window2.get()); 103 window_observer.set_window(window2.get());
104 wm::MaximizeWindow(window.get()); 104 wm::MaximizeWindow(window.get());
105 EXPECT_EQ("10,20 30x40", GetRestoreBoundsInScreen(window.get())->ToString()); 105 EXPECT_EQ("10,20 30x40", GetRestoreBoundsInScreen(window.get())->ToString());
106 window->RemoveObserver(&window_observer); 106 window->RemoveObserver(&window_observer);
107 } 107 }
108 108
109 // Verifies when a window is maximized all descendant windows have a size. 109 // Verifies when a window is maximized all descendant windows have a size.
110 TEST_F(WorkspaceLayoutManager2Test, ChildBoundsResetOnMaximize) { 110 TEST_F(WorkspaceLayoutManagerTest, ChildBoundsResetOnMaximize) {
111 scoped_ptr<aura::Window> window( 111 scoped_ptr<aura::Window> window(
112 CreateTestWindow(gfx::Rect(10, 20, 30, 40))); 112 CreateTestWindow(gfx::Rect(10, 20, 30, 40)));
113 window->Show(); 113 window->Show();
114 ash::wm::ActivateWindow(window.get()); 114 ash::wm::ActivateWindow(window.get());
115 scoped_ptr<aura::Window> child_window( 115 scoped_ptr<aura::Window> child_window(
116 aura::test::CreateTestWindowWithBounds(gfx::Rect(5, 6, 7, 8), 116 aura::test::CreateTestWindowWithBounds(gfx::Rect(5, 6, 7, 8),
117 window.get())); 117 window.get()));
118 child_window->Show(); 118 child_window->Show();
119 ash::wm::MaximizeWindow(window.get()); 119 ash::wm::MaximizeWindow(window.get());
120 EXPECT_EQ("5,6 7x8", child_window->bounds().ToString()); 120 EXPECT_EQ("5,6 7x8", child_window->bounds().ToString());
121 } 121 }
122 122
123 TEST_F(WorkspaceLayoutManager2Test, WindowShouldBeOnScreenWhenAdded) { 123 TEST_F(WorkspaceLayoutManagerTest, WindowShouldBeOnScreenWhenAdded) {
124 // Normal window bounds shouldn't be changed. 124 // Normal window bounds shouldn't be changed.
125 gfx::Rect window_bounds(100, 100, 200, 200); 125 gfx::Rect window_bounds(100, 100, 200, 200);
126 scoped_ptr<aura::Window> window(CreateTestWindow(window_bounds)); 126 scoped_ptr<aura::Window> window(CreateTestWindow(window_bounds));
127 EXPECT_EQ(window_bounds, window->bounds()); 127 EXPECT_EQ(window_bounds, window->bounds());
128 128
129 // If the window is out of the workspace, it would be moved on screen. 129 // If the window is out of the workspace, it would be moved on screen.
130 gfx::Rect root_window_bounds = 130 gfx::Rect root_window_bounds =
131 ash::Shell::GetInstance()->GetPrimaryRootWindow()->bounds(); 131 ash::Shell::GetInstance()->GetPrimaryRootWindow()->bounds();
132 window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height()); 132 window_bounds.Offset(root_window_bounds.width(), root_window_bounds.height());
133 ASSERT_FALSE(window_bounds.Intersects(root_window_bounds)); 133 ASSERT_FALSE(window_bounds.Intersects(root_window_bounds));
134 scoped_ptr<aura::Window> out_window(CreateTestWindow(window_bounds)); 134 scoped_ptr<aura::Window> out_window(CreateTestWindow(window_bounds));
135 EXPECT_EQ(window_bounds.size(), out_window->bounds().size()); 135 EXPECT_EQ(window_bounds.size(), out_window->bounds().size());
136 EXPECT_TRUE(out_window->bounds().Intersects(root_window_bounds)); 136 EXPECT_TRUE(out_window->bounds().Intersects(root_window_bounds));
137 } 137 }
138 138
139 // Verifies the size of a window is enforced to be smaller than the work area. 139 // Verifies the size of a window is enforced to be smaller than the work area.
140 TEST_F(WorkspaceLayoutManager2Test, SizeToWorkArea) { 140 TEST_F(WorkspaceLayoutManagerTest, SizeToWorkArea) {
141 // Normal window bounds shouldn't be changed. 141 // Normal window bounds shouldn't be changed.
142 gfx::Size work_area( 142 gfx::Size work_area(
143 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size()); 143 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size());
144 const gfx::Rect window_bounds( 144 const gfx::Rect window_bounds(
145 100, 101, work_area.width() + 1, work_area.height() + 2); 145 100, 101, work_area.width() + 1, work_area.height() + 2);
146 scoped_ptr<aura::Window> window(CreateTestWindow(window_bounds)); 146 scoped_ptr<aura::Window> window(CreateTestWindow(window_bounds));
147 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), 147 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(),
148 window->bounds().ToString()); 148 window->bounds().ToString());
149 149
150 // Directly setting the bounds triggers a slightly different code path. Verify 150 // Directly setting the bounds triggers a slightly different code path. Verify
151 // that too. 151 // that too.
152 window->SetBounds(window_bounds); 152 window->SetBounds(window_bounds);
153 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(), 153 EXPECT_EQ(gfx::Rect(gfx::Point(100, 101), work_area).ToString(),
154 window->bounds().ToString()); 154 window->bounds().ToString());
155 } 155 }
156 156
157 } // namespace 157 } // namespace
158 } // namespace ash 158 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager2_unittest.cc ('k') | ash/wm/workspace/workspace_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698