OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/dock/docked_window_layout_manager.h" | 5 #include "ash/wm/dock/docked_window_layout_manager.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 203 |
204 // x-coordinate can get adjusted by snapping or sticking. | 204 // x-coordinate can get adjusted by snapping or sticking. |
205 // y-coordinate could be changed by possible automatic layout if docked. | 205 // y-coordinate could be changed by possible automatic layout if docked. |
206 if (window->parent()->id() != kShellWindowId_DockedContainer && | 206 if (window->parent()->id() != kShellWindowId_DockedContainer && |
207 !wm::GetWindowState(window)->HasRestoreBounds()) { | 207 !wm::GetWindowState(window)->HasRestoreBounds()) { |
208 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); | 208 EXPECT_EQ(initial_bounds.y() + dy, window->GetBoundsInScreen().y()); |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 private: | 212 private: |
213 scoped_ptr<WindowResizer> resizer_; | 213 std::unique_ptr<WindowResizer> resizer_; |
214 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; | 214 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; |
215 ui::wm::WindowType window_type_; | 215 ui::wm::WindowType window_type_; |
216 | 216 |
217 // Location at start of the drag in |window->parent()|'s coordinates. | 217 // Location at start of the drag in |window->parent()|'s coordinates. |
218 gfx::Point initial_location_in_parent_; | 218 gfx::Point initial_location_in_parent_; |
219 | 219 |
220 DISALLOW_COPY_AND_ASSIGN(DockedWindowLayoutManagerTest); | 220 DISALLOW_COPY_AND_ASSIGN(DockedWindowLayoutManagerTest); |
221 }; | 221 }; |
222 | 222 |
223 // Tests that a created window is successfully added to the dock | 223 // Tests that a created window is successfully added to the dock |
224 // layout manager. | 224 // layout manager. |
225 TEST_P(DockedWindowLayoutManagerTest, AddOneWindow) { | 225 TEST_P(DockedWindowLayoutManagerTest, AddOneWindow) { |
226 if (!SupportsHostWindowResize()) | 226 if (!SupportsHostWindowResize()) |
227 return; | 227 return; |
228 | 228 |
229 gfx::Rect bounds(0, 0, 201, 201); | 229 gfx::Rect bounds(0, 0, 201, 201); |
230 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 230 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
231 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 231 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
232 | 232 |
233 // The window should be attached and docked at the right edge. | 233 // The window should be attached and docked at the right edge. |
234 // Its width should shrink or grow to ideal width. | 234 // Its width should shrink or grow to ideal width. |
235 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 235 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
236 window->GetBoundsInScreen().right()); | 236 window->GetBoundsInScreen().right()); |
237 EXPECT_EQ(ideal_width(), window->bounds().width()); | 237 EXPECT_EQ(ideal_width(), window->bounds().width()); |
238 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 238 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
239 } | 239 } |
240 | 240 |
241 // Tests that a docked window's bounds cannot be changed programmatically. | 241 // Tests that a docked window's bounds cannot be changed programmatically. |
242 TEST_P(DockedWindowLayoutManagerTest, DockedWindowBoundsDontChange) { | 242 TEST_P(DockedWindowLayoutManagerTest, DockedWindowBoundsDontChange) { |
243 if (!SupportsHostWindowResize()) | 243 if (!SupportsHostWindowResize()) |
244 return; | 244 return; |
245 | 245 |
246 gfx::Rect bounds(0, 0, 201, 201); | 246 gfx::Rect bounds(0, 0, 201, 201); |
247 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 247 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
248 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 248 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
249 | 249 |
250 // The window should be attached and docked at the right edge. | 250 // The window should be attached and docked at the right edge. |
251 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 251 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
252 | 252 |
253 bounds = window->GetBoundsInScreen(); | 253 bounds = window->GetBoundsInScreen(); |
254 window->SetBounds(gfx::Rect(210, 210, 210, 210)); | 254 window->SetBounds(gfx::Rect(210, 210, 210, 210)); |
255 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString()); | 255 EXPECT_EQ(bounds.ToString(), window->GetBoundsInScreen().ToString()); |
256 } | 256 } |
257 | 257 |
258 // Tests that with a window docked on the left the auto-placing logic in | 258 // Tests that with a window docked on the left the auto-placing logic in |
259 // RearrangeVisibleWindowOnShow places windows flush with work area edges. | 259 // RearrangeVisibleWindowOnShow places windows flush with work area edges. |
260 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingLeft) { | 260 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingLeft) { |
261 if (!SupportsHostWindowResize()) | 261 if (!SupportsHostWindowResize()) |
262 return; | 262 return; |
263 | 263 |
264 gfx::Rect bounds(0, 0, 201, 201); | 264 gfx::Rect bounds(0, 0, 201, 201); |
265 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 265 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
266 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); | 266 DragRelativeToEdge(DOCKED_EDGE_LEFT, window.get(), 0); |
267 | 267 |
268 // The window should be attached and snapped to the right side of the screen. | 268 // The window should be attached and snapped to the right side of the screen. |
269 EXPECT_EQ(window->GetRootWindow()->bounds().x(), | 269 EXPECT_EQ(window->GetRootWindow()->bounds().x(), |
270 window->GetBoundsInScreen().x()); | 270 window->GetBoundsInScreen().x()); |
271 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 271 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
272 | 272 |
273 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( | 273 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( |
274 window->parent()->layout_manager()); | 274 window->parent()->layout_manager()); |
275 | 275 |
276 // Create two additional windows and test their auto-placement | 276 // Create two additional windows and test their auto-placement |
277 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 277 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
278 gfx::Rect desktop_area = window1->parent()->bounds(); | 278 gfx::Rect desktop_area = window1->parent()->bounds(); |
279 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 279 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
280 window1->Hide(); | 280 window1->Hide(); |
281 window1->SetBounds(gfx::Rect(250, 32, 231, 320)); | 281 window1->SetBounds(gfx::Rect(250, 32, 231, 320)); |
282 window1->Show(); | 282 window1->Show(); |
283 // |window1| should be centered in work area. | 283 // |window1| should be centered in work area. |
284 EXPECT_EQ(base::IntToString( | 284 EXPECT_EQ(base::IntToString( |
285 docked_width(manager) + min_dock_gap() + | 285 docked_width(manager) + min_dock_gap() + |
286 (desktop_area.width() - docked_width(manager) - | 286 (desktop_area.width() - docked_width(manager) - |
287 min_dock_gap() - window1->bounds().width()) / 2) + | 287 min_dock_gap() - window1->bounds().width()) / 2) + |
288 ",32 231x320", window1->bounds().ToString()); | 288 ",32 231x320", window1->bounds().ToString()); |
289 | 289 |
290 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 290 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
291 wm::GetWindowState(window2.get())->set_window_position_managed(true); | 291 wm::GetWindowState(window2.get())->set_window_position_managed(true); |
292 // To avoid any auto window manager changes due to SetBounds, the window | 292 // To avoid any auto window manager changes due to SetBounds, the window |
293 // gets first hidden and then shown again. | 293 // gets first hidden and then shown again. |
294 window2->Hide(); | 294 window2->Hide(); |
295 window2->SetBounds(gfx::Rect(250, 48, 150, 300)); | 295 window2->SetBounds(gfx::Rect(250, 48, 150, 300)); |
296 window2->Show(); | 296 window2->Show(); |
297 | 297 |
298 // |window1| should be flush left and |window2| flush right. | 298 // |window1| should be flush left and |window2| flush right. |
299 EXPECT_EQ( | 299 EXPECT_EQ( |
300 base::IntToString(docked_width(manager) + min_dock_gap()) + | 300 base::IntToString(docked_width(manager) + min_dock_gap()) + |
301 ",32 231x320", window1->bounds().ToString()); | 301 ",32 231x320", window1->bounds().ToString()); |
302 EXPECT_EQ( | 302 EXPECT_EQ( |
303 base::IntToString( | 303 base::IntToString( |
304 desktop_area.width() - window2->bounds().width()) + | 304 desktop_area.width() - window2->bounds().width()) + |
305 ",48 150x300", window2->bounds().ToString()); | 305 ",48 150x300", window2->bounds().ToString()); |
306 } | 306 } |
307 | 307 |
308 // Tests that with a window docked on the right the auto-placing logic in | 308 // Tests that with a window docked on the right the auto-placing logic in |
309 // RearrangeVisibleWindowOnShow places windows flush with work area edges. | 309 // RearrangeVisibleWindowOnShow places windows flush with work area edges. |
310 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRight) { | 310 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRight) { |
311 if (!SupportsHostWindowResize()) | 311 if (!SupportsHostWindowResize()) |
312 return; | 312 return; |
313 | 313 |
314 gfx::Rect bounds(0, 0, 201, 201); | 314 gfx::Rect bounds(0, 0, 201, 201); |
315 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 315 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
316 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 316 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
317 | 317 |
318 // The window should be attached and snapped to the right side of the screen. | 318 // The window should be attached and snapped to the right side of the screen. |
319 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 319 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
320 window->GetBoundsInScreen().right()); | 320 window->GetBoundsInScreen().right()); |
321 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 321 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
322 | 322 |
323 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( | 323 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( |
324 window->parent()->layout_manager()); | 324 window->parent()->layout_manager()); |
325 | 325 |
326 // Create two additional windows and test their auto-placement | 326 // Create two additional windows and test their auto-placement |
327 scoped_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); | 327 std::unique_ptr<aura::Window> window1(CreateTestWindowInShellWithId(1)); |
328 gfx::Rect desktop_area = window1->parent()->bounds(); | 328 gfx::Rect desktop_area = window1->parent()->bounds(); |
329 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 329 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
330 window1->Hide(); | 330 window1->Hide(); |
331 window1->SetBounds(gfx::Rect(16, 32, 231, 320)); | 331 window1->SetBounds(gfx::Rect(16, 32, 231, 320)); |
332 window1->Show(); | 332 window1->Show(); |
333 | 333 |
334 // |window1| should be centered in work area. | 334 // |window1| should be centered in work area. |
335 EXPECT_EQ(base::IntToString( | 335 EXPECT_EQ(base::IntToString( |
336 (desktop_area.width() - docked_width(manager) - | 336 (desktop_area.width() - docked_width(manager) - |
337 min_dock_gap() - window1->bounds().width()) / 2) + | 337 min_dock_gap() - window1->bounds().width()) / 2) + |
338 ",32 231x320", window1->bounds().ToString()); | 338 ",32 231x320", window1->bounds().ToString()); |
339 | 339 |
340 scoped_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); | 340 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(2)); |
341 wm::GetWindowState(window2.get())->set_window_position_managed(true); | 341 wm::GetWindowState(window2.get())->set_window_position_managed(true); |
342 // To avoid any auto window manager changes due to SetBounds, the window | 342 // To avoid any auto window manager changes due to SetBounds, the window |
343 // gets first hidden and then shown again. | 343 // gets first hidden and then shown again. |
344 window2->Hide(); | 344 window2->Hide(); |
345 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); | 345 window2->SetBounds(gfx::Rect(32, 48, 256, 512)); |
346 window2->Show(); | 346 window2->Show(); |
347 | 347 |
348 // |window1| should be flush left and |window2| flush right. | 348 // |window1| should be flush left and |window2| flush right. |
349 EXPECT_EQ("0,32 231x320", window1->bounds().ToString()); | 349 EXPECT_EQ("0,32 231x320", window1->bounds().ToString()); |
350 EXPECT_EQ( | 350 EXPECT_EQ( |
351 base::IntToString( | 351 base::IntToString( |
352 desktop_area.width() - window2->bounds().width() - | 352 desktop_area.width() - window2->bounds().width() - |
353 docked_width(manager) - min_dock_gap()) + | 353 docked_width(manager) - min_dock_gap()) + |
354 ",48 256x512", window2->bounds().ToString()); | 354 ",48 256x512", window2->bounds().ToString()); |
355 } | 355 } |
356 | 356 |
357 // Tests that with a window docked on the right the auto-placing logic in | 357 // Tests that with a window docked on the right the auto-placing logic in |
358 // RearrangeVisibleWindowOnShow places windows flush with work area edges. | 358 // RearrangeVisibleWindowOnShow places windows flush with work area edges. |
359 // Test case for the secondary screen. | 359 // Test case for the secondary screen. |
360 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRightSecondScreen) { | 360 TEST_P(DockedWindowLayoutManagerTest, AutoPlacingRightSecondScreen) { |
361 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) | 361 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) |
362 return; | 362 return; |
363 | 363 |
364 // Create a dual screen layout. | 364 // Create a dual screen layout. |
365 UpdateDisplay("600x600,600x600"); | 365 UpdateDisplay("600x600,600x600"); |
366 | 366 |
367 gfx::Rect bounds(600, 0, 201, 201); | 367 gfx::Rect bounds(600, 0, 201, 201); |
368 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 368 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
369 // Drag pointer to the right edge of the second screen. | 369 // Drag pointer to the right edge of the second screen. |
370 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 370 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
371 | 371 |
372 // The window should be attached and snapped to the right side of the screen. | 372 // The window should be attached and snapped to the right side of the screen. |
373 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), | 373 EXPECT_EQ(window->GetRootWindow()->GetBoundsInScreen().right(), |
374 window->GetBoundsInScreen().right()); | 374 window->GetBoundsInScreen().right()); |
375 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 375 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
376 | 376 |
377 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( | 377 DockedWindowLayoutManager* manager = static_cast<DockedWindowLayoutManager*>( |
378 window->parent()->layout_manager()); | 378 window->parent()->layout_manager()); |
379 | 379 |
380 // Create two additional windows and test their auto-placement | 380 // Create two additional windows and test their auto-placement |
381 bounds = gfx::Rect(616, 32, 231, 320); | 381 bounds = gfx::Rect(616, 32, 231, 320); |
382 scoped_ptr<aura::Window> window1( | 382 std::unique_ptr<aura::Window> window1( |
383 CreateTestWindowInShellWithDelegate(nullptr, 1, bounds)); | 383 CreateTestWindowInShellWithDelegate(nullptr, 1, bounds)); |
384 gfx::Rect desktop_area = window1->parent()->bounds(); | 384 gfx::Rect desktop_area = window1->parent()->bounds(); |
385 wm::GetWindowState(window1.get())->set_window_position_managed(true); | 385 wm::GetWindowState(window1.get())->set_window_position_managed(true); |
386 window1->Hide(); | 386 window1->Hide(); |
387 window1->Show(); | 387 window1->Show(); |
388 | 388 |
389 // |window1| should be centered in work area. | 389 // |window1| should be centered in work area. |
390 EXPECT_EQ(base::IntToString( | 390 EXPECT_EQ(base::IntToString( |
391 600 + (desktop_area.width() - docked_width(manager) - | 391 600 + (desktop_area.width() - docked_width(manager) - |
392 min_dock_gap() - window1->bounds().width()) / 2) + | 392 min_dock_gap() - window1->bounds().width()) / 2) + |
393 ",32 231x320", window1->GetBoundsInScreen().ToString()); | 393 ",32 231x320", window1->GetBoundsInScreen().ToString()); |
394 | 394 |
395 bounds = gfx::Rect(632, 48, 256, 512); | 395 bounds = gfx::Rect(632, 48, 256, 512); |
396 scoped_ptr<aura::Window> window2( | 396 std::unique_ptr<aura::Window> window2( |
397 CreateTestWindowInShellWithDelegate(nullptr, 2, bounds)); | 397 CreateTestWindowInShellWithDelegate(nullptr, 2, bounds)); |
398 wm::GetWindowState(window2.get())->set_window_position_managed(true); | 398 wm::GetWindowState(window2.get())->set_window_position_managed(true); |
399 // To avoid any auto window manager changes due to SetBounds, the window | 399 // To avoid any auto window manager changes due to SetBounds, the window |
400 // gets first hidden and then shown again. | 400 // gets first hidden and then shown again. |
401 window2->Hide(); | 401 window2->Hide(); |
402 window2->Show(); | 402 window2->Show(); |
403 | 403 |
404 // |window1| should be flush left and |window2| flush right. | 404 // |window1| should be flush left and |window2| flush right. |
405 EXPECT_EQ("600,32 231x320", window1->GetBoundsInScreen().ToString()); | 405 EXPECT_EQ("600,32 231x320", window1->GetBoundsInScreen().ToString()); |
406 EXPECT_EQ( | 406 EXPECT_EQ( |
407 base::IntToString( | 407 base::IntToString( |
408 600 + desktop_area.width() - window2->bounds().width() - | 408 600 + desktop_area.width() - window2->bounds().width() - |
409 docked_width(manager) - min_dock_gap()) + | 409 docked_width(manager) - min_dock_gap()) + |
410 ",48 256x512", window2->GetBoundsInScreen().ToString()); | 410 ",48 256x512", window2->GetBoundsInScreen().ToString()); |
411 } | 411 } |
412 | 412 |
413 // Adds two windows and tests that the gaps are evenly distributed. | 413 // Adds two windows and tests that the gaps are evenly distributed. |
414 TEST_P(DockedWindowLayoutManagerTest, AddTwoWindows) { | 414 TEST_P(DockedWindowLayoutManagerTest, AddTwoWindows) { |
415 if (!SupportsHostWindowResize()) | 415 if (!SupportsHostWindowResize()) |
416 return; | 416 return; |
417 | 417 |
418 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 418 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
419 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); | 419 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); |
420 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 420 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
421 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); | 421 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); |
422 | 422 |
423 // The windows should be attached and snapped to the right side of the screen. | 423 // The windows should be attached and snapped to the right side of the screen. |
424 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 424 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
425 w1->GetBoundsInScreen().right()); | 425 w1->GetBoundsInScreen().right()); |
426 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 426 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
427 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 427 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
428 w2->GetBoundsInScreen().right()); | 428 w2->GetBoundsInScreen().right()); |
429 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 429 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
430 | 430 |
431 // Test that the gaps differ at most by a single pixel. | 431 // Test that the gaps differ at most by a single pixel. |
432 gfx::Rect work_area = | 432 gfx::Rect work_area = |
433 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 433 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
434 int gap1 = w1->GetBoundsInScreen().y(); | 434 int gap1 = w1->GetBoundsInScreen().y(); |
435 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); | 435 int gap2 = w2->GetBoundsInScreen().y() - w1->GetBoundsInScreen().bottom(); |
436 int gap3 = work_area.bottom() - w2->GetBoundsInScreen().bottom(); | 436 int gap3 = work_area.bottom() - w2->GetBoundsInScreen().bottom(); |
437 EXPECT_EQ(0, gap1); | 437 EXPECT_EQ(0, gap1); |
438 EXPECT_NEAR(gap2, min_dock_gap(), 1); | 438 EXPECT_NEAR(gap2, min_dock_gap(), 1); |
439 EXPECT_EQ(0, gap3); | 439 EXPECT_EQ(0, gap3); |
440 } | 440 } |
441 | 441 |
442 // Adds two non-overlapping windows and tests layout after a drag. | 442 // Adds two non-overlapping windows and tests layout after a drag. |
443 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsDragging) { | 443 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsDragging) { |
444 if (!SupportsHostWindowResize()) | 444 if (!SupportsHostWindowResize()) |
445 return; | 445 return; |
446 | 446 |
447 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 447 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
448 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); | 448 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); |
449 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 449 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
450 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); | 450 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); |
451 | 451 |
452 // The windows should be attached and snapped to the right side of the screen. | 452 // The windows should be attached and snapped to the right side of the screen. |
453 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 453 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
454 w1->GetBoundsInScreen().right()); | 454 w1->GetBoundsInScreen().right()); |
455 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 455 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
456 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 456 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
457 w2->GetBoundsInScreen().right()); | 457 w2->GetBoundsInScreen().right()); |
458 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 458 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
(...skipping 13 matching lines...) Expand all Loading... |
472 EXPECT_NEAR(gap2, min_dock_gap(), 1); | 472 EXPECT_NEAR(gap2, min_dock_gap(), 1); |
473 EXPECT_EQ(0, gap3); | 473 EXPECT_EQ(0, gap3); |
474 } | 474 } |
475 | 475 |
476 // Adds three overlapping windows and tests layout after a drag. | 476 // Adds three overlapping windows and tests layout after a drag. |
477 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDragging) { | 477 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsDragging) { |
478 if (!SupportsHostWindowResize()) | 478 if (!SupportsHostWindowResize()) |
479 return; | 479 return; |
480 UpdateDisplay("600x1000"); | 480 UpdateDisplay("600x1000"); |
481 | 481 |
482 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 310))); | 482 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 310))); |
483 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 483 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
484 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 310))); | 484 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 310))); |
485 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 500); | 485 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 500); |
486 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 310))); | 486 std::unique_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 310))); |
487 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 600); | 487 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 600); |
488 | 488 |
489 // All windows should be attached and snapped to the right side of the screen. | 489 // All windows should be attached and snapped to the right side of the screen. |
490 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 490 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
491 w1->GetBoundsInScreen().right()); | 491 w1->GetBoundsInScreen().right()); |
492 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 492 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
493 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 493 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
494 w2->GetBoundsInScreen().right()); | 494 w2->GetBoundsInScreen().right()); |
495 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 495 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
496 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), | 496 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) | 540 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) |
541 return; | 541 return; |
542 | 542 |
543 // Create two screen vertical layout. | 543 // Create two screen vertical layout. |
544 UpdateDisplay("600x1000,600x1000"); | 544 UpdateDisplay("600x1000,600x1000"); |
545 // Layout the secondary display to the bottom of the primary. | 545 // Layout the secondary display to the bottom of the primary. |
546 ASSERT_GT(gfx::Screen::GetScreen()->GetNumDisplays(), 1); | 546 ASSERT_GT(gfx::Screen::GetScreen()->GetNumDisplays(), 1); |
547 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 547 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
548 test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 0)); | 548 test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 0)); |
549 | 549 |
550 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 1000, 201, 310))); | 550 std::unique_ptr<aura::Window> w1( |
| 551 CreateTestWindow(gfx::Rect(0, 1000, 201, 310))); |
551 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 1000 + 20); | 552 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 1000 + 20); |
552 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 1000, 210, 310))); | 553 std::unique_ptr<aura::Window> w2( |
| 554 CreateTestWindow(gfx::Rect(0, 1000, 210, 310))); |
553 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 1000 + 500); | 555 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 1000 + 500); |
554 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 1000, 220, 310))); | 556 std::unique_ptr<aura::Window> w3( |
| 557 CreateTestWindow(gfx::Rect(0, 1000, 220, 310))); |
555 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 1000 + 600); | 558 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 1000 + 600); |
556 | 559 |
557 // All windows should be attached and snapped to the right side of the screen. | 560 // All windows should be attached and snapped to the right side of the screen. |
558 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 561 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
559 w1->GetBoundsInScreen().right()); | 562 w1->GetBoundsInScreen().right()); |
560 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 563 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
561 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 564 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
562 w2->GetBoundsInScreen().right()); | 565 w2->GetBoundsInScreen().right()); |
563 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 566 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
564 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), | 567 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 EXPECT_NEAR(gap2, min_dock_gap(), 1); | 604 EXPECT_NEAR(gap2, min_dock_gap(), 1); |
602 EXPECT_NEAR(gap3, min_dock_gap(), 1); | 605 EXPECT_NEAR(gap3, min_dock_gap(), 1); |
603 EXPECT_EQ(0, gap4); | 606 EXPECT_EQ(0, gap4); |
604 } | 607 } |
605 | 608 |
606 // Tests that a second window added to the dock is resized to match. | 609 // Tests that a second window added to the dock is resized to match. |
607 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsWidthNew) { | 610 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsWidthNew) { |
608 if (!SupportsHostWindowResize()) | 611 if (!SupportsHostWindowResize()) |
609 return; | 612 return; |
610 | 613 |
611 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 614 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
612 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 280, 202))); | 615 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 280, 202))); |
613 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 616 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
614 // The first window should get resized to ideal width. | 617 // The first window should get resized to ideal width. |
615 EXPECT_EQ(ideal_width(), w1->bounds().width()); | 618 EXPECT_EQ(ideal_width(), w1->bounds().width()); |
616 | 619 |
617 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); | 620 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); |
618 // The second window should get resized to the existing dock. | 621 // The second window should get resized to the existing dock. |
619 EXPECT_EQ(ideal_width(), w2->bounds().width()); | 622 EXPECT_EQ(ideal_width(), w2->bounds().width()); |
620 } | 623 } |
621 | 624 |
622 // Tests that a first non-resizable window added to the dock is not resized. | 625 // Tests that a first non-resizable window added to the dock is not resized. |
623 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsWidthNonResizableFirst) { | 626 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsWidthNonResizableFirst) { |
624 if (!SupportsHostWindowResize()) | 627 if (!SupportsHostWindowResize()) |
625 return; | 628 return; |
626 | 629 |
627 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 630 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
628 w1->SetProperty(aura::client::kCanResizeKey, false); | 631 w1->SetProperty(aura::client::kCanResizeKey, false); |
629 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 280, 202))); | 632 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 280, 202))); |
630 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 633 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
631 // The first window should not get resized. | 634 // The first window should not get resized. |
632 EXPECT_EQ(201, w1->bounds().width()); | 635 EXPECT_EQ(201, w1->bounds().width()); |
633 | 636 |
634 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); | 637 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); |
635 // The second window should get resized to the first window's width. | 638 // The second window should get resized to the first window's width. |
636 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); | 639 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); |
637 } | 640 } |
638 | 641 |
639 // Tests that a second non-resizable window added to the dock is not resized. | 642 // Tests that a second non-resizable window added to the dock is not resized. |
640 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsWidthNonResizableSecond) { | 643 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsWidthNonResizableSecond) { |
641 if (!SupportsHostWindowResize()) | 644 if (!SupportsHostWindowResize()) |
642 return; | 645 return; |
643 | 646 |
644 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 647 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
645 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 280, 202))); | 648 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 280, 202))); |
646 w2->SetProperty(aura::client::kCanResizeKey, false); | 649 w2->SetProperty(aura::client::kCanResizeKey, false); |
647 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 650 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
648 // The first window should get resized to ideal width. | 651 // The first window should get resized to ideal width. |
649 EXPECT_EQ(ideal_width(), w1->bounds().width()); | 652 EXPECT_EQ(ideal_width(), w1->bounds().width()); |
650 | 653 |
651 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); | 654 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); |
652 // The second window should not get resized. | 655 // The second window should not get resized. |
653 EXPECT_EQ(280, w2->bounds().width()); | 656 EXPECT_EQ(280, w2->bounds().width()); |
654 | 657 |
655 // The first window should get resized again - to match the second window. | 658 // The first window should get resized again - to match the second window. |
656 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); | 659 EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); |
657 } | 660 } |
658 | 661 |
659 // Test that restrictions on minimum and maximum width of windows are honored. | 662 // Test that restrictions on minimum and maximum width of windows are honored. |
660 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsWidthRestrictions) { | 663 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsWidthRestrictions) { |
661 if (!SupportsHostWindowResize()) | 664 if (!SupportsHostWindowResize()) |
662 return; | 665 return; |
663 | 666 |
664 aura::test::TestWindowDelegate delegate1; | 667 aura::test::TestWindowDelegate delegate1; |
665 delegate1.set_maximum_size(gfx::Size(240, 0)); | 668 delegate1.set_maximum_size(gfx::Size(240, 0)); |
666 scoped_ptr<aura::Window> w1(CreateTestWindowWithDelegate( | 669 std::unique_ptr<aura::Window> w1( |
667 gfx::Rect(0, 0, 201, 201), &delegate1)); | 670 CreateTestWindowWithDelegate(gfx::Rect(0, 0, 201, 201), &delegate1)); |
668 aura::test::TestWindowDelegate delegate2; | 671 aura::test::TestWindowDelegate delegate2; |
669 delegate2.set_minimum_size(gfx::Size(260, 0)); | 672 delegate2.set_minimum_size(gfx::Size(260, 0)); |
670 scoped_ptr<aura::Window> w2(CreateTestWindowWithDelegate( | 673 std::unique_ptr<aura::Window> w2( |
671 gfx::Rect(0, 0, 280, 202), &delegate2)); | 674 CreateTestWindowWithDelegate(gfx::Rect(0, 0, 280, 202), &delegate2)); |
672 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 675 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
673 // The first window should get resized to its maximum width. | 676 // The first window should get resized to its maximum width. |
674 EXPECT_EQ(240, w1->bounds().width()); | 677 EXPECT_EQ(240, w1->bounds().width()); |
675 | 678 |
676 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); | 679 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 300); |
677 // The second window should get resized to its minimum width. | 680 // The second window should get resized to its minimum width. |
678 EXPECT_EQ(260, w2->bounds().width()); | 681 EXPECT_EQ(260, w2->bounds().width()); |
679 | 682 |
680 // The first window should be centered relative to the second. | 683 // The first window should be centered relative to the second. |
681 EXPECT_EQ(w1->bounds().CenterPoint().x(), w2->bounds().CenterPoint().x()); | 684 EXPECT_EQ(w1->bounds().CenterPoint().x(), w2->bounds().CenterPoint().x()); |
682 } | 685 } |
683 | 686 |
684 // Test that restrictions on minimum width of windows are honored. | 687 // Test that restrictions on minimum width of windows are honored. |
685 TEST_P(DockedWindowLayoutManagerTest, WidthMoreThanMax) { | 688 TEST_P(DockedWindowLayoutManagerTest, WidthMoreThanMax) { |
686 if (!SupportsHostWindowResize()) | 689 if (!SupportsHostWindowResize()) |
687 return; | 690 return; |
688 | 691 |
689 aura::test::TestWindowDelegate delegate; | 692 aura::test::TestWindowDelegate delegate; |
690 delegate.set_minimum_size(gfx::Size(400, 0)); | 693 delegate.set_minimum_size(gfx::Size(400, 0)); |
691 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 694 std::unique_ptr<aura::Window> window( |
692 gfx::Rect(0, 0, 400, 201), &delegate)); | 695 CreateTestWindowWithDelegate(gfx::Rect(0, 0, 400, 201), &delegate)); |
693 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); | 696 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, window.get(), 20); |
694 | 697 |
695 // Secondary drag ensures that we are testing the minimum size restriction | 698 // Secondary drag ensures that we are testing the minimum size restriction |
696 // and not just failure to get past the tiling step in SnapSizer. | 699 // and not just failure to get past the tiling step in SnapSizer. |
697 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window.get(), | 700 ASSERT_NO_FATAL_FAILURE(DragStartAtOffsetFromwindowOrigin(window.get(), |
698 25, 5)); | 701 25, 5)); |
699 DragMove(150,0); | 702 DragMove(150,0); |
700 DragEnd(); | 703 DragEnd(); |
701 | 704 |
702 // The window should not get docked even though it is dragged past the edge. | 705 // The window should not get docked even though it is dragged past the edge. |
703 EXPECT_NE(window->GetRootWindow()->bounds().right(), | 706 EXPECT_NE(window->GetRootWindow()->bounds().right(), |
704 window->GetBoundsInScreen().right()); | 707 window->GetBoundsInScreen().right()); |
705 EXPECT_NE(kShellWindowId_DockedContainer, window->parent()->id()); | 708 EXPECT_NE(kShellWindowId_DockedContainer, window->parent()->id()); |
706 } | 709 } |
707 | 710 |
708 // Docks three windows and tests that the very first window gets minimized. | 711 // Docks three windows and tests that the very first window gets minimized. |
709 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsMinimize) { | 712 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsMinimize) { |
710 if (!SupportsHostWindowResize()) | 713 if (!SupportsHostWindowResize()) |
711 return; | 714 return; |
712 | 715 |
713 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 716 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
714 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 717 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
715 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); | 718 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); |
716 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 200); | 719 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 200); |
717 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); | 720 std::unique_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); |
718 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); | 721 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); |
719 | 722 |
720 // The last two windows should be attached and snapped to the right edge. | 723 // The last two windows should be attached and snapped to the right edge. |
721 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 724 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
722 w2->GetBoundsInScreen().right()); | 725 w2->GetBoundsInScreen().right()); |
723 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 726 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
724 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), | 727 EXPECT_EQ(w3->GetRootWindow()->bounds().right(), |
725 w3->GetBoundsInScreen().right()); | 728 w3->GetBoundsInScreen().right()); |
726 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); | 729 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); |
727 | 730 |
(...skipping 12 matching lines...) Expand all Loading... |
740 EXPECT_TRUE(wm::GetWindowState(w3.get())->IsDocked()); | 743 EXPECT_TRUE(wm::GetWindowState(w3.get())->IsDocked()); |
741 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 744 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
742 } | 745 } |
743 | 746 |
744 // Docks up to three windows and tests that they split vertical space. | 747 // Docks up to three windows and tests that they split vertical space. |
745 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsSplitHeightEvenly) { | 748 TEST_P(DockedWindowLayoutManagerTest, ThreeWindowsSplitHeightEvenly) { |
746 if (!SupportsHostWindowResize()) | 749 if (!SupportsHostWindowResize()) |
747 return; | 750 return; |
748 | 751 |
749 UpdateDisplay("600x1000"); | 752 UpdateDisplay("600x1000"); |
750 scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); | 753 std::unique_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); |
751 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 754 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
752 scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); | 755 std::unique_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 202))); |
753 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 200); | 756 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 200); |
754 | 757 |
755 // The two windows should be attached and snapped to the right edge. | 758 // The two windows should be attached and snapped to the right edge. |
756 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 759 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
757 w1->GetBoundsInScreen().right()); | 760 w1->GetBoundsInScreen().right()); |
758 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 761 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
759 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 762 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
760 w2->GetBoundsInScreen().right()); | 763 w2->GetBoundsInScreen().right()); |
761 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 764 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
762 | 765 |
763 // The two windows should be same size vertically and almost 1/2 of work area. | 766 // The two windows should be same size vertically and almost 1/2 of work area. |
764 gfx::Rect work_area = | 767 gfx::Rect work_area = |
765 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); | 768 gfx::Screen::GetScreen()->GetDisplayNearestWindow(w1.get()).work_area(); |
766 EXPECT_NEAR(w1->GetBoundsInScreen().height(), | 769 EXPECT_NEAR(w1->GetBoundsInScreen().height(), |
767 w2->GetBoundsInScreen().height(), | 770 w2->GetBoundsInScreen().height(), |
768 1); | 771 1); |
769 EXPECT_NEAR(work_area.height() / 2, w1->GetBoundsInScreen().height(), | 772 EXPECT_NEAR(work_area.height() / 2, w1->GetBoundsInScreen().height(), |
770 min_dock_gap() * 2); | 773 min_dock_gap() * 2); |
771 | 774 |
772 // Create and dock the third window. | 775 // Create and dock the third window. |
773 scoped_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); | 776 std::unique_ptr<aura::Window> w3(CreateTestWindow(gfx::Rect(0, 0, 220, 204))); |
774 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); | 777 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w3.get(), 300); |
775 | 778 |
776 // All three windows should be docked and snapped to the right edge. | 779 // All three windows should be docked and snapped to the right edge. |
777 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 780 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
778 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); | 781 EXPECT_EQ(kShellWindowId_DockedContainer, w2->parent()->id()); |
779 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); | 782 EXPECT_EQ(kShellWindowId_DockedContainer, w3->parent()->id()); |
780 | 783 |
781 // All windows should be near same size vertically and about 1/3 of work area. | 784 // All windows should be near same size vertically and about 1/3 of work area. |
782 EXPECT_NEAR(w1->GetBoundsInScreen().height(), | 785 EXPECT_NEAR(w1->GetBoundsInScreen().height(), |
783 w2->GetBoundsInScreen().height(), | 786 w2->GetBoundsInScreen().height(), |
784 1); | 787 1); |
785 EXPECT_NEAR(w2->GetBoundsInScreen().height(), | 788 EXPECT_NEAR(w2->GetBoundsInScreen().height(), |
786 w3->GetBoundsInScreen().height(), | 789 w3->GetBoundsInScreen().height(), |
787 1); | 790 1); |
788 EXPECT_NEAR(work_area.height() / 3, w1->GetBoundsInScreen().height(), | 791 EXPECT_NEAR(work_area.height() / 3, w1->GetBoundsInScreen().height(), |
789 min_dock_gap() * 2); | 792 min_dock_gap() * 2); |
790 } | 793 } |
791 | 794 |
792 // Docks two windows and tests that restrictions on vertical size are honored. | 795 // Docks two windows and tests that restrictions on vertical size are honored. |
793 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsHeightRestrictions) { | 796 TEST_P(DockedWindowLayoutManagerTest, TwoWindowsHeightRestrictions) { |
794 if (!SupportsHostWindowResize()) | 797 if (!SupportsHostWindowResize()) |
795 return; | 798 return; |
796 | 799 |
797 // The first window is fixed height. | 800 // The first window is fixed height. |
798 aura::test::TestWindowDelegate delegate1; | 801 aura::test::TestWindowDelegate delegate1; |
799 delegate1.set_minimum_size(gfx::Size(0, 300)); | 802 delegate1.set_minimum_size(gfx::Size(0, 300)); |
800 delegate1.set_maximum_size(gfx::Size(0, 300)); | 803 delegate1.set_maximum_size(gfx::Size(0, 300)); |
801 scoped_ptr<aura::Window> w1(CreateTestWindowWithDelegate( | 804 std::unique_ptr<aura::Window> w1( |
802 gfx::Rect(0, 0, 201, 300), &delegate1)); | 805 CreateTestWindowWithDelegate(gfx::Rect(0, 0, 201, 300), &delegate1)); |
803 // The second window has maximum height. | 806 // The second window has maximum height. |
804 aura::test::TestWindowDelegate delegate2; | 807 aura::test::TestWindowDelegate delegate2; |
805 delegate2.set_maximum_size(gfx::Size(0, 100)); | 808 delegate2.set_maximum_size(gfx::Size(0, 100)); |
806 scoped_ptr<aura::Window> w2(CreateTestWindowWithDelegate( | 809 std::unique_ptr<aura::Window> w2( |
807 gfx::Rect(0, 0, 280, 90), &delegate2)); | 810 CreateTestWindowWithDelegate(gfx::Rect(0, 0, 280, 90), &delegate2)); |
808 | 811 |
809 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); | 812 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); |
810 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 200); | 813 DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w2.get(), 200); |
811 | 814 |
812 // The two windows should be attached and snapped to the right edge. | 815 // The two windows should be attached and snapped to the right edge. |
813 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), | 816 EXPECT_EQ(w1->GetRootWindow()->bounds().right(), |
814 w1->GetBoundsInScreen().right()); | 817 w1->GetBoundsInScreen().right()); |
815 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); | 818 EXPECT_EQ(kShellWindowId_DockedContainer, w1->parent()->id()); |
816 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), | 819 EXPECT_EQ(w2->GetRootWindow()->bounds().right(), |
817 w2->GetBoundsInScreen().right()); | 820 w2->GetBoundsInScreen().right()); |
(...skipping 14 matching lines...) Expand all Loading... |
832 // Tests that a docked window is moved to primary display when secondary display | 835 // Tests that a docked window is moved to primary display when secondary display |
833 // is disconnected and that it stays docked and properly positioned. | 836 // is disconnected and that it stays docked and properly positioned. |
834 TEST_P(DockedWindowLayoutManagerTest, DisplayDisconnectionMovesDocked) { | 837 TEST_P(DockedWindowLayoutManagerTest, DisplayDisconnectionMovesDocked) { |
835 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) | 838 if (!SupportsMultipleDisplays() || !SupportsHostWindowResize()) |
836 return; | 839 return; |
837 | 840 |
838 // Create a dual screen layout. | 841 // Create a dual screen layout. |
839 UpdateDisplay("600x700,800x600"); | 842 UpdateDisplay("600x700,800x600"); |
840 | 843 |
841 gfx::Rect bounds(600, 0, 201, 201); | 844 gfx::Rect bounds(600, 0, 201, 201); |
842 scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); | 845 std::unique_ptr<aura::Window> window(CreateTestWindow(bounds)); |
843 // Drag pointer to the right edge of the second screen. | 846 // Drag pointer to the right edge of the second screen. |
844 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); | 847 DragRelativeToEdge(DOCKED_EDGE_RIGHT, window.get(), 0); |
845 | 848 |
846 // Simulate disconnection of the secondary display. | 849 // Simulate disconnection of the secondary display. |
847 UpdateDisplay("600x700"); | 850 UpdateDisplay("600x700"); |
848 | 851 |
849 // The window should be still docked at the right edge. | 852 // The window should be still docked at the right edge. |
850 // Its height should grow to match the new work area. | 853 // Its height should grow to match the new work area. |
851 EXPECT_EQ(window->GetRootWindow()->bounds().right(), | 854 EXPECT_EQ(window->GetRootWindow()->bounds().right(), |
852 window->GetBoundsInScreen().right()); | 855 window->GetBoundsInScreen().right()); |
853 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 856 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
854 EXPECT_EQ(ideal_width(), window->bounds().width()); | 857 EXPECT_EQ(ideal_width(), window->bounds().width()); |
855 gfx::Rect work_area = gfx::Screen::GetScreen() | 858 gfx::Rect work_area = gfx::Screen::GetScreen() |
856 ->GetDisplayNearestWindow(window.get()) | 859 ->GetDisplayNearestWindow(window.get()) |
857 .work_area(); | 860 .work_area(); |
858 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); | 861 EXPECT_EQ(work_area.height(), window->GetBoundsInScreen().height()); |
859 } | 862 } |
860 | 863 |
861 // Tests run twice - on both panels and normal windows | 864 // Tests run twice - on both panels and normal windows |
862 INSTANTIATE_TEST_CASE_P(NormalOrPanel, | 865 INSTANTIATE_TEST_CASE_P(NormalOrPanel, |
863 DockedWindowLayoutManagerTest, | 866 DockedWindowLayoutManagerTest, |
864 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 867 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
865 ui::wm::WINDOW_TYPE_PANEL)); | 868 ui::wm::WINDOW_TYPE_PANEL)); |
866 | 869 |
867 } // namespace ash | 870 } // namespace ash |
OLD | NEW |