| 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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/root_window_controller.h" | |
| 9 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
| 10 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
| 11 #include "ash/shelf/shelf_button.h" | 10 #include "ash/shelf/shelf_button.h" |
| 12 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
| 13 #include "ash/shelf/shelf_model.h" | 12 #include "ash/shelf/shelf_model.h" |
| 14 #include "ash/shelf/shelf_types.h" | 13 #include "ash/shelf/shelf_types.h" |
| 15 #include "ash/shelf/shelf_util.h" | 14 #include "ash/shelf/shelf_util.h" |
| 16 #include "ash/shelf/shelf_view.h" | 15 #include "ash/shelf/shelf_view.h" |
| 17 #include "ash/shelf/shelf_widget.h" | 16 #include "ash/shelf/shelf_widget.h" |
| 18 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 gfx::Rect window1_bounds = panel1->GetBoundsInRootWindow(); | 111 gfx::Rect window1_bounds = panel1->GetBoundsInRootWindow(); |
| 113 gfx::Rect window2_bounds = panel2->GetBoundsInRootWindow(); | 112 gfx::Rect window2_bounds = panel2->GetBoundsInRootWindow(); |
| 114 | 113 |
| 115 EXPECT_FALSE(window1_bounds.Intersects(window2_bounds)); | 114 EXPECT_FALSE(window1_bounds.Intersects(window2_bounds)); |
| 116 } | 115 } |
| 117 | 116 |
| 118 void IsPanelAboveLauncherIcon(const aura::Window* panel) { | 117 void IsPanelAboveLauncherIcon(const aura::Window* panel) { |
| 119 // Waits until all shelf view animations are done. | 118 // Waits until all shelf view animations are done. |
| 120 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 119 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
| 121 | 120 |
| 122 Shelf* shelf = RootWindowController::ForShelf(panel)->shelf()->shelf(); | 121 Shelf* shelf = Shelf::ForWindow(panel); |
| 123 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); | 122 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); |
| 124 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0); | 123 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0); |
| 125 | 124 |
| 126 gfx::Rect window_bounds = panel->GetBoundsInScreen(); | 125 gfx::Rect window_bounds = panel->GetBoundsInScreen(); |
| 127 ASSERT_LT(icon_bounds.width(), window_bounds.width()); | 126 ASSERT_LT(icon_bounds.width(), window_bounds.width()); |
| 128 ASSERT_LT(icon_bounds.height(), window_bounds.height()); | 127 ASSERT_LT(icon_bounds.height(), window_bounds.height()); |
| 129 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); | 128 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); |
| 130 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); | 129 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); |
| 131 | 130 |
| 132 if (IsHorizontal(alignment)) { | 131 if (IsHorizontal(alignment)) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 155 EXPECT_EQ(shelf_bounds.bottom(), window_bounds.y()); | 154 EXPECT_EQ(shelf_bounds.bottom(), window_bounds.y()); |
| 156 break; | 155 break; |
| 157 } | 156 } |
| 158 } | 157 } |
| 159 | 158 |
| 160 void IsCalloutAboveLauncherIcon(aura::Window* panel) { | 159 void IsCalloutAboveLauncherIcon(aura::Window* panel) { |
| 161 // Flush the message loop, since callout updates use a delayed task. | 160 // Flush the message loop, since callout updates use a delayed task. |
| 162 base::RunLoop().RunUntilIdle(); | 161 base::RunLoop().RunUntilIdle(); |
| 163 views::Widget* widget = GetCalloutWidgetForPanel(panel); | 162 views::Widget* widget = GetCalloutWidgetForPanel(panel); |
| 164 | 163 |
| 165 Shelf* shelf = RootWindowController::ForShelf(panel)->shelf()->shelf(); | 164 Shelf* shelf = Shelf::ForWindow(panel); |
| 166 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); | 165 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); |
| 167 ASSERT_FALSE(icon_bounds.IsEmpty()); | 166 ASSERT_FALSE(icon_bounds.IsEmpty()); |
| 168 | 167 |
| 169 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); | 168 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); |
| 170 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); | 169 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); |
| 171 ASSERT_FALSE(icon_bounds.IsEmpty()); | 170 ASSERT_FALSE(icon_bounds.IsEmpty()); |
| 172 | 171 |
| 173 EXPECT_TRUE(widget->IsVisible()); | 172 EXPECT_TRUE(widget->IsVisible()); |
| 174 | 173 |
| 175 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); | 174 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 shell->SetShelfAlignment(alignment, root_window); | 229 shell->SetShelfAlignment(alignment, root_window); |
| 231 } | 230 } |
| 232 | 231 |
| 233 ShelfAlignment GetAlignment(const aura::Window* root_window) { | 232 ShelfAlignment GetAlignment(const aura::Window* root_window) { |
| 234 ash::Shell* shell = ash::Shell::GetInstance(); | 233 ash::Shell* shell = ash::Shell::GetInstance(); |
| 235 return shell->GetShelfAlignment(root_window); | 234 return shell->GetShelfAlignment(root_window); |
| 236 } | 235 } |
| 237 | 236 |
| 238 void SetShelfAutoHideBehavior(aura::Window* window, | 237 void SetShelfAutoHideBehavior(aura::Window* window, |
| 239 ShelfAutoHideBehavior behavior) { | 238 ShelfAutoHideBehavior behavior) { |
| 240 ShelfLayoutManager* shelf = RootWindowController::ForWindow(window) | 239 Shelf* shelf = Shelf::ForWindow(window); |
| 241 ->shelf() | 240 shelf->shelf_layout_manager()->SetAutoHideBehavior(behavior); |
| 242 ->shelf_layout_manager(); | 241 test::ShelfViewTestAPI test_api(GetShelfView(shelf)); |
| 243 shelf->SetAutoHideBehavior(behavior); | |
| 244 ShelfView* shelf_view = GetShelfView(Shelf::ForWindow(window)); | |
| 245 test::ShelfViewTestAPI test_api(shelf_view); | |
| 246 test_api.RunMessageLoopUntilAnimationsDone(); | 242 test_api.RunMessageLoopUntilAnimationsDone(); |
| 247 } | 243 } |
| 248 | 244 |
| 249 void SetShelfVisibilityState(aura::Window* window, | 245 void SetShelfVisibilityState(aura::Window* window, |
| 250 ShelfVisibilityState visibility_state) { | 246 ShelfVisibilityState visibility_state) { |
| 251 ShelfLayoutManager* shelf = RootWindowController::ForWindow(window) | 247 Shelf* shelf = Shelf::ForWindow(window); |
| 252 ->shelf() | 248 shelf->shelf_layout_manager()->SetState(visibility_state); |
| 253 ->shelf_layout_manager(); | |
| 254 shelf->SetState(visibility_state); | |
| 255 } | 249 } |
| 256 | 250 |
| 257 ShelfView* GetShelfView(Shelf* shelf) { | 251 ShelfView* GetShelfView(Shelf* shelf) { |
| 258 return test::ShelfTestAPI(shelf).shelf_view(); | 252 return test::ShelfTestAPI(shelf).shelf_view(); |
| 259 } | 253 } |
| 260 | 254 |
| 261 private: | 255 private: |
| 262 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; | 256 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; |
| 263 | 257 |
| 264 bool IsHorizontal(ShelfAlignment alignment) { | 258 bool IsHorizontal(ShelfAlignment alignment) { |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 // Hit test outside the top edge with a top-aligned shelf. | 842 // Hit test outside the top edge with a top-aligned shelf. |
| 849 touch.set_location(gfx::Point(bounds.x() + 4, bounds.y() - 6)); | 843 touch.set_location(gfx::Point(bounds.x() + 4, bounds.y() - 6)); |
| 850 target = targeter->FindTargetForEvent(root, &touch); | 844 target = targeter->FindTargetForEvent(root, &touch); |
| 851 EXPECT_NE(w.get(), target); | 845 EXPECT_NE(w.get(), target); |
| 852 } | 846 } |
| 853 | 847 |
| 854 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, | 848 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, |
| 855 testing::Bool()); | 849 testing::Bool()); |
| 856 | 850 |
| 857 } // namespace ash | 851 } // namespace ash |
| OLD | NEW |