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

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

Issue 2300093002: Make //content responsible for generating notification Ids (Closed)
Patch Set: Make //content responsible for generating notification Ids 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..5d253d0ccd9d7de4e5637b4cf08409a2b0b31502 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);
@@ -199,7 +197,7 @@ TEST_F(PlatformNotificationServiceTest, PersistentNotificationDisplay) {
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,7 +209,7 @@ 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)
@@ -229,8 +227,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());
@@ -305,8 +304,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