| Index: chrome/browser/extensions/api/notifications/notifications_apitest.cc
|
| diff --git a/chrome/browser/extensions/api/notifications/notifications_apitest.cc b/chrome/browser/extensions/api/notifications/notifications_apitest.cc
|
| index 426eea9aa2ed4f1af50186fc70c0f2c2ba1fa3a4..2091fd29bba584ec998b94b2154d12c1032ecd5d 100644
|
| --- a/chrome/browser/extensions/api/notifications/notifications_apitest.cc
|
| +++ b/chrome/browser/extensions/api/notifications/notifications_apitest.cc
|
| @@ -5,6 +5,7 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "chrome/browser/apps/app_browsertest_util.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/extensions/api/notifications/notifications_api.h"
|
| #include "chrome/browser/extensions/extension_apitest.h"
|
| @@ -12,12 +13,15 @@
|
| #include "chrome/browser/notifications/notification.h"
|
| #include "chrome/browser/notifications/notification_ui_manager.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| +#include "chrome/browser/ui/extensions/app_launch_params.h"
|
| +#include "chrome/browser/ui/extensions/application_launch.h"
|
| #include "content/public/browser/notification_service.h"
|
| #include "content/public/test/test_utils.h"
|
| #include "extensions/browser/api/test/test_api.h"
|
| #include "extensions/browser/notification_types.h"
|
| #include "extensions/common/features/feature.h"
|
| #include "extensions/common/test_util.h"
|
| +#include "extensions/test/extension_test_message_listener.h"
|
| #include "extensions/test/result_catcher.h"
|
| #include "ui/message_center/message_center.h"
|
| #include "ui/message_center/notification_list.h"
|
| @@ -96,6 +100,20 @@ class NotificationsApiTest : public ExtensionApiTest {
|
| return extension;
|
| }
|
|
|
| + const extensions::Extension* LoadAppWithWindowState(
|
| + const std::string& test_name, const std::string& window_state) {
|
| + base::FilePath extdir = test_data_dir_.AppendASCII(test_name);
|
| + const extensions::Extension* extension = LoadExtension(extdir);
|
| + EXPECT_TRUE(extension);
|
| +
|
| + ExtensionTestMessageListener launched_listener("launched", true);
|
| + LaunchPlatformApp(extension);
|
| + EXPECT_TRUE(launched_listener.WaitUntilSatisfied());
|
| + launched_listener.Reply(window_state);
|
| +
|
| + return extension;
|
| + }
|
| +
|
| protected:
|
| std::string GetNotificationIdFromDelegateId(const std::string& delegate_id) {
|
| return g_browser_process->notification_ui_manager()
|
| @@ -105,6 +123,12 @@ class NotificationsApiTest : public ExtensionApiTest {
|
| g_browser_process->profile_manager()->GetLastUsedProfile()))
|
| ->id();
|
| }
|
| +
|
| + void LaunchPlatformApp(const Extension* extension) {
|
| + OpenApplication(AppLaunchParams(
|
| + browser()->profile(), extension, extensions::LAUNCH_CONTAINER_NONE,
|
| + WindowOpenDisposition::NEW_WINDOW, extensions::SOURCE_TEST));
|
| + }
|
| };
|
|
|
| } // namespace
|
| @@ -302,3 +326,35 @@ IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestRequireInteraction) {
|
|
|
| EXPECT_TRUE(notification->never_timeout());
|
| }
|
| +
|
| +IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestShouldDisplayNormal) {
|
| + ExtensionTestMessageListener notification_created_listener("created", false);
|
| + const extensions::Extension* extension = LoadAppWithWindowState(
|
| + "notifications/api/basic_app", "{\"state\":\"normal\"}");
|
| + ASSERT_TRUE(extension) << message_;
|
| + ASSERT_TRUE(notification_created_listener.WaitUntilSatisfied());
|
| +
|
| + const message_center::NotificationList::Notifications& notifications =
|
| + g_browser_process->message_center()->GetVisibleNotifications();
|
| + ASSERT_EQ(1u, notifications.size());
|
| + message_center::Notification* notification = *(notifications.begin());
|
| + // If the app hasn't created a fullscreen window, then its notifications
|
| + // shouldn't be displayed when a window is fullscreen.
|
| + ASSERT_FALSE(notification->delegate()->ShouldDisplayOverFullscreen());
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestShouldDisplayFullscreen) {
|
| + ExtensionTestMessageListener notification_created_listener("created", false);
|
| + const extensions::Extension* extension = LoadAppWithWindowState(
|
| + "notifications/api/basic_app", "{\"state\":\"fullscreen\"}");
|
| + ASSERT_TRUE(extension) << message_;
|
| + ASSERT_TRUE(notification_created_listener.WaitUntilSatisfied());
|
| +
|
| + const message_center::NotificationList::Notifications& notifications =
|
| + g_browser_process->message_center()->GetVisibleNotifications();
|
| + ASSERT_EQ(1u, notifications.size());
|
| + message_center::Notification* notification = *(notifications.begin());
|
| + // If the app has created a fullscreen window, then its notifications should
|
| + // be displayed when a window is fullscreen.
|
| + ASSERT_TRUE(notification->delegate()->ShouldDisplayOverFullscreen());
|
| +}
|
|
|