Chromium Code Reviews| Index: Source/web/tests/WebFrameTest.cpp |
| diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp |
| index e281bd954a983560bcb1e80e1e437be5d4da8318..b753516931181ddc61929bacbbcd71542c4454dc 100644 |
| --- a/Source/web/tests/WebFrameTest.cpp |
| +++ b/Source/web/tests/WebFrameTest.cpp |
| @@ -88,7 +88,6 @@ |
| #include "public/platform/Platform.h" |
| #include "public/platform/WebFloatRect.h" |
| #include "public/platform/WebSecurityOrigin.h" |
| -#include "public/platform/WebSelectionBound.h" |
| #include "public/platform/WebThread.h" |
| #include "public/platform/WebURL.h" |
| #include "public/platform/WebURLResponse.h" |
| @@ -106,6 +105,7 @@ |
| #include "public/web/WebScriptSource.h" |
| #include "public/web/WebSearchableFormData.h" |
| #include "public/web/WebSecurityPolicy.h" |
| +#include "public/web/WebSelection.h" |
| #include "public/web/WebSettings.h" |
| #include "public/web/WebSpellCheckClient.h" |
| #include "public/web/WebTextCheckingCompletion.h" |
| @@ -4199,16 +4199,14 @@ public: |
| virtual void setNeedsAnimate() override { } |
| virtual bool commitRequested() const override { return false; } |
| virtual void finishAllRendering() override { } |
| - virtual void registerSelection(const WebSelectionBound& start, const WebSelectionBound& end) override |
| + virtual void registerSelection(const WebSelection& selection) override |
| { |
| - m_start = adoptPtr(new WebSelectionBound(start)); |
| - m_end = adoptPtr(new WebSelectionBound(end)); |
| + m_selection = adoptPtr(new WebSelection(selection)); |
| } |
| virtual void clearSelection() override |
| { |
| m_selectionCleared = true; |
| - m_start.clear(); |
| - m_end.clear(); |
| + m_selection.clear(); |
| } |
| bool getAndResetSelectionCleared() |
| @@ -4218,13 +4216,13 @@ public: |
| return selectionCleared; |
| } |
| - const WebSelectionBound* start() const { return m_start.get(); } |
| - const WebSelectionBound* end() const { return m_end.get(); } |
| + const WebSelection* selection() const { return m_selection.get(); } |
| + const WebSelectionBound* start() const { return m_selection ? &m_selection->start() : nullptr; } |
| + const WebSelectionBound* end() const { return m_selection ? &m_selection->end() : nullptr; } |
| private: |
| bool m_selectionCleared; |
| - OwnPtr<WebSelectionBound> m_start; |
| - OwnPtr<WebSelectionBound> m_end; |
| + OwnPtr<WebSelection> m_selection; |
| }; |
| class CompositedSelectionBoundsTestWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| @@ -4258,39 +4256,54 @@ protected: |
| FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), m_baseURL + testFile); |
| m_webViewHelper.webView()->layout(); |
| + const WebSelection* selection = m_fakeSelectionLayerTreeView.selection(); |
| const WebSelectionBound* selectStart = m_fakeSelectionLayerTreeView.start(); |
| const WebSelectionBound* selectEnd = m_fakeSelectionLayerTreeView.end(); |
| v8::HandleScope handleScope(v8::Isolate::GetCurrent()); |
| v8::Handle<v8::Value> result = m_webViewHelper.webView()->mainFrame()->toWebLocalFrame()->executeScriptAndReturnValue(WebScriptSource("expectedResult")); |
| if (result.IsEmpty() || (*result)->IsUndefined()) { |
| + EXPECT_FALSE(selection); |
| EXPECT_FALSE(selectStart); |
| EXPECT_FALSE(selectEnd); |
| return; |
| } |
| + ASSERT_TRUE(selection); |
| ASSERT_TRUE(selectStart); |
| ASSERT_TRUE(selectEnd); |
| + EXPECT_FALSE(selection->isNone()); |
| + |
| ASSERT_TRUE((*result)->IsArray()); |
| v8::Array& expectedResult = *v8::Array::Cast(*result); |
| - ASSERT_EQ(10u, expectedResult.Length()); |
| + ASSERT_GE(expectedResult.Length(), 10u); |
| + |
| + // Platform differences can introduce small stylistic deviations in |
| + // y-axis positioning, the details of which aren't relevant to |
| + // selection behavior. |
| + const int yEpsilon = 2; |
|
yoichio
2015/03/31 05:05:06
Existing tests don't need this margin. What's the
jdduke (slow)
2015/03/31 15:09:23
That's what I asked last week, and nobody had a go
yoichio
2015/04/02 05:20:43
The variance is only on editable element, could yo
jdduke (slow)
2015/04/06 22:41:07
Done.
|
| blink::Node* layerOwnerNodeForStart = blink::V8Node::toImplWithTypeCheck(v8::Isolate::GetCurrent(), expectedResult.Get(0)); |
| ASSERT_TRUE(layerOwnerNodeForStart); |
| EXPECT_EQ(layerOwnerNodeForStart->layoutObject()->enclosingLayer()->enclosingLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(), selectStart->layerId); |
| EXPECT_EQ(expectedResult.Get(1)->Int32Value(), selectStart->edgeTopInLayer.x); |
| - EXPECT_EQ(expectedResult.Get(2)->Int32Value(), selectStart->edgeTopInLayer.y); |
| + EXPECT_NEAR(expectedResult.Get(2)->Int32Value(), selectStart->edgeTopInLayer.y, yEpsilon); |
|
yoichio
2015/04/02 05:20:43
Could you confirm this variance is same for each y
jdduke (slow)
2015/04/06 22:41:07
Done.
|
| EXPECT_EQ(expectedResult.Get(3)->Int32Value(), selectStart->edgeBottomInLayer.x); |
| - EXPECT_EQ(expectedResult.Get(4)->Int32Value(), selectStart->edgeBottomInLayer.y); |
| + EXPECT_NEAR(expectedResult.Get(4)->Int32Value(), selectStart->edgeBottomInLayer.y, yEpsilon); |
| blink::Node* layerOwnerNodeForEnd = blink::V8Node::toImplWithTypeCheck(v8::Isolate::GetCurrent(), expectedResult.Get(5)); |
| ASSERT_TRUE(layerOwnerNodeForEnd); |
| EXPECT_EQ(layerOwnerNodeForEnd->layoutObject()->enclosingLayer()->enclosingLayerForPaintInvalidation()->graphicsLayerBacking()->platformLayer()->id(), selectEnd->layerId); |
| EXPECT_EQ(expectedResult.Get(6)->Int32Value(), selectEnd->edgeTopInLayer.x); |
| - EXPECT_EQ(expectedResult.Get(7)->Int32Value(), selectEnd->edgeTopInLayer.y); |
| + EXPECT_NEAR(expectedResult.Get(7)->Int32Value(), selectEnd->edgeTopInLayer.y, yEpsilon); |
| EXPECT_EQ(expectedResult.Get(8)->Int32Value(), selectEnd->edgeBottomInLayer.x); |
| - EXPECT_EQ(expectedResult.Get(9)->Int32Value(), selectEnd->edgeBottomInLayer.y); |
| + EXPECT_NEAR(expectedResult.Get(9)->Int32Value(), selectEnd->edgeBottomInLayer.y, yEpsilon); |
| + |
| + if (expectedResult.Length() >= 12) { |
| + EXPECT_EQ(expectedResult.Get(10)->BooleanValue(), m_fakeSelectionLayerTreeView.selection()->isEditable()); |
| + EXPECT_EQ(expectedResult.Get(11)->BooleanValue(), m_fakeSelectionLayerTreeView.selection()->isEmptyTextFormControl()); |
| + } |
| } |
| void runTestWithMultipleFiles(const char* testFile, ...) |
| @@ -4316,7 +4329,10 @@ TEST_F(CompositedSelectionBoundsTest, SplitLayer) { runTest("composited_selectio |
| 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"); } |
| TEST_F(WebFrameTest, CompositedSelectionBoundsCleared) |
| { |