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

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

Issue 2143613002: Add new tests to the Notification Mac Bridge Base URL: https://chromium.googlesource.com/chromium/src.git@unit_test
Patch Set: Created 4 years, 5 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.h ('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 84ed1b17b6771aab4941db1d1ab88c1ff35c06d5..f9b0a665f1db9fe148908e82262bb4ec5213dac4 100644
--- a/chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm
+++ b/chrome/browser/notifications/notification_platform_bridge_mac_unittest.mm
@@ -132,8 +132,8 @@ TEST_F(NotificationPlatformBridgeMacTest, TestDisplayNoButtons) {
[[toast actionButtonTitle] isEqualToString:@"Settings"] &&
[[toast otherButtonTitle] isEqualToString:@"Close"];
}]];
- bridge->Display(NotificationCommon::PERSISTENT,
- "notification_id", "profile_id", false, *notification);
+ bridge->Display(NotificationCommon::PERSISTENT, "notification_id",
+ "profile_id", false, *notification);
[notificationCenter verify];
}
@@ -155,7 +155,59 @@ TEST_F(NotificationPlatformBridgeMacTest, TestDisplayOneButton) {
[[toast actionButtonTitle] isEqualToString:@"Options"] &&
[[toast otherButtonTitle] isEqualToString:@"Close"];
}]];
- bridge->Display(NotificationCommon::PERSISTENT,
- "notification_id", "profile_id", false, *notification);
+ bridge->Display(NotificationCommon::PERSISTENT, "notification_id",
+ "profile_id", false, *notification);
+ [notificationCenter verify];
+}
+
+// FAILURE: Uses a nice mock instead of a mock which *should* not
+// not care about uncalled methods.
+// Crashes with : *** -[NSProxy doesNotRecognizeSelector:setDelegate:] called!
+TEST_F(NotificationPlatformBridgeMacTest, TestDisplayNiceMock) {
+ std::unique_ptr<Notification> notification =
+ NotificationGenerator::CreateNotification(
+ "Title", "Context", "https://gmail.com", "Button 1", "",
+ message_center::NOTIFICATION_TYPE_SIMPLE);
+
+ id notificationCenter =
+ [OCMockObject niceMockForClass:[NSUserNotificationCenter class]];
+ NotificationPlatformBridgeMac* bridge =
+ new NotificationPlatformBridgeMac(notificationCenter);
+ [[notificationCenter expect]
+ deliverNotification:[OCMArg checkWithBlock:^BOOL(id toast) {
+ return [[toast title] isEqualToString:@"Title"] &&
+ [[toast informativeText] isEqualToString:@"Context"] &&
+ [[toast subtitle] isEqualToString:@"https://gmail.com"] &&
+ [[toast actionButtonTitle] isEqualToString:@"Options"] &&
+ [[toast otherButtonTitle] isEqualToString:@"Close"];
+ }]];
+ bridge->Display(NotificationCommon::PERSISTENT, "notification_id",
+ "profile_id", false, *notification);
+ [notificationCenter verify];
+}
+
+// Close: Set the property as if it was a method.
+// Fails with
+// [NSProxy doesNotRecognizeSelector:deliveredNotifications] called!
+TEST_F(NotificationPlatformBridgeMacTest, TestCloseOneWay) {
+ id notificationCenter =
+ [OCMockObject niceMockForClass:[NSUserNotificationCenter class]];
+ NotificationPlatformBridgeMac* bridge =
+ new NotificationPlatformBridgeMac(notificationCenter, false);
+ [[notificationCenter expect] deliveredNotifications];
+ bridge->Close("profile_id", "notification_id");
+ [notificationCenter verify];
+}
+
+// Close: Set the property as a key value pair in the documentation.
+// Fails with
+// [NSProxy doesNotRecognizeSelector:deliveredNotifications] called!
+TEST_F(NotificationPlatformBridgeMacTest, TestCloseAnotherWay) {
+ id notificationCenter =
+ [OCMockObject niceMockForClass:[NSUserNotificationCenter class]];
+ NotificationPlatformBridgeMac* bridge =
+ new NotificationPlatformBridgeMac(notificationCenter, false);
+ [[(id)notificationCenter expect] deliveredNotifications];
+ bridge->Close("profile_id", "notification_id");
[notificationCenter verify];
}
« no previous file with comments | « chrome/browser/notifications/notification_platform_bridge_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698