Chromium Code Reviews| Index: chrome/browser/notifications/platform_notification_service_interactive_uitest.cc |
| diff --git a/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc b/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc |
| index 826b8bd8301db231aae034f0d40d7f04dbbdec0d..21b75d5708d2fec0b75ae76effb93b469dbf03cd 100644 |
| --- a/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc |
| +++ b/chrome/browser/notifications/platform_notification_service_interactive_uitest.cc |
| @@ -19,6 +19,8 @@ |
| #include "chrome/browser/permissions/permission_manager.h" |
| #include "chrome/browser/permissions/permission_request_manager.h" |
| #include "chrome/browser/ui/browser.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" |
| @@ -35,6 +37,11 @@ |
| #include "chrome/browser/lifetime/keep_alive_types.h" |
| #endif |
| +#if defined(OS_MACOSX) |
| +#include "base/mac/mac_util.h" |
| +#include "ui/base/test/scoped_fake_nswindow_fullscreen.h" |
| +#endif |
| + |
| // ----------------------------------------------------------------------------- |
| // Dimensions of the icon.png resource in the notification test data directory. |
| @@ -44,6 +51,31 @@ const int kIconHeight = 100; |
| const int kNotificationVibrationPattern[] = { 100, 200, 300 }; |
| const double kNotificationTimestamp = 621046800000.; |
| +namespace { |
| + |
| +// Helper class that has to be created in the stack to check if the fullscreen |
| +// setting of a browser is in the desired state. |
| +class FullscreenStateWaiter { |
| + public: |
| + explicit FullscreenStateWaiter(Browser* browser, bool desired_state) |
| + : browser_(browser), |
| + desired_state_(desired_state) {} |
| + |
| + void Wait() { |
| + while (desired_state_ != |
| + browser_->exclusive_access_manager()->context()->IsFullscreen()) |
| + content::RunAllPendingInMessageLoop(); |
| + } |
| + |
| + private: |
| + Browser* browser_; |
| + bool desired_state_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FullscreenStateWaiter); |
| +}; |
| + |
| +} // namespace |
| + |
| class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { |
| public: |
| PlatformNotificationServiceBrowserTest(); |
| @@ -528,3 +560,88 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
| ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); |
| EXPECT_EQ("action_button_click actionId2", script_result); |
| } |
| + |
| +IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
|
dewittj
2016/09/28 20:01:54
The tests and utilities are essentially copies bet
bmalcolm
2016/09/29 20:53:14
I've moved the utilities into the common utilities
|
| + TestShouldDisplayNormal) { |
| + ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); |
| + |
| + std::string script_result; |
| + ASSERT_TRUE(RunScript( |
| + "DisplayPersistentNotification('display_normal')", &script_result)); |
| + EXPECT_EQ("ok", script_result); |
| + |
| + ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); |
| + const Notification& notification = ui_manager()->GetNotificationAt(0); |
| + EXPECT_FALSE(notification.delegate()->ShouldDisplayOverFullscreen()); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, |
| + TestShouldDisplayFullscreen) { |
| +#if defined(OS_MACOSX) |
| + ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; |
| +#endif |
| + ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); |
| + |
| + std::string script_result; |
| + ASSERT_TRUE(RunScript( |
| + "DisplayPersistentNotification('display_normal')", &script_result)); |
| + EXPECT_EQ("ok", script_result); |
| + |
| + // Set the page fullscreen |
| + browser()->exclusive_access_manager()->fullscreen_controller()-> |
| + ToggleBrowserFullscreenMode(); |
| + |
| + { |
| + FullscreenStateWaiter fs_state(browser(), true); |
| + fs_state.Wait(); |
| + } |
| + |
| + ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); |
| + const Notification& notification = ui_manager()->GetNotificationAt(0); |
| + EXPECT_TRUE(notification.delegate()->ShouldDisplayOverFullscreen()); |
|
dewittj
2016/09/28 20:01:53
does this fail on android?
bmalcolm
2016/09/29 20:53:14
No it passes. Probably because these tests don't g
dewittj
2016/09/29 20:57:38
There's a TODO in chrome/test/BUILD.gn to get thes
Peter Beverloo
2016/09/29 21:30:51
I think the answer has been "soon" for as long as
|
| +} |
| + |
| +// 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(PlatformNotificationServiceBrowserTest, |
| + TestShouldDisplayMultiFullscreen) { |
| + ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); |
| + |
| + Browser* other_browser = CreateBrowser(browser()->profile()); |
| + ui_test_utils::NavigateToURL(other_browser, GURL("about:blank")); |
| + |
| + std::string script_result; |
| + ASSERT_TRUE(RunScript( |
| + "DisplayPersistentNotification('display_normal')", &script_result)); |
| + EXPECT_EQ("ok", script_result); |
| + |
| + // Set the notifcation page fullscreen |
| + browser()->exclusive_access_manager()->fullscreen_controller()-> |
| + ToggleBrowserFullscreenMode(); |
| + { |
| + FullscreenStateWaiter fs_state(browser(), true); |
| + fs_state.Wait(); |
| + } |
| + |
| + // Set the other browser fullscreen |
| + other_browser->exclusive_access_manager()->fullscreen_controller()-> |
| + ToggleBrowserFullscreenMode(); |
| + { |
| + FullscreenStateWaiter fs_state(other_browser, true); |
| + fs_state.Wait(); |
| + } |
| + |
| + 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(1u, ui_manager()->GetNotificationCount()); |
| + const Notification& notification = ui_manager()->GetNotificationAt(0); |
| + EXPECT_FALSE(notification.delegate()->ShouldDisplayOverFullscreen()); |
| +} |
| +#endif |
| + |