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

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

Issue 929213004: Plumb selection bounds as a single unit (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix test Created 5 years, 9 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: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index e59f84849535e532ae27398687b86437c9ca3e7c..f2e6a7504059f62b3acba1efa1f14334b37b4e62 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -87,7 +87,6 @@
#include "platform/weborigin/SecurityOrigin.h"
#include "public/platform/Platform.h"
#include "public/platform/WebFloatRect.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/WebSearchableFormData.h"
#include "public/web/WebSecurityOrigin.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"
@@ -4208,16 +4208,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()
@@ -4227,13 +4225,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 {
@@ -4267,23 +4265,28 @@ 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);
blink::Node* layerOwnerNodeForStart = blink::V8Node::toImplWithTypeCheck(v8::Isolate::GetCurrent(), expectedResult.Get(0));
ASSERT_TRUE(layerOwnerNodeForStart);
@@ -4300,6 +4303,11 @@ protected:
EXPECT_EQ(expectedResult.Get(7)->Int32Value(), selectEnd->edgeTopInLayer.y);
EXPECT_EQ(expectedResult.Get(8)->Int32Value(), selectEnd->edgeBottomInLayer.x);
EXPECT_EQ(expectedResult.Get(9)->Int32Value(), selectEnd->edgeBottomInLayer.y);
+
+ 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, ...)
@@ -4325,7 +4333,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)
{

Powered by Google App Engine
This is Rietveld 408576698