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

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

Issue 268363013: Text selection handles now take into account pinch viewport's offset. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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/WebViewImpl.cpp ('k') | Source/web/tests/data/pinch-viewport-input-field.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/PinchViewportTest.cpp
diff --git a/Source/web/tests/PinchViewportTest.cpp b/Source/web/tests/PinchViewportTest.cpp
index f1e6dbf93f491baf8625b21603e2f3adbac1e6ed..1558189c45f76218f83d38ab29b4df61c2e26e31 100644
--- a/Source/web/tests/PinchViewportTest.cpp
+++ b/Source/web/tests/PinchViewportTest.cpp
@@ -14,6 +14,7 @@
#include "public/platform/Platform.h"
#include "public/platform/WebLayerTreeView.h"
#include "public/platform/WebUnitTestSupport.h"
+#include "public/web/WebScriptSource.h"
#include "public/web/WebSettings.h"
#include "public/web/WebViewClient.h"
#include "web/WebLocalFrameImpl.h"
@@ -28,6 +29,12 @@
EXPECT_FLOAT_EQ((expected).y(), (actual).y()); \
} while (false)
+#define EXPECT_POINT_EQ(expected, actual) \
+ do { \
+ EXPECT_EQ((expected).x(), (actual).x()); \
+ EXPECT_EQ((expected).y(), (actual).y()); \
+ } while (false)
+
#define EXPECT_SIZE_EQ(expected, actual) \
do { \
EXPECT_EQ((expected).width(), (actual).width()); \
@@ -45,6 +52,7 @@
using namespace WebCore;
using namespace blink;
+using blink::FrameTestHelpers::runPendingTasks;
namespace {
@@ -88,6 +96,12 @@ public:
URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8(fileName.c_str()));
}
+ void executeScript(const WebString& code)
+ {
+ webViewImpl()->mainFrame()->executeScript(WebScriptSource(code));
+ runPendingTasks();
+ }
+
WebLayer* getRootScrollLayer()
{
RenderLayerCompositor* compositor = frame()->contentRenderer()->compositor();
@@ -430,4 +444,38 @@ TEST_F(PinchViewportTest, TestPinchViewportGetsSizeInAutoSizeMode)
EXPECT_SIZE_EQ(IntSize(200, 300), frame()->page()->frameHost().pinchViewport().size());
}
+// Test that the text selection handle's position accounts for the pinch viewport.
+TEST_F(PinchViewportTest, TestTextSelectionHandles)
+{
+ initializeWithDesktopSettings();
+ webViewImpl()->resize(IntSize(500, 800));
+
+ registerMockedHttpURLLoad("pinch-viewport-input-field.html");
+ navigateTo(m_baseURL + "pinch-viewport-input-field.html");
+
+ PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport();
+ webViewImpl()->setInitialFocus(false);
+
+ WebRect originalAnchor;
+ WebRect originalFocus;
+ webViewImpl()->selectionBounds(originalAnchor, originalFocus);
+
+ webViewImpl()->setPageScaleFactor(2);
+ pinchViewport.setLocation(FloatPoint(100, 400));
+
+ WebRect anchor;
+ WebRect focus;
+ webViewImpl()->selectionBounds(anchor, focus);
+
+ IntPoint expected(IntRect(originalAnchor).location());
+ expected.moveBy(-flooredIntPoint(pinchViewport.visibleRect().location()));
+ expected.scale(pinchViewport.scale(), pinchViewport.scale());
+
+ EXPECT_POINT_EQ(expected, IntRect(anchor).location());
+ EXPECT_POINT_EQ(expected, IntRect(focus).location());
+
+ // FIXME(bokan) - http://crbug.com/364154 - Figure out how to test text selection
+ // as well rather than just carret.
+}
+
} // namespace
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/data/pinch-viewport-input-field.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698