| 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/shared/immersive_fullscreen_controller.h" | 5 #include "ash/shared/immersive_fullscreen_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/wm_shelf.h" | 7 #include "ash/common/shelf/wm_shelf.h" |
| 8 #include "ash/common/wm/window_state.h" | 8 #include "ash/common/wm/window_state.h" |
| 9 #include "ash/display/mouse_cursor_event_filter.h" | 9 #include "ash/display/mouse_cursor_event_filter.h" |
| 10 #include "ash/public/cpp/shelf_types.h" | 10 #include "ash/public/cpp/shelf_types.h" |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 EXPECT_FALSE(controller()->IsRevealed()); | 655 EXPECT_FALSE(controller()->IsRevealed()); |
| 656 | 656 |
| 657 // Initiate reveal via mouse, end reveal via touch. | 657 // Initiate reveal via mouse, end reveal via touch. |
| 658 AttemptReveal(MODALITY_MOUSE); | 658 AttemptReveal(MODALITY_MOUSE); |
| 659 EXPECT_TRUE(controller()->IsRevealed()); | 659 EXPECT_TRUE(controller()->IsRevealed()); |
| 660 AttemptUnreveal(MODALITY_GESTURE_TAP); | 660 AttemptUnreveal(MODALITY_GESTURE_TAP); |
| 661 EXPECT_FALSE(controller()->IsRevealed()); | 661 EXPECT_FALSE(controller()->IsRevealed()); |
| 662 } | 662 } |
| 663 | 663 |
| 664 // Test when the SWIPE_CLOSE edge gesture closes the top-of-window views. | 664 // Test when the SWIPE_CLOSE edge gesture closes the top-of-window views. |
| 665 #if !defined(OS_CHROMEOS) | 665 TEST_F(ImmersiveFullscreenControllerTest, EndRevealViaGesture) { |
| 666 // On Windows/Linux, touch events do not result in mouse events being disabled. | |
| 667 // As a result, the last part of this test which ends the reveal via a gesture | |
| 668 // will not work correctly. See crbug.com/332430, and the function | |
| 669 // ShouldHideCursorOnTouch() in compound_event_filter.cc. | |
| 670 #define MAYBE_EndRevealViaGesture DISABLED_EndRevealViaGesture | |
| 671 #else | |
| 672 #define MAYBE_EndRevealViaGesture EndRevealViaGesture | |
| 673 #endif | |
| 674 TEST_F(ImmersiveFullscreenControllerTest, MAYBE_EndRevealViaGesture) { | |
| 675 SetEnabled(true); | 666 SetEnabled(true); |
| 676 EXPECT_TRUE(controller()->IsEnabled()); | 667 EXPECT_TRUE(controller()->IsEnabled()); |
| 677 EXPECT_FALSE(controller()->IsRevealed()); | 668 EXPECT_FALSE(controller()->IsRevealed()); |
| 678 | 669 |
| 679 // A gesture should be able to close the top-of-window views when | 670 // A gesture should be able to close the top-of-window views when |
| 680 // top-of-window views have focus. | 671 // top-of-window views have focus. |
| 681 AttemptReveal(MODALITY_MOUSE); | 672 AttemptReveal(MODALITY_MOUSE); |
| 682 top_container()->RequestFocus(); | 673 top_container()->RequestFocus(); |
| 683 EXPECT_TRUE(controller()->IsRevealed()); | 674 EXPECT_TRUE(controller()->IsRevealed()); |
| 684 AttemptUnreveal(MODALITY_GESTURE_SCROLL); | 675 AttemptUnreveal(MODALITY_GESTURE_SCROLL); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 EXPECT_FALSE(window_state->in_immersive_fullscreen()); | 761 EXPECT_FALSE(window_state->in_immersive_fullscreen()); |
| 771 SetEnabled(true); | 762 SetEnabled(true); |
| 772 ASSERT_TRUE(controller()->IsEnabled()); | 763 ASSERT_TRUE(controller()->IsEnabled()); |
| 773 EXPECT_TRUE(window_state->in_immersive_fullscreen()); | 764 EXPECT_TRUE(window_state->in_immersive_fullscreen()); |
| 774 | 765 |
| 775 SetEnabled(false); | 766 SetEnabled(false); |
| 776 ASSERT_FALSE(controller()->IsEnabled()); | 767 ASSERT_FALSE(controller()->IsEnabled()); |
| 777 EXPECT_FALSE(window_state->in_immersive_fullscreen()); | 768 EXPECT_FALSE(window_state->in_immersive_fullscreen()); |
| 778 } | 769 } |
| 779 | 770 |
| 780 // Do not test under windows because focus testing is not reliable on | |
| 781 // Windows. (crbug.com/79493) | |
| 782 #if !defined(OS_WIN) | |
| 783 | |
| 784 // Test how focus and activation affects whether the top-of-window views are | 771 // Test how focus and activation affects whether the top-of-window views are |
| 785 // revealed. | 772 // revealed. |
| 786 TEST_F(ImmersiveFullscreenControllerTest, Focus) { | 773 TEST_F(ImmersiveFullscreenControllerTest, Focus) { |
| 787 // Add views to the view hierarchy which we will focus and unfocus during the | 774 // Add views to the view hierarchy which we will focus and unfocus during the |
| 788 // test. | 775 // test. |
| 789 views::View* child_view = new views::View(); | 776 views::View* child_view = new views::View(); |
| 790 child_view->SetBounds(0, 0, 10, 10); | 777 child_view->SetBounds(0, 0, 10, 10); |
| 791 child_view->SetFocusBehavior(views::View::FocusBehavior::ALWAYS); | 778 child_view->SetFocusBehavior(views::View::FocusBehavior::ALWAYS); |
| 792 top_container()->AddChildView(child_view); | 779 top_container()->AddChildView(child_view); |
| 793 views::View* unrelated_view = new views::View(); | 780 views::View* unrelated_view = new views::View(); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 EXPECT_TRUE(controller()->IsRevealed()); | 996 EXPECT_TRUE(controller()->IsRevealed()); |
| 1010 | 997 |
| 1011 views::Widget* bubble_widget8 = views::BubbleDialogDelegateView::CreateBubble( | 998 views::Widget* bubble_widget8 = views::BubbleDialogDelegateView::CreateBubble( |
| 1012 new TestBubbleDialogDelegate(unrelated_view)); | 999 new TestBubbleDialogDelegate(unrelated_view)); |
| 1013 bubble_widget8->Show(); | 1000 bubble_widget8->Show(); |
| 1014 SetHovered(false); | 1001 SetHovered(false); |
| 1015 EXPECT_FALSE(controller()->IsRevealed()); | 1002 EXPECT_FALSE(controller()->IsRevealed()); |
| 1016 bubble_widget8->Close(); | 1003 bubble_widget8->Close(); |
| 1017 } | 1004 } |
| 1018 | 1005 |
| 1019 #endif // defined(OS_WIN) | |
| 1020 | |
| 1021 // Test that the shelf is set to auto hide as long as the window is in | 1006 // Test that the shelf is set to auto hide as long as the window is in |
| 1022 // immersive fullscreen and that the shelf's state before entering immersive | 1007 // immersive fullscreen and that the shelf's state before entering immersive |
| 1023 // fullscreen is restored upon exiting immersive fullscreen. | 1008 // fullscreen is restored upon exiting immersive fullscreen. |
| 1024 TEST_F(ImmersiveFullscreenControllerTest, Shelf) { | 1009 TEST_F(ImmersiveFullscreenControllerTest, Shelf) { |
| 1025 WmShelf* shelf = GetPrimaryShelf(); | 1010 WmShelf* shelf = GetPrimaryShelf(); |
| 1026 | 1011 |
| 1027 // Shelf is visible by default. | 1012 // Shelf is visible by default. |
| 1028 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 1013 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 1029 ASSERT_FALSE(controller()->IsEnabled()); | 1014 ASSERT_FALSE(controller()->IsEnabled()); |
| 1030 ASSERT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1015 ASSERT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1049 SetEnabled(true); | 1034 SetEnabled(true); |
| 1050 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 1035 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 1051 | 1036 |
| 1052 // Disabling immersive fullscreen maintains the user's auto-hide selection. | 1037 // Disabling immersive fullscreen maintains the user's auto-hide selection. |
| 1053 SetEnabled(false); | 1038 SetEnabled(false); |
| 1054 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 1039 window()->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 1055 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 1040 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 1056 } | 1041 } |
| 1057 | 1042 |
| 1058 } // namespase ash | 1043 } // namespase ash |
| OLD | NEW |