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

Unified Diff: third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp

Issue 2441573002: Move setNonDirectionalSelectionIfNeeded() to SelectionController from FrameSelection (Closed)
Patch Set: 2016-10-24T15:46:27 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/core/editing/FrameSelectionTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
index 84f8742a9e9a160a15598a52449c10d81c072c86..891f0d46ba890dd4a8b5d8c54ad405643bde8ef5 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
@@ -10,8 +10,10 @@
#include "core/dom/Text.h"
#include "core/editing/EditingTestBase.h"
#include "core/editing/FrameCaret.h"
+#include "core/editing/SelectionController.h"
#include "core/frame/FrameView.h"
#include "core/html/HTMLBodyElement.h"
+#include "core/input/EventHandler.h"
#include "core/layout/LayoutView.h"
#include "core/paint/PaintInfo.h"
#include "core/paint/PaintLayer.h"
@@ -273,7 +275,40 @@ TEST_F(FrameSelectionTest, MoveRangeSelectionTest) {
EXPECT_EQ_SELECTED_TEXT("Foo Bar");
}
-TEST_F(FrameSelectionTest, setNonDirectionalSelectionIfNeeded) {
+// TODO(yosin): We should move |SelectionControllerTest" to
+// "SelectionControllerTest.cpp"
+class SelectionControllerTest : public EditingTestBase {
+ protected:
+ SelectionControllerTest() = default;
+
+ const VisibleSelection& visibleSelectionInDOMTree() const {
+ return selection().selection();
+ }
+
+ const VisibleSelectionInFlatTree& visibleSelectionInFlatTree() const {
+ return selection().selectionInFlatTree();
+ }
+
+ void setNonDirectionalSelectionIfNeeded(const VisibleSelectionInFlatTree&,
+ TextGranularity);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SelectionControllerTest);
+};
+
+// TODO(yosin): We should move this function to "SelectionControllerTest.cpp"
+void SelectionControllerTest::setNonDirectionalSelectionIfNeeded(
+ const VisibleSelectionInFlatTree& newSelection,
+ TextGranularity granularity) {
+ frame()
+ .eventHandler()
+ .selectionController()
+ .setNonDirectionalSelectionIfNeeded(
+ newSelection, granularity, SelectionController::DoNotAdjustEndpoints);
+}
+
+// TODO(yosin): We should move this test to "SelectionControllerTest.cpp"
+TEST_F(SelectionControllerTest, setNonDirectionalSelectionIfNeeded) {
const char* bodyContent = "<span id=top>top</span><span id=host></span>";
const char* shadowContent = "<span id=bottom>bottom</span>";
setBodyContent(bodyContent);
@@ -284,7 +319,7 @@ TEST_F(FrameSelectionTest, setNonDirectionalSelectionIfNeeded) {
Node* host = document().getElementById("host");
// top to bottom
- selection().setNonDirectionalSelectionIfNeeded(
+ setNonDirectionalSelectionIfNeeded(
createVisibleSelection(SelectionInFlatTree::Builder()
.collapse(PositionInFlatTree(top, 1))
.extend(PositionInFlatTree(bottom, 3))
@@ -302,7 +337,7 @@ TEST_F(FrameSelectionTest, setNonDirectionalSelectionIfNeeded) {
EXPECT_EQ(PositionInFlatTree(bottom, 3), visibleSelectionInFlatTree().end());
// bottom to top
- selection().setNonDirectionalSelectionIfNeeded(
+ setNonDirectionalSelectionIfNeeded(
createVisibleSelection(SelectionInFlatTree::Builder()
.collapse(PositionInFlatTree(bottom, 3))
.extend(PositionInFlatTree(top, 1))

Powered by Google App Engine
This is Rietveld 408576698