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

Side by Side Diff: ash/wm/panels/panel_layout_manager_unittest.cc

Issue 237963019: Remove remaining window states where window is shown with opacity 0. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove forced relayouts in unittests after adding panel shelf icons. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/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/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shelf/shelf.h" 10 #include "ash/shelf/shelf.h"
11 #include "ash/shelf/shelf_button.h" 11 #include "ash/shelf/shelf_button.h"
12 #include "ash/shelf/shelf_layout_manager.h" 12 #include "ash/shelf/shelf_layout_manager.h"
13 #include "ash/shelf/shelf_model.h" 13 #include "ash/shelf/shelf_model.h"
14 #include "ash/shelf/shelf_types.h" 14 #include "ash/shelf/shelf_types.h"
15 #include "ash/shelf/shelf_util.h" 15 #include "ash/shelf/shelf_util.h"
16 #include "ash/shelf/shelf_view.h" 16 #include "ash/shelf/shelf_view.h"
17 #include "ash/shelf/shelf_widget.h" 17 #include "ash/shelf/shelf_widget.h"
18 #include "ash/shell.h" 18 #include "ash/shell.h"
19 #include "ash/shell_window_ids.h" 19 #include "ash/shell_window_ids.h"
20 #include "ash/test/ash_test_base.h" 20 #include "ash/test/ash_test_base.h"
21 #include "ash/test/shelf_test_api.h" 21 #include "ash/test/shelf_test_api.h"
22 #include "ash/test/shelf_view_test_api.h" 22 #include "ash/test/shelf_view_test_api.h"
23 #include "ash/test/shell_test_api.h" 23 #include "ash/test/shell_test_api.h"
24 #include "ash/test/test_shelf_delegate.h" 24 #include "ash/test/test_shelf_delegate.h"
25 #include "ash/wm/mru_window_tracker.h" 25 #include "ash/wm/mru_window_tracker.h"
26 #include "ash/wm/window_state.h"
26 #include "ash/wm/window_util.h" 27 #include "ash/wm/window_util.h"
27 #include "base/basictypes.h" 28 #include "base/basictypes.h"
28 #include "base/command_line.h" 29 #include "base/command_line.h"
29 #include "base/compiler_specific.h" 30 #include "base/compiler_specific.h"
30 #include "base/i18n/rtl.h" 31 #include "base/i18n/rtl.h"
31 #include "base/run_loop.h" 32 #include "base/run_loop.h"
32 #include "ui/aura/client/aura_constants.h" 33 #include "ui/aura/client/aura_constants.h"
33 #include "ui/aura/test/event_generator.h" 34 #include "ui/aura/test/event_generator.h"
34 #include "ui/aura/test/test_windows.h" 35 #include "ui/aura/test/test_windows.h"
35 #include "ui/aura/window.h" 36 #include "ui/aura/window.h"
(...skipping 24 matching lines...) Expand all
60 return CreateTestWindowInShellWithBounds(bounds); 61 return CreateTestWindowInShellWithBounds(bounds);
61 } 62 }
62 63
63 aura::Window* CreatePanelWindowWithDelegate(aura::WindowDelegate* delegate, 64 aura::Window* CreatePanelWindowWithDelegate(aura::WindowDelegate* delegate,
64 const gfx::Rect& bounds) { 65 const gfx::Rect& bounds) {
65 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( 66 aura::Window* window = CreateTestWindowInShellWithDelegateAndType(
66 delegate, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); 67 delegate, ui::wm::WINDOW_TYPE_PANEL, 0, bounds);
67 test::TestShelfDelegate* shelf_delegate = 68 test::TestShelfDelegate* shelf_delegate =
68 test::TestShelfDelegate::instance(); 69 test::TestShelfDelegate::instance();
69 shelf_delegate->AddShelfItem(window); 70 shelf_delegate->AddShelfItem(window);
70 PanelLayoutManager* manager = static_cast<PanelLayoutManager*>(
71 GetPanelContainer(window)->layout_manager());
72 manager->Relayout();
73 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 71 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
74 return window; 72 return window;
75 } 73 }
76 74
77 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { 75 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) {
78 return CreatePanelWindowWithDelegate(NULL, bounds); 76 return CreatePanelWindowWithDelegate(NULL, bounds);
79 } 77 }
80 78
81 aura::Window* GetPanelContainer(aura::Window* panel) { 79 aura::Window* GetPanelContainer(aura::Window* panel) {
82 return Shell::GetContainer(panel->GetRootWindow(), 80 return Shell::GetContainer(panel->GetRootWindow(),
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 } 568 }
571 569
572 TEST_F(PanelLayoutManagerTest, MinimizeRestorePanel) { 570 TEST_F(PanelLayoutManagerTest, MinimizeRestorePanel) {
573 gfx::Rect bounds(0, 0, 201, 201); 571 gfx::Rect bounds(0, 0, 201, 201);
574 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds)); 572 scoped_ptr<aura::Window> window(CreatePanelWindow(bounds));
575 // Activate the window, ensure callout is visible. 573 // Activate the window, ensure callout is visible.
576 wm::ActivateWindow(window.get()); 574 wm::ActivateWindow(window.get());
577 RunAllPendingInMessageLoop(); 575 RunAllPendingInMessageLoop();
578 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); 576 EXPECT_TRUE(IsPanelCalloutVisible(window.get()));
579 // Minimize the panel, callout should be hidden. 577 // Minimize the panel, callout should be hidden.
580 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 578 wm::GetWindowState(window.get())->Minimize();
581 RunAllPendingInMessageLoop(); 579 RunAllPendingInMessageLoop();
582 EXPECT_FALSE(IsPanelCalloutVisible(window.get())); 580 EXPECT_FALSE(IsPanelCalloutVisible(window.get()));
583 // Restore the pantel; panel should not be activated by default but callout 581 // Restore the pantel; panel should not be activated by default but callout
Mr4D (OOO till 08-26) 2014/04/22 14:45:54 pantel -> panel
flackr 2014/04/22 17:30:38 Done.
584 // should be visible. 582 // should be visible.
585 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 583 wm::GetWindowState(window.get())->Unminimize();
586 RunAllPendingInMessageLoop(); 584 RunAllPendingInMessageLoop();
587 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); 585 EXPECT_TRUE(IsPanelCalloutVisible(window.get()));
588 // Activate the window, ensure callout is visible. 586 // Activate the window, ensure callout is visible.
589 wm::ActivateWindow(window.get()); 587 wm::ActivateWindow(window.get());
590 RunAllPendingInMessageLoop(); 588 RunAllPendingInMessageLoop();
591 EXPECT_TRUE(IsPanelCalloutVisible(window.get())); 589 EXPECT_TRUE(IsPanelCalloutVisible(window.get()));
592 } 590 }
593 591
594 TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) { 592 TEST_F(PanelLayoutManagerTest, PanelMoveBetweenMultipleDisplays) {
595 if (!SupportsMultipleDisplays()) 593 if (!SupportsMultipleDisplays())
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 // Tests that panels will hide and restore their state with the shelf visibility 741 // Tests that panels will hide and restore their state with the shelf visibility
744 // state. This ensures that entering full-screen mode will hide your panels 742 // state. This ensures that entering full-screen mode will hide your panels
745 // until you leave it. 743 // until you leave it.
746 TEST_F(PanelLayoutManagerTest, PanelsHideAndRestoreWithShelf) { 744 TEST_F(PanelLayoutManagerTest, PanelsHideAndRestoreWithShelf) {
747 gfx::Rect bounds(0, 0, 201, 201); 745 gfx::Rect bounds(0, 0, 201, 201);
748 746
749 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 747 scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds));
750 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 748 scoped_ptr<aura::Window> w2(CreatePanelWindow(bounds));
751 scoped_ptr<aura::Window> w3; 749 scoped_ptr<aura::Window> w3;
752 // Minimize w2. 750 // Minimize w2.
753 w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); 751 wm::GetWindowState(w2.get())->Minimize();
Mr4D (OOO till 08-26) 2014/04/22 14:45:54 Ah! Thanks for moving this to the new scheme!
754 RunAllPendingInMessageLoop(); 752 RunAllPendingInMessageLoop();
755 EXPECT_TRUE(w1->IsVisible()); 753 EXPECT_TRUE(w1->IsVisible());
756 EXPECT_FALSE(w2->IsVisible()); 754 EXPECT_FALSE(w2->IsVisible());
757 755
758 SetShelfVisibilityState(Shell::GetPrimaryRootWindow(), SHELF_HIDDEN); 756 SetShelfVisibilityState(Shell::GetPrimaryRootWindow(), SHELF_HIDDEN);
759 RunAllPendingInMessageLoop(); 757 RunAllPendingInMessageLoop();
760 758
761 // w3 is created while in full-screen mode, should only become visible when 759 // w3 is created while in full-screen mode, should only become visible when
762 // we exit fullscreen mode. 760 // we exit fullscreen mode.
763 w3.reset(CreatePanelWindow(bounds)); 761 w3.reset(CreatePanelWindow(bounds));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 // Hit test outside the top edge with a top-aligned shelf. 852 // Hit test outside the top edge with a top-aligned shelf.
855 touch.set_location(gfx::Point(bounds.x() + 4, bounds.y() - 6)); 853 touch.set_location(gfx::Point(bounds.x() + 4, bounds.y() - 6));
856 target = targeter->FindTargetForEvent(root, &touch); 854 target = targeter->FindTargetForEvent(root, &touch);
857 EXPECT_NE(w.get(), target); 855 EXPECT_NE(w.get(), target);
858 } 856 }
859 857
860 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, 858 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest,
861 testing::Bool()); 859 testing::Bool());
862 860
863 } // namespace ash 861 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698