OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/shelf/shelf_widget.h" | 5 #include "ash/shelf/shelf_widget.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
9 #include "ash/shelf/shelf_button.h" | 9 #include "ash/shelf/shelf_button.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
24 | 24 |
25 namespace ash { | 25 namespace ash { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 ShelfWidget* GetShelfWidget() { | 29 ShelfWidget* GetShelfWidget() { |
30 return Shelf::ForPrimaryDisplay()->shelf_widget(); | 30 return Shelf::ForPrimaryDisplay()->shelf_widget(); |
31 } | 31 } |
32 | 32 |
33 internal::ShelfLayoutManager* GetShelfLayoutManager() { | 33 ShelfLayoutManager* GetShelfLayoutManager() { |
34 return GetShelfWidget()->shelf_layout_manager(); | 34 return GetShelfWidget()->shelf_layout_manager(); |
35 } | 35 } |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 typedef test::AshTestBase ShelfWidgetTest; | 39 typedef test::AshTestBase ShelfWidgetTest; |
40 | 40 |
41 void TestLauncherAlignment(aura::Window* root, | 41 void TestLauncherAlignment(aura::Window* root, |
42 ShelfAlignment alignment, | 42 ShelfAlignment alignment, |
43 const std::string& expected) { | 43 const std::string& expected) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 SHELF_ALIGNMENT_LEFT, | 110 SHELF_ALIGNMENT_LEFT, |
111 "347,0 453x500"); | 111 "347,0 453x500"); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 // Makes sure the shelf is initially sized correctly. | 115 // Makes sure the shelf is initially sized correctly. |
116 TEST_F(ShelfWidgetTest, LauncherInitiallySized) { | 116 TEST_F(ShelfWidgetTest, LauncherInitiallySized) { |
117 ShelfWidget* shelf_widget = GetShelfWidget(); | 117 ShelfWidget* shelf_widget = GetShelfWidget(); |
118 Shelf* shelf = shelf_widget->shelf(); | 118 Shelf* shelf = shelf_widget->shelf(); |
119 ASSERT_TRUE(shelf); | 119 ASSERT_TRUE(shelf); |
120 internal::ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); | 120 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); |
121 ASSERT_TRUE(shelf_layout_manager); | 121 ASSERT_TRUE(shelf_layout_manager); |
122 ASSERT_TRUE(shelf_widget->status_area_widget()); | 122 ASSERT_TRUE(shelf_widget->status_area_widget()); |
123 int status_width = shelf_widget->status_area_widget()-> | 123 int status_width = shelf_widget->status_area_widget()-> |
124 GetWindowBoundsInScreen().width(); | 124 GetWindowBoundsInScreen().width(); |
125 // Test only makes sense if the status is > 0, which it better be. | 125 // Test only makes sense if the status is > 0, which it better be. |
126 EXPECT_GT(status_width, 0); | 126 EXPECT_GT(status_width, 0); |
127 EXPECT_EQ(status_width, shelf_widget->GetContentsView()->width() - | 127 EXPECT_EQ(status_width, shelf_widget->GetContentsView()->width() - |
128 test::ShelfTestAPI(shelf).shelf_view()->width()); | 128 test::ShelfTestAPI(shelf).shelf_view()->width()); |
129 } | 129 } |
130 | 130 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 test::ShelfTestAPI(shelf).shelf_view()->width()); | 174 test::ShelfTestAPI(shelf).shelf_view()->width()); |
175 } | 175 } |
176 #endif // defined(OS_CHROMEOS) | 176 #endif // defined(OS_CHROMEOS) |
177 | 177 |
178 // Tests that the shelf lets mouse-events close to the edge fall through to the | 178 // Tests that the shelf lets mouse-events close to the edge fall through to the |
179 // window underneath. | 179 // window underneath. |
180 TEST_F(ShelfWidgetTest, ShelfEdgeOverlappingWindowHitTestMouse) { | 180 TEST_F(ShelfWidgetTest, ShelfEdgeOverlappingWindowHitTestMouse) { |
181 ShelfWidget* shelf_widget = GetShelfWidget(); | 181 ShelfWidget* shelf_widget = GetShelfWidget(); |
182 gfx::Rect shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); | 182 gfx::Rect shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); |
183 EXPECT_TRUE(!shelf_bounds.IsEmpty()); | 183 EXPECT_TRUE(!shelf_bounds.IsEmpty()); |
184 internal::ShelfLayoutManager* shelf_layout_manager = | 184 ShelfLayoutManager* shelf_layout_manager = |
185 shelf_widget->shelf_layout_manager(); | 185 shelf_widget->shelf_layout_manager(); |
186 ASSERT_TRUE(shelf_layout_manager); | 186 ASSERT_TRUE(shelf_layout_manager); |
187 EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); | 187 EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); |
188 | 188 |
189 // Create a Widget which overlaps with the shelf in the top edge. | 189 // Create a Widget which overlaps with the shelf in the top edge. |
190 const int kOverlapSize = 15; | 190 const int kOverlapSize = 15; |
191 const int kWindowHeight = 200; | 191 const int kWindowHeight = 200; |
192 views::Widget* widget = new views::Widget; | 192 views::Widget* widget = new views::Widget; |
193 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 193 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
194 params.bounds = gfx::Rect(0, shelf_bounds.y() - kWindowHeight + kOverlapSize, | 194 params.bounds = gfx::Rect(0, shelf_bounds.y() - kWindowHeight + kOverlapSize, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 EXPECT_EQ(shelf_widget->GetNativeWindow(), target); | 237 EXPECT_EQ(shelf_widget->GetNativeWindow(), target); |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 // Tests that the shelf has a slightly larger hit-region for touch-events when | 241 // Tests that the shelf has a slightly larger hit-region for touch-events when |
242 // it's in the auto-hidden state. | 242 // it's in the auto-hidden state. |
243 TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) { | 243 TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) { |
244 ShelfWidget* shelf_widget = GetShelfWidget(); | 244 ShelfWidget* shelf_widget = GetShelfWidget(); |
245 gfx::Rect shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); | 245 gfx::Rect shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); |
246 EXPECT_TRUE(!shelf_bounds.IsEmpty()); | 246 EXPECT_TRUE(!shelf_bounds.IsEmpty()); |
247 internal::ShelfLayoutManager* shelf_layout_manager = | 247 ShelfLayoutManager* shelf_layout_manager = |
248 shelf_widget->shelf_layout_manager(); | 248 shelf_widget->shelf_layout_manager(); |
249 ASSERT_TRUE(shelf_layout_manager); | 249 ASSERT_TRUE(shelf_layout_manager); |
250 EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); | 250 EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); |
251 | 251 |
252 // Create a widget to make sure that the shelf does auto-hide. | 252 // Create a widget to make sure that the shelf does auto-hide. |
253 views::Widget* widget = new views::Widget; | 253 views::Widget* widget = new views::Widget; |
254 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 254 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
255 params.bounds = gfx::Rect(0, 0, 200, 200); | 255 params.bounds = gfx::Rect(0, 0, 200, 200); |
256 params.context = CurrentContext(); | 256 params.context = CurrentContext(); |
257 // Widget is now owned by the parent window. | 257 // Widget is now owned by the parent window. |
(...skipping 25 matching lines...) Expand all Loading... |
283 { | 283 { |
284 gfx::Point event_location(20, shelf_bounds.y() - 1); | 284 gfx::Point event_location(20, shelf_bounds.y() - 1); |
285 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0, | 285 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0, |
286 ui::EventTimeForNow()); | 286 ui::EventTimeForNow()); |
287 EXPECT_EQ(shelf_widget->GetNativeWindow(), | 287 EXPECT_EQ(shelf_widget->GetNativeWindow(), |
288 targeter->FindTargetForEvent(root, &touch)); | 288 targeter->FindTargetForEvent(root, &touch)); |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 } // namespace ash | 292 } // namespace ash |
OLD | NEW |