summaryrefslogtreecommitdiffstats
path: root/app/text_elider_unittest.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-20 18:28:00 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-20 18:28:00 +0000
commit68da8f78cd06ba70144c9e3fb2e1bae724208e6a (patch)
tree695907a99af87ad2c9ff646893e11588a447e41d /app/text_elider_unittest.cc
parent6658ca866d0e28950179a65179c1a4d6e8e3f8df (diff)
downloadchromium_src-68da8f78cd06ba70144c9e3fb2e1bae724208e6a.zip
chromium_src-68da8f78cd06ba70144c9e3fb2e1bae724208e6a.tar.gz
chromium_src-68da8f78cd06ba70144c9e3fb2e1bae724208e6a.tar.bz2
Elide the EV bubble when it's extremely long. This limits it to half the location bar width, unless eliding to that would result in a width of less than 150 px.
BUG=42856 TEST=Visit https://www.barbican.org.uk/eticketing/index.asp and make the window smaller. The EV bubble should shrink, eliding in middle, until it hits a minimum size. Review URL: http://codereview.chromium.org/2084012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/text_elider_unittest.cc')
-rw-r--r--app/text_elider_unittest.cc60
1 files changed, 42 insertions, 18 deletions
diff --git a/app/text_elider_unittest.cc b/app/text_elider_unittest.cc
index cc421fb..0eacfd2 100644
--- a/app/text_elider_unittest.cc
+++ b/app/text_elider_unittest.cc
@@ -189,6 +189,7 @@ TEST(TextEliderTest, TestFilenameEliding) {
TEST(TextEliderTest, ElideTextLongStrings) {
const std::wstring kEllipsisStr(kEllipsis);
std::wstring data_scheme(L"data:text/plain,");
+ size_t data_scheme_length = data_scheme.length();
std::wstring ten_a(10, L'a');
std::wstring hundred_a(100, L'a');
@@ -197,31 +198,54 @@ TEST(TextEliderTest, ElideTextLongStrings) {
std::wstring hundred_thousand_a(100000, L'a');
std::wstring million_a(1000000, L'a');
- WideTestcase testcases[] = {
- {data_scheme + ten_a,
- data_scheme + ten_a},
- {data_scheme + hundred_a,
- data_scheme + hundred_a},
- {data_scheme + thousand_a,
- data_scheme + std::wstring(156, L'a') + kEllipsisStr},
- {data_scheme + ten_thousand_a,
- data_scheme + std::wstring(156, L'a') + kEllipsisStr},
- {data_scheme + hundred_thousand_a,
- data_scheme + std::wstring(156, L'a') + kEllipsisStr},
- {data_scheme + million_a,
- data_scheme + std::wstring(156, L'a') + kEllipsisStr},
+ size_t number_of_as = 156;
+ std::wstring long_string_end(
+ data_scheme + std::wstring(number_of_as, L'a') + kEllipsisStr);
+ WideTestcase testcases_end[] = {
+ {data_scheme + ten_a, data_scheme + ten_a},
+ {data_scheme + hundred_a, data_scheme + hundred_a},
+ {data_scheme + thousand_a, long_string_end},
+ {data_scheme + ten_thousand_a, long_string_end},
+ {data_scheme + hundred_thousand_a, long_string_end},
+ {data_scheme + million_a, long_string_end},
};
const gfx::Font font;
int ellipsis_width = font.GetStringWidth(kEllipsisStr);
- for (size_t i = 0; i < arraysize(testcases); ++i) {
+ for (size_t i = 0; i < arraysize(testcases_end); ++i) {
+ // Compare sizes rather than actual contents because if the test fails,
+ // output is rather long.
+ EXPECT_EQ(testcases_end[i].output.size(),
+ ElideText(testcases_end[i].input, font,
+ font.GetStringWidth(testcases_end[i].output),
+ false).size());
+ EXPECT_EQ(kEllipsisStr,
+ ElideText(testcases_end[i].input, font, ellipsis_width, false));
+ }
+
+ size_t number_of_trailing_as = (data_scheme_length + number_of_as) / 2;
+ std::wstring long_string_middle(data_scheme +
+ std::wstring(number_of_as - number_of_trailing_as, L'a') + kEllipsisStr +
+ std::wstring(number_of_trailing_as, L'a'));
+ WideTestcase testcases_middle[] = {
+ {data_scheme + ten_a, data_scheme + ten_a},
+ {data_scheme + hundred_a, data_scheme + hundred_a},
+ {data_scheme + thousand_a, long_string_middle},
+ {data_scheme + ten_thousand_a, long_string_middle},
+ {data_scheme + hundred_thousand_a, long_string_middle},
+ {data_scheme + million_a, long_string_middle},
+ };
+
+ for (size_t i = 0; i < arraysize(testcases_middle); ++i) {
// Compare sizes rather than actual contents because if the test fails,
// output is rather long.
- EXPECT_EQ(testcases[i].output.size(),
- ElideText(testcases[i].input, font,
- font.GetStringWidth(testcases[i].output)).size());
+ EXPECT_EQ(testcases_middle[i].output.size(),
+ ElideText(testcases_middle[i].input, font,
+ font.GetStringWidth(testcases_middle[i].output),
+ false).size());
EXPECT_EQ(kEllipsisStr,
- ElideText(testcases[i].input, font, ellipsis_width));
+ ElideText(testcases_middle[i].input, font, ellipsis_width,
+ false));
}
}