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