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

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

Issue 2773883003: Add CompositionMarkerList in preparation for DocumentMarkerController refactor (Closed)
Patch Set: Make requested changes, refactor tests 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
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..8a4c7ceb154330fc2fc361a3d821549fb839a2d5
--- /dev/null
+++ b/third_party/WebKit/Source/core/editing/markers/EditingMarkerListTest.cpp
@@ -0,0 +1,61 @@
+// 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, PushBack) {
+ m_markerList->push_back(createMarker(1, 2));
+ m_markerList->push_back(createMarker(2, 3));
+ m_markerList->push_back(createMarker(3, 4));
+ EXPECT_EQ(true, m_markerList->markerListIsSortedPublicForTesting());
+ m_markerList->push_back(createMarker(0, 1));
+ EXPECT_EQ(false, m_markerList->markerListIsSortedPublicForTesting());
+
+ // The default implementation of push_back() for EditingMarkerList does not
Xiaocheng 2017/03/25 00:05:35 No need to check the content of the list, as Editi
+ // merge touching markers, and we verify this behavior here. However,
+ // some subclasses may have different behavior.
+ EXPECT_EQ(4u, m_markerList->size());
+
+ EXPECT_EQ(1u, m_markerList->at(0)->startOffset());
+ EXPECT_EQ(2u, m_markerList->at(0)->endOffset());
+
+ EXPECT_EQ(2u, m_markerList->at(1)->startOffset());
+ EXPECT_EQ(3u, m_markerList->at(1)->endOffset());
+
+ EXPECT_EQ(3u, m_markerList->at(2)->startOffset());
+ EXPECT_EQ(4u, m_markerList->at(2)->endOffset());
+
+ EXPECT_EQ(0u, m_markerList->at(3)->startOffset());
+ EXPECT_EQ(1u, m_markerList->at(3)->endOffset());
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698