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

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

Issue 2201853002: Blink handle selection handle visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format Created 4 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
Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
index 515c9b2a1e4d61e72e8d90727a2a550008b922e5..b2a40a40283204821884064007ca4161f34f7095 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp
@@ -5331,7 +5331,7 @@ class CompositedSelectionBoundsTest : public WebFrameTest {
m_webViewHelper.resize(WebSize(640, 480));
}
- void runTest(const char* testFile) {
+ void runTestWithNoSelection(const char* testFile) {
registerMockedHttpURLLoad(testFile);
m_webViewHelper.webView()->setFocus(true);
FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(),
@@ -5342,16 +5342,86 @@ class CompositedSelectionBoundsTest : public WebFrameTest {
const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.start();
const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end();
+ EXPECT_FALSE(selection);
+ EXPECT_FALSE(selectStart);
+ EXPECT_FALSE(selectEnd);
+ }
+
+ void runTest(const char* testFile) {
+ registerMockedHttpURLLoad(testFile);
+ m_webViewHelper.webView()->setFocus(true);
+ FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(),
+ m_baseURL + testFile);
+ m_webViewHelper.webView()->updateAllLifecyclePhases();
+
v8::HandleScope handleScope(v8::Isolate::GetCurrent());
v8::Local<v8::Value> result =
m_webViewHelper.webView()->mainFrameImpl()->executeScriptAndReturnValue(
WebScriptSource("expectedResult"));
- if (result.IsEmpty() || (*result)->IsUndefined()) {
- EXPECT_FALSE(selection);
- EXPECT_FALSE(selectStart);
- EXPECT_FALSE(selectEnd);
- return;
- }
+ ASSERT_FALSE(result.IsEmpty() || (*result)->IsUndefined());
+
+ ASSERT_TRUE((*result)->IsArray());
+ v8::Array& expectedResult = *v8::Array::Cast(*result);
+ ASSERT_GE(expectedResult.Length(), 10u);
+
+ v8::Local<v8::Context> context =
+ v8::Isolate::GetCurrent()->GetCurrentContext();
+
+ int startEdgeTopInLayerX = expectedResult.Get(context, 1)
yosin_UTC9 2016/10/19 06:33:05 nit:s/int/const int/
amaralp 2016/10/21 03:47:19 Done.
+ .ToLocalChecked()
+ .As<v8::Int32>()
+ ->Value();
+ int startEdgeTopInLayerY = expectedResult.Get(context, 2)
yosin_UTC9 2016/10/19 06:33:05 nit:s/int/const int/
amaralp 2016/10/21 03:47:19 Done.
+ .ToLocalChecked()
+ .As<v8::Int32>()
+ ->Value();
+ int startEdgeBottomInLayerX = expectedResult.Get(context, 3)
yosin_UTC9 2016/10/19 06:33:05 nit:s/int/const int/
amaralp 2016/10/21 03:47:19 Done.
+ .ToLocalChecked()
+ .As<v8::Int32>()
+ ->Value();
+ int startEdgeBottomInLayerY = expectedResult.Get(context, 4)
yosin_UTC9 2016/10/19 06:33:05 nit:s/int/const int/
amaralp 2016/10/21 03:47:19 Done.
+ .ToLocalChecked()
+ .As<v8::Int32>()
+ ->Value();
+
+ int endEdgeTopInLayerX = expectedResult.Get(context, 6)
yosin_UTC9 2016/10/19 06:33:05 nit:s/int/const int/
amaralp 2016/10/21 03:47:19 Done.
+ .ToLocalChecked()
+ .As<v8::Int32>()
+ ->Value();
+ int endEdgeTopInLayerY = expectedResult.Get(context, 7)
yosin_UTC9 2016/10/19 06:33:05 nit:s/int/const int/
amaralp 2016/10/21 03:47:19 Done.
+ .ToLocalChecked()
+ .As<v8::Int32>()
+ ->Value();
+ int endEdgeBottomInLayerX = expectedResult.Get(context, 8)
yosin_UTC9 2016/10/19 06:33:05 nit:s/int/const int/
amaralp 2016/10/21 03:47:19 Done.
+ .ToLocalChecked()
+ .As<v8::Int32>()
+ ->Value();
+ int endEdgeBottomInLayerY = expectedResult.Get(context, 9)
yosin_UTC9 2016/10/19 06:33:05 nit:s/int/const int/
amaralp 2016/10/21 03:47:19 Done.
+ .ToLocalChecked()
+ .As<v8::Int32>()
+ ->Value();
+
+ IntPoint hitPoint =
yosin_UTC9 2016/10/19 06:33:05 nit:s/IntPoint/const IntPoint/
amaralp 2016/10/21 03:47:19 Done.
+ IntPoint((startEdgeTopInLayerX + startEdgeBottomInLayerX +
+ endEdgeTopInLayerX + endEdgeBottomInLayerX) /
+ 4,
+ (startEdgeTopInLayerY + startEdgeBottomInLayerY +
+ endEdgeTopInLayerY + endEdgeBottomInLayerY) /
+ 4 +
+ 3);
+
+ PlatformGestureEvent gestureEvent(
+ PlatformEvent::EventType::GestureTap, hitPoint, hitPoint, IntSize(0, 0),
+ 0, PlatformEvent::NoModifiers, PlatformGestureSourceTouchscreen);
+ m_webViewHelper.webView()
+ ->mainFrameImpl()
+ ->frame()
+ ->eventHandler()
+ .handleGestureEvent(gestureEvent);
+
+ const WebSelection* selection = m_fakeSelectionLayerTreeView.selection();
+ const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.start();
+ const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end();
ASSERT_TRUE(selection);
ASSERT_TRUE(selectStart);
@@ -5359,10 +5429,6 @@ class CompositedSelectionBoundsTest : public WebFrameTest {
EXPECT_FALSE(selection->isNone());
- ASSERT_TRUE((*result)->IsArray());
- v8::Array& expectedResult = *v8::Array::Cast(*result);
- ASSERT_GE(expectedResult.Length(), 10u);
-
blink::Node* layerOwnerNodeForStart = V8Node::toImplWithTypeCheck(
v8::Isolate::GetCurrent(), expectedResult.Get(0));
ASSERT_TRUE(layerOwnerNodeForStart);
@@ -5373,23 +5439,10 @@ class CompositedSelectionBoundsTest : public WebFrameTest {
->platformLayer()
->id(),
selectStart->layerId);
- v8::Local<v8::Context> context =
- v8::Isolate::GetCurrent()->GetCurrentContext();
- EXPECT_EQ(expectedResult.Get(context, 1)
- .ToLocalChecked()
- .As<v8::Int32>()
- ->Value(),
- selectStart->edgeTopInLayer.x);
- EXPECT_EQ(expectedResult.Get(context, 2)
- .ToLocalChecked()
- .As<v8::Int32>()
- ->Value(),
- selectStart->edgeTopInLayer.y);
- EXPECT_EQ(expectedResult.Get(context, 3)
- .ToLocalChecked()
- .As<v8::Int32>()
- ->Value(),
- selectStart->edgeBottomInLayer.x);
+
+ EXPECT_EQ(startEdgeTopInLayerX, selectStart->edgeTopInLayer.x);
+ EXPECT_EQ(startEdgeTopInLayerY, selectStart->edgeTopInLayer.y);
+ EXPECT_EQ(startEdgeBottomInLayerX, selectStart->edgeBottomInLayer.x);
blink::Node* layerOwnerNodeForEnd = V8Node::toImplWithTypeCheck(
v8::Isolate::GetCurrent(),
@@ -5403,21 +5456,10 @@ class CompositedSelectionBoundsTest : public WebFrameTest {
->platformLayer()
->id(),
selectEnd->layerId);
- EXPECT_EQ(expectedResult.Get(context, 6)
- .ToLocalChecked()
- .As<v8::Int32>()
- ->Value(),
- selectEnd->edgeTopInLayer.x);
- EXPECT_EQ(expectedResult.Get(context, 7)
- .ToLocalChecked()
- .As<v8::Int32>()
- ->Value(),
- selectEnd->edgeTopInLayer.y);
- EXPECT_EQ(expectedResult.Get(context, 8)
- .ToLocalChecked()
- .As<v8::Int32>()
- ->Value(),
- selectEnd->edgeBottomInLayer.x);
+
+ EXPECT_EQ(endEdgeTopInLayerX, selectEnd->edgeTopInLayer.x);
+ EXPECT_EQ(endEdgeTopInLayerY, selectEnd->edgeTopInLayer.y);
+ EXPECT_EQ(endEdgeBottomInLayerX, selectEnd->edgeBottomInLayer.x);
// Platform differences can introduce small stylistic deviations in
// y-axis positioning, the details of which aren't relevant to
@@ -5429,17 +5471,11 @@ class CompositedSelectionBoundsTest : public WebFrameTest {
.ToLocalChecked()
.As<v8::Int32>()
->Value();
- int yBottomDeviation = expectedResult.Get(context, 4)
- .ToLocalChecked()
- .As<v8::Int32>()
- ->Value() -
- selectStart->edgeBottomInLayer.y;
+ int yBottomDeviation =
+ startEdgeBottomInLayerY - selectStart->edgeBottomInLayer.y;
EXPECT_GE(yBottomEpsilon, std::abs(yBottomDeviation));
- EXPECT_EQ(yBottomDeviation, expectedResult.Get(context, 9)
- .ToLocalChecked()
- .As<v8::Int32>()
- ->Value() -
- selectEnd->edgeBottomInLayer.y);
+ EXPECT_EQ(yBottomDeviation,
+ endEdgeBottomInLayerY - selectEnd->edgeBottomInLayer.y);
if (expectedResult.Length() >= 12) {
EXPECT_EQ(expectedResult.Get(context, 10)
@@ -5472,11 +5508,16 @@ class CompositedSelectionBoundsTest : public WebFrameTest {
};
TEST_F(CompositedSelectionBoundsTest, None) {
- runTest("composited_selection_bounds_none.html");
+ runTestWithNoSelection("composited_selection_bounds_none.html");
}
TEST_F(CompositedSelectionBoundsTest, NoneReadonlyCaret) {
- runTest("composited_selection_bounds_none_readonly_caret.html");
+ runTestWithNoSelection(
+ "composited_selection_bounds_none_readonly_caret.html");
}
+TEST_F(CompositedSelectionBoundsTest, DetachedFrame) {
+ runTestWithNoSelection("composited_selection_bounds_detached_frame.html");
+}
+
TEST_F(CompositedSelectionBoundsTest, Basic) {
runTest("composited_selection_bounds_basic.html");
}
@@ -5492,96 +5533,16 @@ TEST_F(CompositedSelectionBoundsTest, VerticalLeftToRight) {
TEST_F(CompositedSelectionBoundsTest, SplitLayer) {
runTest("composited_selection_bounds_split_layer.html");
}
-TEST_F(CompositedSelectionBoundsTest, EmptyLayer) {
- runTest("composited_selection_bounds_empty_layer.html");
-}
TEST_F(CompositedSelectionBoundsTest, Iframe) {
runTestWithMultipleFiles("composited_selection_bounds_iframe.html",
"composited_selection_bounds_basic.html", nullptr);
}
-TEST_F(CompositedSelectionBoundsTest, DetachedFrame) {
- runTest("composited_selection_bounds_detached_frame.html");
-}
TEST_F(CompositedSelectionBoundsTest, Editable) {
runTest("composited_selection_bounds_editable.html");
}
TEST_F(CompositedSelectionBoundsTest, EditableDiv) {
runTest("composited_selection_bounds_editable_div.html");
}
-TEST_F(CompositedSelectionBoundsTest, EmptyEditableInput) {
- runTest("composited_selection_bounds_empty_editable_input.html");
-}
-TEST_F(CompositedSelectionBoundsTest, EmptyEditableArea) {
- runTest("composited_selection_bounds_empty_editable_area.html");
-}
-
-// Fails on Mac ASan 64 bot. https://crbug.com/588769.
-#if OS(MACOSX) && defined(ADDRESS_SANITIZER)
-TEST_P(ParameterizedWebFrameTest, DISABLED_CompositedSelectionBoundsCleared)
-#else
-TEST_P(ParameterizedWebFrameTest, CompositedSelectionBoundsCleared)
-#endif
-{
- RuntimeEnabledFeatures::setCompositedSelectionUpdateEnabled(true);
-
- registerMockedHttpURLLoad("select_range_basic.html");
- registerMockedHttpURLLoad("select_range_scroll.html");
-
- int viewWidth = 500;
- int viewHeight = 500;
-
- CompositedSelectionBoundsTestWebViewClient fakeSelectionWebViewClient;
- CompositedSelectionBoundsTestLayerTreeView& fakeSelectionLayerTreeView =
- fakeSelectionWebViewClient.selectionLayerTreeView();
-
- FrameTestHelpers::WebViewHelper webViewHelper;
- webViewHelper.initialize(true, nullptr, &fakeSelectionWebViewClient, nullptr);
- webViewHelper.webView()->settings()->setDefaultFontSize(12);
- webViewHelper.webView()->setDefaultPageScaleLimits(1, 1);
- webViewHelper.resize(WebSize(viewWidth, viewHeight));
- webViewHelper.webView()->setFocus(true);
- FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(),
- m_baseURL + "select_range_basic.html");
-
- // The frame starts with no selection.
- WebLocalFrame* frame = webViewHelper.webView()->mainFrameImpl();
- ASSERT_TRUE(frame->hasSelection());
- EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
-
- // The selection cleared notification should be triggered upon layout.
- frame->executeCommand(WebString::fromUTF8("Unselect"));
- ASSERT_FALSE(frame->hasSelection());
- EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
- webViewHelper.webView()->updateAllLifecyclePhases();
- EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
-
- frame->executeCommand(WebString::fromUTF8("SelectAll"));
- webViewHelper.webView()->updateAllLifecyclePhases();
- ASSERT_TRUE(frame->hasSelection());
- EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
-
- FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(),
- m_baseURL + "select_range_scroll.html");
- ASSERT_TRUE(frame->hasSelection());
- EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
-
- // Transitions between non-empty selections should not trigger a clearing.
- WebRect startWebRect;
- WebRect endWebRect;
- webViewHelper.webView()->selectionBounds(startWebRect, endWebRect);
- WebPoint movedEnd(bottomRightMinusOne(endWebRect));
- endWebRect.x -= 20;
- frame->selectRange(topLeft(startWebRect), movedEnd);
- webViewHelper.webView()->updateAllLifecyclePhases();
- ASSERT_TRUE(frame->hasSelection());
- EXPECT_FALSE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
-
- frame = webViewHelper.webView()->mainFrameImpl();
- frame->executeCommand(WebString::fromUTF8("Unselect"));
- webViewHelper.webView()->updateAllLifecyclePhases();
- ASSERT_FALSE(frame->hasSelection());
- EXPECT_TRUE(fakeSelectionLayerTreeView.getAndResetSelectionCleared());
-}
class DisambiguationPopupTestWebViewClient
: public FrameTestHelpers::TestWebViewClient {

Powered by Google App Engine
This is Rietveld 408576698