Chromium Code Reviews| 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 |