Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. Use of | |
| 2 // this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/editing/markers/EditingMarkerList.h" | |
| 6 | |
| 7 #include "platform/heap/Handle.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 class EditingMarkerListForTesting : public EditingMarkerList { | |
| 13 public: | |
| 14 DocumentMarker::MarkerType allowedMarkerType() const final { | |
| 15 return DocumentMarker::Composition; | |
| 16 } | |
| 17 | |
| 18 bool markerListIsSortedPublicForTesting() const { | |
| 19 return markerListIsSorted(); | |
| 20 } | |
| 21 }; | |
| 22 | |
| 23 class EditingMarkerListTest : public ::testing::Test { | |
| 24 protected: | |
| 25 EditingMarkerListTest() : m_markerList(new EditingMarkerListForTesting()) {} | |
| 26 | |
| 27 DocumentMarker* createMarker(unsigned startOffset, unsigned endOffset) { | |
| 28 return new DocumentMarker(startOffset, endOffset, Color::black, false, | |
| 29 Color::black); | |
| 30 } | |
| 31 | |
| 32 Persistent<EditingMarkerListForTesting> m_markerList; | |
| 33 }; | |
| 34 | |
| 35 TEST_F(EditingMarkerListTest, PushBack) { | |
| 36 m_markerList->push_back(createMarker(1, 2)); | |
| 37 m_markerList->push_back(createMarker(2, 3)); | |
| 38 m_markerList->push_back(createMarker(3, 4)); | |
| 39 EXPECT_EQ(true, m_markerList->markerListIsSortedPublicForTesting()); | |
| 40 m_markerList->push_back(createMarker(0, 1)); | |
| 41 EXPECT_EQ(false, m_markerList->markerListIsSortedPublicForTesting()); | |
| 42 | |
| 43 // 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
| |
| 44 // merge touching markers, and we verify this behavior here. However, | |
| 45 // some subclasses may have different behavior. | |
| 46 EXPECT_EQ(4u, m_markerList->size()); | |
| 47 | |
| 48 EXPECT_EQ(1u, m_markerList->at(0)->startOffset()); | |
| 49 EXPECT_EQ(2u, m_markerList->at(0)->endOffset()); | |
| 50 | |
| 51 EXPECT_EQ(2u, m_markerList->at(1)->startOffset()); | |
| 52 EXPECT_EQ(3u, m_markerList->at(1)->endOffset()); | |
| 53 | |
| 54 EXPECT_EQ(3u, m_markerList->at(2)->startOffset()); | |
| 55 EXPECT_EQ(4u, m_markerList->at(2)->endOffset()); | |
| 56 | |
| 57 EXPECT_EQ(0u, m_markerList->at(3)->startOffset()); | |
| 58 EXPECT_EQ(1u, m_markerList->at(3)->endOffset()); | |
| 59 } | |
| 60 | |
| 61 } // namespace blink | |
| OLD | NEW |