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

Unified Diff: ui/base/text/text_elider_unittest.cc

Issue 7669040: content: Move render_widget_host_view_gtk to content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: chromeos fix. Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/text/text_elider.cc ('k') | ui/ui.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0ff70e4bba845f6f5e00a8ec2d638cebb00573d5..60ab1f743ed11d135f0a0a3a6749608a005c7da1 100644
--- a/ui/base/text/text_elider_unittest.cc
+++ b/ui/base/text/text_elider_unittest.cc
@@ -547,4 +547,31 @@ TEST(TextEliderTest, ElideRectangleWide32) {
EXPECT_EQ(out, output);
}
+TEST(TextEliderTest, TruncateString) {
+ string16 string = ASCIIToUTF16("foooooey bxxxar baz");
+
+ // Make sure it doesn't modify the string if length > string length.
+ EXPECT_EQ(string, ui::TruncateString(string, 100));
+
+ // Test no characters.
+ EXPECT_EQ(L"", UTF16ToWide(ui::TruncateString(string, 0)));
+
+ // Test 1 character.
+ EXPECT_EQ(L"\x2026", UTF16ToWide(ui::TruncateString(string, 1)));
+
+ // Test adds ... at right spot when there is enough room to break at a
+ // word boundary.
+ EXPECT_EQ(L"foooooey\x2026", UTF16ToWide(ui::TruncateString(string, 14)));
+
+ // Test adds ... at right spot when there is not enough space in first word.
+ EXPECT_EQ(L"f\x2026", UTF16ToWide(ui::TruncateString(string, 2)));
+
+ // Test adds ... at right spot when there is not enough room to break at a
+ // word boundary.
+ EXPECT_EQ(L"foooooey\x2026", UTF16ToWide(ui::TruncateString(string, 11)));
+
+ // Test completely truncates string if break is on initial whitespace.
+ EXPECT_EQ(L"\x2026", UTF16ToWide(ui::TruncateString(ASCIIToUTF16(" "), 2)));
+}
+
} // namespace ui
« no previous file with comments | « ui/base/text/text_elider.cc ('k') | ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698