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

Unified Diff: Source/web/tests/WebFrameTest.cpp

Issue 653383002: Add new API for only moving the selection extent point. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated comment Created 6 years, 2 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 | « Source/web/WebLocalFrameImpl.cpp ('k') | Source/web/tests/data/move_range_selection_extent.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index 2b0965ea90adf4a8d217361aa30c9f75d9ffc256..68f3e0b70dea9139757cdd444cd6342b8545407e 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -4114,6 +4114,65 @@ TEST_F(WebFrameTest, SelectRangeCanMoveSelectionEnd)
// EXPECT_EQ("Editable 1. Editable 2. ]", selectionAsString(frame));
}
+TEST_F(WebFrameTest, MoveRangeSelectionExtent)
+{
+ WebLocalFrameImpl* frame;
+ WebRect startWebRect;
+ WebRect endWebRect;
+
+ registerMockedHttpURLLoad("move_range_selection_extent.html");
+
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent.html", &webViewHelper);
+ frame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame());
+ EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
+ webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
+
+ frame->moveRangeSelectionExtent(WebPoint(640, 480));
+ EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsString(frame));
+
+ frame->moveRangeSelectionExtent(WebPoint(0, 0));
+ EXPECT_EQ("16-char header. ", selectionAsString(frame));
+
+ // Reset with swapped base and extent.
+ frame->selectRange(topLeft(endWebRect), bottomRightMinusOne(startWebRect));
+ EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
+
+ frame->moveRangeSelectionExtent(WebPoint(640, 480));
+ EXPECT_EQ(" 16-char footer.", selectionAsString(frame));
+
+ frame->moveRangeSelectionExtent(WebPoint(0, 0));
+ EXPECT_EQ("16-char header. This text is initially selected.", selectionAsString(frame));
+
+ frame->executeCommand(WebString::fromUTF8("Unselect"));
+ EXPECT_EQ("", selectionAsString(frame));
+}
+
+TEST_F(WebFrameTest, MoveRangeSelectionExtentCannotCollapse)
+{
+ WebLocalFrameImpl* frame;
+ WebRect startWebRect;
+ WebRect endWebRect;
+
+ registerMockedHttpURLLoad("move_range_selection_extent.html");
+
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ initializeTextSelectionWebView(m_baseURL + "move_range_selection_extent.html", &webViewHelper);
+ frame = toWebLocalFrameImpl(webViewHelper.webView()->mainFrame());
+ EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
+ webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
+
+ frame->moveRangeSelectionExtent(bottomRightMinusOne(startWebRect));
+ EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
+
+ // Reset with swapped base and extent.
+ frame->selectRange(topLeft(endWebRect), bottomRightMinusOne(startWebRect));
+ EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
+
+ frame->moveRangeSelectionExtent(bottomRightMinusOne(endWebRect));
+ EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
+}
+
static int computeOffset(RenderObject* renderer, int x, int y)
{
return VisiblePosition(renderer->positionForPoint(LayoutPoint(x, y))).deepEquivalent().computeOffsetInContainerNode();
« no previous file with comments | « Source/web/WebLocalFrameImpl.cpp ('k') | Source/web/tests/data/move_range_selection_extent.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698