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

Unified Diff: third_party/WebKit/Source/core/editing/markers/EditingMarkerListTest.cpp

Issue 2772423002: Add EditingMarkerList in preparation for DocumentMarkerController refactor (Closed)
Patch Set: Remove explicit Created 3 years, 9 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/markers/EditingMarkerList.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/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..3f818fc9a642cee6806caa6c3149bf22e796ac3b
--- /dev/null
+++ b/third_party/WebKit/Source/core/editing/markers/EditingMarkerListTest.cpp
@@ -0,0 +1,60 @@
+// 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/EditingMarkerList.h"
+
+#include "platform/heap/Handle.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+class EditingMarkerListForTesting : public EditingMarkerList {
+ public:
+ DocumentMarker::MarkerType allowedMarkerType() const final {
+ return DocumentMarker::Composition;
+ }
+
+ bool markerListIsSortedPublicForTesting() const {
+ return markerListIsSorted();
+ }
+};
+
+class EditingMarkerListTest : public ::testing::Test {
+ protected:
+ EditingMarkerListTest() : m_markerList(new EditingMarkerListForTesting()) {}
+
+ DocumentMarker* createMarker(unsigned startOffset, unsigned endOffset) {
+ return new DocumentMarker(startOffset, endOffset, Color::black, false,
+ Color::black);
+ }
+
+ Persistent<EditingMarkerListForTesting> m_markerList;
+};
+
+TEST_F(EditingMarkerListTest, NewlyConstructedListIsSorted) {
+ EXPECT_TRUE(m_markerList->markerListIsSortedPublicForTesting());
+}
+
+TEST_F(EditingMarkerListTest, InsertingMarkersInSortedOrderKeepsListSorted) {
+ m_markerList->add(createMarker(1, 2));
+ m_markerList->add(createMarker(2, 3));
+ m_markerList->add(createMarker(3, 4));
+ EXPECT_TRUE(m_markerList->markerListIsSortedPublicForTesting());
+}
+
+TEST_F(EditingMarkerListTest, InsertingMarkersOutOfOrderMakesListUnsorted) {
+ m_markerList->add(createMarker(1, 2));
+ m_markerList->add(createMarker(0, 1));
+ EXPECT_FALSE(m_markerList->markerListIsSortedPublicForTesting());
+}
+
+TEST_F(EditingMarkerListTest, ClearingListMakesItSorted) {
+ m_markerList->add(createMarker(1, 2));
+ m_markerList->add(createMarker(0, 1));
+ EXPECT_FALSE(m_markerList->markerListIsSortedPublicForTesting());
+ m_markerList->clear();
+ EXPECT_TRUE(m_markerList->markerListIsSortedPublicForTesting());
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/markers/EditingMarkerList.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698