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/screen_util.h" | 8 #include "ash/screen_util.h" |
9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
10 #include "ash/shelf/shelf_button.h" | 10 #include "ash/shelf/shelf_button.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // the shelf icon. | 133 // the shelf icon. |
134 EXPECT_LE(window_bounds.x(), icon_bounds.x()); | 134 EXPECT_LE(window_bounds.x(), icon_bounds.x()); |
135 EXPECT_GE(window_bounds.right(), icon_bounds.right()); | 135 EXPECT_GE(window_bounds.right(), icon_bounds.right()); |
136 } else { | 136 } else { |
137 // The vertical bounds of the panel window should contain the bounds of | 137 // The vertical bounds of the panel window should contain the bounds of |
138 // the shelf icon. | 138 // the shelf icon. |
139 EXPECT_LE(window_bounds.y(), icon_bounds.y()); | 139 EXPECT_LE(window_bounds.y(), icon_bounds.y()); |
140 EXPECT_GE(window_bounds.bottom(), icon_bounds.bottom()); | 140 EXPECT_GE(window_bounds.bottom(), icon_bounds.bottom()); |
141 } | 141 } |
142 | 142 |
143 switch (alignment) { | 143 if (alignment == SHELF_ALIGNMENT_LEFT) |
144 case SHELF_ALIGNMENT_BOTTOM: | 144 EXPECT_EQ(shelf_bounds.right(), window_bounds.x()); |
145 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom()); | 145 else if (alignment == SHELF_ALIGNMENT_RIGHT) |
146 break; | 146 EXPECT_EQ(shelf_bounds.x(), window_bounds.right()); |
147 case SHELF_ALIGNMENT_LEFT: | 147 else |
148 EXPECT_EQ(shelf_bounds.right(), window_bounds.x()); | 148 EXPECT_EQ(shelf_bounds.y(), window_bounds.bottom()); |
149 break; | |
150 case SHELF_ALIGNMENT_RIGHT: | |
151 EXPECT_EQ(shelf_bounds.x(), window_bounds.right()); | |
152 break; | |
153 } | |
154 } | 149 } |
155 | 150 |
156 void IsCalloutAboveLauncherIcon(aura::Window* panel) { | 151 void IsCalloutAboveLauncherIcon(aura::Window* panel) { |
157 // Flush the message loop, since callout updates use a delayed task. | 152 // Flush the message loop, since callout updates use a delayed task. |
158 base::RunLoop().RunUntilIdle(); | 153 base::RunLoop().RunUntilIdle(); |
159 views::Widget* widget = GetCalloutWidgetForPanel(panel); | 154 views::Widget* widget = GetCalloutWidgetForPanel(panel); |
160 | 155 |
161 Shelf* shelf = Shelf::ForWindow(panel); | 156 Shelf* shelf = Shelf::ForWindow(panel); |
162 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); | 157 gfx::Rect icon_bounds = shelf->GetScreenBoundsOfItemIconForWindow(panel); |
163 ASSERT_FALSE(icon_bounds.IsEmpty()); | 158 ASSERT_FALSE(icon_bounds.IsEmpty()); |
164 | 159 |
165 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); | 160 gfx::Rect panel_bounds = panel->GetBoundsInScreen(); |
166 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); | 161 gfx::Rect callout_bounds = widget->GetWindowBoundsInScreen(); |
167 ASSERT_FALSE(icon_bounds.IsEmpty()); | 162 ASSERT_FALSE(icon_bounds.IsEmpty()); |
168 | 163 |
169 EXPECT_TRUE(widget->IsVisible()); | 164 EXPECT_TRUE(widget->IsVisible()); |
170 | 165 |
171 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); | 166 ShelfAlignment alignment = GetAlignment(panel->GetRootWindow()); |
172 switch (alignment) { | 167 if (alignment == SHELF_ALIGNMENT_LEFT) |
173 case SHELF_ALIGNMENT_BOTTOM: | 168 EXPECT_EQ(panel_bounds.x(), callout_bounds.right()); |
174 EXPECT_EQ(panel_bounds.bottom(), callout_bounds.y()); | 169 else if (alignment == SHELF_ALIGNMENT_RIGHT) |
175 break; | 170 EXPECT_EQ(panel_bounds.right(), callout_bounds.x()); |
176 case SHELF_ALIGNMENT_LEFT: | 171 else |
177 EXPECT_EQ(panel_bounds.x(), callout_bounds.right()); | 172 EXPECT_EQ(panel_bounds.bottom(), callout_bounds.y()); |
178 break; | |
179 case SHELF_ALIGNMENT_RIGHT: | |
180 EXPECT_EQ(panel_bounds.right(), callout_bounds.x()); | |
181 break; | |
182 } | |
183 | 173 |
184 if (IsHorizontal(alignment)) { | 174 if (IsHorizontal(alignment)) { |
185 EXPECT_NEAR(icon_bounds.CenterPoint().x(), | 175 EXPECT_NEAR(icon_bounds.CenterPoint().x(), |
186 widget->GetWindowBoundsInScreen().CenterPoint().x(), | 176 widget->GetWindowBoundsInScreen().CenterPoint().x(), |
187 1); | 177 1); |
188 } else { | 178 } else { |
189 EXPECT_NEAR(icon_bounds.CenterPoint().y(), | 179 EXPECT_NEAR(icon_bounds.CenterPoint().y(), |
190 widget->GetWindowBoundsInScreen().CenterPoint().y(), | 180 widget->GetWindowBoundsInScreen().CenterPoint().y(), |
191 1); | 181 1); |
192 } | 182 } |
(...skipping 19 matching lines...) Expand all Loading... |
212 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); | 202 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); |
213 | 203 |
214 ui::test::EventGenerator& event_generator = GetEventGenerator(); | 204 ui::test::EventGenerator& event_generator = GetEventGenerator(); |
215 event_generator.MoveMouseTo(bounds.CenterPoint()); | 205 event_generator.MoveMouseTo(bounds.CenterPoint()); |
216 event_generator.ClickLeftButton(); | 206 event_generator.ClickLeftButton(); |
217 | 207 |
218 test_api.RunMessageLoopUntilAnimationsDone(); | 208 test_api.RunMessageLoopUntilAnimationsDone(); |
219 } | 209 } |
220 | 210 |
221 void SetAlignment(aura::Window* root_window, ShelfAlignment alignment) { | 211 void SetAlignment(aura::Window* root_window, ShelfAlignment alignment) { |
222 ash::Shell* shell = ash::Shell::GetInstance(); | 212 Shelf::ForWindow(root_window)->SetAlignment(alignment); |
223 shell->SetShelfAlignment(alignment, root_window); | |
224 } | 213 } |
225 | 214 |
226 ShelfAlignment GetAlignment(const aura::Window* root_window) { | 215 ShelfAlignment GetAlignment(const aura::Window* root_window) { |
227 ash::Shell* shell = ash::Shell::GetInstance(); | 216 return Shelf::ForWindow(root_window)->alignment(); |
228 return shell->GetShelfAlignment(root_window); | |
229 } | 217 } |
230 | 218 |
231 void SetShelfAutoHideBehavior(aura::Window* window, | 219 void SetShelfAutoHideBehavior(aura::Window* window, |
232 ShelfAutoHideBehavior behavior) { | 220 ShelfAutoHideBehavior behavior) { |
233 Shelf* shelf = Shelf::ForWindow(window); | 221 Shelf* shelf = Shelf::ForWindow(window); |
234 shelf->shelf_layout_manager()->SetAutoHideBehavior(behavior); | 222 shelf->shelf_layout_manager()->SetAutoHideBehavior(behavior); |
235 test::ShelfViewTestAPI test_api(GetShelfView(shelf)); | 223 test::ShelfViewTestAPI test_api(GetShelfView(shelf)); |
236 test_api.RunMessageLoopUntilAnimationsDone(); | 224 test_api.RunMessageLoopUntilAnimationsDone(); |
237 } | 225 } |
238 | 226 |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 // Hit test outside the left edge with a left-aligned shelf. | 811 // Hit test outside the left edge with a left-aligned shelf. |
824 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); | 812 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); |
825 target = targeter->FindTargetForEvent(root, &touch); | 813 target = targeter->FindTargetForEvent(root, &touch); |
826 EXPECT_NE(w.get(), target); | 814 EXPECT_NE(w.get(), target); |
827 } | 815 } |
828 | 816 |
829 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, | 817 INSTANTIATE_TEST_CASE_P(LtrRtl, PanelLayoutManagerTextDirectionTest, |
830 testing::Bool()); | 818 testing::Bool()); |
831 | 819 |
832 } // namespace ash | 820 } // namespace ash |
OLD | NEW |