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

Side by Side Diff: chrome/browser/notifications/notification_interactive_uitest.cc

Issue 2377553003: Add ShouldDisplayOverFullscreen support to web notifications. (Closed)
Patch Set: Cleanup #includes in notification_object_proxy.* Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <deque> 5 #include <deque>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 22 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
23 #include "chrome/browser/infobars/infobar_service.h" 23 #include "chrome/browser/infobars/infobar_service.h"
24 #include "chrome/browser/notifications/desktop_notification_profile_util.h" 24 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
25 #include "chrome/browser/notifications/notification.h" 25 #include "chrome/browser/notifications/notification.h"
26 #include "chrome/browser/permissions/permission_request_manager.h" 26 #include "chrome/browser/permissions/permission_request_manager.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_tabstrip.h" 29 #include "chrome/browser/ui/browser_tabstrip.h"
30 #include "chrome/browser/ui/browser_window.h" 30 #include "chrome/browser/ui/browser_window.h"
31 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
31 #include "chrome/browser/ui/tabs/tab_strip_model.h" 32 #include "chrome/browser/ui/tabs/tab_strip_model.h"
32 #include "chrome/test/base/in_process_browser_test.h" 33 #include "chrome/test/base/in_process_browser_test.h"
33 #include "chrome/test/base/ui_test_utils.h" 34 #include "chrome/test/base/ui_test_utils.h"
34 #include "components/content_settings/core/browser/host_content_settings_map.h" 35 #include "components/content_settings/core/browser/host_content_settings_map.h"
35 #include "components/content_settings/core/common/content_settings.h" 36 #include "components/content_settings/core/common/content_settings.h"
36 #include "components/content_settings/core/common/content_settings_pattern.h" 37 #include "components/content_settings/core/common/content_settings_pattern.h"
37 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
38 #include "content/public/browser/notification_source.h" 39 #include "content/public/browser/notification_source.h"
39 #include "content/public/browser/notification_types.h" 40 #include "content/public/browser/notification_types.h"
40 #include "content/public/browser/render_view_host.h" 41 #include "content/public/browser/render_view_host.h"
41 #include "content/public/browser/web_contents.h" 42 #include "content/public/browser/web_contents.h"
42 #include "content/public/test/browser_test_utils.h" 43 #include "content/public/test/browser_test_utils.h"
43 #include "content/public/test/test_utils.h" 44 #include "content/public/test/test_utils.h"
44 #include "net/test/embedded_test_server/embedded_test_server.h" 45 #include "net/test/embedded_test_server/embedded_test_server.h"
45 #include "testing/gtest/include/gtest/gtest.h" 46 #include "testing/gtest/include/gtest/gtest.h"
46 #include "ui/base/window_open_disposition.h" 47 #include "ui/base/window_open_disposition.h"
47 #include "ui/message_center/message_center.h" 48 #include "ui/message_center/message_center.h"
48 #include "ui/message_center/message_center_observer.h" 49 #include "ui/message_center/message_center_observer.h"
49 #include "ui/message_center/message_center_style.h" 50 #include "ui/message_center/message_center_style.h"
50 #include "ui/message_center/notification_blocker.h" 51 #include "ui/message_center/notification_blocker.h"
51 #include "url/gurl.h" 52 #include "url/gurl.h"
52 53
54 #if defined(OS_MACOSX)
55 #include "base/mac/mac_util.h"
56 #include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
57 #endif
58
53 namespace { 59 namespace {
54 60
55 class ToggledNotificationBlocker : public message_center::NotificationBlocker { 61 class ToggledNotificationBlocker : public message_center::NotificationBlocker {
56 public: 62 public:
57 ToggledNotificationBlocker() 63 ToggledNotificationBlocker()
58 : message_center::NotificationBlocker( 64 : message_center::NotificationBlocker(
59 message_center::MessageCenter::Get()), 65 message_center::MessageCenter::Get()),
60 notifications_enabled_(true) {} 66 notifications_enabled_(true) {}
61 ~ToggledNotificationBlocker() override {} 67 ~ToggledNotificationBlocker() override {}
62 68
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 true); // by_user 880 true); // by_user
875 881
876 ASSERT_EQ(0, GetNotificationCount()); 882 ASSERT_EQ(0, GetNotificationCount());
877 883
878 // Calling WebContents::IsCrashed() will return FALSE here, even if the WC did 884 // Calling WebContents::IsCrashed() will return FALSE here, even if the WC did
879 // crash. Work around this timing issue by creating another notification, 885 // crash. Work around this timing issue by creating another notification,
880 // which requires interaction with the renderer process. 886 // which requires interaction with the renderer process.
881 result = CreateNotification(browser(), true, "", "Title1", "Body1", "chat"); 887 result = CreateNotification(browser(), true, "", "Title1", "Body1", "chat");
882 EXPECT_NE("-1", result); 888 EXPECT_NE("-1", result);
883 } 889 }
890
891 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestShouldDisplayNormal) {
892 ASSERT_TRUE(embedded_test_server()->Start());
893
894 // Creates a simple notification.
895 AllowAllOrigins();
896 ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
897
898 std::string result = CreateSimpleNotification(browser(), true);
899 EXPECT_NE("-1", result);
900
901 ASSERT_EQ(1, GetNotificationCount());
902 message_center::NotificationList::Notifications notifications =
903 message_center::MessageCenter::Get()->GetVisibleNotifications();
904
905 // Because the webpage is not fullscreen, ShouldDisplayOverFullscreen will be
906 // false.
907 EXPECT_FALSE(
908 (*notifications.rbegin())->delegate()->ShouldDisplayOverFullscreen());
909 }
910
911 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestShouldDisplayFullscreen) {
912 #if defined(OS_MACOSX)
913 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen;
Peter Beverloo 2016/09/28 12:23:13 Looks like the Mac test is failing because transit
bmalcolm 2016/09/28 18:30:09 I think both are probably related - on the Mac we
914 #endif
915 ASSERT_TRUE(embedded_test_server()->Start());
916
917 // Creates a simple notification.
918 AllowAllOrigins();
919 ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
920
921 std::string result = CreateSimpleNotification(browser(), true);
922 EXPECT_NE("-1", result);
923
924 // Set the page fullscreen
925 browser()->exclusive_access_manager()->fullscreen_controller()->
926 ToggleBrowserFullscreenMode();
927
928 ASSERT_EQ(1, GetNotificationCount());
929 message_center::NotificationList::Notifications notifications =
930 message_center::MessageCenter::Get()->GetVisibleNotifications();
931
932 // Because the webpage is fullscreen, ShouldDisplayOverFullscreen will be true
933 EXPECT_TRUE(
934 (*notifications.rbegin())->delegate()->ShouldDisplayOverFullscreen());
935 }
936
937 // The Fake OSX fullscreen window doesn't like drawing a second fullscreen
938 // window when another is visible.
939 #if !defined(OS_MACOSX)
940 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestShouldDisplayMultiFullscreen) {
941 ASSERT_TRUE(embedded_test_server()->Start());
942 AllowAllOrigins();
943
944 ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
945
946 Browser* other_browser = CreateBrowser(browser()->profile());
947 ui_test_utils::NavigateToURL(other_browser, GURL("about:blank"));
948
949 std::string result = CreateSimpleNotification(browser(), true);
950 EXPECT_NE("-1", result);
951
952 // Set the notifcation page fullscreen
953 browser()->exclusive_access_manager()->fullscreen_controller()->
954 ToggleBrowserFullscreenMode();
955
956 // Set the other browser fullscreen
957 other_browser->exclusive_access_manager()->fullscreen_controller()->
958 ToggleBrowserFullscreenMode();
959
960 ASSERT_TRUE(browser()->exclusive_access_manager()->context()->IsFullscreen());
961 ASSERT_TRUE(
962 other_browser->exclusive_access_manager()->context()->IsFullscreen());
963
964 ASSERT_FALSE(browser()->window()->IsActive());
965 ASSERT_TRUE(other_browser->window()->IsActive());
966
967 ASSERT_EQ(1, GetNotificationCount());
968 message_center::NotificationList::Notifications notifications =
969 message_center::MessageCenter::Get()->GetVisibleNotifications();
970 // Because the second page is the top-most fullscreen,
971 // ShouldDisplayOverFullscreen will be false
972 EXPECT_FALSE(
973 (*notifications.rbegin())->delegate()->ShouldDisplayOverFullscreen());
974 }
975 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698