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

Side by Side Diff: chrome/browser/sync/notifier/communicator/mailbox_unittest.cc

Issue 1956001: Moved XMPP notifier library from chrome/browser/sync to chrome/common.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/notifier/communicator/mailbox.h"
6
7 namespace notifier {
8
9 TEST_NOTIFIER_F(MailBoxTest);
10
11 TEST_F(MailBoxTest, SingleSenderHtml) {
12 std::string me_address("random@company.com");
13 MailSenderList sender_list;
14 sender_list.push_back(MailSender("Alex Smith", "a@a.com", true, true));
15 std::string sender_html = GetSenderHtml(sender_list, 1, me_address, 25);
16 ASSERT_STREQ("<b>Alex Smith</b>", sender_html.c_str());
17 }
18
19 TEST_F(MailBoxTest, TruncatedSingleSenderHtml) {
20 std::string me_address("random@company.com");
21 MailSenderList sender_list;
22 sender_list.push_back(MailSender(
23 "Alex Smith AReallyLongLastNameThatWillBeTruncated",
24 "a@a.com",
25 true,
26 true));
27 std::string sender_html = GetSenderHtml(sender_list, 1, me_address, 25);
28 ASSERT_STREQ("<b>Alex Smith AReallyLongLa.</b>", sender_html.c_str());
29 }
30
31 TEST_F(MailBoxTest, SingleSenderManyTimesHtml) {
32 std::string me_address("random@company.com");
33 MailSenderList sender_list;
34 sender_list.push_back(MailSender("Alex Smith", "a@a.com", true, true));
35 std::string sender_html = GetSenderHtml(sender_list, 10, me_address, 25);
36 ASSERT_STREQ("<b>Alex Smith</b>&nbsp;(10)", sender_html.c_str());
37 }
38
39 TEST_F(MailBoxTest, SenderWithMeHtml) {
40 std::string me_address("randOm@comPany.Com");
41 MailSenderList sender_list;
42 sender_list.push_back(
43 MailSender("Alex Smith", "alex@jones.com", false, false));
44 sender_list.push_back(
45 MailSender("Your Name Goes Here", "raNdom@coMpany.cOm", true, true));
46 std::string sender_html = GetSenderHtml(sender_list, 5, me_address, 25);
47 ASSERT_STREQ("me,&nbsp;Alex,&nbsp;<b>me</b>&nbsp;(5)", sender_html.c_str());
48 }
49
50 TEST_F(MailBoxTest, SenderHtmlWithAllUnread) {
51 std::string me_address("random@company.com");
52 MailSenderList sender_list;
53 sender_list.push_back(
54 MailSender("Alex Smith", "alex@jones.com", true, false));
55 sender_list.push_back(MailSender(
56 "Your Name Goes Here",
57 "foo@company.com",
58 true,
59 true));
60 sender_list.push_back(MailSender("", "bob@davis.com", true, false));
61 std::string sender_html = GetSenderHtml(sender_list, 100, me_address, 25);
62 ASSERT_STREQ("<b>Your</b>,&nbsp;<b>Alex</b>,&nbsp;<b>bob</b>&nbsp;(100)",
63 sender_html.c_str());
64 }
65
66 TEST_F(MailBoxTest, SenderHtmlWithTruncatedNames) {
67 std::string me_address("random@company.com");
68 MailSenderList sender_list;
69 sender_list.push_back(MailSender(
70 "ReallyLongName Smith",
71 "alex@jones.com",
72 true,
73 false));
74 sender_list.push_back(MailSender(
75 "AnotherVeryLongFirstNameIsHere",
76 "foo@company.com",
77 true,
78 true));
79 std::string sender_html = GetSenderHtml(sender_list, 2, me_address, 25);
80 ASSERT_STREQ("<b>AnotherV.</b>,&nbsp;<b>ReallyLo.</b>&nbsp;(2)",
81 sender_html.c_str());
82 }
83
84 TEST_F(MailBoxTest, SenderWithTwoSendersShowing) {
85 std::string me_address("random@company.com");
86 MailSenderList sender_list;
87 sender_list.push_back(
88 MailSender("ALongishName Smith", "alex@jones.com", false, false));
89 sender_list.push_back(
90 MailSender("AnotherBigName", "no@company.com", true, false));
91 sender_list.push_back(
92 MailSender("Person1", "no1@company.com", true, false));
93 sender_list.push_back(
94 MailSender("Person2", "no2@company.com", false, true));
95 std::string sender_html = GetSenderHtml(sender_list, 6, me_address, 25);
96 ASSERT_STREQ("Person2&nbsp;..&nbsp;<b>AnotherB.</b>&nbsp;..&nbsp;(6)",
97 sender_html.c_str());
98 }
99
100 TEST_F(MailBoxTest, SenderWithThreeSendersShowing) {
101 std::string me_address("random@company.com");
102 MailSenderList sender_list;
103 sender_list.push_back(
104 MailSender("Joe Smith", "alex@jones.com", false, false));
105 sender_list.push_back(
106 MailSender("Bob Other", "no@company.com", true, false));
107 sender_list.push_back(
108 MailSender("Person0", "no0@company.com", true, false));
109 sender_list.push_back(
110 MailSender("Person1", "no1@company.com", true, false));
111 sender_list.push_back(
112 MailSender("ted", "ted@company.com", false, true));
113 std::string sender_html = GetSenderHtml(sender_list, 6, me_address, 25);
114 ASSERT_STREQ(
115 "ted&nbsp;..&nbsp;<b>Bob</b>&nbsp;..&nbsp;<b>Person1</b>&nbsp;(6)",
116 sender_html.c_str());
117 }
118
119 } // namespace notifier
OLDNEW
« no previous file with comments | « chrome/browser/sync/notifier/communicator/mailbox.cc ('k') | chrome/browser/sync/notifier/communicator/product_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698