OLD | NEW |
---|---|
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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
6 | 6 |
7 #include "ash/session_state_delegate.h" | 7 #include "ash/session_state_delegate.h" |
8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 return widget; | 145 return widget; |
146 } | 146 } |
147 | 147 |
148 aura::Window* GetModalContainer(aura::Window* root_window) { | 148 aura::Window* GetModalContainer(aura::Window* root_window) { |
149 return Shell::GetContainer( | 149 return Shell::GetContainer( |
150 root_window, | 150 root_window, |
151 ash::internal::kShellWindowId_SystemModalContainer); | 151 ash::internal::kShellWindowId_SystemModalContainer); |
152 } | 152 } |
153 }; | 153 }; |
154 | 154 |
155 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { | 155 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { |
varkha
2013/12/12 16:20:46
nit: I think you could quote this test in the CL T
oshima
2013/12/12 19:07:14
Done.
| |
156 if (!SupportsMultipleDisplays()) | 156 if (!SupportsMultipleDisplays()) |
157 return; | 157 return; |
158 | 158 // Windows origin should be doubled when moved to the 1st display. |
159 UpdateDisplay("600x600,500x500"); | 159 UpdateDisplay("600x600,300x300"); |
160 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 160 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
161 internal::RootWindowController* controller = | 161 internal::RootWindowController* controller = |
162 Shell::GetPrimaryRootWindowController(); | 162 Shell::GetPrimaryRootWindowController(); |
163 internal::ShelfLayoutManager* shelf_layout_manager = | 163 internal::ShelfLayoutManager* shelf_layout_manager = |
164 controller->GetShelfLayoutManager(); | 164 controller->GetShelfLayoutManager(); |
165 shelf_layout_manager->SetAutoHideBehavior( | 165 shelf_layout_manager->SetAutoHideBehavior( |
166 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 166 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
167 | 167 |
168 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); | 168 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); |
169 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); | 169 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); |
170 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); | 170 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); |
171 EXPECT_EQ("50,10 100x100", | 171 EXPECT_EQ("50,10 100x100", |
172 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 172 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
173 | 173 |
174 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); | 174 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); |
175 maximized->Maximize(); | 175 maximized->Maximize(); |
176 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); | 176 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); |
177 EXPECT_EQ("600,0 500x453", maximized->GetWindowBoundsInScreen().ToString()); | 177 EXPECT_EQ("600,0 300x253", maximized->GetWindowBoundsInScreen().ToString()); |
178 EXPECT_EQ("0,0 500x453", | 178 EXPECT_EQ("0,0 300x253", |
179 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 179 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
180 | 180 |
181 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); | 181 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); |
182 minimized->Minimize(); | 182 minimized->Minimize(); |
183 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); | 183 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); |
184 EXPECT_EQ("800,10 100x100", | 184 EXPECT_EQ("800,10 100x100", |
185 minimized->GetWindowBoundsInScreen().ToString()); | 185 minimized->GetWindowBoundsInScreen().ToString()); |
186 | 186 |
187 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(900, 10, 100, 100)); | 187 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100)); |
188 fullscreen->SetFullscreen(true); | 188 fullscreen->SetFullscreen(true); |
189 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); | 189 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); |
190 | 190 |
191 EXPECT_EQ("600,0 500x500", | 191 EXPECT_EQ("600,0 300x300", |
192 fullscreen->GetWindowBoundsInScreen().ToString()); | 192 fullscreen->GetWindowBoundsInScreen().ToString()); |
193 EXPECT_EQ("0,0 500x500", | 193 EXPECT_EQ("0,0 300x300", |
194 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 194 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
195 | 195 |
196 views::Widget* unparented_control = new Widget; | 196 views::Widget* unparented_control = new Widget; |
197 Widget::InitParams params; | 197 Widget::InitParams params; |
198 params.bounds = gfx::Rect(650, 10, 100, 100); | 198 params.bounds = gfx::Rect(650, 10, 100, 100); |
199 params.context = CurrentContext(); | 199 params.context = CurrentContext(); |
200 params.type = Widget::InitParams::TYPE_CONTROL; | 200 params.type = Widget::InitParams::TYPE_CONTROL; |
201 unparented_control->Init(params); | 201 unparented_control->Init(params); |
202 EXPECT_EQ(root_windows[1], | 202 EXPECT_EQ(root_windows[1], |
203 unparented_control->GetNativeView()->GetRootWindow()); | 203 unparented_control->GetNativeView()->GetRootWindow()); |
(...skipping 14 matching lines...) Expand all Loading... | |
218 delete_on_blur_delegate.SetWindow(d2); | 218 delete_on_blur_delegate.SetWindow(d2); |
219 aura::client::GetFocusClient(root_windows[0])->FocusWindow(d2); | 219 aura::client::GetFocusClient(root_windows[0])->FocusWindow(d2); |
220 tracker.Add(d2); | 220 tracker.Add(d2); |
221 | 221 |
222 UpdateDisplay("600x600"); | 222 UpdateDisplay("600x600"); |
223 | 223 |
224 // d2 must have been deleted. | 224 // d2 must have been deleted. |
225 EXPECT_FALSE(tracker.Contains(d2)); | 225 EXPECT_FALSE(tracker.Contains(d2)); |
226 | 226 |
227 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); | 227 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); |
228 EXPECT_EQ("50,10 100x100", normal->GetWindowBoundsInScreen().ToString()); | 228 EXPECT_EQ("100,20 100x100", normal->GetWindowBoundsInScreen().ToString()); |
229 EXPECT_EQ("50,10 100x100", | 229 EXPECT_EQ("100,20 100x100", |
230 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 230 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
231 | 231 |
232 // Maximized area on primary display has 3px (given as | 232 // Maximized area on primary display has 3px (given as |
233 // kAutoHideSize in shelf_layout_manager.cc) inset at the bottom. | 233 // kAutoHideSize in shelf_layout_manager.cc) inset at the bottom. |
234 | 234 |
235 // First clear fullscreen status, since both fullscreen and maximized windows | 235 // First clear fullscreen status, since both fullscreen and maximized windows |
236 // share the same desktop workspace, which cancels the shelf status. | 236 // share the same desktop workspace, which cancels the shelf status. |
237 fullscreen->SetFullscreen(false); | 237 fullscreen->SetFullscreen(false); |
238 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); | 238 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
239 EXPECT_EQ("0,0 600x597", | 239 EXPECT_EQ("0,0 600x597", |
240 maximized->GetWindowBoundsInScreen().ToString()); | 240 maximized->GetWindowBoundsInScreen().ToString()); |
241 EXPECT_EQ("0,0 600x597", | 241 EXPECT_EQ("0,0 600x597", |
242 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 242 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
243 | 243 |
244 // Set fullscreen to true. In that case the 3px inset becomes invisible so | 244 // Set fullscreen to true. In that case the 3px inset becomes invisible so |
245 // the maximized window can also use the area fully. | 245 // the maximized window can also use the area fully. |
246 fullscreen->SetFullscreen(true); | 246 fullscreen->SetFullscreen(true); |
247 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); | 247 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
248 EXPECT_EQ("0,0 600x600", | 248 EXPECT_EQ("0,0 600x600", |
249 maximized->GetWindowBoundsInScreen().ToString()); | 249 maximized->GetWindowBoundsInScreen().ToString()); |
250 EXPECT_EQ("0,0 600x600", | 250 EXPECT_EQ("0,0 600x600", |
251 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 251 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
252 | 252 |
253 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); | 253 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); |
254 EXPECT_EQ("200,10 100x100", | 254 EXPECT_EQ("400,20 100x100", |
255 minimized->GetWindowBoundsInScreen().ToString()); | 255 minimized->GetWindowBoundsInScreen().ToString()); |
256 | 256 |
257 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); | 257 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); |
258 EXPECT_TRUE(fullscreen->IsFullscreen()); | 258 EXPECT_TRUE(fullscreen->IsFullscreen()); |
259 EXPECT_EQ("0,0 600x600", | 259 EXPECT_EQ("0,0 600x600", |
260 fullscreen->GetWindowBoundsInScreen().ToString()); | 260 fullscreen->GetWindowBoundsInScreen().ToString()); |
261 EXPECT_EQ("0,0 600x600", | 261 EXPECT_EQ("0,0 600x600", |
262 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 262 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
263 | 263 |
264 // Test if the restore bounds are correctly updated. | 264 // Test if the restore bounds are correctly updated. |
265 wm::GetWindowState(maximized->GetNativeView())->Restore(); | 265 wm::GetWindowState(maximized->GetNativeView())->Restore(); |
266 EXPECT_EQ("100,10 100x100", maximized->GetWindowBoundsInScreen().ToString()); | 266 EXPECT_EQ("200,20 100x100", maximized->GetWindowBoundsInScreen().ToString()); |
267 EXPECT_EQ("100,10 100x100", | 267 EXPECT_EQ("200,20 100x100", |
268 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 268 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
269 | 269 |
270 fullscreen->SetFullscreen(false); | 270 fullscreen->SetFullscreen(false); |
271 EXPECT_EQ("300,10 100x100", | 271 EXPECT_EQ("500,20 100x100", |
272 fullscreen->GetWindowBoundsInScreen().ToString()); | 272 fullscreen->GetWindowBoundsInScreen().ToString()); |
273 EXPECT_EQ("300,10 100x100", | 273 EXPECT_EQ("500,20 100x100", |
274 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 274 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
275 | 275 |
276 // Test if the unparented widget has moved. | 276 // Test if the unparented widget has moved. |
277 EXPECT_EQ(root_windows[0], | 277 EXPECT_EQ(root_windows[0], |
278 unparented_control->GetNativeView()->GetRootWindow()); | 278 unparented_control->GetNativeView()->GetRootWindow()); |
279 EXPECT_EQ(internal::kShellWindowId_UnparentedControlContainer, | 279 EXPECT_EQ(internal::kShellWindowId_UnparentedControlContainer, |
280 unparented_control->GetNativeView()->parent()->id()); | 280 unparented_control->GetNativeView()->parent()->id()); |
281 | 281 |
282 // Test if the panel has moved. | 282 // Test if the panel has moved. |
283 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); | 283 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
697 aura::WindowTracker tracker; | 697 aura::WindowTracker tracker; |
698 tracker.Add(keyboard_container); | 698 tracker.Add(keyboard_container); |
699 // Mock a login user profile change to reinitialize the keyboard. | 699 // Mock a login user profile change to reinitialize the keyboard. |
700 ash::Shell::GetInstance()->OnLoginUserProfilePrepared(); | 700 ash::Shell::GetInstance()->OnLoginUserProfilePrepared(); |
701 // keyboard_container should no longer be present. | 701 // keyboard_container should no longer be present. |
702 EXPECT_FALSE(tracker.Contains(keyboard_container)); | 702 EXPECT_FALSE(tracker.Contains(keyboard_container)); |
703 } | 703 } |
704 | 704 |
705 } // namespace test | 705 } // namespace test |
706 } // namespace ash | 706 } // namespace ash |
OLD | NEW |