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

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

Issue 2875253002: Introduce Position::IsEquivalent() (Closed)
Patch Set: 2017-05-15T13:06:34 Created 3 years, 7 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/Position.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/PositionTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/PositionTest.cpp b/third_party/WebKit/Source/core/editing/PositionTest.cpp
index 2d947238f576820d96a6b3c037613b1eb98b87ff..f158bca8ff5a648489df1959f5ffcd986a331740 100644
--- a/third_party/WebKit/Source/core/editing/PositionTest.cpp
+++ b/third_party/WebKit/Source/core/editing/PositionTest.cpp
@@ -10,6 +10,33 @@ namespace blink {
class PositionTest : public EditingTestBase {};
+TEST_F(PositionTest, IsEquivalent) {
+ SetBodyContent("<a id=sample>0<b>1</b>2</a>");
+
+ Element* sample = GetDocument().getElementById("sample");
+
+ EXPECT_TRUE(Position(sample, 0).IsEquivalent(Position(sample, 0)));
+
+ EXPECT_TRUE(
+ Position(sample, 0).IsEquivalent(Position::FirstPositionInNode(sample)));
+ EXPECT_TRUE(Position(sample, 0).IsEquivalent(
+ Position::BeforeNode(sample->firstChild())));
+ EXPECT_TRUE(Position(sample, 1).IsEquivalent(
+ Position::AfterNode(sample->firstChild())));
+ EXPECT_TRUE(Position(sample, 1).IsEquivalent(
+ Position::BeforeNode(sample->firstChild()->nextSibling())));
+ EXPECT_TRUE(Position(sample, 2).IsEquivalent(
+ Position::BeforeNode(sample->lastChild())));
+ EXPECT_TRUE(Position(sample, 3).IsEquivalent(
+ Position::AfterNode(sample->lastChild())));
+ EXPECT_TRUE(
+ Position(sample, 3).IsEquivalent(Position::LastPositionInNode(sample)));
+
+ EXPECT_FALSE(Position(sample, 0).IsEquivalent(Position(sample, 1)));
+ EXPECT_FALSE(
+ Position(sample, 0).IsEquivalent(Position::LastPositionInNode(sample)));
+}
+
TEST_F(PositionTest, NodeAsRangeLastNodeNull) {
EXPECT_EQ(nullptr, Position().NodeAsRangeLastNode());
EXPECT_EQ(nullptr, PositionInFlatTree().NodeAsRangeLastNode());
« no previous file with comments | « third_party/WebKit/Source/core/editing/Position.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698