Index: third_party/WebKit/Source/core/editing/markers/EditingMarkerListTest.cpp |
diff --git a/third_party/WebKit/Source/core/editing/markers/EditingMarkerListTest.cpp b/third_party/WebKit/Source/core/editing/markers/EditingMarkerListTest.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..23f5725b41ebd08812f8a7162bbdefbf7cd8ac02 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/editing/markers/EditingMarkerListTest.cpp |
@@ -0,0 +1,517 @@ |
+// Copyright 2017 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/markers/CompositionMarkerList.h" |
+ |
+#include "core/dom/Document.h" |
+#include "core/editing/markers/DocumentMarkerController.h" |
+#include "core/testing/DummyPageHolder.h" |
+#include "platform/heap/Handle.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace blink { |
+ |
+template <typename EditingMarkerListType> |
+class EditingMarkerListTest : public ::testing::Test { |
Xiaocheng
2017/03/24 19:43:49
With DML independent from DMC, the unit test can b
|
+ protected: |
+ EditingMarkerListTest() |
+ : m_dummyPageHolder(DummyPageHolder::create(IntSize(800, 600))), |
+ m_markerList(new EditingMarkerListType(&markerController())) {} |
+ |
+ Document& document() const { return m_dummyPageHolder->document(); } |
+ DocumentMarkerController& markerController() const { |
+ return document().markers(); |
+ } |
+ |
+ void setBodyInnerHTML(const char* bodyContent) { |
+ document().body()->setInnerHTML(String::fromUTF8(bodyContent)); |
+ } |
+ |
+ DocumentMarker* createMarker(unsigned startOffset, unsigned endOffset) { |
+ return new DocumentMarker(startOffset, endOffset, Color::black, false, |
+ Color::black); |
+ } |
+ |
+ private: |
+ std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
+ |
+ protected: |
+ // must be listed after m_dummyPageHolder so it can be initialized later |
+ Persistent<EditingMarkerListType> m_markerList; |
+}; |
+ |
+TYPED_TEST_CASE_P(EditingMarkerListTest); |
+ |
+TYPED_TEST_P(EditingMarkerListTest, Insert) { |
+ this->m_markerList->insert(this->createMarker(1, 2)); |
+ this->m_markerList->insert(this->createMarker(2, 3)); |
+ this->m_markerList->insert(this->createMarker(3, 4)); |
+ this->m_markerList->insert(this->createMarker(0, 1)); |
+ |
+ EXPECT_EQ(4u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(1u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(2u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(2u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(3u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(3u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(4u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(1u, this->m_markerList->at(3)->endOffset()); |
+} |
+ |
+TYPED_TEST_P(EditingMarkerListTest, |
+ RemoveMarkersSortedDoRemovePartiallyOverlapping) { |
+ this->m_markerList->insert(this->createMarker(0, 5)); |
+ this->m_markerList->insert(this->createMarker(5, 10)); |
+ this->m_markerList->insert(this->createMarker(10, 15)); |
+ this->m_markerList->insert(this->createMarker(15, 20)); |
+ this->m_markerList->insert(this->createMarker(20, 25)); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->size()); |
+ |
+ bool didRemoveMarker = false; |
+ |
+ // test no-op remove |
+ this->m_markerList->removeMarkers(100, 100, true, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, false); |
+ EXPECT_EQ(5u, this->m_markerList->size()); |
+ |
+ // remove middle marker |
+ this->m_markerList->removeMarkers(10, 2, true, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, true); |
+ EXPECT_EQ(4u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(10u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(15u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(20u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(3)->endOffset()); |
+ |
+ // remove middle two markers |
+ didRemoveMarker = false; |
+ this->m_markerList->removeMarkers(7, 9, true, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, true); |
+ EXPECT_EQ(2u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(1)->endOffset()); |
+} |
+ |
+TYPED_TEST_P(EditingMarkerListTest, |
+ RemoveMarkersUnsortedDoRemovePartiallyOverlapping) { |
+ this->m_markerList->insert(this->createMarker(20, 25)); |
+ this->m_markerList->insert(this->createMarker(15, 20)); |
+ this->m_markerList->insert(this->createMarker(10, 15)); |
+ this->m_markerList->insert(this->createMarker(5, 10)); |
+ this->m_markerList->insert(this->createMarker(0, 5)); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->size()); |
+ |
+ bool didRemoveMarker = false; |
+ |
+ // test no-op remove |
+ this->m_markerList->removeMarkers(100, 100, true, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, false); |
+ EXPECT_EQ(5u, this->m_markerList->size()); |
+ |
+ // remove middle marker |
+ this->m_markerList->removeMarkers(10, 2, true, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, true); |
+ EXPECT_EQ(4u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(15u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(20u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(10u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(3)->endOffset()); |
+ |
+ // remove middle two markers |
+ didRemoveMarker = false; |
+ this->m_markerList->removeMarkers(7, 9, true, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, true); |
+ EXPECT_EQ(2u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(1)->endOffset()); |
+} |
+ |
+TYPED_TEST_P(EditingMarkerListTest, |
+ RemoveMarkersSortedDontRemovePartiallyOverlapping) { |
+ this->m_markerList->insert(this->createMarker(0, 5)); |
+ this->m_markerList->insert(this->createMarker(5, 10)); |
+ this->m_markerList->insert(this->createMarker(10, 15)); |
+ this->m_markerList->insert(this->createMarker(15, 20)); |
+ this->m_markerList->insert(this->createMarker(20, 25)); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->size()); |
+ |
+ bool didRemoveMarker = false; |
+ |
+ // test no-op remove |
+ this->m_markerList->removeMarkers(100, 100, false, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, false); |
+ EXPECT_EQ(5u, this->m_markerList->size()); |
+ |
+ // remove chunk from beginning of middle marker |
+ this->m_markerList->removeMarkers(10, 2, false, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, true); |
+ EXPECT_EQ(5u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(10u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(12u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(15u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(15u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(20u, this->m_markerList->at(3)->endOffset()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(4)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(4)->endOffset()); |
+ |
+ // remove chunk from end of second marker |
+ didRemoveMarker = false; |
+ this->m_markerList->removeMarkers(8, 2, false, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, true); |
+ EXPECT_EQ(5u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(8u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(12u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(15u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(15u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(20u, this->m_markerList->at(3)->endOffset()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(4)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(4)->endOffset()); |
+ |
+ // remove chunk from middle of fourth marker |
+ didRemoveMarker = false; |
+ this->m_markerList->removeMarkers(16, 1, false, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, true); |
+ EXPECT_EQ(6u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(8u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(12u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(15u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(15u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(16u, this->m_markerList->at(3)->endOffset()); |
+ |
+ EXPECT_EQ(17u, this->m_markerList->at(4)->startOffset()); |
+ EXPECT_EQ(20u, this->m_markerList->at(4)->endOffset()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(5)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(5)->endOffset()); |
+ |
+ // remove middle four markers |
+ didRemoveMarker = false; |
+ this->m_markerList->removeMarkers(5, 15, false, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, true); |
+ EXPECT_EQ(2u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(1)->endOffset()); |
+} |
+ |
+TYPED_TEST_P(EditingMarkerListTest, |
+ RemoveMarkersUnsortedDontRemovePartiallyOverlapping) { |
+ this->m_markerList->insert(this->createMarker(20, 25)); |
+ this->m_markerList->insert(this->createMarker(15, 20)); |
+ this->m_markerList->insert(this->createMarker(10, 15)); |
+ this->m_markerList->insert(this->createMarker(5, 10)); |
+ this->m_markerList->insert(this->createMarker(0, 5)); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->size()); |
+ |
+ bool didRemoveMarker = false; |
+ |
+ // test no-op remove |
+ this->m_markerList->removeMarkers(100, 100, false, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, false); |
+ EXPECT_EQ(5u, this->m_markerList->size()); |
+ |
+ // remove chunk from beginning of middle marker |
+ this->m_markerList->removeMarkers(10, 2, false, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, true); |
+ EXPECT_EQ(5u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(15u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(20u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(10u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(3)->endOffset()); |
+ |
+ EXPECT_EQ(12u, this->m_markerList->at(4)->startOffset()); |
+ EXPECT_EQ(15u, this->m_markerList->at(4)->endOffset()); |
+ |
+ // remove chunk from end of middle marker |
+ didRemoveMarker = false; |
+ this->m_markerList->removeMarkers(8, 2, false, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, true); |
+ EXPECT_EQ(5u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(15u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(20u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(12u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(15u, this->m_markerList->at(3)->endOffset()); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->at(4)->startOffset()); |
+ EXPECT_EQ(8u, this->m_markerList->at(4)->endOffset()); |
+ |
+ // remove chunk from middle of second marker |
+ didRemoveMarker = false; |
+ this->m_markerList->removeMarkers(16, 1, false, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, true); |
+ EXPECT_EQ(6u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(12u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(15u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(8u, this->m_markerList->at(3)->endOffset()); |
+ |
+ EXPECT_EQ(15u, this->m_markerList->at(4)->startOffset()); |
+ EXPECT_EQ(16u, this->m_markerList->at(4)->endOffset()); |
+ |
+ EXPECT_EQ(17u, this->m_markerList->at(5)->startOffset()); |
+ EXPECT_EQ(20u, this->m_markerList->at(5)->endOffset()); |
+ |
+ // remove all markers except 0 to 5 and 20 to 25 |
+ didRemoveMarker = false; |
+ this->m_markerList->removeMarkers(5, 15, false, &didRemoveMarker); |
+ EXPECT_EQ(didRemoveMarker, true); |
+ EXPECT_EQ(2u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(1)->endOffset()); |
+} |
+ |
+TYPED_TEST_P(EditingMarkerListTest, ShiftMarkersDeletions) { |
+ this->m_markerList->insert(this->createMarker(0, 5)); |
+ this->m_markerList->insert(this->createMarker(5, 10)); |
+ this->m_markerList->insert(this->createMarker(10, 15)); |
+ this->m_markerList->insert(this->createMarker(15, 20)); |
+ this->m_markerList->insert(this->createMarker(20, 25)); |
+ // delete end of second marker, entirety of third marker, and start of fourth |
+ // marker |
+ this->m_markerList->shiftMarkers(8, 9, 0); |
+ |
+ EXPECT_EQ(4u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(8u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(8u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(11u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(11u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(16u, this->m_markerList->at(3)->endOffset()); |
+ |
+ this->m_markerList->clear(); |
+ this->m_markerList->insert(this->createMarker(5, 10)); |
+ // delete exactly on a marker |
+ this->m_markerList->shiftMarkers(5, 5, 0); |
+ EXPECT_EQ(0u, this->m_markerList->size()); |
+ |
+ this->m_markerList->insert(this->createMarker(5, 10)); |
+ // delete middle of marker |
+ this->m_markerList->shiftMarkers(6, 3, 0); |
+ EXPECT_EQ(1u, this->m_markerList->size()); |
+ EXPECT_EQ(5u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(7u, this->m_markerList->at(0)->endOffset()); |
+} |
+ |
+TYPED_TEST_P(EditingMarkerListTest, ShiftMarkersInsertions) { |
+ this->m_markerList->insert(this->createMarker(0, 5)); |
+ this->m_markerList->insert(this->createMarker(5, 10)); |
+ this->m_markerList->insert(this->createMarker(10, 15)); |
+ // insert in middle of second marker |
+ this->m_markerList->shiftMarkers(7, 0, 5); |
+ |
+ EXPECT_EQ(3u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(15u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(15u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(20u, this->m_markerList->at(2)->endOffset()); |
+ |
+ // insert between first and second markers |
+ this->m_markerList->shiftMarkers(5, 0, 5); |
+ |
+ EXPECT_EQ(3u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(10u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(20u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(20u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(25u, this->m_markerList->at(2)->endOffset()); |
+} |
+ |
+TYPED_TEST_P(EditingMarkerListTest, ShiftMarkersReplacements) { |
+ this->m_markerList->insert(this->createMarker(0, 5)); |
+ this->m_markerList->insert(this->createMarker(5, 10)); |
+ this->m_markerList->insert(this->createMarker(10, 15)); |
+ this->m_markerList->insert(this->createMarker(15, 20)); |
+ this->m_markerList->insert(this->createMarker(20, 25)); |
+ |
+ // Replace entirely of third marker and portions of second and fourth |
+ this->m_markerList->shiftMarkers(7, 11, 1); |
+ |
+ EXPECT_EQ(4u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(5u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(5u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(7u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(8u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(10u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(10u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(15u, this->m_markerList->at(3)->endOffset()); |
+ |
+ // Replace end of first marker |
+ this->m_markerList->shiftMarkers(3, 2, 1); |
+ |
+ EXPECT_EQ(4u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(4u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(4u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(6u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(7u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(9u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(9u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(14u, this->m_markerList->at(3)->endOffset()); |
+ |
+ // Replace beginning of fourth marker |
+ this->m_markerList->shiftMarkers(9, 2, 1); |
+ |
+ EXPECT_EQ(4u, this->m_markerList->size()); |
+ |
+ EXPECT_EQ(0u, this->m_markerList->at(0)->startOffset()); |
+ EXPECT_EQ(4u, this->m_markerList->at(0)->endOffset()); |
+ |
+ EXPECT_EQ(4u, this->m_markerList->at(1)->startOffset()); |
+ EXPECT_EQ(6u, this->m_markerList->at(1)->endOffset()); |
+ |
+ EXPECT_EQ(7u, this->m_markerList->at(2)->startOffset()); |
+ EXPECT_EQ(9u, this->m_markerList->at(2)->endOffset()); |
+ |
+ EXPECT_EQ(9u, this->m_markerList->at(3)->startOffset()); |
+ EXPECT_EQ(13u, this->m_markerList->at(3)->endOffset()); |
+} |
+ |
+TYPED_TEST_P(EditingMarkerListTest, CopyMarkers) { |
+ this->setBodyInnerHTML("<div>012</div>"); |
+ Element* div = toElement(this->document().body()->firstChild()); |
+ |
+ this->m_markerList->insert(this->createMarker(0, 1)); |
+ this->m_markerList->insert(this->createMarker(1, 2)); |
+ this->m_markerList->insert(this->createMarker(2, 3)); |
+ this->m_markerList->insert(this->createMarker(3, 4)); |
+ |
+ this->m_markerList->copyMarkers(1, 3, div, -1); |
+ |
+ EXPECT_EQ(2u, this->markerController().markers().size()); |
+ |
+ EXPECT_EQ(0u, this->markerController().markers()[0]->startOffset()); |
+ EXPECT_EQ(1u, this->markerController().markers()[0]->endOffset()); |
+ |
+ EXPECT_EQ(1u, this->markerController().markers()[1]->startOffset()); |
+ EXPECT_EQ(2u, this->markerController().markers()[1]->endOffset()); |
+} |
+ |
+REGISTER_TYPED_TEST_CASE_P(EditingMarkerListTest, |
+ Insert, |
+ RemoveMarkersSortedDoRemovePartiallyOverlapping, |
+ RemoveMarkersUnsortedDoRemovePartiallyOverlapping, |
+ RemoveMarkersSortedDontRemovePartiallyOverlapping, |
+ RemoveMarkersUnsortedDontRemovePartiallyOverlapping, |
+ ShiftMarkersDeletions, |
+ ShiftMarkersInsertions, |
+ ShiftMarkersReplacements, |
+ CopyMarkers); |
+ |
+typedef ::testing::Types<CompositionMarkerList> TestConfigs; |
+INSTANTIATE_TYPED_TEST_CASE_P(EditingMarkerList, |
+ EditingMarkerListTest, |
+ TestConfigs); |
+ |
+} // namespace blink |