| Index: Source/web/tests/WebFrameTest.cpp
|
| diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
|
| index 2b0965ea90adf4a8d217361aa30c9f75d9ffc256..f44c393093dbdc4adbefe574b062b89b47216545 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, MoveSelectionExtent)
|
| +{
|
| + WebFrame* frame;
|
| + WebRect startWebRect;
|
| + WebRect endWebRect;
|
| +
|
| + registerMockedHttpURLLoad("move_selection_extent.html");
|
| +
|
| + FrameTestHelpers::WebViewHelper webViewHelper;
|
| + initializeTextSelectionWebView(m_baseURL + "move_selection_extent.html", &webViewHelper);
|
| + frame = webViewHelper.webView()->mainFrame();
|
| + EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
|
| + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
|
| +
|
| + frame->moveSelectionExtent(WebPoint(640, 480));
|
| + EXPECT_EQ("This text is initially selected. 16-char footer.", selectionAsString(frame));
|
| +
|
| + frame->moveSelectionExtent(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->moveSelectionExtent(WebPoint(640, 480));
|
| + EXPECT_EQ(" 16-char footer.", selectionAsString(frame));
|
| +
|
| + frame->moveSelectionExtent(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, MoveSelectionExtentCannotCollapse)
|
| +{
|
| + WebFrame* frame;
|
| + WebRect startWebRect;
|
| + WebRect endWebRect;
|
| +
|
| + registerMockedHttpURLLoad("move_selection_extent.html");
|
| +
|
| + FrameTestHelpers::WebViewHelper webViewHelper;
|
| + initializeTextSelectionWebView(m_baseURL + "move_selection_extent.html", &webViewHelper);
|
| + frame = webViewHelper.webView()->mainFrame();
|
| + EXPECT_EQ("This text is initially selected.", selectionAsString(frame));
|
| + webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
|
| +
|
| + frame->moveSelectionExtent(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->moveSelectionExtent(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();
|
|
|