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/common/shelf/shelf_widget.h" | 5 #include "ash/common/shelf/shelf_widget.h" |
6 | 6 |
7 #include "ash/common/shelf/shelf_constants.h" | 7 #include "ash/common/shelf/shelf_constants.h" |
8 #include "ash/common/shelf/shelf_layout_manager.h" | 8 #include "ash/common/shelf/shelf_layout_manager.h" |
9 #include "ash/common/shelf/shelf_view.h" | 9 #include "ash/common/shelf/shelf_view.h" |
10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 params.bounds = gfx::Rect(shelf_bounds.height() - kOverlapSize, | 207 params.bounds = gfx::Rect(shelf_bounds.height() - kOverlapSize, |
208 shelf_bounds.y() - kWindowHeight + kOverlapSize, | 208 shelf_bounds.y() - kWindowHeight + kOverlapSize, |
209 kWindowWidth, kWindowHeight); | 209 kWindowWidth, kWindowHeight); |
210 params.context = CurrentContext(); | 210 params.context = CurrentContext(); |
211 // Widget is now owned by the parent window. | 211 // Widget is now owned by the parent window. |
212 widget->Init(params); | 212 widget->Init(params); |
213 widget->Show(); | 213 widget->Show(); |
214 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen(); | 214 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen(); |
215 EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds)); | 215 EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds)); |
216 | 216 |
217 ui::EventTarget* root = widget->GetNativeWindow()->GetRootWindow(); | 217 aura::Window* root = widget->GetNativeWindow()->GetRootWindow(); |
218 ui::EventTargeter* targeter = root->GetEventTargeter(); | 218 ui::EventTargeter* targeter = |
| 219 root->GetHost()->dispatcher()->GetDefaultEventTargeter(); |
219 { | 220 { |
220 // Create a mouse-event targeting the top of the shelf widget. The | 221 // Create a mouse-event targeting the top of the shelf widget. The |
221 // window-targeter should find |widget| as the target (instead of the | 222 // window-targeter should find |widget| as the target (instead of the |
222 // shelf). | 223 // shelf). |
223 gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1); | 224 gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1); |
224 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, | 225 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, |
225 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 226 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
226 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); | 227 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); |
227 EXPECT_EQ(widget->GetNativeWindow(), target); | 228 EXPECT_EQ(widget->GetNativeWindow(), target); |
228 } | 229 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 284 |
284 // Create a widget to make sure that the shelf does auto-hide. | 285 // Create a widget to make sure that the shelf does auto-hide. |
285 views::Widget* widget = new views::Widget; | 286 views::Widget* widget = new views::Widget; |
286 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 287 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
287 params.bounds = gfx::Rect(0, 0, 200, 200); | 288 params.bounds = gfx::Rect(0, 0, 200, 200); |
288 params.context = CurrentContext(); | 289 params.context = CurrentContext(); |
289 // Widget is now owned by the parent window. | 290 // Widget is now owned by the parent window. |
290 widget->Init(params); | 291 widget->Init(params); |
291 widget->Show(); | 292 widget->Show(); |
292 | 293 |
293 ui::EventTarget* root = shelf_widget->GetNativeWindow()->GetRootWindow(); | 294 aura::Window* root = shelf_widget->GetNativeWindow()->GetRootWindow(); |
294 ui::EventTargeter* targeter = root->GetEventTargeter(); | 295 ui::EventTargeter* targeter = |
| 296 root->GetHost()->dispatcher()->GetDefaultEventTargeter(); |
295 // Touch just over the shelf. Since the shelf is visible, the window-targeter | 297 // Touch just over the shelf. Since the shelf is visible, the window-targeter |
296 // should not find the shelf as the target. | 298 // should not find the shelf as the target. |
297 { | 299 { |
298 gfx::Point event_location(20, shelf_bounds.y() - 1); | 300 gfx::Point event_location(20, shelf_bounds.y() - 1); |
299 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0, | 301 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0, |
300 ui::EventTimeForNow()); | 302 ui::EventTimeForNow()); |
301 EXPECT_NE(shelf_widget->GetNativeWindow(), | 303 EXPECT_NE(shelf_widget->GetNativeWindow(), |
302 targeter->FindTargetForEvent(root, &touch)); | 304 targeter->FindTargetForEvent(root, &touch)); |
303 } | 305 } |
304 | 306 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 } | 408 } |
407 | 409 |
408 TEST_F(ShelfWidgetTestWithInitializer, CreateLockedShelf) { | 410 TEST_F(ShelfWidgetTestWithInitializer, CreateLockedShelf) { |
409 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. | 411 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. |
410 TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM_LOCKED, | 412 TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM_LOCKED, |
411 SHELF_AUTO_HIDE_BEHAVIOR_NEVER, | 413 SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |
412 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); | 414 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); |
413 } | 415 } |
414 | 416 |
415 } // namespace ash | 417 } // namespace ash |
OLD | NEW |