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/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shelf/shelf_types.h" | 10 #include "ash/shelf/shelf_types.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
13 #include "ui/aura/client/aura_constants.h" | 13 #include "ui/aura/client/aura_constants.h" |
14 #include "ui/aura/client/cursor_client.h" | 14 #include "ui/aura/client/cursor_client.h" |
15 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
16 #include "ui/aura/test/event_generator.h" | 16 #include "ui/aura/test/event_generator.h" |
17 #include "ui/aura/test/test_event_handler.h" | 17 #include "ui/aura/test/test_event_handler.h" |
18 #include "ui/aura/test/test_window_delegate.h" | 18 #include "ui/aura/test/test_window_delegate.h" |
19 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
20 #include "ui/aura/window_event_dispatcher.h" | 20 #include "ui/aura/window_event_dispatcher.h" |
21 #include "ui/events/event_utils.h" | 21 #include "ui/events/event_utils.h" |
22 #include "ui/gfx/animation/slide_animation.h" | 22 #include "ui/gfx/animation/slide_animation.h" |
23 #include "ui/views/bubble/bubble_delegate.h" | 23 #include "ui/views/bubble/bubble_delegate.h" |
24 #include "ui/views/controls/native/native_view_host.h" | 24 #include "ui/views/controls/native/native_view_host.h" |
25 #include "ui/views/view.h" | 25 #include "ui/views/view.h" |
26 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
27 | 27 |
28 // For now, immersive fullscreen is Chrome OS only. | |
29 #if defined(OS_CHROMEOS) | |
30 | |
31 namespace ash { | 28 namespace ash { |
32 | 29 |
33 namespace { | 30 namespace { |
34 | 31 |
35 class MockImmersiveFullscreenControllerDelegate | 32 class MockImmersiveFullscreenControllerDelegate |
36 : public ImmersiveFullscreenController::Delegate { | 33 : public ImmersiveFullscreenController::Delegate { |
37 public: | 34 public: |
38 MockImmersiveFullscreenControllerDelegate(views::View* top_container_view) | 35 MockImmersiveFullscreenControllerDelegate(views::View* top_container_view) |
39 : top_container_view_(top_container_view), | 36 : top_container_view_(top_container_view), |
40 enabled_(false), | 37 enabled_(false), |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 lock1.reset(); | 336 lock1.reset(); |
340 EXPECT_TRUE(controller()->IsRevealed()); | 337 EXPECT_TRUE(controller()->IsRevealed()); |
341 | 338 |
342 lock2.reset(); | 339 lock2.reset(); |
343 EXPECT_FALSE(controller()->IsRevealed()); | 340 EXPECT_FALSE(controller()->IsRevealed()); |
344 } | 341 } |
345 | 342 |
346 // Test mouse event processing for top-of-screen reveal triggering. | 343 // Test mouse event processing for top-of-screen reveal triggering. |
347 TEST_F(ImmersiveFullscreenControllerTest, OnMouseEvent) { | 344 TEST_F(ImmersiveFullscreenControllerTest, OnMouseEvent) { |
348 // Set up initial state. | 345 // Set up initial state. |
349 UpdateDisplay("800x600,800x600"); | |
350 ash::DisplayLayout display_layout(ash::DisplayLayout::RIGHT, 0); | |
351 ash::Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | |
352 display_layout); | |
353 | |
354 // Set up initial state. | |
355 SetEnabled(true); | 346 SetEnabled(true); |
356 ASSERT_TRUE(controller()->IsEnabled()); | 347 ASSERT_TRUE(controller()->IsEnabled()); |
357 ASSERT_FALSE(controller()->IsRevealed()); | 348 ASSERT_FALSE(controller()->IsRevealed()); |
358 | 349 |
359 aura::test::EventGenerator& event_generator(GetEventGenerator()); | 350 aura::test::EventGenerator& event_generator(GetEventGenerator()); |
360 | 351 |
361 gfx::Rect top_container_bounds_in_screen = | 352 gfx::Rect top_container_bounds_in_screen = |
362 top_container()->GetBoundsInScreen(); | 353 top_container()->GetBoundsInScreen(); |
363 // A position along the top edge of TopContainerView in screen coordinates. | 354 // A position along the top edge of TopContainerView in screen coordinates. |
364 gfx::Point top_edge_pos(top_container_bounds_in_screen.x() + 100, | 355 gfx::Point top_edge_pos(top_container_bounds_in_screen.x() + 100, |
365 top_container_bounds_in_screen.y()); | 356 top_container_bounds_in_screen.y()); |
366 | 357 |
367 // Mouse wheel event does nothing. | 358 // Mouse wheel event does nothing. |
368 ui::MouseEvent wheel( | 359 ui::MouseEvent wheel( |
369 ui::ET_MOUSEWHEEL, top_edge_pos, top_edge_pos, ui::EF_NONE, ui::EF_NONE); | 360 ui::ET_MOUSEWHEEL, top_edge_pos, top_edge_pos, ui::EF_NONE, ui::EF_NONE); |
370 event_generator.Dispatch(&wheel); | 361 event_generator.Dispatch(&wheel); |
371 EXPECT_FALSE(top_edge_hover_timer_running()); | 362 EXPECT_FALSE(top_edge_hover_timer_running()); |
372 | 363 |
373 // Move to top edge of screen starts hover timer running. We cannot use | 364 // Move to top edge of screen starts hover timer running. We cannot use |
374 // MoveMouse() because MoveMouse() stops the timer if it started running. | 365 // MoveMouse() because MoveMouse() stops the timer if it started running. |
375 event_generator.MoveMouseTo(top_edge_pos); | 366 event_generator.MoveMouseTo(top_edge_pos); |
376 EXPECT_TRUE(top_edge_hover_timer_running()); | 367 EXPECT_TRUE(top_edge_hover_timer_running()); |
377 EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top()); | 368 EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top()); |
378 | 369 |
379 // Moving |ImmersiveFullscreenControllerTest::kMouseRevealBoundsHeight| down | 370 // Moving |ImmersiveFullscreenControllerTest::kMouseRevealBoundsHeight| down |
380 // from the top edge stops it. | 371 // from the top edge stops it. |
381 event_generator.MoveMouseBy(0, 3); | 372 event_generator.MoveMouseBy(0, |
| 373 ImmersiveFullscreenController::kMouseRevealBoundsHeight); |
382 EXPECT_FALSE(top_edge_hover_timer_running()); | 374 EXPECT_FALSE(top_edge_hover_timer_running()); |
383 | 375 |
384 // Moving back to the top starts the timer again. | 376 // Moving back to the top starts the timer again. |
385 event_generator.MoveMouseTo(top_edge_pos); | 377 event_generator.MoveMouseTo(top_edge_pos); |
386 EXPECT_TRUE(top_edge_hover_timer_running()); | 378 EXPECT_TRUE(top_edge_hover_timer_running()); |
387 EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top()); | 379 EXPECT_EQ(top_edge_pos.x(), mouse_x_when_hit_top()); |
388 | 380 |
389 // Slight move to the right keeps the timer running for the same hit point. | 381 // Slight move to the right keeps the timer running for the same hit point. |
390 event_generator.MoveMouseBy(1, 0); | 382 event_generator.MoveMouseBy(1, 0); |
391 EXPECT_TRUE(top_edge_hover_timer_running()); | 383 EXPECT_TRUE(top_edge_hover_timer_running()); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 EXPECT_FALSE(controller()->IsRevealed()); | 664 EXPECT_FALSE(controller()->IsRevealed()); |
673 | 665 |
674 // Initiate reveal via mouse, end reveal via touch. | 666 // Initiate reveal via mouse, end reveal via touch. |
675 AttemptReveal(MODALITY_MOUSE); | 667 AttemptReveal(MODALITY_MOUSE); |
676 EXPECT_TRUE(controller()->IsRevealed()); | 668 EXPECT_TRUE(controller()->IsRevealed()); |
677 AttemptUnreveal(MODALITY_GESTURE_TAP); | 669 AttemptUnreveal(MODALITY_GESTURE_TAP); |
678 EXPECT_FALSE(controller()->IsRevealed()); | 670 EXPECT_FALSE(controller()->IsRevealed()); |
679 } | 671 } |
680 | 672 |
681 // Test when the SWIPE_CLOSE edge gesture closes the top-of-window views. | 673 // Test when the SWIPE_CLOSE edge gesture closes the top-of-window views. |
682 TEST_F(ImmersiveFullscreenControllerTest, EndRevealViaGesture) { | 674 #if defined(OS_WIN) |
| 675 // On Windows, touch events do not result in mouse events being disabled. As |
| 676 // a result, the last part of this test which ends the reveal via a gesture will |
| 677 // not work correctly. See crbug.com/332430, and the function |
| 678 // ShouldHideCursorOnTouch() in compound_event_filter.cc. |
| 679 #define MAYBE_EndRevealViaGesture DISABLED_EndRevealViaGesture |
| 680 #else |
| 681 #define MAYBE_EndRevealViaGesture EndRevealViaGesture |
| 682 #endif |
| 683 TEST_F(ImmersiveFullscreenControllerTest, MAYBE_EndRevealViaGesture) { |
683 SetEnabled(true); | 684 SetEnabled(true); |
684 EXPECT_TRUE(controller()->IsEnabled()); | 685 EXPECT_TRUE(controller()->IsEnabled()); |
685 EXPECT_FALSE(controller()->IsRevealed()); | 686 EXPECT_FALSE(controller()->IsRevealed()); |
686 | 687 |
687 // A gesture should be able to close the top-of-window views when | 688 // A gesture should be able to close the top-of-window views when |
688 // top-of-window views have focus. | 689 // top-of-window views have focus. |
689 AttemptReveal(MODALITY_MOUSE); | 690 AttemptReveal(MODALITY_MOUSE); |
690 top_container()->RequestFocus(); | 691 top_container()->RequestFocus(); |
691 EXPECT_TRUE(controller()->IsRevealed()); | 692 EXPECT_TRUE(controller()->IsRevealed()); |
692 AttemptUnreveal(MODALITY_GESTURE_SCROLL); | 693 AttemptUnreveal(MODALITY_GESTURE_SCROLL); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | 1048 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); |
1048 | 1049 |
1049 // Disabling immersive fullscreen maintains the user's auto-hide selection. | 1050 // Disabling immersive fullscreen maintains the user's auto-hide selection. |
1050 SetEnabled(false); | 1051 SetEnabled(false); |
1051 window()->SetProperty(aura::client::kShowStateKey, | 1052 window()->SetProperty(aura::client::kShowStateKey, |
1052 ui::SHOW_STATE_NORMAL); | 1053 ui::SHOW_STATE_NORMAL); |
1053 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); | 1054 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); |
1054 } | 1055 } |
1055 | 1056 |
1056 } // namespase ash | 1057 } // namespase ash |
1057 | |
1058 #endif // defined(OS_CHROMEOS) | |
OLD | NEW |