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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 103493003: Revert of Implement eliding/truncating at end in RenderText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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/gfx/render_text.cc ('k') | ui/gfx/text_elider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_unittest.cc
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index b300a0f7e9b052d8d1c8e675916013d77e69d3e3..c8c50d428141cf2be2af4ae08c33b522a9befff6 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -399,77 +399,6 @@
EXPECT_EQ(valid_expect_5_and_6, render_text->GetLayoutText());
render_text->RenderText::SetObscuredRevealIndex(6);
EXPECT_EQ(valid_expect_5_and_6, render_text->GetLayoutText());
-}
-
-TEST_F(RenderTextTest, ElidedText) {
- // TODO(skanuj) : Add more test cases for following
- // - RenderText styles.
- // - Cross interaction of truncate, elide and obscure.
- // - ElideText tests from text_elider.cc.
- struct {
- const wchar_t* text;
- const wchar_t* layout_text;
- } cases[] = {
- // Strings shorter than the elision width should be laid out in full.
- { L"" , L"" },
- { kWeak , kWeak },
- { kLtr , kLtr },
- { kLtrRtl , kLtrRtl },
- { kLtrRtlLtr , kLtrRtlLtr },
- { kRtl , kRtl },
- { kRtlLtr , kRtlLtr },
- { kRtlLtrRtl , kRtlLtrRtl },
- // Strings as long as the elision width should be laid out in full.
- { L"012ab", L"012ab" },
- // Long strings should be elided with an ellipsis appended at the end.
- { L"012" L"abc" , L"012a\x2026" },
msw 2013/12/13 20:46:34 nit: When you re-land, you can remove all the pref
Anuj 2013/12/13 21:05:59 Why does that matter? 012 is just some random stri
msw 2013/12/13 21:17:10 It's just a nit, but I asked to keep the test simp
- { L"012" L"ab" L"\x5d0\x5d1" , L"012a\x2026" },
- { L"012" L"a" L"\x5d1" L"b" , L"012a\x2026" },
- { L"01" L"\x5d0\x5d1\x5d2" L"ab" , L"01\x5d0\x5d1\x2026" },
- { L"ab" L"\x5d0\x5d1\x5d2" L"ab" , L"ab\x5d0\x5d1\x2026\x200f" },
- // Surrogate pairs should be elided reasonably enough.
- { L"0123\x0915\x093f" L"abcd" , L"0123\x0915\x2026" },
msw 2013/12/13 20:46:34 Hmm, I missed this in the original review. In the
Anuj 2013/12/13 21:05:59 I am a native speaker of Hindi (script devanagari)
- { L"0\x05e9\x05bc\x05c1\x05b8" , L"0\x05e9\x05bc\x05c1\x05b8" },
- { L"0\x05e9\x05bc\x05c1\x05b8" L"ab" , L"0\x05e9\x05bc\x2026" },
- { L"01\x05e9\x05bc\x05c1\x05b8" L"ab" , L"01\x05e9\x2026" },
- { L"012\x05e9\x05bc\x05c1\x05b8" L"ab" , L"012\x2026" },
- { L"012\xF0\x9D\x84\x9E" , L"012\xF0\x2026" },
msw 2013/12/13 20:46:34 Oddly, I don't remember why this failing test case
Anuj 2013/12/13 21:05:59 I think I will be cautious :)
- };
-
- scoped_ptr<RenderText> expected_render_text(RenderText::CreateInstance());
- expected_render_text->SetFontList(FontList("serif, Sans serif, 12px"));
- expected_render_text->SetDisplayRect(gfx::Rect(0, 0, 9999, 100));
-
- scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
- render_text->SetFontList(FontList("serif, Sans serif, 12px"));
- render_text->SetElideBehavior(gfx::ELIDE_AT_END);
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) {
- expected_render_text->SetText(WideToUTF16(cases[i].layout_text));
- render_text->SetDisplayRect(
- gfx::Rect(0, 0, expected_render_text->GetContentWidth(), 100));
- render_text->SetText(WideToUTF16(cases[i].text));
- EXPECT_EQ(WideToUTF16(cases[i].text), render_text->text());
- EXPECT_EQ(WideToUTF16(cases[i].layout_text), render_text->GetLayoutText())
- << "->For case " << i << ": " << cases[i].text << "\n";
- expected_render_text->SetText(base::string16());
- }
-}
-
-TEST_F(RenderTextTest, ElidedObscuredText) {
- scoped_ptr<RenderText> expected_render_text(RenderText::CreateInstance());
- expected_render_text->SetFontList(FontList("serif, Sans serif, 12px"));
- expected_render_text->SetDisplayRect(gfx::Rect(0, 0, 9999, 100));
- expected_render_text->SetText(WideToUTF16(L"**\x2026"));
-
- scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
- render_text->SetFontList(FontList("serif, Sans serif, 12px"));
- render_text->SetElideBehavior(gfx::ELIDE_AT_END);
- render_text->SetDisplayRect(
- gfx::Rect(0, 0, expected_render_text->GetContentWidth(), 100));
- render_text->SetObscured(true);
- render_text->SetText(WideToUTF16(L"abcdef"));
- EXPECT_EQ(WideToUTF16(L"abcdef"), render_text->text());
- EXPECT_EQ(WideToUTF16(L"**\x2026"), render_text->GetLayoutText());
}
TEST_F(RenderTextTest, TruncatedText) {
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/gfx/text_elider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698