OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/wm/immersive_fullscreen_controller.h" | 5 #include "ash/wm/immersive_fullscreen_controller.h" |
6 | 6 |
7 #include "ash/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
8 #include "ash/display/mouse_cursor_event_filter.h" | 8 #include "ash/display/mouse_cursor_event_filter.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
11 #include "ash/shelf/shelf_types.h" | 11 #include "ash/shelf/shelf_types.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
14 #include "ash/wm/window_state.h" | 14 #include "ash/wm/window_state.h" |
15 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
16 #include "ui/aura/client/cursor_client.h" | 16 #include "ui/aura/client/cursor_client.h" |
17 #include "ui/aura/env.h" | 17 #include "ui/aura/env.h" |
18 #include "ui/aura/test/event_generator.h" | |
19 #include "ui/aura/test/test_window_delegate.h" | 18 #include "ui/aura/test/test_window_delegate.h" |
20 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
21 #include "ui/aura/window_event_dispatcher.h" | 20 #include "ui/aura/window_event_dispatcher.h" |
22 #include "ui/events/event_utils.h" | 21 #include "ui/events/event_utils.h" |
| 22 #include "ui/events/test/event_generator.h" |
23 #include "ui/events/test/test_event_handler.h" | 23 #include "ui/events/test/test_event_handler.h" |
24 #include "ui/gfx/animation/slide_animation.h" | 24 #include "ui/gfx/animation/slide_animation.h" |
25 #include "ui/views/bubble/bubble_delegate.h" | 25 #include "ui/views/bubble/bubble_delegate.h" |
26 #include "ui/views/controls/native/native_view_host.h" | 26 #include "ui/views/controls/native/native_view_host.h" |
27 #include "ui/views/view.h" | 27 #include "ui/views/view.h" |
28 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
29 | 29 |
30 namespace ash { | 30 namespace ash { |
31 | 31 |
32 namespace { | 32 namespace { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // Compute the event position in |top_container_| coordinates. | 224 // Compute the event position in |top_container_| coordinates. |
225 gfx::Point event_position(0, revealed ? 0 : top_container_->height() + 100); | 225 gfx::Point event_position(0, revealed ? 0 : top_container_->height() + 100); |
226 switch (modality) { | 226 switch (modality) { |
227 case MODALITY_MOUSE: { | 227 case MODALITY_MOUSE: { |
228 MoveMouse(event_position.x(), event_position.y()); | 228 MoveMouse(event_position.x(), event_position.y()); |
229 break; | 229 break; |
230 } | 230 } |
231 case MODALITY_GESTURE_TAP: { | 231 case MODALITY_GESTURE_TAP: { |
232 gfx::Point screen_position = event_position; | 232 gfx::Point screen_position = event_position; |
233 views::View::ConvertPointToScreen(top_container_, &screen_position); | 233 views::View::ConvertPointToScreen(top_container_, &screen_position); |
234 aura::test::EventGenerator& event_generator(GetEventGenerator()); | 234 ui::test::EventGenerator& event_generator(GetEventGenerator()); |
235 event_generator.MoveTouch(event_position); | 235 event_generator.MoveTouch(event_position); |
236 event_generator.PressTouch(); | 236 event_generator.PressTouch(); |
237 event_generator.ReleaseTouch(); | 237 event_generator.ReleaseTouch(); |
238 break; | 238 break; |
239 } | 239 } |
240 case MODALITY_GESTURE_SCROLL: { | 240 case MODALITY_GESTURE_SCROLL: { |
241 gfx::Point start(0, revealed ? 0 : top_container_->height() - 2); | 241 gfx::Point start(0, revealed ? 0 : top_container_->height() - 2); |
242 gfx::Vector2d scroll_delta(0, 40); | 242 gfx::Vector2d scroll_delta(0, 40); |
243 gfx::Point end = revealed ? start + scroll_delta : start - scroll_delta; | 243 gfx::Point end = revealed ? start + scroll_delta : start - scroll_delta; |
244 views::View::ConvertPointToScreen(top_container_, &start); | 244 views::View::ConvertPointToScreen(top_container_, &start); |
245 views::View::ConvertPointToScreen(top_container_, &end); | 245 views::View::ConvertPointToScreen(top_container_, &end); |
246 aura::test::EventGenerator& event_generator(GetEventGenerator()); | 246 ui::test::EventGenerator& event_generator(GetEventGenerator()); |
247 event_generator.GestureScrollSequence( | 247 event_generator.GestureScrollSequence( |
248 start, end, | 248 start, end, |
249 base::TimeDelta::FromMilliseconds(30), 1); | 249 base::TimeDelta::FromMilliseconds(30), 1); |
250 break; | 250 break; |
251 } | 251 } |
252 } | 252 } |
253 } | 253 } |
254 | 254 |
255 scoped_ptr<ImmersiveFullscreenController> controller_; | 255 scoped_ptr<ImmersiveFullscreenController> controller_; |
256 scoped_ptr<MockImmersiveFullscreenControllerDelegate> delegate_; | 256 scoped_ptr<MockImmersiveFullscreenControllerDelegate> delegate_; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 EXPECT_FALSE(controller()->IsRevealed()); | 342 EXPECT_FALSE(controller()->IsRevealed()); |
343 } | 343 } |
344 | 344 |
345 // Test mouse event processing for top-of-screen reveal triggering. | 345 // Test mouse event processing for top-of-screen reveal triggering. |
346 TEST_F(ImmersiveFullscreenControllerTest, OnMouseEvent) { | 346 TEST_F(ImmersiveFullscreenControllerTest, OnMouseEvent) { |
347 // Set up initial state. | 347 // Set up initial state. |
348 SetEnabled(true); | 348 SetEnabled(true); |
349 ASSERT_TRUE(controller()->IsEnabled()); | 349 ASSERT_TRUE(controller()->IsEnabled()); |
350 ASSERT_FALSE(controller()->IsRevealed()); | 350 ASSERT_FALSE(controller()->IsRevealed()); |
351 | 351 |
352 aura::test::EventGenerator& event_generator(GetEventGenerator()); | 352 ui::test::EventGenerator& event_generator(GetEventGenerator()); |
353 | 353 |
354 gfx::Rect top_container_bounds_in_screen = | 354 gfx::Rect top_container_bounds_in_screen = |
355 top_container()->GetBoundsInScreen(); | 355 top_container()->GetBoundsInScreen(); |
356 // A position along the top edge of TopContainerView in screen coordinates. | 356 // A position along the top edge of TopContainerView in screen coordinates. |
357 gfx::Point top_edge_pos(top_container_bounds_in_screen.x() + 100, | 357 gfx::Point top_edge_pos(top_container_bounds_in_screen.x() + 100, |
358 top_container_bounds_in_screen.y()); | 358 top_container_bounds_in_screen.y()); |
359 | 359 |
360 // Mouse wheel event does nothing. | 360 // Mouse wheel event does nothing. |
361 ui::MouseEvent wheel( | 361 ui::MouseEvent wheel( |
362 ui::ET_MOUSEWHEEL, top_edge_pos, top_edge_pos, ui::EF_NONE, ui::EF_NONE); | 362 ui::ET_MOUSEWHEEL, top_edge_pos, top_edge_pos, ui::EF_NONE, ui::EF_NONE); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 top_container()->GetWidget()->GetNativeWindow()->GetRootWindow()); | 521 top_container()->GetWidget()->GetNativeWindow()->GetRootWindow()); |
522 | 522 |
523 gfx::Rect primary_root_window_bounds_in_screen = | 523 gfx::Rect primary_root_window_bounds_in_screen = |
524 root_windows[0]->GetBoundsInScreen(); | 524 root_windows[0]->GetBoundsInScreen(); |
525 // Do not set |x| to the root window's x position because the display's | 525 // Do not set |x| to the root window's x position because the display's |
526 // corners have special behavior. | 526 // corners have special behavior. |
527 int x = primary_root_window_bounds_in_screen.x() + 10; | 527 int x = primary_root_window_bounds_in_screen.x() + 10; |
528 // The y position of the top edge of the primary display. | 528 // The y position of the top edge of the primary display. |
529 int y_top_edge = primary_root_window_bounds_in_screen.y(); | 529 int y_top_edge = primary_root_window_bounds_in_screen.y(); |
530 | 530 |
531 aura::test::EventGenerator& event_generator(GetEventGenerator()); | 531 ui::test::EventGenerator& event_generator(GetEventGenerator()); |
532 | 532 |
533 // Moving right below the top edge starts the hover timer running. We | 533 // Moving right below the top edge starts the hover timer running. We |
534 // cannot use MoveMouse() because MoveMouse() stops the timer if it started | 534 // cannot use MoveMouse() because MoveMouse() stops the timer if it started |
535 // running. | 535 // running. |
536 event_generator.MoveMouseTo(x, y_top_edge + 1); | 536 event_generator.MoveMouseTo(x, y_top_edge + 1); |
537 EXPECT_TRUE(top_edge_hover_timer_running()); | 537 EXPECT_TRUE(top_edge_hover_timer_running()); |
538 EXPECT_EQ(y_top_edge + 1, | 538 EXPECT_EQ(y_top_edge + 1, |
539 aura::Env::GetInstance()->last_mouse_location().y()); | 539 aura::Env::GetInstance()->last_mouse_location().y()); |
540 | 540 |
541 // The timer should continue running if the user moves the mouse to the top | 541 // The timer should continue running if the user moves the mouse to the top |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | 1067 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); |
1068 | 1068 |
1069 // Disabling immersive fullscreen maintains the user's auto-hide selection. | 1069 // Disabling immersive fullscreen maintains the user's auto-hide selection. |
1070 SetEnabled(false); | 1070 SetEnabled(false); |
1071 window()->SetProperty(aura::client::kShowStateKey, | 1071 window()->SetProperty(aura::client::kShowStateKey, |
1072 ui::SHOW_STATE_NORMAL); | 1072 ui::SHOW_STATE_NORMAL); |
1073 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | 1073 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); |
1074 } | 1074 } |
1075 | 1075 |
1076 } // namespase ash | 1076 } // namespase ash |
OLD | NEW |