Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: ash/wm/immersive_fullscreen_controller_unittest.cc

Issue 1922813002: Vanquish views::BubbleDelegate{View,} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix other test, respond to comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/test/display_manager_test_api.h" 14 #include "ash/test/display_manager_test_api.h"
15 #include "ash/wm/window_state.h" 15 #include "ash/wm/window_state.h"
16 #include "ash/wm/window_state_aura.h" 16 #include "ash/wm/window_state_aura.h"
17 #include "ui/aura/client/aura_constants.h" 17 #include "ui/aura/client/aura_constants.h"
18 #include "ui/aura/client/cursor_client.h" 18 #include "ui/aura/client/cursor_client.h"
19 #include "ui/aura/env.h" 19 #include "ui/aura/env.h"
20 #include "ui/aura/test/test_window_delegate.h" 20 #include "ui/aura/test/test_window_delegate.h"
21 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
22 #include "ui/aura/window_event_dispatcher.h" 22 #include "ui/aura/window_event_dispatcher.h"
23 #include "ui/display/manager/display_layout.h" 23 #include "ui/display/manager/display_layout.h"
24 #include "ui/events/event_utils.h" 24 #include "ui/events/event_utils.h"
25 #include "ui/events/test/event_generator.h" 25 #include "ui/events/test/event_generator.h"
26 #include "ui/events/test/test_event_handler.h" 26 #include "ui/events/test/test_event_handler.h"
27 #include "ui/gfx/animation/slide_animation.h" 27 #include "ui/gfx/animation/slide_animation.h"
28 #include "ui/views/bubble/bubble_delegate.h" 28 #include "ui/views/bubble/bubble_dialog_delegate.h"
29 #include "ui/views/controls/native/native_view_host.h" 29 #include "ui/views/controls/native/native_view_host.h"
30 #include "ui/views/view.h" 30 #include "ui/views/view.h"
31 #include "ui/views/widget/widget.h" 31 #include "ui/views/widget/widget.h"
32 32
33 namespace ash { 33 namespace ash {
34 34
35 namespace { 35 namespace {
36 36
37 class TestBubbleDialogDelegate : public views::BubbleDialogDelegateView {
38 public:
39 explicit TestBubbleDialogDelegate(views::View* anchor)
40 : BubbleDialogDelegateView(anchor, views::BubbleBorder::NONE) {}
41 ~TestBubbleDialogDelegate() override {}
42
43 private:
44 DISALLOW_COPY_AND_ASSIGN(TestBubbleDialogDelegate);
45 };
46
37 class MockImmersiveFullscreenControllerDelegate 47 class MockImmersiveFullscreenControllerDelegate
38 : public ImmersiveFullscreenController::Delegate { 48 : public ImmersiveFullscreenController::Delegate {
39 public: 49 public:
40 MockImmersiveFullscreenControllerDelegate(views::View* top_container_view) 50 MockImmersiveFullscreenControllerDelegate(views::View* top_container_view)
41 : top_container_view_(top_container_view), 51 : top_container_view_(top_container_view),
42 enabled_(false), 52 enabled_(false),
43 visible_fraction_(1) { 53 visible_fraction_(1) {
44 } 54 }
45 ~MockImmersiveFullscreenControllerDelegate() override {} 55 ~MockImmersiveFullscreenControllerDelegate() override {}
46 56
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 EXPECT_FALSE(controller()->IsRevealed()); 668 EXPECT_FALSE(controller()->IsRevealed());
659 669
660 // Initiate reveal via mouse, end reveal via touch. 670 // Initiate reveal via mouse, end reveal via touch.
661 AttemptReveal(MODALITY_MOUSE); 671 AttemptReveal(MODALITY_MOUSE);
662 EXPECT_TRUE(controller()->IsRevealed()); 672 EXPECT_TRUE(controller()->IsRevealed());
663 AttemptUnreveal(MODALITY_GESTURE_TAP); 673 AttemptUnreveal(MODALITY_GESTURE_TAP);
664 EXPECT_FALSE(controller()->IsRevealed()); 674 EXPECT_FALSE(controller()->IsRevealed());
665 } 675 }
666 676
667 // Test when the SWIPE_CLOSE edge gesture closes the top-of-window views. 677 // Test when the SWIPE_CLOSE edge gesture closes the top-of-window views.
668 #if defined(OS_WIN) 678 #if !defined(OS_CHROMEOS)
669 // On Windows, touch events do not result in mouse events being disabled. As 679 // On Windows/Linux, touch events do not result in mouse events being disabled.
670 // a result, the last part of this test which ends the reveal via a gesture will 680 // As a result, the last part of this test which ends the reveal via a gesture
671 // not work correctly. See crbug.com/332430, and the function 681 // will not work correctly. See crbug.com/332430, and the function
672 // ShouldHideCursorOnTouch() in compound_event_filter.cc. 682 // ShouldHideCursorOnTouch() in compound_event_filter.cc.
673 #define MAYBE_EndRevealViaGesture DISABLED_EndRevealViaGesture 683 #define MAYBE_EndRevealViaGesture DISABLED_EndRevealViaGesture
674 #else 684 #else
675 #define MAYBE_EndRevealViaGesture EndRevealViaGesture 685 #define MAYBE_EndRevealViaGesture EndRevealViaGesture
676 #endif 686 #endif
677 TEST_F(ImmersiveFullscreenControllerTest, MAYBE_EndRevealViaGesture) { 687 TEST_F(ImmersiveFullscreenControllerTest, MAYBE_EndRevealViaGesture) {
678 SetEnabled(true); 688 SetEnabled(true);
679 EXPECT_TRUE(controller()->IsEnabled()); 689 EXPECT_TRUE(controller()->IsEnabled());
680 EXPECT_FALSE(controller()->IsRevealed()); 690 EXPECT_FALSE(controller()->IsRevealed());
681 691
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 views::View* unrelated_view = new views::View(); 917 views::View* unrelated_view = new views::View();
908 unrelated_view->SetBounds(0, 100, 10, 10); 918 unrelated_view->SetBounds(0, 100, 10, 10);
909 top_container()->parent()->AddChildView(unrelated_view); 919 top_container()->parent()->AddChildView(unrelated_view);
910 920
911 SetEnabled(true); 921 SetEnabled(true);
912 ASSERT_FALSE(controller()->IsRevealed()); 922 ASSERT_FALSE(controller()->IsRevealed());
913 923
914 // 1) Test that a bubble anchored to a child of the top container triggers 924 // 1) Test that a bubble anchored to a child of the top container triggers
915 // a reveal and keeps the top-of-window views revealed for the duration of 925 // a reveal and keeps the top-of-window views revealed for the duration of
916 // its visibility. 926 // its visibility.
917 views::Widget* bubble_widget1(views::BubbleDelegateView::CreateBubble( 927 views::Widget* bubble_widget1(views::BubbleDialogDelegateView::CreateBubble(
918 new views::BubbleDelegateView(child_view, views::BubbleBorder::NONE))); 928 new TestBubbleDialogDelegate(child_view)));
919 bubble_widget1->Show(); 929 bubble_widget1->Show();
920 EXPECT_TRUE(controller()->IsRevealed()); 930 EXPECT_TRUE(controller()->IsRevealed());
921 931
922 // Activating |top_container_widget| will close |bubble_widget1|. 932 // Activating |top_container_widget| will close |bubble_widget1|.
923 top_container_widget->Activate(); 933 top_container_widget->Activate();
924 AttemptReveal(MODALITY_MOUSE); 934 AttemptReveal(MODALITY_MOUSE);
925 revealed_lock.reset(controller()->GetRevealedLock( 935 revealed_lock.reset(controller()->GetRevealedLock(
926 ImmersiveFullscreenController::ANIMATE_REVEAL_NO)); 936 ImmersiveFullscreenController::ANIMATE_REVEAL_NO));
927 EXPECT_TRUE(controller()->IsRevealed()); 937 EXPECT_TRUE(controller()->IsRevealed());
928 938
929 views::Widget* bubble_widget2 = views::BubbleDelegateView::CreateBubble( 939 views::Widget* bubble_widget2 = views::BubbleDialogDelegateView::CreateBubble(
930 new views::BubbleDelegateView(child_view, views::BubbleBorder::NONE)); 940 new TestBubbleDialogDelegate(child_view));
931 bubble_widget2->Show(); 941 bubble_widget2->Show();
932 EXPECT_TRUE(controller()->IsRevealed()); 942 EXPECT_TRUE(controller()->IsRevealed());
933 revealed_lock.reset(); 943 revealed_lock.reset();
934 SetHovered(false); 944 SetHovered(false);
935 EXPECT_TRUE(controller()->IsRevealed()); 945 EXPECT_TRUE(controller()->IsRevealed());
936 bubble_widget2->Close(); 946 bubble_widget2->Close();
937 EXPECT_FALSE(controller()->IsRevealed()); 947 EXPECT_FALSE(controller()->IsRevealed());
938 948
939 // 2) Test that transitioning from keeping the top-of-window views revealed 949 // 2) Test that transitioning from keeping the top-of-window views revealed
940 // because of a bubble to keeping the top-of-window views revealed because of 950 // because of a bubble to keeping the top-of-window views revealed because of
941 // mouse hover by activating |top_container_widget| works. 951 // mouse hover by activating |top_container_widget| works.
942 views::Widget* bubble_widget3 = views::BubbleDelegateView::CreateBubble( 952 views::Widget* bubble_widget3 = views::BubbleDialogDelegateView::CreateBubble(
943 new views::BubbleDelegateView(child_view, views::BubbleBorder::NONE)); 953 new TestBubbleDialogDelegate(child_view));
944 bubble_widget3->Show(); 954 bubble_widget3->Show();
945 SetHovered(true); 955 SetHovered(true);
946 EXPECT_TRUE(controller()->IsRevealed()); 956 EXPECT_TRUE(controller()->IsRevealed());
947 top_container_widget->Activate(); 957 top_container_widget->Activate();
948 EXPECT_TRUE(controller()->IsRevealed()); 958 EXPECT_TRUE(controller()->IsRevealed());
949 959
950 // 3) Test that the top-of-window views stay revealed as long as at least one 960 // 3) Test that the top-of-window views stay revealed as long as at least one
951 // bubble anchored to a child of the top container is visible. 961 // bubble anchored to a child of the top container is visible.
952 SetHovered(false); 962 SetHovered(false);
953 EXPECT_FALSE(controller()->IsRevealed()); 963 EXPECT_FALSE(controller()->IsRevealed());
954 964
955 views::BubbleDelegateView* bubble_delegate4(new views::BubbleDelegateView( 965 views::BubbleDialogDelegateView* bubble_delegate4(
956 child_view, views::BubbleBorder::NONE)); 966 new TestBubbleDialogDelegate(child_view));
957 bubble_delegate4->set_can_activate(false); 967 bubble_delegate4->set_can_activate(false);
958 views::Widget* bubble_widget4(views::BubbleDelegateView::CreateBubble( 968 views::Widget* bubble_widget4(
959 bubble_delegate4)); 969 views::BubbleDialogDelegateView::CreateBubble(bubble_delegate4));
960 bubble_widget4->Show(); 970 bubble_widget4->Show();
961 971
962 views::BubbleDelegateView* bubble_delegate5(new views::BubbleDelegateView( 972 views::BubbleDialogDelegateView* bubble_delegate5(
963 child_view, views::BubbleBorder::NONE)); 973 new TestBubbleDialogDelegate(child_view));
964 bubble_delegate5->set_can_activate(false); 974 bubble_delegate5->set_can_activate(false);
965 views::Widget* bubble_widget5(views::BubbleDelegateView::CreateBubble( 975 views::Widget* bubble_widget5(
966 bubble_delegate5)); 976 views::BubbleDialogDelegateView::CreateBubble(bubble_delegate5));
967 bubble_widget5->Show(); 977 bubble_widget5->Show();
968 978
969 EXPECT_TRUE(controller()->IsRevealed()); 979 EXPECT_TRUE(controller()->IsRevealed());
970 bubble_widget4->Hide(); 980 bubble_widget4->Hide();
971 EXPECT_TRUE(controller()->IsRevealed()); 981 EXPECT_TRUE(controller()->IsRevealed());
972 bubble_widget5->Hide(); 982 bubble_widget5->Hide();
973 EXPECT_FALSE(controller()->IsRevealed()); 983 EXPECT_FALSE(controller()->IsRevealed());
974 bubble_widget5->Show(); 984 bubble_widget5->Show();
975 EXPECT_TRUE(controller()->IsRevealed()); 985 EXPECT_TRUE(controller()->IsRevealed());
976 986
977 // 4) Test that visibility changes which occur while immersive fullscreen is 987 // 4) Test that visibility changes which occur while immersive fullscreen is
978 // disabled are handled upon reenabling immersive fullscreen. 988 // disabled are handled upon reenabling immersive fullscreen.
979 SetEnabled(false); 989 SetEnabled(false);
980 bubble_widget5->Hide(); 990 bubble_widget5->Hide();
981 SetEnabled(true); 991 SetEnabled(true);
982 EXPECT_FALSE(controller()->IsRevealed()); 992 EXPECT_FALSE(controller()->IsRevealed());
983 993
984 // We do not need |bubble_widget4| or |bubble_widget5| anymore, close them. 994 // We do not need |bubble_widget4| or |bubble_widget5| anymore, close them.
985 bubble_widget4->Close(); 995 bubble_widget4->Close();
986 bubble_widget5->Close(); 996 bubble_widget5->Close();
987 997
988 // 5) Test that a bubble added while immersive fullscreen is disabled is 998 // 5) Test that a bubble added while immersive fullscreen is disabled is
989 // handled upon reenabling immersive fullscreen. 999 // handled upon reenabling immersive fullscreen.
990 SetEnabled(false); 1000 SetEnabled(false);
991 1001
992 views::Widget* bubble_widget6 = views::BubbleDelegateView::CreateBubble( 1002 views::Widget* bubble_widget6 = views::BubbleDialogDelegateView::CreateBubble(
993 new views::BubbleDelegateView(child_view, views::BubbleBorder::NONE)); 1003 new TestBubbleDialogDelegate(child_view));
994 bubble_widget6->Show(); 1004 bubble_widget6->Show();
995 1005
996 SetEnabled(true); 1006 SetEnabled(true);
997 EXPECT_TRUE(controller()->IsRevealed()); 1007 EXPECT_TRUE(controller()->IsRevealed());
998 1008
999 bubble_widget6->Close(); 1009 bubble_widget6->Close();
1000 1010
1001 // 6) Test that a bubble which is not anchored to a child of the 1011 // 6) Test that a bubble which is not anchored to a child of the
1002 // TopContainerView does not trigger a reveal or keep the 1012 // TopContainerView does not trigger a reveal or keep the
1003 // top-of-window views revealed if they are already revealed. 1013 // top-of-window views revealed if they are already revealed.
1004 views::Widget* bubble_widget7 = views::BubbleDelegateView::CreateBubble( 1014 views::Widget* bubble_widget7 = views::BubbleDialogDelegateView::CreateBubble(
1005 new views::BubbleDelegateView(unrelated_view, views::BubbleBorder::NONE)); 1015 new TestBubbleDialogDelegate(unrelated_view));
1006 bubble_widget7->Show(); 1016 bubble_widget7->Show();
1007 EXPECT_FALSE(controller()->IsRevealed()); 1017 EXPECT_FALSE(controller()->IsRevealed());
1008 1018
1009 // Activating |top_container_widget| will close |bubble_widget6|. 1019 // Activating |top_container_widget| will close |bubble_widget6|.
1010 top_container_widget->Activate(); 1020 top_container_widget->Activate();
1011 AttemptReveal(MODALITY_MOUSE); 1021 AttemptReveal(MODALITY_MOUSE);
1012 EXPECT_TRUE(controller()->IsRevealed()); 1022 EXPECT_TRUE(controller()->IsRevealed());
1013 1023
1014 views::Widget* bubble_widget8 = views::BubbleDelegateView::CreateBubble( 1024 views::Widget* bubble_widget8 = views::BubbleDialogDelegateView::CreateBubble(
1015 new views::BubbleDelegateView(unrelated_view, views::BubbleBorder::NONE)); 1025 new TestBubbleDialogDelegate(unrelated_view));
1016 bubble_widget8->Show(); 1026 bubble_widget8->Show();
1017 SetHovered(false); 1027 SetHovered(false);
1018 EXPECT_FALSE(controller()->IsRevealed()); 1028 EXPECT_FALSE(controller()->IsRevealed());
1019 bubble_widget8->Close(); 1029 bubble_widget8->Close();
1020 } 1030 }
1021 1031
1022 #endif // defined(OS_WIN) 1032 #endif // defined(OS_WIN)
1023 1033
1024 // Test that the shelf is set to auto hide as long as the window is in 1034 // Test that the shelf is set to auto hide as long as the window is in
1025 // immersive fullscreen and that the shelf's state before entering immersive 1035 // immersive fullscreen and that the shelf's state before entering immersive
(...skipping 28 matching lines...) Expand all
1054 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 1064 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
1055 1065
1056 // Disabling immersive fullscreen maintains the user's auto-hide selection. 1066 // Disabling immersive fullscreen maintains the user's auto-hide selection.
1057 SetEnabled(false); 1067 SetEnabled(false);
1058 window()->SetProperty(aura::client::kShowStateKey, 1068 window()->SetProperty(aura::client::kShowStateKey,
1059 ui::SHOW_STATE_NORMAL); 1069 ui::SHOW_STATE_NORMAL);
1060 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state()); 1070 EXPECT_EQ(ash::SHELF_AUTO_HIDE, shelf->visibility_state());
1061 } 1071 }
1062 1072
1063 } // namespase ash 1073 } // namespase ash
OLDNEW
« no previous file with comments | « ash/wm/immersive_fullscreen_controller.cc ('k') | chrome/browser/ui/views/autofill/save_card_bubble_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698