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