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

Unified Diff: chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm

Issue 2827543003: Display ETLD+1 instead of the full domain in MacOSX native notifications (Closed)
Patch Set: format Created 3 years, 8 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
« no previous file with comments | « chrome/browser/notifications/notification_platform_bridge_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm
diff --git a/chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm b/chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm
index 41effda35e38e5e866ce287217703903eb99a22c..89acbc7325c999b9150557fe66bce90dd51ea27e 100644
--- a/chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm
+++ b/chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm
@@ -46,7 +46,6 @@ class NotificationPlatformBridgeMacTest : public testing::Test {
optionsLabel:@"More"
settingsLabel:@"Settings"]);
[builder setTitle:@"Title"];
- [builder setSubTitle:@"https://www.miguel.com"];
[builder setOrigin:@"https://www.miguel.com/"];
[builder setContextMessage:@""];
[builder setButtons:@"Button1" secondaryButton:@"Button2"];
@@ -95,7 +94,6 @@ class NotificationPlatformBridgeMacTest : public testing::Test {
const char* button2,
bool require_interaction) {
message_center::RichNotificationData optional_fields;
- optional_fields.context_message = base::UTF8ToUTF16(origin);
if (button1) {
optional_fields.buttons.push_back(
message_center::ButtonInfo(base::UTF8ToUTF16(button1)));
@@ -218,7 +216,7 @@ TEST_F(NotificationPlatformBridgeMacTest, TestDisplayNoButtons) {
NSUserNotification* delivered_notification = [notifications objectAtIndex:0];
EXPECT_NSEQ(@"Title", [delivered_notification title]);
EXPECT_NSEQ(@"Context", [delivered_notification informativeText]);
- EXPECT_NSEQ(@"https://gmail.com", [delivered_notification subtitle]);
+ EXPECT_NSEQ(@"gmail.com", [delivered_notification subtitle]);
EXPECT_NSEQ(@"Close", [delivered_notification otherButtonTitle]);
EXPECT_NSEQ(@"Settings", [delivered_notification actionButtonTitle]);
}
@@ -238,7 +236,7 @@ TEST_F(NotificationPlatformBridgeMacTest, TestDisplayOneButton) {
NSUserNotification* delivered_notification = [notifications objectAtIndex:0];
EXPECT_NSEQ(@"Title", [delivered_notification title]);
EXPECT_NSEQ(@"Context", [delivered_notification informativeText]);
- EXPECT_NSEQ(@"https://gmail.com", [delivered_notification subtitle]);
+ EXPECT_NSEQ(@"gmail.com", [delivered_notification subtitle]);
EXPECT_NSEQ(@"Close", [delivered_notification otherButtonTitle]);
EXPECT_NSEQ(@"More", [delivered_notification actionButtonTitle]);
}
@@ -420,3 +418,51 @@ TEST_F(NotificationPlatformBridgeMacTest, TestQuitRemovesBannersAndAlerts) {
EXPECT_EQ(0u, [[notification_center() deliveredNotifications] count]);
EXPECT_EQ(0u, [[alert_dispatcher() alerts] count]);
}
+
+TEST_F(NotificationPlatformBridgeMacTest, TestDisplayETLDPlusOne) {
+ std::unique_ptr<Notification> notification =
+ CreateBanner("Title", "Context", "https://hello.world.test.co.uk",
+ "Button 1", nullptr);
+
+ std::unique_ptr<NotificationPlatformBridgeMac> bridge(
+ new NotificationPlatformBridgeMac(notification_center(),
+ alert_dispatcher()));
+ bridge->Display(NotificationCommon::PERSISTENT, "notification_id1",
+ "profile_id", false, *notification);
+
+ notification = CreateBanner("Title", "Context", "https://mail.appspot.com",
+ "Button 1", nullptr);
+
+ bridge->Display(NotificationCommon::PERSISTENT, "notification_id2",
+ "profile_id", false, *notification);
+ notification = CreateBanner("Title", "Context", "https://tests.peter.sh",
+ "Button 1", nullptr);
+
+ bridge->Display(NotificationCommon::PERSISTENT, "notification_id3",
+ "profile_id", false, *notification);
+
+ notification = CreateBanner("Title", "Context", "http://localhost:8080",
+ "Button 1", nullptr);
+
+ bridge->Display(NotificationCommon::PERSISTENT, "notification_id4",
+ "profile_id", false, *notification);
+
+ notification = CreateBanner("Title", "Context", "https://93.186.186.172",
+ "Button 1", nullptr);
+
+ bridge->Display(NotificationCommon::PERSISTENT, "notification_id5",
+ "profile_id", false, *notification);
+
+ NSArray* notifications = [notification_center() deliveredNotifications];
+ EXPECT_EQ(5u, [notifications count]);
+ NSUserNotification* delivered_notification = [notifications objectAtIndex:0];
+ EXPECT_NSEQ(@"test.co.uk", [delivered_notification subtitle]);
+ delivered_notification = [notifications objectAtIndex:1];
+ EXPECT_NSEQ(@"mail.appspot.com", [delivered_notification subtitle]);
+ delivered_notification = [notifications objectAtIndex:2];
+ EXPECT_NSEQ(@"peter.sh", [delivered_notification subtitle]);
+ delivered_notification = [notifications objectAtIndex:3];
+ EXPECT_NSEQ(@"localhost:8080", [delivered_notification subtitle]);
+ delivered_notification = [notifications objectAtIndex:4];
+ EXPECT_NSEQ(@"93.186.186.172", [delivered_notification subtitle]);
+}
« no previous file with comments | « chrome/browser/notifications/notification_platform_bridge_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698