Chromium Code Reviews| Index: chrome/browser/notifications/notification_interactive_uitest.cc |
| diff --git a/chrome/browser/notifications/notification_interactive_uitest.cc b/chrome/browser/notifications/notification_interactive_uitest.cc |
| index f1b87e8b8a9719391685b23fbfb188a50397bc24..6914ea118674d84d7f32597d686d342cca01bf88 100644 |
| --- a/chrome/browser/notifications/notification_interactive_uitest.cc |
| +++ b/chrome/browser/notifications/notification_interactive_uitest.cc |
| @@ -28,6 +28,7 @@ |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_tabstrip.h" |
| #include "chrome/browser/ui/browser_window.h" |
| +#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/test/base/in_process_browser_test.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| @@ -50,6 +51,11 @@ |
| #include "ui/message_center/notification_blocker.h" |
| #include "url/gurl.h" |
| +#if defined(OS_MACOSX) |
| +#include "base/mac/mac_util.h" |
| +#include "ui/base/test/scoped_fake_nswindow_fullscreen.h" |
| +#endif |
| + |
| namespace { |
| class ToggledNotificationBlocker : public message_center::NotificationBlocker { |
| @@ -881,3 +887,89 @@ IN_PROC_BROWSER_TEST_F(NotificationsTest, TestNotificationDoubleClose) { |
| result = CreateNotification(browser(), true, "", "Title1", "Body1", "chat"); |
| EXPECT_NE("-1", result); |
| } |
| + |
| +IN_PROC_BROWSER_TEST_F(NotificationsTest, TestShouldDisplayNormal) { |
| + ASSERT_TRUE(embedded_test_server()->Start()); |
| + |
| + // Creates a simple notification. |
| + AllowAllOrigins(); |
| + ui_test_utils::NavigateToURL(browser(), GetTestPageURL()); |
| + |
| + std::string result = CreateSimpleNotification(browser(), true); |
| + EXPECT_NE("-1", result); |
| + |
| + ASSERT_EQ(1, GetNotificationCount()); |
| + message_center::NotificationList::Notifications notifications = |
| + message_center::MessageCenter::Get()->GetVisibleNotifications(); |
| + |
| + // Because the webpage is not fullscreen, ShouldDisplayOverFullscreen will be |
| + // false. |
| + EXPECT_FALSE( |
| + (*notifications.rbegin())->delegate()->ShouldDisplayOverFullscreen()); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(NotificationsTest, TestShouldDisplayFullscreen) { |
| +#if defined(OS_MACOSX) |
| + 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
|
| +#endif |
| + ASSERT_TRUE(embedded_test_server()->Start()); |
| + |
| + // Creates a simple notification. |
| + AllowAllOrigins(); |
| + ui_test_utils::NavigateToURL(browser(), GetTestPageURL()); |
| + |
| + std::string result = CreateSimpleNotification(browser(), true); |
| + EXPECT_NE("-1", result); |
| + |
| + // Set the page fullscreen |
| + browser()->exclusive_access_manager()->fullscreen_controller()-> |
| + ToggleBrowserFullscreenMode(); |
| + |
| + ASSERT_EQ(1, GetNotificationCount()); |
| + message_center::NotificationList::Notifications notifications = |
| + message_center::MessageCenter::Get()->GetVisibleNotifications(); |
| + |
| + // Because the webpage is fullscreen, ShouldDisplayOverFullscreen will be true |
| + EXPECT_TRUE( |
| + (*notifications.rbegin())->delegate()->ShouldDisplayOverFullscreen()); |
| +} |
| + |
| +// The Fake OSX fullscreen window doesn't like drawing a second fullscreen |
| +// window when another is visible. |
| +#if !defined(OS_MACOSX) |
| +IN_PROC_BROWSER_TEST_F(NotificationsTest, TestShouldDisplayMultiFullscreen) { |
| + ASSERT_TRUE(embedded_test_server()->Start()); |
| + AllowAllOrigins(); |
| + |
| + ui_test_utils::NavigateToURL(browser(), GetTestPageURL()); |
| + |
| + Browser* other_browser = CreateBrowser(browser()->profile()); |
| + ui_test_utils::NavigateToURL(other_browser, GURL("about:blank")); |
| + |
| + std::string result = CreateSimpleNotification(browser(), true); |
| + EXPECT_NE("-1", result); |
| + |
| + // Set the notifcation page fullscreen |
| + browser()->exclusive_access_manager()->fullscreen_controller()-> |
| + ToggleBrowserFullscreenMode(); |
| + |
| + // Set the other browser fullscreen |
| + other_browser->exclusive_access_manager()->fullscreen_controller()-> |
| + ToggleBrowserFullscreenMode(); |
| + |
| + ASSERT_TRUE(browser()->exclusive_access_manager()->context()->IsFullscreen()); |
| + ASSERT_TRUE( |
| + other_browser->exclusive_access_manager()->context()->IsFullscreen()); |
| + |
| + ASSERT_FALSE(browser()->window()->IsActive()); |
| + ASSERT_TRUE(other_browser->window()->IsActive()); |
| + |
| + ASSERT_EQ(1, GetNotificationCount()); |
| + message_center::NotificationList::Notifications notifications = |
| + message_center::MessageCenter::Get()->GetVisibleNotifications(); |
| + // Because the second page is the top-most fullscreen, |
| + // ShouldDisplayOverFullscreen will be false |
| + EXPECT_FALSE( |
| + (*notifications.rbegin())->delegate()->ShouldDisplayOverFullscreen()); |
| +} |
| +#endif |