summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 10:30:43 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-31 10:30:43 +0000
commit40470aa0b59d881135c4bfdc76fcee27aa3044b4 (patch)
treecab068878d31482debe97abbe5c80d7219588b39 /ui
parent7ee8c2517723b5b94232111c5347a9cf8800d416 (diff)
downloadchromium_src-40470aa0b59d881135c4bfdc76fcee27aa3044b4.zip
chromium_src-40470aa0b59d881135c4bfdc76fcee27aa3044b4.tar.gz
chromium_src-40470aa0b59d881135c4bfdc76fcee27aa3044b4.tar.bz2
Add a RenderText SelectWord unit test.
BUG=183,131660 TEST=None R=asvitkine@chromium.org Review URL: https://chromiumcodereview.appspot.com/21077003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214670 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/render_text_unittest.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index 1573128..107d03b 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";