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

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

Issue 2629643002: chromeos: Renames WmWindowAura to WmWindow (Closed)
Patch Set: feedback Created 3 years, 11 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
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/common/wm/panels/panel_layout_manager.h" 5 #include "ash/common/wm/panels/panel_layout_manager.h"
6 6
7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/shelf/shelf_button.h" 7 #include "ash/common/shelf/shelf_button.h"
9 #include "ash/common/shelf/shelf_layout_manager.h" 8 #include "ash/common/shelf/shelf_layout_manager.h"
10 #include "ash/common/shelf/shelf_model.h" 9 #include "ash/common/shelf/shelf_model.h"
11 #include "ash/common/shelf/shelf_view.h" 10 #include "ash/common/shelf/shelf_view.h"
12 #include "ash/common/shelf/shelf_widget.h" 11 #include "ash/common/shelf/shelf_widget.h"
13 #include "ash/common/shelf/wm_shelf.h" 12 #include "ash/common/shelf/wm_shelf.h"
14 #include "ash/common/system/web_notification/web_notification_tray.h" 13 #include "ash/common/system/web_notification/web_notification_tray.h"
15 #include "ash/common/test/test_shelf_delegate.h" 14 #include "ash/common/test/test_shelf_delegate.h"
16 #include "ash/common/wm/mru_window_tracker.h" 15 #include "ash/common/wm/mru_window_tracker.h"
17 #include "ash/common/wm/window_state.h" 16 #include "ash/common/wm/window_state.h"
18 #include "ash/common/wm_shell.h" 17 #include "ash/common/wm_shell.h"
18 #include "ash/common/wm_window.h"
19 #include "ash/common/wm_window_property.h" 19 #include "ash/common/wm_window_property.h"
20 #include "ash/public/cpp/shelf_types.h" 20 #include "ash/public/cpp/shelf_types.h"
21 #include "ash/public/cpp/shell_window_ids.h" 21 #include "ash/public/cpp/shell_window_ids.h"
22 #include "ash/root_window_controller.h" 22 #include "ash/root_window_controller.h"
23 #include "ash/shell.h" 23 #include "ash/shell.h"
24 #include "ash/test/ash_test_base.h" 24 #include "ash/test/ash_test_base.h"
25 #include "ash/test/shelf_view_test_api.h" 25 #include "ash/test/shelf_view_test_api.h"
26 #include "ash/wm/window_state_aura.h" 26 #include "ash/wm/window_state_aura.h"
27 #include "ash/wm/window_util.h" 27 #include "ash/wm/window_util.h"
28 #include "base/command_line.h" 28 #include "base/command_line.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 83
84 aura::Window* CreateNormalWindow(const gfx::Rect& bounds) { 84 aura::Window* CreateNormalWindow(const gfx::Rect& bounds) {
85 return CreateTestWindowInShellWithBounds(bounds); 85 return CreateTestWindowInShellWithBounds(bounds);
86 } 86 }
87 87
88 aura::Window* CreatePanelWindowWithDelegate(aura::WindowDelegate* delegate, 88 aura::Window* CreatePanelWindowWithDelegate(aura::WindowDelegate* delegate,
89 const gfx::Rect& bounds) { 89 const gfx::Rect& bounds) {
90 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( 90 aura::Window* window = CreateTestWindowInShellWithDelegateAndType(
91 delegate, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); 91 delegate, ui::wm::WINDOW_TYPE_PANEL, 0, bounds);
92 test::TestShelfDelegate::instance()->AddShelfItem( 92 test::TestShelfDelegate::instance()->AddShelfItem(WmWindow::Get(window));
93 WmWindowAura::Get(window));
94 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 93 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
95 return window; 94 return window;
96 } 95 }
97 96
98 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { 97 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) {
99 return CreatePanelWindowWithDelegate(NULL, bounds); 98 return CreatePanelWindowWithDelegate(NULL, bounds);
100 } 99 }
101 100
102 aura::Window* GetPanelContainer(aura::Window* panel) { 101 aura::Window* GetPanelContainer(aura::Window* panel) {
103 return Shell::GetContainer(panel->GetRootWindow(), 102 return Shell::GetContainer(panel->GetRootWindow(),
104 kShellWindowId_PanelContainer); 103 kShellWindowId_PanelContainer);
105 } 104 }
106 105
107 views::Widget* GetCalloutWidgetForPanel(aura::Window* panel) { 106 views::Widget* GetCalloutWidgetForPanel(aura::Window* panel) {
108 WmWindow* wm_panel = WmWindowAura::Get(panel); 107 WmWindow* wm_panel = WmWindow::Get(panel);
109 PanelLayoutManager* manager = PanelLayoutManager::Get(wm_panel); 108 PanelLayoutManager* manager = PanelLayoutManager::Get(wm_panel);
110 DCHECK(manager); 109 DCHECK(manager);
111 PanelLayoutManager::PanelList::iterator found = 110 PanelLayoutManager::PanelList::iterator found =
112 std::find(manager->panel_windows_.begin(), 111 std::find(manager->panel_windows_.begin(),
113 manager->panel_windows_.end(), wm_panel); 112 manager->panel_windows_.end(), wm_panel);
114 DCHECK(found != manager->panel_windows_.end()); 113 DCHECK(found != manager->panel_windows_.end());
115 DCHECK(found->callout_widget); 114 DCHECK(found->callout_widget);
116 return found->CalloutWidget(); 115 return found->CalloutWidget();
117 } 116 }
118 117
(...skipping 17 matching lines...) Expand all
136 gfx::Rect window1_bounds = panel1->GetBoundsInRootWindow(); 135 gfx::Rect window1_bounds = panel1->GetBoundsInRootWindow();
137 gfx::Rect window2_bounds = panel2->GetBoundsInRootWindow(); 136 gfx::Rect window2_bounds = panel2->GetBoundsInRootWindow();
138 137
139 EXPECT_FALSE(window1_bounds.Intersects(window2_bounds)); 138 EXPECT_FALSE(window1_bounds.Intersects(window2_bounds));
140 } 139 }
141 140
142 void IsPanelAboveLauncherIcon(aura::Window* panel) { 141 void IsPanelAboveLauncherIcon(aura::Window* panel) {
143 // Waits until all shelf view animations are done. 142 // Waits until all shelf view animations are done.
144 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 143 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
145 144
146 WmWindow* wm_panel = WmWindowAura::Get(panel); 145 WmWindow* wm_panel = WmWindow::Get(panel);
147 WmShelf* shelf = wm_panel->GetRootWindowController()->GetShelf(); 146 WmShelf* shelf = wm_panel->GetRootWindowController()->GetShelf();
148 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(wm_panel); 147 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(wm_panel);
149 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0); 148 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0);
150 149
151 gfx::Rect window_bounds = panel->GetBoundsInScreen(); 150 gfx::Rect window_bounds = panel->GetBoundsInScreen();
152 ASSERT_LT(icon_bounds.width(), window_bounds.width()); 151 ASSERT_LT(icon_bounds.width(), window_bounds.width());
153 ASSERT_LT(icon_bounds.height(), window_bounds.height()); 152 ASSERT_LT(icon_bounds.height(), window_bounds.height());
154 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); 153 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen();
155 const ShelfAlignment alignment = shelf->alignment(); 154 const ShelfAlignment alignment = shelf->alignment();
156 155
(...skipping 15 matching lines...) Expand all
172 EXPECT_EQ(shelf_bounds.x(), window_bounds.right()); 171 EXPECT_EQ(shelf_bounds.x(), window_bounds.right());
173 else 172 else
174 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom()); 173 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom());
175 } 174 }
176 175
177 void IsCalloutAboveLauncherIcon(aura::Window* panel) { 176 void IsCalloutAboveLauncherIcon(aura::Window* panel) {
178 // Flush the message loop, since callout updates use a delayed task. 177 // Flush the message loop, since callout updates use a delayed task.
179 base::RunLoop().RunUntilIdle(); 178 base::RunLoop().RunUntilIdle();
180 views::Widget* widget = GetCalloutWidgetForPanel(panel); 179 views::Widget* widget = GetCalloutWidgetForPanel(panel);
181 180
182 WmWindow* wm_panel = WmWindowAura::Get(panel); 181 WmWindow* wm_panel = WmWindow::Get(panel);
183 WmShelf* shelf = wm_panel->GetRootWindowController()->GetShelf(); 182 WmShelf* shelf = wm_panel->GetRootWindowController()->GetShelf();
184 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(wm_panel); 183 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(wm_panel);
185 ASSERT_FALSE(icon_bounds.IsEmpty()); 184 ASSERT_FALSE(icon_bounds.IsEmpty());
186 185
187 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); 186 gfx::Rect panel_bounds = panel->GetBoundsInScreen();
188 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); 187 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen();
189 ASSERT_FALSE(icon_bounds.IsEmpty()); 188 ASSERT_FALSE(icon_bounds.IsEmpty());
190 189
191 EXPECT_TRUE(widget->IsVisible()); 190 EXPECT_TRUE(widget->IsVisible());
192 191
(...skipping 21 matching lines...) Expand all
214 213
215 test::ShelfViewTestAPI* shelf_view_test() { return shelf_view_test_.get(); } 214 test::ShelfViewTestAPI* shelf_view_test() { return shelf_view_test_.get(); }
216 215
217 // Clicks the shelf items on |shelf_view| that is associated with given 216 // Clicks the shelf items on |shelf_view| that is associated with given
218 // |window|. 217 // |window|.
219 void ClickShelfItemForWindow(ShelfView* shelf_view, aura::Window* window) { 218 void ClickShelfItemForWindow(ShelfView* shelf_view, aura::Window* window) {
220 test::ShelfViewTestAPI test_api(shelf_view); 219 test::ShelfViewTestAPI test_api(shelf_view);
221 test_api.SetAnimationDuration(1); 220 test_api.SetAnimationDuration(1);
222 test_api.RunMessageLoopUntilAnimationsDone(); 221 test_api.RunMessageLoopUntilAnimationsDone();
223 int index = WmShell::Get()->shelf_model()->ItemIndexByID( 222 int index = WmShell::Get()->shelf_model()->ItemIndexByID(
224 WmWindowAura::Get(window)->GetIntProperty(WmWindowProperty::SHELF_ID)); 223 WmWindow::Get(window)->GetIntProperty(WmWindowProperty::SHELF_ID));
225 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); 224 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen();
226 225
227 ui::test::EventGenerator& event_generator = GetEventGenerator(); 226 ui::test::EventGenerator& event_generator = GetEventGenerator();
228 event_generator.MoveMouseTo(bounds.CenterPoint()); 227 event_generator.MoveMouseTo(bounds.CenterPoint());
229 event_generator.ClickLeftButton(); 228 event_generator.ClickLeftButton();
230 229
231 test_api.RunMessageLoopUntilAnimationsDone(); 230 test_api.RunMessageLoopUntilAnimationsDone();
232 } 231 }
233 232
234 WmShelf* GetShelfForWindow(aura::Window* window) { 233 WmShelf* GetShelfForWindow(aura::Window* window) {
235 return WmWindowAura::Get(window)->GetRootWindowController()->GetShelf(); 234 return WmWindow::Get(window)->GetRootWindowController()->GetShelf();
236 } 235 }
237 236
238 void SetAlignment(aura::Window* root_window, ShelfAlignment alignment) { 237 void SetAlignment(aura::Window* root_window, ShelfAlignment alignment) {
239 GetShelfForWindow(root_window)->SetAlignment(alignment); 238 GetShelfForWindow(root_window)->SetAlignment(alignment);
240 } 239 }
241 240
242 void SetShelfAutoHideBehavior(aura::Window* window, 241 void SetShelfAutoHideBehavior(aura::Window* window,
243 ShelfAutoHideBehavior behavior) { 242 ShelfAutoHideBehavior behavior) {
244 WmShelf* shelf = GetShelfForWindow(window); 243 WmShelf* shelf = GetShelfForWindow(window);
245 shelf->SetAutoHideBehavior(behavior); 244 shelf->SetAutoHideBehavior(behavior);
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); 596 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds));
598 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); 597 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds));
599 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); 598 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds));
600 599
601 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 600 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
602 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); 601 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x();
603 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); 602 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x();
604 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); 603 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x();
605 WmShelf* shelf = GetPrimaryShelf(); 604 WmShelf* shelf = GetPrimaryShelf();
606 int icon_x1 = 605 int icon_x1 =
607 shelf->GetScreenBoundsOfItemIconForWindow(WmWindowAura::Get(w1.get())) 606 shelf->GetScreenBoundsOfItemIconForWindow(WmWindow::Get(w1.get())).x();
608 .x();
609 int icon_x2 = 607 int icon_x2 =
610 shelf->GetScreenBoundsOfItemIconForWindow(WmWindowAura::Get(w2.get())) 608 shelf->GetScreenBoundsOfItemIconForWindow(WmWindow::Get(w2.get())).x();
611 .x();
612 EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2); 609 EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2);
613 int spacing = window_x2 - window_x1; 610 int spacing = window_x2 - window_x1;
614 EXPECT_GT(spacing, icon_x2 - icon_x1); 611 EXPECT_GT(spacing, icon_x2 - icon_x1);
615 } 612 }
616 613
617 TEST_F(PanelLayoutManagerTest, FanLargeWindow) { 614 TEST_F(PanelLayoutManagerTest, FanLargeWindow) {
618 gfx::Rect small_bounds(0, 0, 201, 201); 615 gfx::Rect small_bounds(0, 0, 201, 201);
619 gfx::Rect large_bounds(0, 0, 501, 201); 616 gfx::Rect large_bounds(0, 0, 501, 201);
620 std::unique_ptr<aura::Window> w1(CreatePanelWindow(small_bounds)); 617 std::unique_ptr<aura::Window> w1(CreatePanelWindow(small_bounds));
621 std::unique_ptr<aura::Window> w2(CreatePanelWindow(large_bounds)); 618 std::unique_ptr<aura::Window> w2(CreatePanelWindow(large_bounds));
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 // w3 is created while in full-screen mode, should only become visible when 816 // w3 is created while in full-screen mode, should only become visible when
820 // we exit fullscreen mode. 817 // we exit fullscreen mode.
821 w3.reset(CreatePanelWindow(bounds)); 818 w3.reset(CreatePanelWindow(bounds));
822 819
823 EXPECT_FALSE(w1->IsVisible()); 820 EXPECT_FALSE(w1->IsVisible());
824 EXPECT_FALSE(w2->IsVisible()); 821 EXPECT_FALSE(w2->IsVisible());
825 EXPECT_FALSE(w3->IsVisible()); 822 EXPECT_FALSE(w3->IsVisible());
826 823
827 // While in full-screen mode, the panel windows should still be in the 824 // While in full-screen mode, the panel windows should still be in the
828 // switchable window list - http://crbug.com/313919. 825 // switchable window list - http://crbug.com/313919.
829 aura::Window::Windows switchable_window_list = WmWindowAura::ToAuraWindows( 826 aura::Window::Windows switchable_window_list = WmWindow::ToAuraWindows(
830 WmShell::Get()->mru_window_tracker()->BuildMruWindowList()); 827 WmShell::Get()->mru_window_tracker()->BuildMruWindowList());
831 EXPECT_EQ(3u, switchable_window_list.size()); 828 EXPECT_EQ(3u, switchable_window_list.size());
832 EXPECT_NE(switchable_window_list.end(), 829 EXPECT_NE(switchable_window_list.end(),
833 std::find(switchable_window_list.begin(), 830 std::find(switchable_window_list.begin(),
834 switchable_window_list.end(), w1.get())); 831 switchable_window_list.end(), w1.get()));
835 EXPECT_NE(switchable_window_list.end(), 832 EXPECT_NE(switchable_window_list.end(),
836 std::find(switchable_window_list.begin(), 833 std::find(switchable_window_list.begin(),
837 switchable_window_list.end(), w2.get())); 834 switchable_window_list.end(), w2.get()));
838 EXPECT_NE(switchable_window_list.end(), 835 EXPECT_NE(switchable_window_list.end(),
839 std::find(switchable_window_list.begin(), 836 std::find(switchable_window_list.begin(),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); 898 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5));
902 target = targeter->FindTargetForEvent(root, &touch); 899 target = targeter->FindTargetForEvent(root, &touch);
903 EXPECT_NE(w.get(), target); 900 EXPECT_NE(w.get(), target);
904 } 901 }
905 902
906 INSTANTIATE_TEST_CASE_P(LtrRtl, 903 INSTANTIATE_TEST_CASE_P(LtrRtl,
907 PanelLayoutManagerTextDirectionTest, 904 PanelLayoutManagerTextDirectionTest,
908 testing::Bool()); 905 testing::Bool());
909 906
910 } // namespace ash 907 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panels/attached_panel_window_targeter.cc ('k') | ash/wm/panels/panel_window_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698