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/config.h" |
8 #include "ash/public/cpp/shelf_types.h" | 8 #include "ash/public/cpp/shelf_types.h" |
9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
10 #include "ash/public/cpp/window_properties.h" | 10 #include "ash/public/cpp/window_properties.h" |
11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 12 #include "ash/shelf/shelf.h" |
12 #include "ash/shelf/shelf_button.h" | 13 #include "ash/shelf/shelf_button.h" |
13 #include "ash/shelf/shelf_layout_manager.h" | 14 #include "ash/shelf/shelf_layout_manager.h" |
14 #include "ash/shelf/shelf_model.h" | 15 #include "ash/shelf/shelf_model.h" |
15 #include "ash/shelf/shelf_view.h" | 16 #include "ash/shelf/shelf_view.h" |
16 #include "ash/shelf/shelf_widget.h" | 17 #include "ash/shelf/shelf_widget.h" |
17 #include "ash/shelf/wm_shelf.h" | |
18 #include "ash/shell.h" | 18 #include "ash/shell.h" |
19 #include "ash/system/web_notification/web_notification_tray.h" | 19 #include "ash/system/web_notification/web_notification_tray.h" |
20 #include "ash/test/ash_test_base.h" | 20 #include "ash/test/ash_test_base.h" |
21 #include "ash/test/shelf_view_test_api.h" | 21 #include "ash/test/shelf_view_test_api.h" |
22 #include "ash/wm/mru_window_tracker.h" | 22 #include "ash/wm/mru_window_tracker.h" |
23 #include "ash/wm/window_state.h" | 23 #include "ash/wm/window_state.h" |
24 #include "ash/wm/window_util.h" | 24 #include "ash/wm/window_util.h" |
25 #include "ash/wm_window.h" | 25 #include "ash/wm_window.h" |
26 #include "base/command_line.h" | 26 #include "base/command_line.h" |
27 #include "base/compiler_specific.h" | 27 #include "base/compiler_specific.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 gfx::Rect window2_bounds = panel2->GetBoundsInRootWindow(); | 135 gfx::Rect window2_bounds = panel2->GetBoundsInRootWindow(); |
136 | 136 |
137 EXPECT_FALSE(window1_bounds.Intersects(window2_bounds)); | 137 EXPECT_FALSE(window1_bounds.Intersects(window2_bounds)); |
138 } | 138 } |
139 | 139 |
140 void IsPanelAboveLauncherIcon(aura::Window* panel) { | 140 void IsPanelAboveLauncherIcon(aura::Window* panel) { |
141 // Waits until all shelf view animations are done. | 141 // Waits until all shelf view animations are done. |
142 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 142 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
143 | 143 |
144 WmWindow* wm_panel = WmWindow::Get(panel); | 144 WmWindow* wm_panel = WmWindow::Get(panel); |
145 WmShelf* shelf = wm_panel->GetRootWindowController()->GetShelf(); | 145 Shelf* shelf = wm_panel->GetRootWindowController()->shelf(); |
146 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(wm_panel); | 146 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(wm_panel); |
147 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0); | 147 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0); |
148 | 148 |
149 gfx::Rect window_bounds = panel->GetBoundsInScreen(); | 149 gfx::Rect window_bounds = panel->GetBoundsInScreen(); |
150 ASSERT_LT(icon_bounds.width(), window_bounds.width()); | 150 ASSERT_LT(icon_bounds.width(), window_bounds.width()); |
151 ASSERT_LT(icon_bounds.height(), window_bounds.height()); | 151 ASSERT_LT(icon_bounds.height(), window_bounds.height()); |
152 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); | 152 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); |
153 const ShelfAlignment alignment = shelf->alignment(); | 153 const ShelfAlignment alignment = shelf->alignment(); |
154 | 154 |
155 if (IsHorizontal(alignment)) { | 155 if (IsHorizontal(alignment)) { |
(...skipping 15 matching lines...) Expand all Loading... |
171 else | 171 else |
172 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom()); | 172 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom()); |
173 } | 173 } |
174 | 174 |
175 void IsCalloutAboveLauncherIcon(aura::Window* panel) { | 175 void IsCalloutAboveLauncherIcon(aura::Window* panel) { |
176 // Flush the message loop, since callout updates use a delayed task. | 176 // Flush the message loop, since callout updates use a delayed task. |
177 base::RunLoop().RunUntilIdle(); | 177 base::RunLoop().RunUntilIdle(); |
178 views::Widget* widget = GetCalloutWidgetForPanel(panel); | 178 views::Widget* widget = GetCalloutWidgetForPanel(panel); |
179 | 179 |
180 WmWindow* wm_panel = WmWindow::Get(panel); | 180 WmWindow* wm_panel = WmWindow::Get(panel); |
181 WmShelf* shelf = wm_panel->GetRootWindowController()->GetShelf(); | 181 Shelf* shelf = wm_panel->GetRootWindowController()->shelf(); |
182 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(wm_panel); | 182 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(wm_panel); |
183 ASSERT_FALSE(icon_bounds.IsEmpty()); | 183 ASSERT_FALSE(icon_bounds.IsEmpty()); |
184 | 184 |
185 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); | 185 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); |
186 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); | 186 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); |
187 ASSERT_FALSE(icon_bounds.IsEmpty()); | 187 ASSERT_FALSE(icon_bounds.IsEmpty()); |
188 | 188 |
189 EXPECT_TRUE(widget->IsVisible()); | 189 EXPECT_TRUE(widget->IsVisible()); |
190 | 190 |
191 const ShelfAlignment alignment = shelf->alignment(); | 191 const ShelfAlignment alignment = shelf->alignment(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 DCHECK_GE(index, 0); | 223 DCHECK_GE(index, 0); |
224 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); | 224 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); |
225 | 225 |
226 ui::test::EventGenerator& event_generator = GetEventGenerator(); | 226 ui::test::EventGenerator& event_generator = GetEventGenerator(); |
227 event_generator.MoveMouseTo(bounds.CenterPoint()); | 227 event_generator.MoveMouseTo(bounds.CenterPoint()); |
228 event_generator.ClickLeftButton(); | 228 event_generator.ClickLeftButton(); |
229 | 229 |
230 test_api.RunMessageLoopUntilAnimationsDone(); | 230 test_api.RunMessageLoopUntilAnimationsDone(); |
231 } | 231 } |
232 | 232 |
233 WmShelf* GetShelfForWindow(aura::Window* window) { | 233 Shelf* GetShelfForWindow(aura::Window* window) { |
234 return WmWindow::Get(window)->GetRootWindowController()->GetShelf(); | 234 return WmWindow::Get(window)->GetRootWindowController()->GetShelf(); |
235 } | 235 } |
236 | 236 |
237 void SetAlignment(aura::Window* root_window, ShelfAlignment alignment) { | 237 void SetAlignment(aura::Window* root_window, ShelfAlignment alignment) { |
238 GetShelfForWindow(root_window)->SetAlignment(alignment); | 238 GetShelfForWindow(root_window)->SetAlignment(alignment); |
239 } | 239 } |
240 | 240 |
241 void SetShelfAutoHideBehavior(aura::Window* window, | 241 void SetShelfAutoHideBehavior(aura::Window* window, |
242 ShelfAutoHideBehavior behavior) { | 242 ShelfAutoHideBehavior behavior) { |
243 WmShelf* shelf = GetShelfForWindow(window); | 243 Shelf* shelf = GetShelfForWindow(window); |
244 shelf->SetAutoHideBehavior(behavior); | 244 shelf->SetAutoHideBehavior(behavior); |
245 test::ShelfViewTestAPI test_api(shelf->GetShelfViewForTesting()); | 245 test::ShelfViewTestAPI test_api(shelf->GetShelfViewForTesting()); |
246 test_api.RunMessageLoopUntilAnimationsDone(); | 246 test_api.RunMessageLoopUntilAnimationsDone(); |
247 } | 247 } |
248 | 248 |
249 void SetShelfVisibilityState(aura::Window* window, | 249 void SetShelfVisibilityState(aura::Window* window, |
250 ShelfVisibilityState visibility_state) { | 250 ShelfVisibilityState visibility_state) { |
251 WmShelf* shelf = GetShelfForWindow(window); | 251 Shelf* shelf = GetShelfForWindow(window); |
252 shelf->shelf_layout_manager()->SetState(visibility_state); | 252 shelf->shelf_layout_manager()->SetState(visibility_state); |
253 } | 253 } |
254 | 254 |
255 private: | 255 private: |
256 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; | 256 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; |
257 | 257 |
258 bool IsHorizontal(ShelfAlignment alignment) { | 258 bool IsHorizontal(ShelfAlignment alignment) { |
259 return alignment == SHELF_ALIGNMENT_BOTTOM; | 259 return alignment == SHELF_ALIGNMENT_BOTTOM; |
260 } | 260 } |
261 | 261 |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 TEST_F(PanelLayoutManagerTest, FanWindows) { | 620 TEST_F(PanelLayoutManagerTest, FanWindows) { |
621 gfx::Rect bounds(0, 0, 201, 201); | 621 gfx::Rect bounds(0, 0, 201, 201); |
622 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 622 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
623 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 623 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
624 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 624 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
625 | 625 |
626 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 626 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
627 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); | 627 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); |
628 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); | 628 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); |
629 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); | 629 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); |
630 WmShelf* shelf = GetPrimaryShelf(); | 630 Shelf* shelf = GetPrimaryShelf(); |
631 int icon_x1 = | 631 int icon_x1 = |
632 shelf->GetScreenBoundsOfItemIconForWindow(WmWindow::Get(w1.get())).x(); | 632 shelf->GetScreenBoundsOfItemIconForWindow(WmWindow::Get(w1.get())).x(); |
633 int icon_x2 = | 633 int icon_x2 = |
634 shelf->GetScreenBoundsOfItemIconForWindow(WmWindow::Get(w2.get())).x(); | 634 shelf->GetScreenBoundsOfItemIconForWindow(WmWindow::Get(w2.get())).x(); |
635 // TODO(crbug.com/698887): investigate failure in Mash. | 635 // TODO(crbug.com/698887): investigate failure in Mash. |
636 if (Shell::GetAshConfig() != Config::MASH) | 636 if (Shell::GetAshConfig() != Config::MASH) |
637 EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2); | 637 EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2); |
638 // New shelf items for panels are inserted before existing panel items. | 638 // New shelf items for panels are inserted before existing panel items. |
639 EXPECT_LT(window_x2, window_x1); | 639 EXPECT_LT(window_x2, window_x1); |
640 EXPECT_LT(window_x3, window_x2); | 640 EXPECT_LT(window_x3, window_x2); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); | 927 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); |
928 target = targeter->FindTargetForEvent(root, &touch); | 928 target = targeter->FindTargetForEvent(root, &touch); |
929 EXPECT_NE(w.get(), target); | 929 EXPECT_NE(w.get(), target); |
930 } | 930 } |
931 | 931 |
932 INSTANTIATE_TEST_CASE_P(LtrRtl, | 932 INSTANTIATE_TEST_CASE_P(LtrRtl, |
933 PanelLayoutManagerTextDirectionTest, | 933 PanelLayoutManagerTextDirectionTest, |
934 testing::Bool()); | 934 testing::Bool()); |
935 | 935 |
936 } // namespace ash | 936 } // namespace ash |
OLD | NEW |