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

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

Issue 2354893002: Introduce VisiblePosition::isValid (Closed)
Patch Set: Further fix compile... Created 4 years, 3 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/VisiblePositionTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp b/third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp
index 2b1baab6ed0e4bf2e136f5b2b41d7e6268fd9dc3..d9f21d60b2a9c50ee18c24ca503419049dd39e55 100644
--- a/third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp
+++ b/third_party/WebKit/Source/core/editing/VisiblePositionTest.cpp
@@ -36,4 +36,38 @@ TEST_F(VisiblePositionTest, ShadowV0DistributedNodes)
EXPECT_EQ(PositionInFlatTree(four->firstChild(), 2), createVisiblePosition(PositionInFlatTree(two, 0)).deepEquivalent());
}
+#if DCHECK_IS_ON()
+
+TEST_F(VisiblePositionTest, NullIsValid)
+{
+ EXPECT_TRUE(VisiblePosition().isValid());
+}
+
+TEST_F(VisiblePositionTest, NonNullIsValidInCleanTree)
+{
+ setBodyContent("<p>one</p>");
+
+ Element* paragraph = document().querySelector("p");
+ Position position(paragraph->firstChild(), 1);
+ EXPECT_TRUE(createVisiblePosition(position).isValid());
+}
+
+TEST_F(VisiblePositionTest, NonNullInvalidatedAfterMutation)
+{
+ setBodyContent("<p>one</p>");
+
+ Element* paragraph = document().querySelector("p");
+ Position position(paragraph->firstChild(), 1);
+ VisiblePosition nullVisiblePosition;
+ VisiblePosition nonNullVisiblePosition = createVisiblePosition(position);
+
+ Element* div = document().createElement("div", ASSERT_NO_EXCEPTION);
+ document().body()->appendChild(div);
+
+ EXPECT_TRUE(nullVisiblePosition.isValid());
+ EXPECT_FALSE(nonNullVisiblePosition.isValid());
+}
+
+#endif
yosin_UTC9 2016/09/20 13:55:51 Let's check "display" property change. Not sure ab
Xiaocheng 2016/09/21 06:31:49 Done.
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698