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

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

Issue 2161373002: Make FrameCaret to retrieve caret position from SelectionEditor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-07-21T11:26:04 Created 4 years, 5 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 | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1924c0958e7ca057d898843d52897651fa9358a0..31aee794cdd7ee85c899f12e872794e9eb68a403 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelectionTest.cpp
@@ -9,6 +9,7 @@
#include "core/dom/Element.h"
#include "core/dom/Text.h"
#include "core/editing/EditingTestBase.h"
+#include "core/editing/FrameCaret.h"
#include "core/frame/FrameView.h"
#include "core/html/HTMLBodyElement.h"
#include "core/html/HTMLDocument.h"
@@ -39,6 +40,11 @@ protected:
bool shouldPaintCaretForTesting() const { return selection().shouldPaintCaretForTesting(); }
bool isPreviousCaretDirtyForTesting() const { return selection().isPreviousCaretDirtyForTesting(); }
+ PositionWithAffinity caretPosition() const
+ {
+ return selection().m_frameCaret->caretPosition();
+ }
+
private:
Persistent<Text> m_textNode;
};
@@ -273,4 +279,26 @@ TEST_F(FrameSelectionTest, SelectAllWithUnselectableRoot)
EXPECT_TRUE(selection().isNone()) << "Nothing should be selected if the content of the documentElement is not selctable.";
}
+TEST_F(FrameSelectionTest, updateIfNeededAndFrameCaret)
+{
+ setBodyContent("<style id=sample></style>");
+ document().setDesignMode("on");
+ Element* sample = document().getElementById("sample");
+ setSelection(VisibleSelection(Position(sample, 0)));
+ EXPECT_EQ(Position(document().body(), 0), selection().start());
+ EXPECT_EQ(selection().start(), caretPosition().position());
+ document().body()->remove();
+ // TODO(yosin): Once lazy canonicalization implemented, selection.start
+ // should be Position(HTML, 0).
+ EXPECT_EQ(Position(document().documentElement(), 1), selection().start());
+ EXPECT_EQ(selection().start(), caretPosition().position());
+ selection().updateIfNeeded();
+
+ // TODO(yosin): Once lazy canonicalization implemented, selection.start
+ // should be Position(HTML, 0).
+ EXPECT_EQ(Position(), selection().start())
+ << "updateIfNeeded() makes selection to null.";
+ EXPECT_EQ(selection().start(), caretPosition().position());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698