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]); |
+} |