| 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/wm/panels/panel_layout_manager.h" | 5 #include "ash/wm/panels/panel_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
| 9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
| 10 #include "ash/shelf/shelf_button.h" | 10 #include "ash/shelf/shelf_button.h" |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 ShelfVisibilityState visibility_state) { | 240 ShelfVisibilityState visibility_state) { |
| 241 Shelf* shelf = Shelf::ForWindow(window); | 241 Shelf* shelf = Shelf::ForWindow(window); |
| 242 shelf->shelf_layout_manager()->SetState(visibility_state); | 242 shelf->shelf_layout_manager()->SetState(visibility_state); |
| 243 } | 243 } |
| 244 | 244 |
| 245 ShelfView* GetShelfView(Shelf* shelf) { | 245 ShelfView* GetShelfView(Shelf* shelf) { |
| 246 return test::ShelfTestAPI(shelf).shelf_view(); | 246 return test::ShelfTestAPI(shelf).shelf_view(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 private: | 249 private: |
| 250 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; | 250 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; |
| 251 | 251 |
| 252 bool IsHorizontal(ShelfAlignment alignment) { | 252 bool IsHorizontal(ShelfAlignment alignment) { |
| 253 return alignment == SHELF_ALIGNMENT_BOTTOM; | 253 return alignment == SHELF_ALIGNMENT_BOTTOM; |
| 254 } | 254 } |
| 255 | 255 |
| 256 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest); | 256 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTest); |
| 257 }; | 257 }; |
| 258 | 258 |
| 259 class PanelLayoutManagerTextDirectionTest | 259 class PanelLayoutManagerTextDirectionTest |
| 260 : public PanelLayoutManagerTest, | 260 : public PanelLayoutManagerTest, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 280 private: | 280 private: |
| 281 bool is_rtl_; | 281 bool is_rtl_; |
| 282 std::string original_locale_; | 282 std::string original_locale_; |
| 283 | 283 |
| 284 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTextDirectionTest); | 284 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManagerTextDirectionTest); |
| 285 }; | 285 }; |
| 286 | 286 |
| 287 // Tests that a created panel window is above the shelf icon in LTR and RTL. | 287 // Tests that a created panel window is above the shelf icon in LTR and RTL. |
| 288 TEST_P(PanelLayoutManagerTextDirectionTest, AddOnePanel) { | 288 TEST_P(PanelLayoutManagerTextDirectionTest, AddOnePanel) { |
| 289 gfx::Rect bounds(0, 0, 201, 201); | 289 gfx::Rect bounds(0, 0, 201, 201); |
| 290 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); | 290 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds)); |
| 291 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); | 291 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); |
| 292 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); | 292 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); |
| 293 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); | 293 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); |
| 294 } | 294 } |
| 295 | 295 |
| 296 // Tests that a created panel window is successfully aligned over a hidden | 296 // Tests that a created panel window is successfully aligned over a hidden |
| 297 // shelf icon. | 297 // shelf icon. |
| 298 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) { | 298 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIcon) { |
| 299 gfx::Rect bounds(0, 0, 201, 201); | 299 gfx::Rect bounds(0, 0, 201, 201); |
| 300 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(), | 300 SetShelfAutoHideBehavior(Shell::GetPrimaryRootWindow(), |
| 301 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 301 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 302 scoped_ptr<aura::Window> normal_window(CreateNormalWindow(bounds)); | 302 std::unique_ptr<aura::Window> normal_window(CreateNormalWindow(bounds)); |
| 303 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); | 303 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds)); |
| 304 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); | 304 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); |
| 305 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); | 305 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); |
| 306 } | 306 } |
| 307 | 307 |
| 308 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIconSecondDisplay) { | 308 TEST_F(PanelLayoutManagerTest, PanelAlignsToHiddenLauncherIconSecondDisplay) { |
| 309 if (!SupportsMultipleDisplays()) | 309 if (!SupportsMultipleDisplays()) |
| 310 return; | 310 return; |
| 311 | 311 |
| 312 // Keep the displays wide so that shelves have enough space for shelves | 312 // Keep the displays wide so that shelves have enough space for shelves |
| 313 // buttons. | 313 // buttons. |
| 314 UpdateDisplay("400x400,600x400"); | 314 UpdateDisplay("400x400,600x400"); |
| 315 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 315 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 316 | 316 |
| 317 scoped_ptr<aura::Window> normal_window( | 317 std::unique_ptr<aura::Window> normal_window( |
| 318 CreateNormalWindow(gfx::Rect(450, 0, 100, 100))); | 318 CreateNormalWindow(gfx::Rect(450, 0, 100, 100))); |
| 319 scoped_ptr<aura::Window> panel(CreatePanelWindow(gfx::Rect(400, 0, 50, 50))); | 319 std::unique_ptr<aura::Window> panel( |
| 320 CreatePanelWindow(gfx::Rect(400, 0, 50, 50))); |
| 320 EXPECT_EQ(root_windows[1], panel->GetRootWindow()); | 321 EXPECT_EQ(root_windows[1], panel->GetRootWindow()); |
| 321 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(panel.get())); | 322 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(panel.get())); |
| 322 gfx::Rect shelf_visible_position = panel->GetBoundsInScreen(); | 323 gfx::Rect shelf_visible_position = panel->GetBoundsInScreen(); |
| 323 | 324 |
| 324 SetShelfAutoHideBehavior(root_windows[1], | 325 SetShelfAutoHideBehavior(root_windows[1], |
| 325 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 326 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 326 // Expect the panel X position to remain the same after the shelf is hidden | 327 // Expect the panel X position to remain the same after the shelf is hidden |
| 327 // but the Y to move down. | 328 // but the Y to move down. |
| 328 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(panel.get())); | 329 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(panel.get())); |
| 329 EXPECT_EQ(shelf_visible_position.x(), panel->GetBoundsInScreen().x()); | 330 EXPECT_EQ(shelf_visible_position.x(), panel->GetBoundsInScreen().x()); |
| 330 EXPECT_GT(panel->GetBoundsInScreen().y(), shelf_visible_position.y()); | 331 EXPECT_GT(panel->GetBoundsInScreen().y(), shelf_visible_position.y()); |
| 331 } | 332 } |
| 332 | 333 |
| 333 // Tests interactions between multiple panels | 334 // Tests interactions between multiple panels |
| 334 TEST_F(PanelLayoutManagerTest, MultiplePanelsAreAboveIcons) { | 335 TEST_F(PanelLayoutManagerTest, MultiplePanelsAreAboveIcons) { |
| 335 gfx::Rect odd_bounds(0, 0, 201, 201); | 336 gfx::Rect odd_bounds(0, 0, 201, 201); |
| 336 gfx::Rect even_bounds(0, 0, 200, 200); | 337 gfx::Rect even_bounds(0, 0, 200, 200); |
| 337 | 338 |
| 338 scoped_ptr<aura::Window> w1(CreatePanelWindow(odd_bounds)); | 339 std::unique_ptr<aura::Window> w1(CreatePanelWindow(odd_bounds)); |
| 339 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); | 340 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); |
| 340 | 341 |
| 341 scoped_ptr<aura::Window> w2(CreatePanelWindow(even_bounds)); | 342 std::unique_ptr<aura::Window> w2(CreatePanelWindow(even_bounds)); |
| 342 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); | 343 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); |
| 343 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); | 344 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); |
| 344 | 345 |
| 345 scoped_ptr<aura::Window> w3(CreatePanelWindow(odd_bounds)); | 346 std::unique_ptr<aura::Window> w3(CreatePanelWindow(odd_bounds)); |
| 346 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); | 347 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); |
| 347 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); | 348 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); |
| 348 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); | 349 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); |
| 349 } | 350 } |
| 350 | 351 |
| 351 TEST_F(PanelLayoutManagerTest, MultiplePanelStacking) { | 352 TEST_F(PanelLayoutManagerTest, MultiplePanelStacking) { |
| 352 gfx::Rect bounds(0, 0, 201, 201); | 353 gfx::Rect bounds(0, 0, 201, 201); |
| 353 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 354 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
| 354 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 355 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
| 355 scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 356 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
| 356 | 357 |
| 357 // Default stacking order. | 358 // Default stacking order. |
| 358 EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); | 359 EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); |
| 359 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); | 360 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); |
| 360 | 361 |
| 361 // Changing the active window should update the stacking order. | 362 // Changing the active window should update the stacking order. |
| 362 wm::ActivateWindow(w1.get()); | 363 wm::ActivateWindow(w1.get()); |
| 363 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 364 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 364 EXPECT_TRUE(WindowIsAbove(w1.get(), w2.get())); | 365 EXPECT_TRUE(WindowIsAbove(w1.get(), w2.get())); |
| 365 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); | 366 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); |
| 366 | 367 |
| 367 wm::ActivateWindow(w2.get()); | 368 wm::ActivateWindow(w2.get()); |
| 368 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 369 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 369 EXPECT_TRUE(WindowIsAbove(w1.get(), w3.get())); | 370 EXPECT_TRUE(WindowIsAbove(w1.get(), w3.get())); |
| 370 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); | 371 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); |
| 371 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); | 372 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); |
| 372 | 373 |
| 373 wm::ActivateWindow(w3.get()); | 374 wm::ActivateWindow(w3.get()); |
| 374 EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); | 375 EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); |
| 375 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); | 376 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); |
| 376 } | 377 } |
| 377 | 378 |
| 378 TEST_F(PanelLayoutManagerTest, MultiplePanelStackingVertical) { | 379 TEST_F(PanelLayoutManagerTest, MultiplePanelStackingVertical) { |
| 379 // Set shelf to be aligned on the right. | 380 // Set shelf to be aligned on the right. |
| 380 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT); | 381 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT); |
| 381 | 382 |
| 382 // Size panels in such a way that ordering them by X coordinate would cause | 383 // Size panels in such a way that ordering them by X coordinate would cause |
| 383 // stacking order to be incorrect. Test that stacking order is based on Y. | 384 // stacking order to be incorrect. Test that stacking order is based on Y. |
| 384 scoped_ptr<aura::Window> w1(CreatePanelWindow(gfx::Rect(0, 0, 210, 201))); | 385 std::unique_ptr<aura::Window> w1( |
| 385 scoped_ptr<aura::Window> w2(CreatePanelWindow(gfx::Rect(0, 0, 220, 201))); | 386 CreatePanelWindow(gfx::Rect(0, 0, 210, 201))); |
| 386 scoped_ptr<aura::Window> w3(CreatePanelWindow(gfx::Rect(0, 0, 200, 201))); | 387 std::unique_ptr<aura::Window> w2( |
| 388 CreatePanelWindow(gfx::Rect(0, 0, 220, 201))); |
| 389 std::unique_ptr<aura::Window> w3( |
| 390 CreatePanelWindow(gfx::Rect(0, 0, 200, 201))); |
| 387 | 391 |
| 388 // Default stacking order. | 392 // Default stacking order. |
| 389 EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); | 393 EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); |
| 390 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); | 394 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); |
| 391 | 395 |
| 392 // Changing the active window should update the stacking order. | 396 // Changing the active window should update the stacking order. |
| 393 wm::ActivateWindow(w1.get()); | 397 wm::ActivateWindow(w1.get()); |
| 394 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 398 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 395 EXPECT_TRUE(WindowIsAbove(w1.get(), w2.get())); | 399 EXPECT_TRUE(WindowIsAbove(w1.get(), w2.get())); |
| 396 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); | 400 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); |
| 397 | 401 |
| 398 wm::ActivateWindow(w2.get()); | 402 wm::ActivateWindow(w2.get()); |
| 399 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 403 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 400 EXPECT_TRUE(WindowIsAbove(w1.get(), w3.get())); | 404 EXPECT_TRUE(WindowIsAbove(w1.get(), w3.get())); |
| 401 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); | 405 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); |
| 402 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); | 406 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); |
| 403 | 407 |
| 404 wm::ActivateWindow(w3.get()); | 408 wm::ActivateWindow(w3.get()); |
| 405 EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); | 409 EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get())); |
| 406 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); | 410 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); |
| 407 } | 411 } |
| 408 | 412 |
| 409 TEST_F(PanelLayoutManagerTest, MultiplePanelCallout) { | 413 TEST_F(PanelLayoutManagerTest, MultiplePanelCallout) { |
| 410 gfx::Rect bounds(0, 0, 200, 200); | 414 gfx::Rect bounds(0, 0, 200, 200); |
| 411 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 415 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
| 412 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 416 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
| 413 scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 417 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
| 414 scoped_ptr<aura::Window> w4(CreateNormalWindow(gfx::Rect())); | 418 std::unique_ptr<aura::Window> w4(CreateNormalWindow(gfx::Rect())); |
| 415 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 419 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 416 EXPECT_TRUE(IsPanelCalloutVisible(w1.get())); | 420 EXPECT_TRUE(IsPanelCalloutVisible(w1.get())); |
| 417 EXPECT_TRUE(IsPanelCalloutVisible(w2.get())); | 421 EXPECT_TRUE(IsPanelCalloutVisible(w2.get())); |
| 418 EXPECT_TRUE(IsPanelCalloutVisible(w3.get())); | 422 EXPECT_TRUE(IsPanelCalloutVisible(w3.get())); |
| 419 wm::ActivateWindow(w1.get()); | 423 wm::ActivateWindow(w1.get()); |
| 420 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w1.get())); | 424 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w1.get())); |
| 421 wm::ActivateWindow(w2.get()); | 425 wm::ActivateWindow(w2.get()); |
| 422 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w2.get())); | 426 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w2.get())); |
| 423 wm::ActivateWindow(w3.get()); | 427 wm::ActivateWindow(w3.get()); |
| 424 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w3.get())); | 428 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w3.get())); |
| 425 wm::ActivateWindow(w4.get()); | 429 wm::ActivateWindow(w4.get()); |
| 426 wm::ActivateWindow(w3.get()); | 430 wm::ActivateWindow(w3.get()); |
| 427 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w3.get())); | 431 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w3.get())); |
| 428 w3.reset(); | 432 w3.reset(); |
| 429 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w2.get())); | 433 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w2.get())); |
| 430 } | 434 } |
| 431 | 435 |
| 432 // Tests removing panels. | 436 // Tests removing panels. |
| 433 TEST_F(PanelLayoutManagerTest, RemoveLeftPanel) { | 437 TEST_F(PanelLayoutManagerTest, RemoveLeftPanel) { |
| 434 gfx::Rect bounds(0, 0, 201, 201); | 438 gfx::Rect bounds(0, 0, 201, 201); |
| 435 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 439 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
| 436 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 440 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
| 437 scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 441 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
| 438 | 442 |
| 439 // At this point, windows should be stacked with 1 < 2 < 3 | 443 // At this point, windows should be stacked with 1 < 2 < 3 |
| 440 wm::ActivateWindow(w1.get()); | 444 wm::ActivateWindow(w1.get()); |
| 441 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 445 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 442 // Now, windows should be stacked 1 > 2 > 3 | 446 // Now, windows should be stacked 1 > 2 > 3 |
| 443 w1.reset(); | 447 w1.reset(); |
| 444 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); | 448 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); |
| 445 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); | 449 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); |
| 446 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); | 450 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); |
| 447 } | 451 } |
| 448 | 452 |
| 449 TEST_F(PanelLayoutManagerTest, RemoveMiddlePanel) { | 453 TEST_F(PanelLayoutManagerTest, RemoveMiddlePanel) { |
| 450 gfx::Rect bounds(0, 0, 201, 201); | 454 gfx::Rect bounds(0, 0, 201, 201); |
| 451 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 455 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
| 452 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 456 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
| 453 scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 457 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
| 454 | 458 |
| 455 // At this point, windows should be stacked with 1 < 2 < 3 | 459 // At this point, windows should be stacked with 1 < 2 < 3 |
| 456 wm::ActivateWindow(w2.get()); | 460 wm::ActivateWindow(w2.get()); |
| 457 // Windows should be stacked 1 < 2 > 3 | 461 // Windows should be stacked 1 < 2 > 3 |
| 458 w2.reset(); | 462 w2.reset(); |
| 459 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); | 463 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); |
| 460 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); | 464 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); |
| 461 EXPECT_TRUE(WindowIsAbove(w3.get(), w1.get())); | 465 EXPECT_TRUE(WindowIsAbove(w3.get(), w1.get())); |
| 462 } | 466 } |
| 463 | 467 |
| 464 TEST_F(PanelLayoutManagerTest, RemoveRightPanel) { | 468 TEST_F(PanelLayoutManagerTest, RemoveRightPanel) { |
| 465 gfx::Rect bounds(0, 0, 201, 201); | 469 gfx::Rect bounds(0, 0, 201, 201); |
| 466 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 470 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
| 467 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 471 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
| 468 scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 472 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
| 469 | 473 |
| 470 // At this point, windows should be stacked with 1 < 2 < 3 | 474 // At this point, windows should be stacked with 1 < 2 < 3 |
| 471 wm::ActivateWindow(w3.get()); | 475 wm::ActivateWindow(w3.get()); |
| 472 // Order shouldn't change. | 476 // Order shouldn't change. |
| 473 w3.reset(); | 477 w3.reset(); |
| 474 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); | 478 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); |
| 475 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); | 479 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); |
| 476 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); | 480 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); |
| 477 } | 481 } |
| 478 | 482 |
| 479 TEST_F(PanelLayoutManagerTest, RemoveNonActivePanel) { | 483 TEST_F(PanelLayoutManagerTest, RemoveNonActivePanel) { |
| 480 gfx::Rect bounds(0, 0, 201, 201); | 484 gfx::Rect bounds(0, 0, 201, 201); |
| 481 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 485 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
| 482 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 486 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
| 483 scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 487 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
| 484 | 488 |
| 485 // At this point, windows should be stacked with 1 < 2 < 3 | 489 // At this point, windows should be stacked with 1 < 2 < 3 |
| 486 wm::ActivateWindow(w2.get()); | 490 wm::ActivateWindow(w2.get()); |
| 487 // Windows should be stacked 1 < 2 > 3 | 491 // Windows should be stacked 1 < 2 > 3 |
| 488 w1.reset(); | 492 w1.reset(); |
| 489 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); | 493 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); |
| 490 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); | 494 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); |
| 491 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); | 495 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); |
| 492 } | 496 } |
| 493 | 497 |
| 494 TEST_F(PanelLayoutManagerTest, SplitView) { | 498 TEST_F(PanelLayoutManagerTest, SplitView) { |
| 495 gfx::Rect bounds(0, 0, 90, 201); | 499 gfx::Rect bounds(0, 0, 90, 201); |
| 496 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 500 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
| 497 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 501 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
| 498 | 502 |
| 499 EXPECT_NO_FATAL_FAILURE(PanelsNotOverlapping(w1.get(), w2.get())); | 503 EXPECT_NO_FATAL_FAILURE(PanelsNotOverlapping(w1.get(), w2.get())); |
| 500 } | 504 } |
| 501 | 505 |
| 502 #if defined(OS_WIN) | 506 #if defined(OS_WIN) |
| 503 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 507 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 504 #define MAYBE_SplitViewOverlapWhenLarge DISABLED_SplitViewOverlapWhenLarge | 508 #define MAYBE_SplitViewOverlapWhenLarge DISABLED_SplitViewOverlapWhenLarge |
| 505 #else | 509 #else |
| 506 #define MAYBE_SplitViewOverlapWhenLarge SplitViewOverlapWhenLarge | 510 #define MAYBE_SplitViewOverlapWhenLarge SplitViewOverlapWhenLarge |
| 507 #endif | 511 #endif |
| 508 | 512 |
| 509 TEST_F(PanelLayoutManagerTest, MAYBE_SplitViewOverlapWhenLarge) { | 513 TEST_F(PanelLayoutManagerTest, MAYBE_SplitViewOverlapWhenLarge) { |
| 510 gfx::Rect bounds(0, 0, 600, 201); | 514 gfx::Rect bounds(0, 0, 600, 201); |
| 511 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 515 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
| 512 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 516 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
| 513 | 517 |
| 514 EXPECT_NO_FATAL_FAILURE(PanelInScreen(w1.get())); | 518 EXPECT_NO_FATAL_FAILURE(PanelInScreen(w1.get())); |
| 515 EXPECT_NO_FATAL_FAILURE(PanelInScreen(w2.get())); | 519 EXPECT_NO_FATAL_FAILURE(PanelInScreen(w2.get())); |
| 516 } | 520 } |
| 517 | 521 |
| 518 TEST_F(PanelLayoutManagerTest, FanWindows) { | 522 TEST_F(PanelLayoutManagerTest, FanWindows) { |
| 519 gfx::Rect bounds(0, 0, 201, 201); | 523 gfx::Rect bounds(0, 0, 201, 201); |
| 520 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 524 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
| 521 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 525 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
| 522 scoped_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 526 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
| 523 | 527 |
| 524 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 528 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 525 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); | 529 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); |
| 526 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); | 530 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); |
| 527 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); | 531 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); |
| 528 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 532 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 529 int icon_x1 = shelf->GetScreenBoundsOfItemIconForWindow(w1.get()).x(); | 533 int icon_x1 = shelf->GetScreenBoundsOfItemIconForWindow(w1.get()).x(); |
| 530 int icon_x2 = shelf->GetScreenBoundsOfItemIconForWindow(w2.get()).x(); | 534 int icon_x2 = shelf->GetScreenBoundsOfItemIconForWindow(w2.get()).x(); |
| 531 EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2); | 535 EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2); |
| 532 int spacing = window_x2 - window_x1; | 536 int spacing = window_x2 - window_x1; |
| 533 EXPECT_GT(spacing, icon_x2 - icon_x1); | 537 EXPECT_GT(spacing, icon_x2 - icon_x1); |
| 534 } | 538 } |
| 535 | 539 |
| 536 TEST_F(PanelLayoutManagerTest, FanLargeWindow) { | 540 TEST_F(PanelLayoutManagerTest, FanLargeWindow) { |
| 537 gfx::Rect small_bounds(0, 0, 201, 201); | 541 gfx::Rect small_bounds(0, 0, 201, 201); |
| 538 gfx::Rect large_bounds(0, 0, 501, 201); | 542 gfx::Rect large_bounds(0, 0, 501, 201); |
| 539 scoped_ptr<aura::Window> w1(CreatePanelWindow(small_bounds)); | 543 std::unique_ptr<aura::Window> w1(CreatePanelWindow(small_bounds)); |
| 540 scoped_ptr<aura::Window> w2(CreatePanelWindow(large_bounds)); | 544 std::unique_ptr<aura::Window> w2(CreatePanelWindow(large_bounds)); |
| 541 scoped_ptr<aura::Window> w3(CreatePanelWindow(small_bounds)); | 545 std::unique_ptr<aura::Window> w3(CreatePanelWindow(small_bounds)); |
| 542 | 546 |
| 543 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 547 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 544 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); | 548 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); |
| 545 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); | 549 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); |
| 546 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); | 550 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); |
| 547 // The distances may not be equidistant with a large panel but the panels | 551 // The distances may not be equidistant with a large panel but the panels |
| 548 // should be in the correct order with respect to their midpoints. | 552 // should be in the correct order with respect to their midpoints. |
| 549 EXPECT_GT(window_x2, window_x1); | 553 EXPECT_GT(window_x2, window_x1); |
| 550 EXPECT_GT(window_x3, window_x2); | 554 EXPECT_GT(window_x3, window_x2); |
| 551 } | 555 } |
| 552 | 556 |
| 553 TEST_F(PanelLayoutManagerTest, MinimizeRestorePanel) { | 557 TEST_F(PanelLayoutManagerTest, MinimizeRestorePanel) { |
| 554 gfx::Rect bounds(0, 0, 201, 201); | 558 gfx::Rect bounds(0, 0, 201, 201); |
| 555 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); | 559 std::unique_ptr<aura::Window> window(CreatePanelWindow(bounds)); |
| 556 // Activate the window, ensure callout is visible. | 560 // Activate the window, ensure callout is visible. |
| 557 wm::ActivateWindow(window.get()); | 561 wm::ActivateWindow(window.get()); |
| 558 RunAllPendingInMessageLoop(); | 562 RunAllPendingInMessageLoop(); |
| 559 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); | 563 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); |
| 560 // Minimize the panel, callout should be hidden. | 564 // Minimize the panel, callout should be hidden. |
| 561 wm::GetWindowState(window.get())->Minimize(); | 565 wm::GetWindowState(window.get())->Minimize(); |
| 562 RunAllPendingInMessageLoop(); | 566 RunAllPendingInMessageLoop(); |
| 563 EXPECT_FALSE(IsPanelCalloutVisible(window.get())); | 567 EXPECT_FALSE(IsPanelCalloutVisible(window.get())); |
| 564 // Restore the panel; panel should not be activated by default but callout | 568 // Restore the panel; panel should not be activated by default but callout |
| 565 // should be visible. | 569 // should be visible. |
| 566 wm::GetWindowState(window.get())->Unminimize(); | 570 wm::GetWindowState(window.get())->Unminimize(); |
| 567 RunAllPendingInMessageLoop(); | 571 RunAllPendingInMessageLoop(); |
| 568 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); | 572 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); |
| 569 // Activate the window, ensure callout is visible. | 573 // Activate the window, ensure callout is visible. |
| 570 wm::ActivateWindow(window.get()); | 574 wm::ActivateWindow(window.get()); |
| 571 RunAllPendingInMessageLoop(); | 575 RunAllPendingInMessageLoop(); |
| 572 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); | 576 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); |
| 573 } | 577 } |
| 574 | 578 |
| 575 TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { | 579 TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { |
| 576 if (!SupportsMultipleDisplays()) | 580 if (!SupportsMultipleDisplays()) |
| 577 return; | 581 return; |
| 578 | 582 |
| 579 // Keep the displays wide so that shelves have enough space for launcher | 583 // Keep the displays wide so that shelves have enough space for launcher |
| 580 // buttons. | 584 // buttons. |
| 581 UpdateDisplay("600x400,600x400"); | 585 UpdateDisplay("600x400,600x400"); |
| 582 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 586 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 583 | 587 |
| 584 scoped_ptr<aura::Window> p1_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); | 588 std::unique_ptr<aura::Window> p1_d1( |
| 585 scoped_ptr<aura::Window> p2_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); | 589 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); |
| 586 scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); | 590 std::unique_ptr<aura::Window> p2_d1( |
| 587 scoped_ptr<aura::Window> p2_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); | 591 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); |
| 592 std::unique_ptr<aura::Window> p1_d2( |
| 593 CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); |
| 594 std::unique_ptr<aura::Window> p2_d2( |
| 595 CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); |
| 588 | 596 |
| 589 ShelfView* shelf_view_1st = GetShelfView(Shelf::ForPrimaryDisplay()); | 597 ShelfView* shelf_view_1st = GetShelfView(Shelf::ForPrimaryDisplay()); |
| 590 ShelfView* shelf_view_2nd = | 598 ShelfView* shelf_view_2nd = |
| 591 GetShelfView(Shelf::ForWindow(root_windows[1])); | 599 GetShelfView(Shelf::ForWindow(root_windows[1])); |
| 592 | 600 |
| 593 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); | 601 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); |
| 594 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); | 602 EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); |
| 595 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); | 603 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); |
| 596 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); | 604 EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); |
| 597 | 605 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 TEST_F(PanelLayoutManagerTest, PanelAttachPositionMultipleDisplays) { | 662 TEST_F(PanelLayoutManagerTest, PanelAttachPositionMultipleDisplays) { |
| 655 if (!SupportsMultipleDisplays()) | 663 if (!SupportsMultipleDisplays()) |
| 656 return; | 664 return; |
| 657 | 665 |
| 658 // Keep the displays wide so that shelves have enough space for shelf buttons. | 666 // Keep the displays wide so that shelves have enough space for shelf buttons. |
| 659 // Use differently sized displays so the shelf is in a different | 667 // Use differently sized displays so the shelf is in a different |
| 660 // position on second display. | 668 // position on second display. |
| 661 UpdateDisplay("600x400,600x600"); | 669 UpdateDisplay("600x400,600x600"); |
| 662 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 670 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 663 | 671 |
| 664 scoped_ptr<aura::Window> p1_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); | 672 std::unique_ptr<aura::Window> p1_d1( |
| 665 scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); | 673 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); |
| 674 std::unique_ptr<aura::Window> p1_d2( |
| 675 CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); |
| 666 | 676 |
| 667 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); | 677 EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); |
| 668 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); | 678 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); |
| 669 | 679 |
| 670 IsPanelAboveLauncherIcon(p1_d1.get()); | 680 IsPanelAboveLauncherIcon(p1_d1.get()); |
| 671 IsCalloutAboveLauncherIcon(p1_d1.get()); | 681 IsCalloutAboveLauncherIcon(p1_d1.get()); |
| 672 IsPanelAboveLauncherIcon(p1_d2.get()); | 682 IsPanelAboveLauncherIcon(p1_d2.get()); |
| 673 IsCalloutAboveLauncherIcon(p1_d2.get()); | 683 IsCalloutAboveLauncherIcon(p1_d2.get()); |
| 674 } | 684 } |
| 675 | 685 |
| 676 TEST_F(PanelLayoutManagerTest, PanelAlignmentSecondDisplay) { | 686 TEST_F(PanelLayoutManagerTest, PanelAlignmentSecondDisplay) { |
| 677 if (!SupportsMultipleDisplays()) | 687 if (!SupportsMultipleDisplays()) |
| 678 return; | 688 return; |
| 679 | 689 |
| 680 UpdateDisplay("600x400,600x400"); | 690 UpdateDisplay("600x400,600x400"); |
| 681 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 691 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 682 | 692 |
| 683 scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); | 693 std::unique_ptr<aura::Window> p1_d2( |
| 694 CreatePanelWindow(gfx::Rect(600, 0, 50, 50))); |
| 684 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); | 695 EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); |
| 685 | 696 |
| 686 IsPanelAboveLauncherIcon(p1_d2.get()); | 697 IsPanelAboveLauncherIcon(p1_d2.get()); |
| 687 IsCalloutAboveLauncherIcon(p1_d2.get()); | 698 IsCalloutAboveLauncherIcon(p1_d2.get()); |
| 688 | 699 |
| 689 SetAlignment(root_windows[1], SHELF_ALIGNMENT_RIGHT); | 700 SetAlignment(root_windows[1], SHELF_ALIGNMENT_RIGHT); |
| 690 IsPanelAboveLauncherIcon(p1_d2.get()); | 701 IsPanelAboveLauncherIcon(p1_d2.get()); |
| 691 IsCalloutAboveLauncherIcon(p1_d2.get()); | 702 IsCalloutAboveLauncherIcon(p1_d2.get()); |
| 692 SetAlignment(root_windows[1], SHELF_ALIGNMENT_LEFT); | 703 SetAlignment(root_windows[1], SHELF_ALIGNMENT_LEFT); |
| 693 IsPanelAboveLauncherIcon(p1_d2.get()); | 704 IsPanelAboveLauncherIcon(p1_d2.get()); |
| 694 IsCalloutAboveLauncherIcon(p1_d2.get()); | 705 IsCalloutAboveLauncherIcon(p1_d2.get()); |
| 695 } | 706 } |
| 696 | 707 |
| 697 TEST_F(PanelLayoutManagerTest, AlignmentLeft) { | 708 TEST_F(PanelLayoutManagerTest, AlignmentLeft) { |
| 698 gfx::Rect bounds(0, 0, 201, 201); | 709 gfx::Rect bounds(0, 0, 201, 201); |
| 699 scoped_ptr<aura::Window> w(CreatePanelWindow(bounds)); | 710 std::unique_ptr<aura::Window> w(CreatePanelWindow(bounds)); |
| 700 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT); | 711 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT); |
| 701 IsPanelAboveLauncherIcon(w.get()); | 712 IsPanelAboveLauncherIcon(w.get()); |
| 702 IsCalloutAboveLauncherIcon(w.get()); | 713 IsCalloutAboveLauncherIcon(w.get()); |
| 703 } | 714 } |
| 704 | 715 |
| 705 TEST_F(PanelLayoutManagerTest, AlignmentRight) { | 716 TEST_F(PanelLayoutManagerTest, AlignmentRight) { |
| 706 gfx::Rect bounds(0, 0, 201, 201); | 717 gfx::Rect bounds(0, 0, 201, 201); |
| 707 scoped_ptr<aura::Window> w(CreatePanelWindow(bounds)); | 718 std::unique_ptr<aura::Window> w(CreatePanelWindow(bounds)); |
| 708 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT); | 719 SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT); |
| 709 IsPanelAboveLauncherIcon(w.get()); | 720 IsPanelAboveLauncherIcon(w.get()); |
| 710 IsCalloutAboveLauncherIcon(w.get()); | 721 IsCalloutAboveLauncherIcon(w.get()); |
| 711 } | 722 } |
| 712 | 723 |
| 713 // Tests that panels will hide and restore their state with the shelf visibility | 724 // Tests that panels will hide and restore their state with the shelf visibility |
| 714 // state. This ensures that entering full-screen mode will hide your panels | 725 // state. This ensures that entering full-screen mode will hide your panels |
| 715 // until you leave it. | 726 // until you leave it. |
| 716 TEST_F(PanelLayoutManagerTest, PanelsHideAndRestoreWithShelf) { | 727 TEST_F(PanelLayoutManagerTest, PanelsHideAndRestoreWithShelf) { |
| 717 gfx::Rect bounds(0, 0, 201, 201); | 728 gfx::Rect bounds(0, 0, 201, 201); |
| 718 | 729 |
| 719 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 730 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
| 720 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 731 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
| 721 scoped_ptr<aura::Window> w3; | 732 std::unique_ptr<aura::Window> w3; |
| 722 // Minimize w2. | 733 // Minimize w2. |
| 723 wm::GetWindowState(w2.get())->Minimize(); | 734 wm::GetWindowState(w2.get())->Minimize(); |
| 724 RunAllPendingInMessageLoop(); | 735 RunAllPendingInMessageLoop(); |
| 725 EXPECT_TRUE(w1->IsVisible()); | 736 EXPECT_TRUE(w1->IsVisible()); |
| 726 EXPECT_FALSE(w2->IsVisible()); | 737 EXPECT_FALSE(w2->IsVisible()); |
| 727 | 738 |
| 728 SetShelfVisibilityState(Shell::GetPrimaryRootWindow(), SHELF_HIDDEN); | 739 SetShelfVisibilityState(Shell::GetPrimaryRootWindow(), SHELF_HIDDEN); |
| 729 RunAllPendingInMessageLoop(); | 740 RunAllPendingInMessageLoop(); |
| 730 | 741 |
| 731 // w3 is created while in full-screen mode, should only become visible when | 742 // w3 is created while in full-screen mode, should only become visible when |
| (...skipping 25 matching lines...) Expand all Loading... |
| 757 // Windows should be restored to their prior state. | 768 // Windows should be restored to their prior state. |
| 758 EXPECT_TRUE(w1->IsVisible()); | 769 EXPECT_TRUE(w1->IsVisible()); |
| 759 EXPECT_FALSE(w2->IsVisible()); | 770 EXPECT_FALSE(w2->IsVisible()); |
| 760 EXPECT_TRUE(w3->IsVisible()); | 771 EXPECT_TRUE(w3->IsVisible()); |
| 761 } | 772 } |
| 762 | 773 |
| 763 // Verifies that touches along the attached edge of a panel do not | 774 // Verifies that touches along the attached edge of a panel do not |
| 764 // target the panel itself. | 775 // target the panel itself. |
| 765 TEST_F(PanelLayoutManagerTest, TouchHitTestPanel) { | 776 TEST_F(PanelLayoutManagerTest, TouchHitTestPanel) { |
| 766 aura::test::TestWindowDelegate delegate; | 777 aura::test::TestWindowDelegate delegate; |
| 767 scoped_ptr<aura::Window> w( | 778 std::unique_ptr<aura::Window> w( |
| 768 CreatePanelWindowWithDelegate(&delegate, gfx::Rect(0, 0, 200, 200))); | 779 CreatePanelWindowWithDelegate(&delegate, gfx::Rect(0, 0, 200, 200))); |
| 769 ui::EventTarget* root = w->GetRootWindow(); | 780 ui::EventTarget* root = w->GetRootWindow(); |
| 770 ui::EventTargeter* targeter = root->GetEventTargeter(); | 781 ui::EventTargeter* targeter = root->GetEventTargeter(); |
| 771 | 782 |
| 772 // Note that the constants used in the touch locations below are | 783 // Note that the constants used in the touch locations below are |
| 773 // arbitrarily-selected small numbers which will ensure the point is | 784 // arbitrarily-selected small numbers which will ensure the point is |
| 774 // within the default extended region surrounding the panel. This value | 785 // within the default extended region surrounding the panel. This value |
| 775 // is calculated as | 786 // is calculated as |
| 776 // kResizeOutsideBoundsSize * kResizeOutsideBoundsScaleForTouch | 787 // kResizeOutsideBoundsSize * kResizeOutsideBoundsScaleForTouch |
| 777 // in src/ash/root_window_controller.cc. | 788 // in src/ash/root_window_controller.cc. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 // Hit test outside the left edge with a left-aligned shelf. | 823 // Hit test outside the left edge with a left-aligned shelf. |
| 813 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); | 824 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); |
| 814 target = targeter->FindTargetForEvent(root, &touch); | 825 target = targeter->FindTargetForEvent(root, &touch); |
| 815 EXPECT_NE(w.get(), target); | 826 EXPECT_NE(w.get(), target); |
| 816 } | 827 } |
| 817 | 828 |
| 818 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, | 829 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, |
| 819 testing::Bool()); | 830 testing::Bool()); |
| 820 | 831 |
| 821 } // namespace ash | 832 } // namespace ash |
| OLD | NEW |