Chromium Code Reviews| Index: chrome/browser/ui/cocoa/notifications/notification_response_builder_mac_unittest.mm |
| diff --git a/chrome/browser/ui/cocoa/notifications/notification_response_builder_mac_unittest.mm b/chrome/browser/ui/cocoa/notifications/notification_response_builder_mac_unittest.mm |
| index 93896d3c36c0a38976a3874099ec5d90523fa680..ddfd6152598a7b0a0458a2dec71780f75b6ce179 100644 |
| --- a/chrome/browser/ui/cocoa/notifications/notification_response_builder_mac_unittest.mm |
| +++ b/chrome/browser/ui/cocoa/notifications/notification_response_builder_mac_unittest.mm |
| @@ -29,6 +29,13 @@ TEST(NotificationResponseBuilderMacTest, TestNotificationClick) { |
| numberWithInt:NotificationCommon::PERSISTENT]]; |
| NSUserNotification* notification = [builder buildUserNotification]; |
| + // This will be set by the notification center to indicate the notification |
| + // was clicked. |
| + [notification |
| + setValue:[NSNumber numberWithInt: |
| + NSUserNotificationActivationTypeContentsClicked] |
|
Robert Sesek
2016/10/05 20:33:32
You should be able to just use @(NSUserNotificatio
Miguel Garcia
2016/10/05 21:58:37
Ah great, changed in all the tests.
|
| + forKey:@"_activationType"]; |
| + |
| NSDictionary* response = |
| [NotificationResponseBuilder buildDictionary:notification]; |
| @@ -199,3 +206,38 @@ TEST(NotificationResponseBuilderMacTest, |
| EXPECT_EQ(2 /* NOTIFICATION_SETTINGS */, operation.intValue); |
| EXPECT_EQ(-1, buttonIndex.intValue); |
| } |
| + |
| +TEST(NotificationResponseBuilderMacTest, TestNotificationClose) { |
| + base::scoped_nsobject<NotificationBuilder> builder( |
| + [[NotificationBuilder alloc] initWithCloseLabel:@"Close" |
| + optionsLabel:@"Options" |
| + settingsLabel:@"Settings"]); |
| + [builder setTitle:@"Title"]; |
| + [builder setSubTitle:@"https://www.miguel.com"]; |
| + [builder setContextMessage:@""]; |
| + [builder setTag:@"tag1"]; |
| + [builder setIcon:[NSImage imageNamed:@"NSApplicationIcon"]]; |
| + [builder setNotificationId:@"notificationId"]; |
| + [builder setProfileId:@"profileId"]; |
| + [builder setIncognito:false]; |
| + [builder |
| + setNotificationType:[NSNumber |
| + numberWithInt:NotificationCommon::PERSISTENT]]; |
| + |
| + NSUserNotification* notification = [builder buildUserNotification]; |
| + // None is what the NSUserNotification center emits when closing since it |
| + // interprets it as not activated. |
| + [notification |
| + setValue:[NSNumber numberWithInt:NSUserNotificationActivationTypeNone] |
| + forKey:@"_activationType"]; |
| + |
| + NSDictionary* response = |
| + [NotificationResponseBuilder buildDictionary:notification]; |
| + |
| + NSNumber* operation = |
| + [response objectForKey:notification_constants::kNotificationOperation]; |
| + NSNumber* buttonIndex = |
| + [response objectForKey:notification_constants::kNotificationButtonIndex]; |
| + EXPECT_EQ(1 /* NOTIFICATION_CLOSE */, operation.intValue); |
| + EXPECT_EQ(-1, buttonIndex.intValue); |
| +} |