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

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

Issue 1007503003: Fixed key event context menu and added tests for coordinate cleanups (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed typo in expectation Created 5 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 | « Source/core/page/EventHandler.cpp ('k') | Source/web/tests/WebViewTest.cpp » ('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 adc100981c54bc4617ffee5794d0025cf6144fda..18f37c4311660cddef2a8112f137c919207f01cc 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -2838,6 +2838,59 @@ TEST_F(WebFrameTest, DivScrollIntoEditableTest)
EXPECT_FALSE(needAnimation);
}
+TEST_F(WebFrameTest, CharacterIndexAtPointWithPinchZoom)
+{
+ registerMockedHttpURLLoad("sometext.html");
+
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ webViewHelper.initializeAndLoad(m_baseURL + "sometext.html");
+ webViewHelper.webViewImpl()->resize(WebSize(640, 480));
+ webViewHelper.webViewImpl()->layout();
+
+
+ webViewHelper.webViewImpl()->setPageScaleFactor(2);
+ webViewHelper.webViewImpl()->setPinchViewportOffset(WebFloatPoint(50, 60));
+
+ WebRect baseRect;
+ WebRect extentRect;
+
+ WebFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame();
+ size_t ix = mainFrame->characterIndexForPoint(WebPoint(320, 388));
+
+ EXPECT_EQ(2ul, ix);
+}
+
+TEST_F(WebFrameTest, FirstRectForCharacterRangeWithPinchZoom)
+{
+ registerMockedHttpURLLoad("textbox.html");
+
+ FrameTestHelpers::WebViewHelper webViewHelper;
+ webViewHelper.initializeAndLoad(m_baseURL + "textbox.html", true);
+ webViewHelper.webViewImpl()->resize(WebSize(640, 480));
+
+ WebFrame* mainFrame = webViewHelper.webViewImpl()->mainFrame();
+ mainFrame->executeScript(WebScriptSource("selectRange();"));
+
+ WebRect oldRect;
+ mainFrame->firstRectForCharacterRange(0, 5, oldRect);
+
+ WebFloatPoint pinchOffset(100, 130);
+ float scale = 2;
+ webViewHelper.webViewImpl()->setPageScaleFactor(scale);
+ webViewHelper.webViewImpl()->setPinchViewportOffset(pinchOffset);
+
+ WebRect baseRect;
+ WebRect extentRect;
+
+ WebRect rect;
+ mainFrame->firstRectForCharacterRange(0, 5, rect);
+
+ EXPECT_EQ((oldRect.x - pinchOffset.x) * scale, rect.x);
+ EXPECT_EQ((oldRect.y - pinchOffset.y) * scale, rect.y);
+ EXPECT_EQ(oldRect.width*scale, rect.width);
+ EXPECT_EQ(oldRect.height*scale, rect.height);
+}
+
TEST_F(WebFrameTest, DivScrollIntoEditablePreservePageScaleTest)
{
registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html");
« no previous file with comments | « Source/core/page/EventHandler.cpp ('k') | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698