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

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

Issue 2123893002: Introduce class RelocatablePosition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add CORE_EXPORT 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/RelocatablePosition.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/RelocatablePositionTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/RelocatablePositionTest.cpp b/third_party/WebKit/Source/core/editing/RelocatablePositionTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..11a71b534e44ffe437de9119adb8e80fdc1f5979
--- /dev/null
+++ b/third_party/WebKit/Source/core/editing/RelocatablePositionTest.cpp
@@ -0,0 +1,32 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/editing/RelocatablePosition.h"
+
+#include "core/editing/EditingTestBase.h"
+#include "core/editing/VisiblePosition.h"
+
+namespace blink {
+
+class RelocatablePositionTest : public EditingTestBase {
+};
+
+TEST_F(RelocatablePositionTest, position)
+{
+ setBodyContent("<b>foo</b><textarea>bar</textarea>");
+ Node* boldface = document().querySelector("b", ASSERT_NO_EXCEPTION);
+ Node* textarea = document().querySelector("textarea", ASSERT_NO_EXCEPTION);
+
+ RelocatablePosition relocatablePosition(Position(textarea, PositionAnchorType::BeforeAnchor));
+ textarea->remove();
+
+ // RelocatablePosition should track the given Position even if its original
+ // anchor node is moved away from the document.
+ Position expectedPosition(boldface, PositionAnchorType::AfterAnchor);
+ Position trackedPosition = relocatablePosition.position();
+ EXPECT_TRUE(trackedPosition.anchorNode()->inShadowIncludingDocument());
+ EXPECT_EQ(createVisiblePosition(expectedPosition).deepEquivalent(), createVisiblePosition(trackedPosition).deepEquivalent());
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/RelocatablePosition.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698