Index: ui/message_center/views/notification_view_unittest.cc |
diff --git a/ui/message_center/views/notification_view_unittest.cc b/ui/message_center/views/notification_view_unittest.cc |
index 054dfbd97bc7a6c3d351bc25268a5360c166da34..e6d2b53ec3f86f660462d17a13876d1f24ecd42a 100644 |
--- a/ui/message_center/views/notification_view_unittest.cc |
+++ b/ui/message_center/views/notification_view_unittest.cc |
@@ -253,7 +253,7 @@ TEST_F(NotificationViewTest, CreateOrUpdateTest) { |
TEST_F(NotificationViewTest, TestLineLimits) { |
notification()->set_image(CreateTestImage(0, 0)); |
- notification()->set_context_message(base::ASCIIToUTF16("")); |
+ notification()->set_context_message("", false); |
notification_view()->CreateOrUpdateViews(*notification()); |
EXPECT_EQ(5, notification_view()->GetMessageLineLimit(0, 360)); |
@@ -267,7 +267,7 @@ TEST_F(NotificationViewTest, TestLineLimits) { |
EXPECT_EQ(2, notification_view()->GetMessageLineLimit(1, 360)); |
EXPECT_EQ(1, notification_view()->GetMessageLineLimit(2, 360)); |
- notification()->set_context_message(base::UTF8ToUTF16("foo")); |
+ notification()->set_context_message("foo", false); |
notification_view()->CreateOrUpdateViews(*notification()); |
EXPECT_TRUE(notification_view()->context_message_view_ != NULL); |
@@ -461,4 +461,44 @@ TEST_F(NotificationViewTest, ViewOrderingTest) { |
CheckVerticalOrderInNotification(); |
} |
+TEST_F(NotificationViewTest, FormatContextMessageTest) { |
+ const std::string kRegularContextText = "Context Text"; |
+ const std::string kVeryLongContextText = |
+ "VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY" |
+ "VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY" |
+ "VERY VERY VERY VERY Long Long Long Long Long Long Long Long context"; |
+ |
+ const std::string kVeryLongElidedContextText = |
+ "VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERY VERYVERY VERY " |
+ "VERY VERY VERY VERY VERY VERY VERY VERY VERY\xE2\x80\xA6"; |
+ |
+ const std::string kUrlContext = "http://chromium.org/hello"; |
+ const std::string kHostContext = "chromium.org"; |
+ const std::string kLongUrlContext = |
+ "https://veryveryveryveryveyrylong.chromium.org"; |
+ const std::string kLongElidedHostContext = |
+ "\xE2\x80\xA6veryveryveryveyrylong.chromium.org"; |
+ |
+ ContextMessage text_context(kRegularContextText, false); |
+ base::string16 result = |
+ notification_view()->FormatContextMessage(text_context); |
+ EXPECT_EQ(kRegularContextText, base::UTF16ToUTF8(result)); |
+ |
+ ContextMessage long_text_context(kVeryLongContextText, false); |
+ result = notification_view()->FormatContextMessage(long_text_context); |
+ EXPECT_EQ(kVeryLongElidedContextText, base::UTF16ToUTF8(result)); |
+ |
+ ContextMessage url_context(kUrlContext, true); |
+ result = notification_view()->FormatContextMessage(url_context); |
+ EXPECT_EQ(kHostContext, base::UTF16ToUTF8(result)); |
+ |
+ ContextMessage long_url_context(kLongUrlContext, true); |
+ result = notification_view()->FormatContextMessage(long_url_context); |
+ EXPECT_EQ(kLongElidedHostContext, base::UTF16ToUTF8(result)); |
+ |
+ ContextMessage invalid_url_context("notreallyaurl", true); |
+ result = notification_view()->FormatContextMessage(invalid_url_context); |
+ EXPECT_EQ("", base::UTF16ToUTF8(result)); |
+} |
+ |
} // namespace message_center |