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

Unified Diff: chrome/browser/notifications/platform_notification_service_unittest.cc

Issue 2300093002: Make //content responsible for generating notification Ids (Closed)
Patch Set: comments Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/platform_notification_service_unittest.cc
diff --git a/chrome/browser/notifications/platform_notification_service_unittest.cc b/chrome/browser/notifications/platform_notification_service_unittest.cc
index 451a2dbfddc53cb52bbe9cf5090128ebbeb7eac4..ac36b8c103fca086448a534cf68923a1251bbe19 100644
--- a/chrome/browser/notifications/platform_notification_service_unittest.cc
+++ b/chrome/browser/notifications/platform_notification_service_unittest.cc
@@ -54,12 +54,9 @@ using content::PlatformNotificationData;
namespace {
+const char kNotificationId[] = "my-notification-id";
const int kNotificationVibrationPattern[] = { 100, 200, 300 };
-#if !defined(OS_ANDROID)
-const int64_t kPersistentNotificationId = 42;
-#endif
-
class MockDesktopNotificationDelegate
: public content::DesktopNotificationDelegate {
public:
@@ -126,7 +123,8 @@ class PlatformNotificationServiceTest : public testing::Test {
MockDesktopNotificationDelegate* delegate =
new MockDesktopNotificationDelegate();
- service()->DisplayNotification(profile(), GURL("https://chrome.com/"),
+ service()->DisplayNotification(profile(), kNotificationId,
+ GURL("https://chrome.com/"),
notification_data, NotificationResources(),
base::WrapUnique(delegate), close_closure);
@@ -190,16 +188,13 @@ TEST_F(PlatformNotificationServiceTest, DisplayPageCloseClosure) {
// delegate given that it'd result in a use-after-free.
}
-// TODO(peter): Re-enable this test when //content is responsible for creating
-// the notification delegate ids.
-#if !defined(OS_ANDROID)
TEST_F(PlatformNotificationServiceTest, PersistentNotificationDisplay) {
PlatformNotificationData notification_data;
notification_data.title = base::ASCIIToUTF16("My notification's title");
notification_data.body = base::ASCIIToUTF16("Hello, world!");
service()->DisplayPersistentNotification(
- profile(), kPersistentNotificationId, GURL() /* service_worker_scope */,
+ profile(), kNotificationId, GURL() /* service_worker_scope */,
GURL("https://chrome.com/"), notification_data, NotificationResources());
ASSERT_EQ(1u, GetNotificationCount());
@@ -211,10 +206,9 @@ TEST_F(PlatformNotificationServiceTest, PersistentNotificationDisplay) {
EXPECT_EQ("Hello, world!",
base::UTF16ToUTF8(notification.message()));
- service()->ClosePersistentNotification(profile(), kPersistentNotificationId);
+ service()->ClosePersistentNotification(profile(), kNotificationId);
EXPECT_EQ(0u, GetNotificationCount());
}
-#endif // !defined(OS_ANDROID)
TEST_F(PlatformNotificationServiceTest, DisplayPageNotificationMatches) {
std::vector<int> vibration_pattern(
@@ -229,8 +223,9 @@ TEST_F(PlatformNotificationServiceTest, DisplayPageNotificationMatches) {
MockDesktopNotificationDelegate* delegate
= new MockDesktopNotificationDelegate();
- service()->DisplayNotification(profile(), GURL("https://chrome.com/"),
- notification_data, NotificationResources(),
+ service()->DisplayNotification(profile(), kNotificationId,
+ GURL("https://chrome.com/"), notification_data,
+ NotificationResources(),
base::WrapUnique(delegate), nullptr);
ASSERT_EQ(1u, GetNotificationCount());
@@ -266,9 +261,8 @@ TEST_F(PlatformNotificationServiceTest, DisplayPersistentNotificationMatches) {
notification_resources.action_icons.resize(notification_data.actions.size());
service()->DisplayPersistentNotification(
- profile(), 0u /* persistent notification */,
- GURL() /* service_worker_scope */, GURL("https://chrome.com/"),
- notification_data, notification_resources);
+ profile(), kNotificationId, GURL() /* service_worker_scope */,
+ GURL("https://chrome.com/"), notification_data, notification_resources);
ASSERT_EQ(1u, GetNotificationCount());
@@ -305,8 +299,8 @@ TEST_F(PlatformNotificationServiceTest, NotificationPermissionLastUsage) {
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
service()->DisplayPersistentNotification(
- profile(), 42 /* sw_registration_id */, GURL() /* service_worker_scope */,
- origin, PlatformNotificationData(), NotificationResources());
+ profile(), kNotificationId, GURL() /* service_worker_scope */, origin,
+ PlatformNotificationData(), NotificationResources());
base::Time after_persistent_notification =
HostContentSettingsMapFactory::GetForProfile(profile())->GetLastUsage(

Powered by Google App Engine
This is Rietveld 408576698