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/public/cpp/config.h" |
7 #include "ash/public/cpp/shelf_types.h" | 8 #include "ash/public/cpp/shelf_types.h" |
8 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
9 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
10 #include "ash/shelf/shelf_button.h" | 11 #include "ash/shelf/shelf_button.h" |
11 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
12 #include "ash/shelf/shelf_model.h" | 13 #include "ash/shelf/shelf_model.h" |
13 #include "ash/shelf/shelf_view.h" | 14 #include "ash/shelf/shelf_view.h" |
14 #include "ash/shelf/shelf_widget.h" | 15 #include "ash/shelf/shelf_widget.h" |
15 #include "ash/shelf/wm_shelf.h" | 16 #include "ash/shelf/wm_shelf.h" |
16 #include "ash/shell.h" | 17 #include "ash/shell.h" |
17 #include "ash/shell_port.h" | |
18 #include "ash/system/web_notification/web_notification_tray.h" | 18 #include "ash/system/web_notification/web_notification_tray.h" |
19 #include "ash/test/ash_test_base.h" | 19 #include "ash/test/ash_test_base.h" |
20 #include "ash/test/shelf_view_test_api.h" | 20 #include "ash/test/shelf_view_test_api.h" |
21 #include "ash/test/test_shelf_delegate.h" | 21 #include "ash/test/test_shelf_delegate.h" |
22 #include "ash/wm/mru_window_tracker.h" | 22 #include "ash/wm/mru_window_tracker.h" |
23 #include "ash/wm/window_properties.h" | 23 #include "ash/wm/window_properties.h" |
24 #include "ash/wm/window_state.h" | 24 #include "ash/wm/window_state.h" |
25 #include "ash/wm/window_state_aura.h" | 25 #include "ash/wm/window_state_aura.h" |
26 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
27 #include "ash/wm_window.h" | 27 #include "ash/wm_window.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); | 298 EXPECT_EQ(GetPanelContainer(window.get()), window->parent()); |
299 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); | 299 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(window.get())); |
300 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); | 300 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(window.get())); |
301 } | 301 } |
302 | 302 |
303 // Tests for crashes during undocking. | 303 // Tests for crashes during undocking. |
304 // See https://crbug.com/632755 | 304 // See https://crbug.com/632755 |
305 TEST_F(PanelLayoutManagerTest, UndockTest) { | 305 TEST_F(PanelLayoutManagerTest, UndockTest) { |
306 // TODO: mash doesn't support SetFirstDisplayAsInternalDisplay(). | 306 // TODO: mash doesn't support SetFirstDisplayAsInternalDisplay(). |
307 // http://crbug.com/698091. | 307 // http://crbug.com/698091. |
308 if (ShellPort::Get()->IsRunningInMash()) | 308 if (Shell::GetAshConfig() == Config::MASH) |
309 return; | 309 return; |
310 | 310 |
311 std::vector<display::ManagedDisplayInfo> info_list; | 311 std::vector<display::ManagedDisplayInfo> info_list; |
312 | 312 |
313 const int64_t internal_display_id = | 313 const int64_t internal_display_id = |
314 display::test::DisplayManagerTestApi(Shell::Get()->display_manager()) | 314 display::test::DisplayManagerTestApi(Shell::Get()->display_manager()) |
315 .SetFirstDisplayAsInternalDisplay(); | 315 .SetFirstDisplayAsInternalDisplay(); |
316 | 316 |
317 // Create the primary display info. | 317 // Create the primary display info. |
318 display::ManagedDisplayInfo internal_display = | 318 display::ManagedDisplayInfo internal_display = |
(...skipping 15 matching lines...) Expand all Loading... |
334 | 334 |
335 // Undock and bring back the native device display as primary display. | 335 // Undock and bring back the native device display as primary display. |
336 display_manager()->OnNativeDisplaysChanged(info_list); | 336 display_manager()->OnNativeDisplaysChanged(info_list); |
337 } | 337 } |
338 | 338 |
339 // Tests for any crash during docking and then undocking. | 339 // Tests for any crash during docking and then undocking. |
340 // See https://crbug.com/632755 | 340 // See https://crbug.com/632755 |
341 TEST_F(PanelLayoutManagerTest, DockUndockTest) { | 341 TEST_F(PanelLayoutManagerTest, DockUndockTest) { |
342 // TODO: mash doesn't support SetFirstDisplayAsInternalDisplay(). | 342 // TODO: mash doesn't support SetFirstDisplayAsInternalDisplay(). |
343 // http://crbug.com/698091. | 343 // http://crbug.com/698091. |
344 if (ShellPort::Get()->IsRunningInMash()) | 344 if (Shell::GetAshConfig() == Config::MASH) |
345 return; | 345 return; |
346 | 346 |
347 std::vector<display::ManagedDisplayInfo> info_list; | 347 std::vector<display::ManagedDisplayInfo> info_list; |
348 | 348 |
349 const int64_t internal_display_id = | 349 const int64_t internal_display_id = |
350 display::test::DisplayManagerTestApi(Shell::Get()->display_manager()) | 350 display::test::DisplayManagerTestApi(Shell::Get()->display_manager()) |
351 .SetFirstDisplayAsInternalDisplay(); | 351 .SetFirstDisplayAsInternalDisplay(); |
352 | 352 |
353 // Create the primary display info. | 353 // Create the primary display info. |
354 display::ManagedDisplayInfo internal_display = | 354 display::ManagedDisplayInfo internal_display = |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 500 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
501 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 501 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
502 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 502 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
503 std::unique_ptr<aura::Window> w4(CreateNormalWindow(gfx::Rect())); | 503 std::unique_ptr<aura::Window> w4(CreateNormalWindow(gfx::Rect())); |
504 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 504 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
505 EXPECT_TRUE(IsPanelCalloutVisible(w1.get())); | 505 EXPECT_TRUE(IsPanelCalloutVisible(w1.get())); |
506 EXPECT_TRUE(IsPanelCalloutVisible(w2.get())); | 506 EXPECT_TRUE(IsPanelCalloutVisible(w2.get())); |
507 EXPECT_TRUE(IsPanelCalloutVisible(w3.get())); | 507 EXPECT_TRUE(IsPanelCalloutVisible(w3.get())); |
508 | 508 |
509 // TODO: investigate failure. http://crbug.com/698887. | 509 // TODO: investigate failure. http://crbug.com/698887. |
510 if (ShellPort::Get()->IsRunningInMash()) | 510 if (Shell::GetAshConfig() == Config::MASH) |
511 return; | 511 return; |
512 | 512 |
513 wm::ActivateWindow(w1.get()); | 513 wm::ActivateWindow(w1.get()); |
514 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w1.get())); | 514 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w1.get())); |
515 wm::ActivateWindow(w2.get()); | 515 wm::ActivateWindow(w2.get()); |
516 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w2.get())); | 516 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w2.get())); |
517 wm::ActivateWindow(w3.get()); | 517 wm::ActivateWindow(w3.get()); |
518 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w3.get())); | 518 EXPECT_NO_FATAL_FAILURE(IsCalloutAboveLauncherIcon(w3.get())); |
519 wm::ActivateWindow(w4.get()); | 519 wm::ActivateWindow(w4.get()); |
520 wm::ActivateWindow(w3.get()); | 520 wm::ActivateWindow(w3.get()); |
(...skipping 14 matching lines...) Expand all Loading... |
535 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 535 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
536 // Now, windows should be stacked 1 > 2 > 3 | 536 // Now, windows should be stacked 1 > 2 > 3 |
537 w1.reset(); | 537 w1.reset(); |
538 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); | 538 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); |
539 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); | 539 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); |
540 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); | 540 EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get())); |
541 } | 541 } |
542 | 542 |
543 TEST_F(PanelLayoutManagerTest, RemoveMiddlePanel) { | 543 TEST_F(PanelLayoutManagerTest, RemoveMiddlePanel) { |
544 // TODO: fails because of ShelfModel. http://crbug.com/698878. | 544 // TODO: fails because of ShelfModel. http://crbug.com/698878. |
545 if (ShellPort::Get()->IsRunningInMash()) | 545 if (Shell::GetAshConfig() == Config::MASH) |
546 return; | 546 return; |
547 | 547 |
548 gfx::Rect bounds(0, 0, 201, 201); | 548 gfx::Rect bounds(0, 0, 201, 201); |
549 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 549 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
550 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 550 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
551 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 551 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
552 | 552 |
553 // At this point, windows should be stacked with 1 < 2 < 3 | 553 // At this point, windows should be stacked with 1 < 2 < 3 |
554 wm::ActivateWindow(w2.get()); | 554 wm::ActivateWindow(w2.get()); |
555 // Windows should be stacked 1 < 2 > 3 | 555 // Windows should be stacked 1 < 2 > 3 |
556 w2.reset(); | 556 w2.reset(); |
557 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); | 557 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); |
558 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); | 558 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w3.get())); |
559 EXPECT_TRUE(WindowIsAbove(w3.get(), w1.get())); | 559 EXPECT_TRUE(WindowIsAbove(w3.get(), w1.get())); |
560 } | 560 } |
561 | 561 |
562 TEST_F(PanelLayoutManagerTest, RemoveRightPanel) { | 562 TEST_F(PanelLayoutManagerTest, RemoveRightPanel) { |
563 // TODO: fails because of ShelfModel. http://crbug.com/698878. | 563 // TODO: fails because of ShelfModel. http://crbug.com/698878. |
564 if (ShellPort::Get()->IsRunningInMash()) | 564 if (Shell::GetAshConfig() == Config::MASH) |
565 return; | 565 return; |
566 | 566 |
567 gfx::Rect bounds(0, 0, 201, 201); | 567 gfx::Rect bounds(0, 0, 201, 201); |
568 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 568 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
569 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 569 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
570 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 570 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
571 | 571 |
572 // At this point, windows should be stacked with 1 < 2 < 3 | 572 // At this point, windows should be stacked with 1 < 2 < 3 |
573 wm::ActivateWindow(w3.get()); | 573 wm::ActivateWindow(w3.get()); |
574 // Order shouldn't change. | 574 // Order shouldn't change. |
575 w3.reset(); | 575 w3.reset(); |
576 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); | 576 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w1.get())); |
577 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); | 577 EXPECT_NO_FATAL_FAILURE(IsPanelAboveLauncherIcon(w2.get())); |
578 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); | 578 EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get())); |
579 } | 579 } |
580 | 580 |
581 TEST_F(PanelLayoutManagerTest, RemoveNonActivePanel) { | 581 TEST_F(PanelLayoutManagerTest, RemoveNonActivePanel) { |
582 // TODO: fails because of ShelfModel. http://crbug.com/698878. | 582 // TODO: fails because of ShelfModel. http://crbug.com/698878. |
583 if (ShellPort::Get()->IsRunningInMash()) | 583 if (Shell::GetAshConfig() == Config::MASH) |
584 return; | 584 return; |
585 | 585 |
586 gfx::Rect bounds(0, 0, 201, 201); | 586 gfx::Rect bounds(0, 0, 201, 201); |
587 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 587 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
588 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 588 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
589 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 589 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
590 | 590 |
591 // At this point, windows should be stacked with 1 < 2 < 3 | 591 // At this point, windows should be stacked with 1 < 2 < 3 |
592 wm::ActivateWindow(w2.get()); | 592 wm::ActivateWindow(w2.get()); |
593 // Windows should be stacked 1 < 2 > 3 | 593 // Windows should be stacked 1 < 2 > 3 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 RunAllPendingInMessageLoop(); | 668 RunAllPendingInMessageLoop(); |
669 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); | 669 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); |
670 // Activate the window, ensure callout is visible. | 670 // Activate the window, ensure callout is visible. |
671 wm::ActivateWindow(window.get()); | 671 wm::ActivateWindow(window.get()); |
672 RunAllPendingInMessageLoop(); | 672 RunAllPendingInMessageLoop(); |
673 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); | 673 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); |
674 } | 674 } |
675 | 675 |
676 TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { | 676 TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { |
677 // TODO: fails because of ShelfModel. http://crbug.com/698878. | 677 // TODO: fails because of ShelfModel. http://crbug.com/698878. |
678 if (ShellPort::Get()->IsRunningInMash()) | 678 if (Shell::GetAshConfig() == Config::MASH) |
679 return; | 679 return; |
680 | 680 |
681 // Keep the displays wide so that shelves have enough space for launcher | 681 // Keep the displays wide so that shelves have enough space for launcher |
682 // buttons. | 682 // buttons. |
683 UpdateDisplay("600x400,600x400"); | 683 UpdateDisplay("600x400,600x400"); |
684 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 684 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
685 | 685 |
686 std::unique_ptr<aura::Window> p1_d1( | 686 std::unique_ptr<aura::Window> p1_d1( |
687 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); | 687 CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); |
688 std::unique_ptr<aura::Window> p2_d1( | 688 std::unique_ptr<aura::Window> p2_d1( |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); | 918 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); |
919 target = targeter->FindTargetForEvent(root, &touch); | 919 target = targeter->FindTargetForEvent(root, &touch); |
920 EXPECT_NE(w.get(), target); | 920 EXPECT_NE(w.get(), target); |
921 } | 921 } |
922 | 922 |
923 INSTANTIATE_TEST_CASE_P(LtrRtl, | 923 INSTANTIATE_TEST_CASE_P(LtrRtl, |
924 PanelLayoutManagerTextDirectionTest, | 924 PanelLayoutManagerTextDirectionTest, |
925 testing::Bool()); | 925 testing::Bool()); |
926 | 926 |
927 } // namespace ash | 927 } // namespace ash |
OLD | NEW |