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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 21140002: Consolidate RenderText adjacent word selection model code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup comments and add a unit test.~ Created 7 years, 5 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/gfx/render_text_mac.cc ('k') | ui/gfx/render_text_win.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 fb889f4b1b80b9a0f509922a09a22d58a77d907b..dca5b811c155a676db451030b2f9cdcbae9a5d8e 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -1370,6 +1370,42 @@ TEST_F(RenderTextTest, CaretWidth) {
EXPECT_GE(render_text->GetUpdatedCursorBounds().width(), 1);
}
+TEST_F(RenderTextTest, SelectWord) {
+ scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
+ render_text->SetText(ASCIIToUTF16(" foo a.bc.d bar"));
+
+ struct {
+ size_t cursor;
+ size_t selection_start;
+ size_t selection_end;
+ } cases[] = {
+ { 0, 0, 1 },
+ { 1, 1, 4 },
+ { 2, 1, 4 },
+ { 3, 1, 4 },
+ { 4, 4, 6 },
+ { 5, 4, 6 },
+ { 6, 6, 7 },
+ { 7, 7, 8 },
+ { 8, 8, 10 },
+ { 9, 8, 10 },
+ { 10, 10, 11 },
+ { 11, 11, 12 },
+ { 12, 12, 13 },
+ { 13, 13, 16 },
+ { 14, 13, 16 },
+ { 15, 13, 16 },
+ { 16, 13, 16 },
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
+ render_text->SetCursorPosition(cases[i].cursor);
+ render_text->SelectWord();
+ EXPECT_EQ(ui::Range(cases[i].selection_start, cases[i].selection_end),
+ render_text->selection());
+ }
+}
+
// Make sure the last word is selected when the cursor is at text.length().
TEST_F(RenderTextTest, LastWordSelected) {
const std::string kTestURL1 = "http://www.google.com";
« no previous file with comments | « ui/gfx/render_text_mac.cc ('k') | ui/gfx/render_text_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698