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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 13972015: Select last word when double clicked after the last character (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 2 Created 7 years, 8 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.cc ('k') | no next file » | 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 e330fe827958b88cfacd787a035371d23af701c6..e85cb720b75bb120ca8d2d276ddb6280aaf328b6 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -1108,6 +1108,26 @@ TEST_F(RenderTextTest, CaretWidth) {
EXPECT_GE(render_text->GetUpdatedCursorBounds().width(), 1);
}
+// 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";
+ const std::string kTestURL2 = "http://www.google.com/something/";
+
+ scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
+
+ render_text->SetText(ASCIIToUTF16(kTestURL1));
+ render_text->SetCursorPosition(kTestURL1.length());
+ render_text->SelectWord();
+ EXPECT_EQ(ui::Range(kTestURL1.length() - 3, kTestURL1.length()),
+ render_text->selection());
+
+ render_text->SetText(ASCIIToUTF16(kTestURL2));
+ render_text->SetCursorPosition(kTestURL2.length());
+ render_text->SelectWord();
+ EXPECT_EQ(ui::Range(kTestURL2.length() - 1, kTestURL2.length()),
+ render_text->selection());
+}
+
// TODO(asvitkine): Cursor movements tests disabled on Mac because RenderTextMac
// does not implement this yet. http://crbug.com/131618
#if !defined(OS_MACOSX)
« no previous file with comments | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698