| Index: ui/base/text/text_elider_unittest.cc
|
| diff --git a/ui/base/text/text_elider_unittest.cc b/ui/base/text/text_elider_unittest.cc
|
| index b342b4c5dbae63b1a67287f75febe0130111471f..2c04138546efcddcdffa11934d09c5b17f138dd0 100644
|
| --- a/ui/base/text/text_elider_unittest.cc
|
| +++ b/ui/base/text/text_elider_unittest.cc
|
| @@ -53,8 +53,68 @@ void RunTest(Testcase* testcases, size_t num_testcases) {
|
| }
|
| }
|
|
|
| +void RunEmailTest(Testcase* testcases,
|
| + size_t num_testcases,
|
| + size_t max_email_length) {
|
| + for (size_t i = 0; i < num_testcases; ++i) {
|
| + EXPECT_EQ(UTF8ToUTF16(testcases[i].output),
|
| + ElideEmail(UTF8ToUTF16(testcases[i].input), max_email_length));
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
| +TEST(TextEliderTest, SmallestElideEmail) {
|
| + const std::string kEllipsisStr(kEllipsis);
|
| +
|
| + // Make sure the ellipsis is of length 1 in UTF16 as all the tests below
|
| + // assume this to be true.
|
| + ASSERT_EQ(UTF8ToUTF16(kEllipsisStr).length(), size_t(1));
|
| +
|
| + // 5 is the smallest max_email_length allowed in ui::ElideEmail
|
| + const size_t max_email_length = 5;
|
| +
|
| + Testcase testcases[] = {
|
| + {"g@g.c", "g@g.c"},
|
| + {"ga@co", "ga@co"},
|
| + {"short@small.com", "s" + kEllipsisStr + "@s" + kEllipsisStr},
|
| + };
|
| +
|
| + RunEmailTest(testcases, arraysize(testcases), max_email_length);
|
| +}
|
| +
|
| +TEST(TextEliderTest, RegularElideEmail) {
|
| + const std::string kEllipsisStr(kEllipsis);
|
| +
|
| + // Make sure the ellipsis is of length 1 in UTF16 as all the tests below
|
| + // assume this to be true.
|
| + ASSERT_EQ(UTF8ToUTF16(kEllipsisStr).length(), size_t(1));
|
| +
|
| + const size_t max_email_length = 20;
|
| +
|
| + Testcase testcases[] = {
|
| + {"short@small.com", "short@small.com"},
|
| + {"justunder@test19.ca", "justunder@test19.ca"},
|
| + {"exactly@righton20.ca", "exactly@righton20.ca"},
|
| + {"justover20@test21.com", "justover" + kEllipsisStr + "@test21.com"},
|
| + {"longusernameshortdomain@short.com", "longusern" + kEllipsisStr +
|
| + "@short.com"},
|
| + {"short@verysuperlongdomain.com", "short@verys" + kEllipsisStr + ".com"},
|
| + {"waytoobigofanemail@somealsoverybigdomain.com", "waytoobi" +
|
| + kEllipsisStr +
|
| + "@somea" +
|
| + kEllipsisStr +
|
| + ".com"},
|
| + {"toolongusername@maxsizedomain.com", "t" + kEllipsisStr +
|
| + "@maxsizedomain.com"},
|
| + {"toolongusername@justovermaxof17.tv", "toolongu" + kEllipsisStr +
|
| + "@justo" + kEllipsisStr +
|
| + "7.tv"},
|
| + };
|
| +
|
| + RunEmailTest(testcases, arraysize(testcases), max_email_length);
|
| +}
|
| +
|
| // Test eliding of commonplace URLs.
|
| TEST(TextEliderTest, TestGeneralEliding) {
|
| const std::string kEllipsisStr(kEllipsis);
|
|
|