summaryrefslogtreecommitdiffstats
path: root/app/text_elider_unittest.cc
diff options
context:
space:
mode:
authorjschuh@google.com <jschuh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-17 17:24:59 +0000
committerjschuh@google.com <jschuh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-17 17:24:59 +0000
commit173293170c18302eae5d2cf77d995daad74d4db1 (patch)
tree07b1516c8dc0e42859ae538e4a217d68f6bea958 /app/text_elider_unittest.cc
parent1f2d03b835c575406136a347cbbee6074b284793 (diff)
downloadchromium_src-173293170c18302eae5d2cf77d995daad74d4db1.zip
chromium_src-173293170c18302eae5d2cf77d995daad74d4db1.tar.gz
chromium_src-173293170c18302eae5d2cf77d995daad74d4db1.tar.bz2
Move ElideString() from base/string_util.cc to app/text_elider.cc to
reduce size of widely-included base libraries. Committing for tsepez. BUG=49747 TEST=TextEliderTest.* Review URL: http://codereview.chromium.org/6017001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69555 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/text_elider_unittest.cc')
-rw-r--r--app/text_elider_unittest.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/text_elider_unittest.cc b/app/text_elider_unittest.cc
index 8bb224c..e5a29d9 100644
--- a/app/text_elider_unittest.cc
+++ b/app/text_elider_unittest.cc
@@ -295,3 +295,30 @@ TEST(TextEliderTest, SortedDisplayURLCompare) {
EXPECT_EQ(-tests[i].compare_result, url2.Compare(url1, collator.get()));
}
}
+
+TEST(TextEliderTest, ElideString) {
+ struct TestData {
+ const wchar_t* input;
+ int max_len;
+ bool result;
+ const wchar_t* output;
+ } cases[] = {
+ { L"Hello", 0, true, L"" },
+ { L"", 0, false, L"" },
+ { L"Hello, my name is Tom", 1, true, L"H" },
+ { L"Hello, my name is Tom", 2, true, L"He" },
+ { L"Hello, my name is Tom", 3, true, L"H.m" },
+ { L"Hello, my name is Tom", 4, true, L"H..m" },
+ { L"Hello, my name is Tom", 5, true, L"H...m" },
+ { L"Hello, my name is Tom", 6, true, L"He...m" },
+ { L"Hello, my name is Tom", 7, true, L"He...om" },
+ { L"Hello, my name is Tom", 10, true, L"Hell...Tom" },
+ { L"Hello, my name is Tom", 100, false, L"Hello, my name is Tom" }
+ };
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
+ std::wstring output;
+ EXPECT_EQ(cases[i].result,
+ gfx::ElideString(cases[i].input, cases[i].max_len, &output));
+ EXPECT_TRUE(output == cases[i].output);
+ }
+}