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

Unified Diff: ui/message_center/cocoa/popup_collection_unittest.mm

Issue 14598015: [Mac][MC] Implement notification updates and relayouts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments Created 7 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 | « ui/message_center/cocoa/popup_collection.mm ('k') | ui/message_center/cocoa/popup_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/cocoa/popup_collection_unittest.mm
diff --git a/ui/message_center/cocoa/popup_collection_unittest.mm b/ui/message_center/cocoa/popup_collection_unittest.mm
index c99db600846744ad69925159fe7316ad9c32dc7c..f3711d7572757d73b9901cf559c9cdd03e6f71fd 100644
--- a/ui/message_center/cocoa/popup_collection_unittest.mm
+++ b/ui/message_center/cocoa/popup_collection_unittest.mm
@@ -9,6 +9,7 @@
#include "base/strings/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#import "ui/base/test/ui_cocoa_test_helper.h"
+#import "ui/message_center/cocoa/notification_controller.h"
#import "ui/message_center/cocoa/popup_controller.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_constants.h"
@@ -20,6 +21,13 @@
}
@end
+
+@implementation MCNotificationController (TestingInterface)
+- (NSImageView*)iconView {
+ return icon_.get();
+}
+@end
+
class PopupCollectionTest : public ui::CocoaTest {
public:
PopupCollectionTest() {
@@ -161,3 +169,50 @@ TEST_F(PopupCollectionTest, LayoutSpacing) {
EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0],
[popups objectAtIndex:1]));
}
+
+TEST_F(PopupCollectionTest, UpdateIconAndBody) {
+ AddThreeNotifications();
+ NSArray* popups = [collection_ popups];
+
+ EXPECT_EQ(3u, [popups count]);
+
+ // Update "2" icon.
+ MCNotificationController* controller =
+ [[popups objectAtIndex:1] notificationController];
+ EXPECT_FALSE([[controller iconView] image]);
+ center_->SetNotificationIcon("2",
+ gfx::Image([[NSImage imageNamed:NSImageNameUser] retain]));
+ EXPECT_TRUE([[controller iconView] image]);
+
+ EXPECT_EQ(3u, [popups count]);
+ EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0],
+ [popups objectAtIndex:1]));
+ EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:1],
+ [popups objectAtIndex:2]));
+
+ // Replace "1".
+ controller = [[popups objectAtIndex:0] notificationController];
+ NSRect old_frame = [[controller view] frame];
+ center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE,
+ "1",
+ ASCIIToUTF16("One is going to get a much longer "
+ "title than it previously had."),
+ ASCIIToUTF16("This is the first notification to "
+ "be displayed, but it will also be "
+ "updated to have a significantly "
+ "longer body"),
+ string16(),
+ std::string(),
+ NULL);
+ EXPECT_GT(NSHeight([[controller view] frame]), NSHeight(old_frame));
+
+ // Test updated spacing.
+ EXPECT_EQ(3u, [popups count]);
+ EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0],
+ [popups objectAtIndex:1]));
+ EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:1],
+ [popups objectAtIndex:2]));
+ EXPECT_EQ("1", [[popups objectAtIndex:0] notificationID]);
+ EXPECT_EQ("2", [[popups objectAtIndex:1] notificationID]);
+ EXPECT_EQ("3", [[popups objectAtIndex:2] notificationID]);
+}
« no previous file with comments | « ui/message_center/cocoa/popup_collection.mm ('k') | ui/message_center/cocoa/popup_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698