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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 8819001: Revert 113075 (requested by asvitkine) (requested by asvitkine) (requested by asvitkine) (request... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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_linux.cc ('k') | ui/gfx/render_text_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_unittest.cc
===================================================================
--- ui/gfx/render_text_unittest.cc (revision 113082)
+++ ui/gfx/render_text_unittest.cc (working copy)
@@ -543,105 +543,6 @@
}
#endif
-TEST_F(RenderTextTest, GraphemePositions) {
- // LTR 2-character grapheme, LTR abc, LTR 2-character grapheme.
- const string16 kText1 = WideToUTF16(L"\x0915\x093f"L"abc"L"\x0915\x093f");
-
- // LTR ab, LTR 2-character grapheme, LTR cd.
- const string16 kText2 = WideToUTF16(L"ab"L"\x0915\x093f"L"cd");
-
- struct {
- string16 text;
- size_t index;
- size_t expected_previous;
- size_t expected_next;
- } cases[] = {
- { string16(), 0, 0, 0 },
- { string16(), 1, 0, 0 },
- { string16(), 50, 0, 0 },
- { kText1, 0, 0, 2 },
- { kText1, 1, 0, 2 },
- { kText1, 2, 0, 3 },
- { kText1, 3, 2, 4 },
- { kText1, 4, 3, 5 },
- { kText1, 5, 4, 7 },
- { kText1, 6, 5, 7 },
- { kText1, 7, 5, 7 },
- { kText1, 8, 7, 7 },
- { kText1, 50, 7, 7 },
- { kText2, 0, 0, 1 },
- { kText2, 1, 0, 2 },
- { kText2, 2, 1, 4 },
- { kText2, 3, 2, 4 },
- { kText2, 4, 2, 5 },
- { kText2, 5, 4, 6 },
- { kText2, 6, 5, 6 },
- { kText2, 7, 6, 6 },
- { kText2, 50, 6, 6 },
- };
-
- scoped_ptr<RenderText> render_text(RenderText::CreateRenderText());
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) {
- render_text->SetText(cases[i].text);
-
- size_t next = render_text->GetIndexOfNextGrapheme(cases[i].index);
- EXPECT_EQ(cases[i].expected_next, next);
- EXPECT_TRUE(render_text->IsCursorablePosition(next));
-
- size_t previous = render_text->GetIndexOfPreviousGrapheme(cases[i].index);
- EXPECT_EQ(cases[i].expected_previous, previous);
- EXPECT_TRUE(render_text->IsCursorablePosition(previous));
- }
-}
-
-TEST_F(RenderTextTest, SelectionModels) {
- // Simple Latin text.
- const string16 kLatin = WideToUTF16(L"abc");
- // LTR 2-character grapheme.
- const string16 kLTRGrapheme = WideToUTF16(L"\x0915\x093f");
- // LTR 2-character grapheme, LTR a, LTR 2-character grapheme.
- const string16 kHindiLatin = WideToUTF16(L"\x0915\x093f"L"a"L"\x0915\x093f");
- // RTL 2-character grapheme.
- const string16 kRTLGrapheme = WideToUTF16(L"\x05e0\x05b8");
- // RTL 2-character grapheme, LTR a, RTL 2-character grapheme.
- const string16 kHebrewLatin = WideToUTF16(L"\x05e0\x05b8"L"a"L"\x05e0\x05b8");
-
- struct {
- string16 text;
- size_t expected_left_end_caret;
- SelectionModel::CaretPlacement expected_left_end_placement;
- size_t expected_right_end_caret;
- SelectionModel::CaretPlacement expected_right_end_placement;
- } cases[] = {
- { string16(), 0, SelectionModel::LEADING, 0, SelectionModel::LEADING },
- { kLatin, 0, SelectionModel::LEADING, 2, SelectionModel::TRAILING },
- { kLTRGrapheme, 0, SelectionModel::LEADING, 0, SelectionModel::TRAILING },
- { kHindiLatin, 0, SelectionModel::LEADING, 3, SelectionModel::TRAILING },
- { kRTLGrapheme, 0, SelectionModel::TRAILING, 0, SelectionModel::LEADING },
-#if defined(OS_LINUX)
- // On Linux, the whole string is displayed RTL, rather than individual runs.
- { kHebrewLatin, 3, SelectionModel::TRAILING, 0, SelectionModel::LEADING },
-#else
- { kHebrewLatin, 0, SelectionModel::TRAILING, 3, SelectionModel::LEADING },
-#endif
- };
-
- scoped_ptr<RenderText> render_text(RenderText::CreateRenderText());
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) {
- render_text->SetText(cases[i].text);
-
- SelectionModel model = render_text->LeftEndSelectionModel();
- EXPECT_EQ(cases[i].expected_left_end_caret, model.caret_pos());
- EXPECT_TRUE(render_text->IsCursorablePosition(model.caret_pos()));
- EXPECT_EQ(cases[i].expected_left_end_placement, model.caret_placement());
-
- model = render_text->RightEndSelectionModel();
- EXPECT_EQ(cases[i].expected_right_end_caret, model.caret_pos());
- EXPECT_TRUE(render_text->IsCursorablePosition(model.caret_pos()));
- EXPECT_EQ(cases[i].expected_right_end_placement, model.caret_placement());
- }
-}
-
TEST_F(RenderTextTest, MoveCursorLeftRightWithSelection) {
scoped_ptr<RenderText> render_text(RenderText::CreateRenderText());
render_text->SetText(WideToUTF16(L"abc\x05d0\x05d1\x05d2"));
« no previous file with comments | « ui/gfx/render_text_linux.cc ('k') | ui/gfx/render_text_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698