Chromium Code Reviews| 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 217170c812c0ab22813390f61dec2b9b660e8e2a..847123a698272bacc0339cf1a0345ce2fe53b8cb 100644 |
| --- a/ui/base/text/text_elider_unittest.cc |
| +++ b/ui/base/text/text_elider_unittest.cc |
| @@ -55,6 +55,42 @@ void RunUrlTest(Testcase* testcases, size_t num_testcases) { |
| } // namespace |
| +TEST(TextEliderTest, ElideEmail) { |
| + const std::string kEllipsisStr(kEllipsis); |
| + |
| + Testcase testcases[] = { |
|
asvitkine_google
2012/03/01 20:13:29
Please add some tests that check no eliding takes
|
| + {"g@g.c", "g@g.c"}, |
| + {"g@g.c", kEllipsisStr}, |
| + {"ga@co.ca", "ga@c" + kEllipsisStr + "a"}, |
| + {"short@small.com", "s" + kEllipsisStr + "@s" + kEllipsisStr}, |
| + {"short@small.com", "s" + kEllipsisStr + "@small.com"}, |
| + {"short@longbutlotsofspace.com", "short@longbutlotsofspace.com"}, |
| + {"short@longbutnotverymuchspace.com", |
| + "short@long" + kEllipsisStr + ".com"}, |
| + {"short@longbutverytightspace.ca", |
| + "sh" + kEllipsisStr + "@l" + kEllipsisStr + "a"}, |
| + {"longusername@gmail.com", "long" + kEllipsisStr + "@gmail.com"}, |
| + {"elidetothemax@justfits.com", "e" + kEllipsisStr + "@justfits.com"}, |
| + {"somelongemail@thatdoesntfit.com", |
| + "somelo" + kEllipsisStr + "@tha" + kEllipsisStr + "om"}, |
| + {"namefits@butthedomaindoesnt.com", |
| + "namefits@butthedo" + kEllipsisStr + "snt.com"}, |
| + {"widthtootight@nospace.com", kEllipsisStr}, |
| + {"nospaceforusername@l", kEllipsisStr}, |
| + {"little@littlespace.com", "l" + kEllipsisStr + "@l" + kEllipsisStr}, |
| + }; |
| + |
| + const gfx::Font font; |
| + const size_t num_testcases = arraysize(testcases); |
| + for (size_t i = 0; i < num_testcases; ++i) { |
| + const string16 expected_output = UTF8ToUTF16(testcases[i].output); |
| + EXPECT_EQ(expected_output, |
| + ElideEmail(UTF8ToUTF16(testcases[i].input), |
| + font, |
| + font.GetStringWidth(expected_output))); |
| + } |
| +} |
| + |
| // Test eliding of commonplace URLs. |
| TEST(TextEliderTest, TestGeneralEliding) { |
| const std::string kEllipsisStr(kEllipsis); |