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

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

Issue 10442017: Rename GetRootWindow() -> GetPrimaryRootWindow() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git-try -b linux_chromeos,win_aura Created 8 years, 7 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
« no previous file with comments | « ash/wm/activation_controller_unittest.cc ('k') | ash/wm/panel_layout_manager.cc » ('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/base_layout_manager.h" 5 #include "ash/wm/base_layout_manager.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/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
(...skipping 12 matching lines...) Expand all
23 namespace { 23 namespace {
24 24
25 class BaseLayoutManagerTest : public test::AshTestBase { 25 class BaseLayoutManagerTest : public test::AshTestBase {
26 public: 26 public:
27 BaseLayoutManagerTest() {} 27 BaseLayoutManagerTest() {}
28 virtual ~BaseLayoutManagerTest() {} 28 virtual ~BaseLayoutManagerTest() {}
29 29
30 virtual void SetUp() OVERRIDE { 30 virtual void SetUp() OVERRIDE {
31 test::AshTestBase::SetUp(); 31 test::AshTestBase::SetUp();
32 Shell::GetInstance()->SetMonitorWorkAreaInsets( 32 Shell::GetInstance()->SetMonitorWorkAreaInsets(
33 Shell::GetRootWindow(), 33 Shell::GetPrimaryRootWindow(),
34 gfx::Insets(1, 2, 3, 4)); 34 gfx::Insets(1, 2, 3, 4));
35 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); 35 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600));
36 aura::Window* default_container = Shell::GetInstance()->GetContainer( 36 aura::Window* default_container = Shell::GetInstance()->GetContainer(
37 internal::kShellWindowId_DefaultContainer); 37 internal::kShellWindowId_DefaultContainer);
38 default_container->SetLayoutManager(new internal::BaseLayoutManager( 38 default_container->SetLayoutManager(new internal::BaseLayoutManager(
39 Shell::GetRootWindow())); 39 Shell::GetPrimaryRootWindow()));
40 } 40 }
41 41
42 aura::Window* CreateTestWindow(const gfx::Rect& bounds) { 42 aura::Window* CreateTestWindow(const gfx::Rect& bounds) {
43 return aura::test::CreateTestWindowWithBounds(bounds, NULL); 43 return aura::test::CreateTestWindowWithBounds(bounds, NULL);
44 } 44 }
45 45
46 private: 46 private:
47 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManagerTest); 47 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManagerTest);
48 }; 48 };
49 49
(...skipping 23 matching lines...) Expand all
73 73
74 // Tests maximized window size during root window resize. 74 // Tests maximized window size during root window resize.
75 TEST_F(BaseLayoutManagerTest, MaximizeRootWindowResize) { 75 TEST_F(BaseLayoutManagerTest, MaximizeRootWindowResize) {
76 gfx::Rect bounds(100, 100, 200, 200); 76 gfx::Rect bounds(100, 100, 200, 200);
77 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); 77 scoped_ptr<aura::Window> window(CreateTestWindow(bounds));
78 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 78 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
79 gfx::Rect initial_work_area_bounds = 79 gfx::Rect initial_work_area_bounds =
80 ScreenAsh::GetMaximizedWindowBounds(window.get()); 80 ScreenAsh::GetMaximizedWindowBounds(window.get());
81 EXPECT_EQ(initial_work_area_bounds.ToString(), window->bounds().ToString()); 81 EXPECT_EQ(initial_work_area_bounds.ToString(), window->bounds().ToString());
82 // Enlarge the root window. We should still match the work area size. 82 // Enlarge the root window. We should still match the work area size.
83 Shell::GetRootWindow()->SetHostSize(gfx::Size(900, 700)); 83 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(900, 700));
84 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBounds(window.get()).ToString(), 84 EXPECT_EQ(ScreenAsh::GetMaximizedWindowBounds(window.get()).ToString(),
85 window->bounds().ToString()); 85 window->bounds().ToString());
86 EXPECT_NE(initial_work_area_bounds.ToString(), 86 EXPECT_NE(initial_work_area_bounds.ToString(),
87 ScreenAsh::GetMaximizedWindowBounds(window.get()).ToString()); 87 ScreenAsh::GetMaximizedWindowBounds(window.get()).ToString());
88 } 88 }
89 89
90 // Tests normal->fullscreen->normal. 90 // Tests normal->fullscreen->normal.
91 TEST_F(BaseLayoutManagerTest, Fullscreen) { 91 TEST_F(BaseLayoutManagerTest, Fullscreen) {
92 gfx::Rect bounds(100, 100, 200, 200); 92 gfx::Rect bounds(100, 100, 200, 200);
93 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); 93 scoped_ptr<aura::Window> window(CreateTestWindow(bounds));
94 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 94 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
95 // Fullscreen window fills the whole monitor. 95 // Fullscreen window fills the whole monitor.
96 EXPECT_EQ( 96 EXPECT_EQ(
97 gfx::Screen::GetMonitorNearestWindow(window.get()).bounds().ToString(), 97 gfx::Screen::GetMonitorNearestWindow(window.get()).bounds().ToString(),
98 window->bounds().ToString()); 98 window->bounds().ToString());
99 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 99 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
100 EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); 100 EXPECT_EQ(bounds.ToString(), window->bounds().ToString());
101 } 101 }
102 102
103 // Tests fullscreen window size during root window resize. 103 // Tests fullscreen window size during root window resize.
104 TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) { 104 TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) {
105 gfx::Rect bounds(100, 100, 200, 200); 105 gfx::Rect bounds(100, 100, 200, 200);
106 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); 106 scoped_ptr<aura::Window> window(CreateTestWindow(bounds));
107 // Fullscreen window fills the whole monitor. 107 // Fullscreen window fills the whole monitor.
108 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 108 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
109 EXPECT_EQ( 109 EXPECT_EQ(
110 gfx::Screen::GetMonitorNearestWindow(window.get()).bounds().ToString(), 110 gfx::Screen::GetMonitorNearestWindow(window.get()).bounds().ToString(),
111 window->bounds().ToString()); 111 window->bounds().ToString());
112 // Enlarge the root window. We should still match the monitor size. 112 // Enlarge the root window. We should still match the monitor size.
113 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); 113 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600));
114 EXPECT_EQ( 114 EXPECT_EQ(
115 gfx::Screen::GetMonitorNearestWindow(window.get()).bounds().ToString(), 115 gfx::Screen::GetMonitorNearestWindow(window.get()).bounds().ToString(),
116 window->bounds().ToString()); 116 window->bounds().ToString());
117 } 117 }
118 118
119 // Fails on Mac only. Need to be implemented. http://crbug.com/111279. 119 // Fails on Mac only. Need to be implemented. http://crbug.com/111279.
120 #if defined(OS_MACOSX) 120 #if defined(OS_MACOSX)
121 #define MAYBE_RootWindowResizeShrinksWindows \ 121 #define MAYBE_RootWindowResizeShrinksWindows \
122 FAILS_RootWindowResizeShrinksWindows 122 FAILS_RootWindowResizeShrinksWindows
123 #else 123 #else
124 #define MAYBE_RootWindowResizeShrinksWindows RootWindowResizeShrinksWindows 124 #define MAYBE_RootWindowResizeShrinksWindows RootWindowResizeShrinksWindows
125 #endif 125 #endif
126 // Tests that when the screen gets smaller the windows aren't bigger than 126 // Tests that when the screen gets smaller the windows aren't bigger than
127 // the screen. 127 // the screen.
128 TEST_F(BaseLayoutManagerTest, MAYBE_RootWindowResizeShrinksWindows) { 128 TEST_F(BaseLayoutManagerTest, MAYBE_RootWindowResizeShrinksWindows) {
129 scoped_ptr<aura::Window> window( 129 scoped_ptr<aura::Window> window(
130 CreateTestWindow(gfx::Rect(10, 20, 500, 400))); 130 CreateTestWindow(gfx::Rect(10, 20, 500, 400)));
131 gfx::Rect work_area = 131 gfx::Rect work_area =
132 gfx::Screen::GetMonitorNearestWindow(window.get()).work_area(); 132 gfx::Screen::GetMonitorNearestWindow(window.get()).work_area();
133 // Invariant: Window is smaller than work area. 133 // Invariant: Window is smaller than work area.
134 EXPECT_LE(window->bounds().width(), work_area.width()); 134 EXPECT_LE(window->bounds().width(), work_area.width());
135 EXPECT_LE(window->bounds().height(), work_area.height()); 135 EXPECT_LE(window->bounds().height(), work_area.height());
136 136
137 // Make the root window narrower than our window. 137 // Make the root window narrower than our window.
138 Shell::GetRootWindow()->SetHostSize(gfx::Size(300, 400)); 138 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 400));
139 work_area = gfx::Screen::GetMonitorNearestWindow(window.get()).work_area(); 139 work_area = gfx::Screen::GetMonitorNearestWindow(window.get()).work_area();
140 EXPECT_LE(window->bounds().width(), work_area.width()); 140 EXPECT_LE(window->bounds().width(), work_area.width());
141 EXPECT_LE(window->bounds().height(), work_area.height()); 141 EXPECT_LE(window->bounds().height(), work_area.height());
142 142
143 // Make the root window shorter than our window. 143 // Make the root window shorter than our window.
144 Shell::GetRootWindow()->SetHostSize(gfx::Size(300, 200)); 144 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(300, 200));
145 work_area = gfx::Screen::GetMonitorNearestWindow(window.get()).work_area(); 145 work_area = gfx::Screen::GetMonitorNearestWindow(window.get()).work_area();
146 EXPECT_LE(window->bounds().width(), work_area.width()); 146 EXPECT_LE(window->bounds().width(), work_area.width());
147 EXPECT_LE(window->bounds().height(), work_area.height()); 147 EXPECT_LE(window->bounds().height(), work_area.height());
148 148
149 // Enlarging the root window does not change the window bounds. 149 // Enlarging the root window does not change the window bounds.
150 gfx::Rect old_bounds = window->bounds(); 150 gfx::Rect old_bounds = window->bounds();
151 Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); 151 Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600));
152 EXPECT_EQ(old_bounds.width(), window->bounds().width()); 152 EXPECT_EQ(old_bounds.width(), window->bounds().width());
153 EXPECT_EQ(old_bounds.height(), window->bounds().height()); 153 EXPECT_EQ(old_bounds.height(), window->bounds().height());
154 } 154 }
155 155
156 // Tests that a maximized window with too-large restore bounds will be restored 156 // Tests that a maximized window with too-large restore bounds will be restored
157 // to smaller than the full work area. 157 // to smaller than the full work area.
158 TEST_F(BaseLayoutManagerTest, BoundsWithScreenEdgeVisible) { 158 TEST_F(BaseLayoutManagerTest, BoundsWithScreenEdgeVisible) {
159 // Create a window with bounds that fill the screen. 159 // Create a window with bounds that fill the screen.
160 gfx::Rect bounds = gfx::Screen::GetPrimaryMonitor().bounds(); 160 gfx::Rect bounds = gfx::Screen::GetPrimaryMonitor().bounds();
161 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); 161 scoped_ptr<aura::Window> window(CreateTestWindow(bounds));
162 // Maximize it, which writes the old bounds to restore bounds. 162 // Maximize it, which writes the old bounds to restore bounds.
163 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 163 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
164 // Restore it. 164 // Restore it.
165 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 165 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
166 // It should have the default maximized window bounds, inset by the grid size. 166 // It should have the default maximized window bounds, inset by the grid size.
167 int grid_size = ash::Shell::GetInstance()->GetGridSize(); 167 int grid_size = ash::Shell::GetInstance()->GetGridSize();
168 gfx::Rect max_bounds = ash::ScreenAsh::GetMaximizedWindowBounds(window.get()); 168 gfx::Rect max_bounds = ash::ScreenAsh::GetMaximizedWindowBounds(window.get());
169 max_bounds.Inset(grid_size, grid_size); 169 max_bounds.Inset(grid_size, grid_size);
170 EXPECT_EQ(max_bounds.ToString(), window->bounds().ToString()); 170 EXPECT_EQ(max_bounds.ToString(), window->bounds().ToString());
171 } 171 }
172 172
173 } // namespace 173 } // namespace
174 174
175 } // namespace ash 175 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/activation_controller_unittest.cc ('k') | ash/wm/panel_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698