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" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 gfx::Rect window1_bounds = panel1->GetBoundsInRootWindow(); | 134 gfx::Rect window1_bounds = panel1->GetBoundsInRootWindow(); |
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 Shelf* shelf = GetShelfForWindow(panel); |
145 Shelf* shelf = wm_panel->GetRootWindowController()->shelf(); | 145 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); |
146 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(wm_panel); | |
147 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0); | 146 ASSERT_FALSE(icon_bounds.width() == 0 && icon_bounds.height() == 0); |
148 | 147 |
149 gfx::Rect window_bounds = panel->GetBoundsInScreen(); | 148 gfx::Rect window_bounds = panel->GetBoundsInScreen(); |
150 ASSERT_LT(icon_bounds.width(), window_bounds.width()); | 149 ASSERT_LT(icon_bounds.width(), window_bounds.width()); |
151 ASSERT_LT(icon_bounds.height(), window_bounds.height()); | 150 ASSERT_LT(icon_bounds.height(), window_bounds.height()); |
152 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); | 151 gfx::Rect shelf_bounds = shelf->shelf_widget()->GetWindowBoundsInScreen(); |
153 const ShelfAlignment alignment = shelf->alignment(); | 152 const ShelfAlignment alignment = shelf->alignment(); |
154 | 153 |
155 if (IsHorizontal(alignment)) { | 154 if (IsHorizontal(alignment)) { |
156 // The horizontal bounds of the panel window should contain the bounds of | 155 // The horizontal bounds of the panel window should contain the bounds of |
(...skipping 13 matching lines...) Expand all Loading... |
170 EXPECT_EQ(shelf_bounds.x(), window_bounds.right()); | 169 EXPECT_EQ(shelf_bounds.x(), window_bounds.right()); |
171 else | 170 else |
172 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom()); | 171 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom()); |
173 } | 172 } |
174 | 173 |
175 void IsCalloutAboveLauncherIcon(aura::Window* panel) { | 174 void IsCalloutAboveLauncherIcon(aura::Window* panel) { |
176 // Flush the message loop, since callout updates use a delayed task. | 175 // Flush the message loop, since callout updates use a delayed task. |
177 base::RunLoop().RunUntilIdle(); | 176 base::RunLoop().RunUntilIdle(); |
178 views::Widget* widget = GetCalloutWidgetForPanel(panel); | 177 views::Widget* widget = GetCalloutWidgetForPanel(panel); |
179 | 178 |
180 WmWindow* wm_panel = WmWindow::Get(panel); | 179 Shelf* shelf = GetShelfForWindow(panel); |
181 Shelf* shelf = wm_panel->GetRootWindowController()->shelf(); | 180 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); |
182 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(wm_panel); | |
183 ASSERT_FALSE(icon_bounds.IsEmpty()); | 181 ASSERT_FALSE(icon_bounds.IsEmpty()); |
184 | 182 |
185 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); | 183 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); |
186 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); | 184 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); |
187 ASSERT_FALSE(icon_bounds.IsEmpty()); | 185 ASSERT_FALSE(icon_bounds.IsEmpty()); |
188 | 186 |
189 EXPECT_TRUE(widget->IsVisible()); | 187 EXPECT_TRUE(widget->IsVisible()); |
190 | 188 |
191 const ShelfAlignment alignment = shelf->alignment(); | 189 const ShelfAlignment alignment = shelf->alignment(); |
192 if (alignment == SHELF_ALIGNMENT_LEFT) | 190 if (alignment == SHELF_ALIGNMENT_LEFT) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); | 222 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); |
225 | 223 |
226 ui::test::EventGenerator& event_generator = GetEventGenerator(); | 224 ui::test::EventGenerator& event_generator = GetEventGenerator(); |
227 event_generator.MoveMouseTo(bounds.CenterPoint()); | 225 event_generator.MoveMouseTo(bounds.CenterPoint()); |
228 event_generator.ClickLeftButton(); | 226 event_generator.ClickLeftButton(); |
229 | 227 |
230 test_api.RunMessageLoopUntilAnimationsDone(); | 228 test_api.RunMessageLoopUntilAnimationsDone(); |
231 } | 229 } |
232 | 230 |
233 Shelf* GetShelfForWindow(aura::Window* window) { | 231 Shelf* GetShelfForWindow(aura::Window* window) { |
234 return WmWindow::Get(window)->GetRootWindowController()->GetShelf(); | 232 return RootWindowController::ForWindow(window)->shelf(); |
235 } | 233 } |
236 | 234 |
237 void SetAlignment(aura::Window* root_window, ShelfAlignment alignment) { | 235 void SetAlignment(aura::Window* window, ShelfAlignment alignment) { |
238 GetShelfForWindow(root_window)->SetAlignment(alignment); | 236 GetShelfForWindow(window)->SetAlignment(alignment); |
239 } | 237 } |
240 | 238 |
241 void SetShelfAutoHideBehavior(aura::Window* window, | 239 void SetShelfAutoHideBehavior(aura::Window* window, |
242 ShelfAutoHideBehavior behavior) { | 240 ShelfAutoHideBehavior behavior) { |
243 Shelf* shelf = GetShelfForWindow(window); | 241 Shelf* shelf = GetShelfForWindow(window); |
244 shelf->SetAutoHideBehavior(behavior); | 242 shelf->SetAutoHideBehavior(behavior); |
245 test::ShelfViewTestAPI test_api(shelf->GetShelfViewForTesting()); | 243 test::ShelfViewTestAPI test_api(shelf->GetShelfViewForTesting()); |
246 test_api.RunMessageLoopUntilAnimationsDone(); | 244 test_api.RunMessageLoopUntilAnimationsDone(); |
247 } | 245 } |
248 | 246 |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 gfx::Rect bounds(0, 0, 201, 201); | 619 gfx::Rect bounds(0, 0, 201, 201); |
622 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); | 620 std::unique_ptr<aura::Window> w1(CreatePanelWindow(bounds)); |
623 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); | 621 std::unique_ptr<aura::Window> w2(CreatePanelWindow(bounds)); |
624 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); | 622 std::unique_ptr<aura::Window> w3(CreatePanelWindow(bounds)); |
625 | 623 |
626 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 624 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
627 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); | 625 int window_x1 = w1->GetBoundsInRootWindow().CenterPoint().x(); |
628 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); | 626 int window_x2 = w2->GetBoundsInRootWindow().CenterPoint().x(); |
629 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); | 627 int window_x3 = w3->GetBoundsInRootWindow().CenterPoint().x(); |
630 Shelf* shelf = GetPrimaryShelf(); | 628 Shelf* shelf = GetPrimaryShelf(); |
631 int icon_x1 = | 629 int icon_x1 = shelf->GetScreenBoundsOfItemIconForWindow(w1.get()).x(); |
632 shelf->GetScreenBoundsOfItemIconForWindow(WmWindow::Get(w1.get())).x(); | 630 int icon_x2 = shelf->GetScreenBoundsOfItemIconForWindow(w2.get()).x(); |
633 int icon_x2 = | |
634 shelf->GetScreenBoundsOfItemIconForWindow(WmWindow::Get(w2.get())).x(); | |
635 // TODO(crbug.com/698887): investigate failure in Mash. | 631 // TODO(crbug.com/698887): investigate failure in Mash. |
636 if (Shell::GetAshConfig() != Config::MASH) | 632 if (Shell::GetAshConfig() != Config::MASH) |
637 EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2); | 633 EXPECT_EQ(window_x2 - window_x1, window_x3 - window_x2); |
638 // New shelf items for panels are inserted before existing panel items. | 634 // New shelf items for panels are inserted before existing panel items. |
639 EXPECT_LT(window_x2, window_x1); | 635 EXPECT_LT(window_x2, window_x1); |
640 EXPECT_LT(window_x3, window_x2); | 636 EXPECT_LT(window_x3, window_x2); |
641 int spacing = window_x2 - window_x1; | 637 int spacing = window_x2 - window_x1; |
642 EXPECT_GT(std::abs(spacing), std::abs(icon_x2 - icon_x1)); | 638 EXPECT_GT(std::abs(spacing), std::abs(icon_x2 - icon_x1)); |
643 } | 639 } |
644 | 640 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); | 923 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); |
928 target = targeter->FindTargetForEvent(root, &touch); | 924 target = targeter->FindTargetForEvent(root, &touch); |
929 EXPECT_NE(w.get(), target); | 925 EXPECT_NE(w.get(), target); |
930 } | 926 } |
931 | 927 |
932 INSTANTIATE_TEST_CASE_P(LtrRtl, | 928 INSTANTIATE_TEST_CASE_P(LtrRtl, |
933 PanelLayoutManagerTextDirectionTest, | 929 PanelLayoutManagerTextDirectionTest, |
934 testing::Bool()); | 930 testing::Bool()); |
935 | 931 |
936 } // namespace ash | 932 } // namespace ash |
OLD | NEW |