| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. Use of | 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 | 2 // this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/editing/markers/EditingMarkerList.h" | 5 #include "core/editing/markers/EditingMarkerList.h" |
| 6 | 6 |
| 7 #include "core/editing/markers/CompositionMarker.h" |
| 7 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 10 |
| 10 namespace blink { | 11 namespace blink { |
| 11 | 12 |
| 12 class EditingMarkerListForTesting : public EditingMarkerList { | 13 class EditingMarkerListForTesting : public EditingMarkerList { |
| 13 public: | 14 public: |
| 14 DocumentMarker::MarkerType allowedMarkerType() const final { | 15 DocumentMarker::MarkerType allowedMarkerType() const final { |
| 15 return DocumentMarker::Composition; | 16 return DocumentMarker::Composition; |
| 16 } | 17 } |
| 17 | 18 |
| 18 bool markerListIsSortedPublicForTesting() const { | 19 bool markerListIsSortedPublicForTesting() const { |
| 19 return markerListIsSorted(); | 20 return markerListIsSorted(); |
| 20 } | 21 } |
| 21 }; | 22 }; |
| 22 | 23 |
| 23 class EditingMarkerListTest : public ::testing::Test { | 24 class EditingMarkerListTest : public ::testing::Test { |
| 24 protected: | 25 protected: |
| 25 EditingMarkerListTest() : m_markerList(new EditingMarkerListForTesting()) {} | 26 EditingMarkerListTest() : m_markerList(new EditingMarkerListForTesting()) {} |
| 26 | 27 |
| 27 DocumentMarker* createMarker(unsigned startOffset, unsigned endOffset) { | 28 DocumentMarker* createMarker(unsigned startOffset, unsigned endOffset) { |
| 28 return new DocumentMarker(startOffset, endOffset, Color::black, false, | 29 return new CompositionMarker(startOffset, endOffset, Color::black, false, |
| 29 Color::black); | 30 Color::black); |
| 30 } | 31 } |
| 31 | 32 |
| 32 Persistent<EditingMarkerListForTesting> m_markerList; | 33 Persistent<EditingMarkerListForTesting> m_markerList; |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 TEST_F(EditingMarkerListTest, NewlyConstructedListIsSorted) { | 36 TEST_F(EditingMarkerListTest, NewlyConstructedListIsSorted) { |
| 36 EXPECT_TRUE(m_markerList->markerListIsSortedPublicForTesting()); | 37 EXPECT_TRUE(m_markerList->markerListIsSortedPublicForTesting()); |
| 37 } | 38 } |
| 38 | 39 |
| 39 TEST_F(EditingMarkerListTest, InsertingMarkersInSortedOrderKeepsListSorted) { | 40 TEST_F(EditingMarkerListTest, InsertingMarkersInSortedOrderKeepsListSorted) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 51 | 52 |
| 52 TEST_F(EditingMarkerListTest, ClearingListMakesItSorted) { | 53 TEST_F(EditingMarkerListTest, ClearingListMakesItSorted) { |
| 53 m_markerList->add(createMarker(1, 2)); | 54 m_markerList->add(createMarker(1, 2)); |
| 54 m_markerList->add(createMarker(0, 1)); | 55 m_markerList->add(createMarker(0, 1)); |
| 55 EXPECT_FALSE(m_markerList->markerListIsSortedPublicForTesting()); | 56 EXPECT_FALSE(m_markerList->markerListIsSortedPublicForTesting()); |
| 56 m_markerList->clear(); | 57 m_markerList->clear(); |
| 57 EXPECT_TRUE(m_markerList->markerListIsSortedPublicForTesting()); | 58 EXPECT_TRUE(m_markerList->markerListIsSortedPublicForTesting()); |
| 58 } | 59 } |
| 59 | 60 |
| 60 } // namespace blink | 61 } // namespace blink |
| OLD | NEW |