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

Unified Diff: chrome/browser/sync/notifier/communicator/mailbox_unittest.cc

Issue 194065: Initial commit of sync engine code to browser/sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fixes to gtest include path, reverted syncapi. Created 11 years, 3 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
Index: chrome/browser/sync/notifier/communicator/mailbox_unittest.cc
===================================================================
--- chrome/browser/sync/notifier/communicator/mailbox_unittest.cc (revision 0)
+++ chrome/browser/sync/notifier/communicator/mailbox_unittest.cc (revision 0)
@@ -0,0 +1,118 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/notifier/communicator/mailbox.h"
+#include "notifier/testing/notifier/unittest.h"
+
+namespace notifier {
+TEST_NOTIFIER_F(MailBoxTest);
+
+TEST_F(MailBoxTest, SingleSenderHtml) {
+ std::string me_address("random@company.com");
+ MailSenderList sender_list;
+ sender_list.push_back(MailSender("Alex Smith", "a@a.com", true, true));
+ std::string sender_html = GetSenderHtml(sender_list, 1, me_address, 25);
+ ASSERT_STREQ("<b>Alex Smith</b>", sender_html.c_str());
+}
+
+TEST_F(MailBoxTest, TruncatedSingleSenderHtml) {
+ std::string me_address("random@company.com");
+ MailSenderList sender_list;
+ sender_list.push_back(MailSender(
+ "Alex Smith AReallyLongLastNameThatWillBeTruncated",
+ "a@a.com",
+ true,
+ true));
+ std::string sender_html = GetSenderHtml(sender_list, 1, me_address, 25);
+ ASSERT_STREQ("<b>Alex Smith AReallyLongLa.</b>", sender_html.c_str());
+}
+
+TEST_F(MailBoxTest, SingleSenderManyTimesHtml) {
+ std::string me_address("random@company.com");
+ MailSenderList sender_list;
+ sender_list.push_back(MailSender("Alex Smith", "a@a.com", true, true));
+ std::string sender_html = GetSenderHtml(sender_list, 10, me_address, 25);
+ ASSERT_STREQ("<b>Alex Smith</b>&nbsp;(10)", sender_html.c_str());
+}
+
+TEST_F(MailBoxTest, SenderWithMeHtml) {
+ std::string me_address("randOm@comPany.Com");
+ MailSenderList sender_list;
+ sender_list.push_back(
+ MailSender("Alex Smith", "alex@jones.com", false, false));
+ sender_list.push_back(
+ MailSender("Your Name Goes Here", "raNdom@coMpany.cOm", true, true));
+ std::string sender_html = GetSenderHtml(sender_list, 5, me_address, 25);
+ ASSERT_STREQ("me,&nbsp;Alex,&nbsp;<b>me</b>&nbsp;(5)", sender_html.c_str());
+}
+
+TEST_F(MailBoxTest, SenderHtmlWithAllUnread) {
+ std::string me_address("random@company.com");
+ MailSenderList sender_list;
+ sender_list.push_back(
+ MailSender("Alex Smith", "alex@jones.com", true, false));
+ sender_list.push_back(MailSender(
+ "Your Name Goes Here",
+ "foo@company.com",
+ true,
+ true));
+ sender_list.push_back(MailSender("", "bob@davis.com", true, false));
+ std::string sender_html = GetSenderHtml(sender_list, 100, me_address, 25);
+ ASSERT_STREQ("<b>Your</b>,&nbsp;<b>Alex</b>,&nbsp;<b>bob</b>&nbsp;(100)",
+ sender_html.c_str());
+}
+
+TEST_F(MailBoxTest, SenderHtmlWithTruncatedNames) {
+ std::string me_address("random@company.com");
+ MailSenderList sender_list;
+ sender_list.push_back(MailSender(
+ "ReallyLongName Smith",
+ "alex@jones.com",
+ true,
+ false));
+ sender_list.push_back(MailSender(
+ "AnotherVeryLongFirstNameIsHere",
+ "foo@company.com",
+ true,
+ true));
+ std::string sender_html = GetSenderHtml(sender_list, 2, me_address, 25);
+ ASSERT_STREQ("<b>AnotherV.</b>,&nbsp;<b>ReallyLo.</b>&nbsp;(2)",
+ sender_html.c_str());
+}
+
+TEST_F(MailBoxTest, SenderWithTwoSendersShowing) {
+ std::string me_address("random@company.com");
+ MailSenderList sender_list;
+ sender_list.push_back(
+ MailSender("ALongishName Smith", "alex@jones.com", false, false));
+ sender_list.push_back(
+ MailSender("AnotherBigName", "no@company.com", true, false));
+ sender_list.push_back(
+ MailSender("Person1", "no1@company.com", true, false));
+ sender_list.push_back(
+ MailSender("Person2", "no2@company.com", false, true));
+ std::string sender_html = GetSenderHtml(sender_list, 6, me_address, 25);
+ ASSERT_STREQ("Person2&nbsp;..&nbsp;<b>AnotherB.</b>&nbsp;..&nbsp;(6)",
+ sender_html.c_str());
+}
+
+TEST_F(MailBoxTest, SenderWithThreeSendersShowing) {
+ std::string me_address("random@company.com");
+ MailSenderList sender_list;
+ sender_list.push_back(
+ MailSender("Joe Smith", "alex@jones.com", false, false));
+ sender_list.push_back(
+ MailSender("Bob Other", "no@company.com", true, false));
+ sender_list.push_back(
+ MailSender("Person0", "no0@company.com", true, false));
+ sender_list.push_back(
+ MailSender("Person1", "no1@company.com", true, false));
+ sender_list.push_back(
+ MailSender("ted", "ted@company.com", false, true));
+ std::string sender_html = GetSenderHtml(sender_list, 6, me_address, 25);
+ ASSERT_STREQ(
+ "ted&nbsp;..&nbsp;<b>Bob</b>&nbsp;..&nbsp;<b>Person1</b>&nbsp;(6)",
+ sender_html.c_str());
+}
+} // namespace notifier
Property changes on: chrome\browser\sync\notifier\communicator\mailbox_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698