OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of 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/DocumentMarkerListEditor.h" | 5 #include "core/editing/markers/DocumentMarkerListEditor.h" |
6 | 6 |
7 #include "core/editing/markers/TextMatchMarker.h" | 7 #include "core/editing/markers/TextMatchMarker.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 class DocumentMarkerListEditorTest : public ::testing::Test { | 12 class DocumentMarkerListEditorTest : public ::testing::Test { |
13 protected: | 13 protected: |
14 DocumentMarker* CreateMarker(unsigned startOffset, unsigned endOffset) { | 14 DocumentMarker* CreateMarker(unsigned startOffset, unsigned endOffset) { |
15 return new TextMatchMarker(startOffset, endOffset, | 15 return new TextMatchMarker(startOffset, endOffset, |
16 TextMatchMarker::MatchStatus::kInactive); | 16 TextMatchMarker::MatchStatus::kInactive); |
17 } | 17 } |
18 }; | 18 }; |
19 | 19 |
| 20 TEST_F(DocumentMarkerListEditorTest, RemoveMarkersEmptyList) { |
| 21 DocumentMarkerListEditor::MarkerList markers; |
| 22 DocumentMarkerListEditor::RemoveMarkers(&markers, 0, 10); |
| 23 EXPECT_EQ(0u, markers.size()); |
| 24 } |
| 25 |
| 26 TEST_F(DocumentMarkerListEditorTest, RemoveMarkersTouchingEndpoints) { |
| 27 DocumentMarkerListEditor::MarkerList markers; |
| 28 markers.push_back(CreateMarker(0, 10)); |
| 29 markers.push_back(CreateMarker(10, 20)); |
| 30 markers.push_back(CreateMarker(20, 30)); |
| 31 |
| 32 DocumentMarkerListEditor::RemoveMarkers(&markers, 10, 10); |
| 33 |
| 34 EXPECT_EQ(2u, markers.size()); |
| 35 |
| 36 EXPECT_EQ(0u, markers[0]->StartOffset()); |
| 37 EXPECT_EQ(10u, markers[0]->EndOffset()); |
| 38 |
| 39 EXPECT_EQ(20u, markers[1]->StartOffset()); |
| 40 EXPECT_EQ(30u, markers[1]->EndOffset()); |
| 41 } |
| 42 |
| 43 TEST_F(DocumentMarkerListEditorTest, RemoveMarkersOneCharacterIntoInterior) { |
| 44 DocumentMarkerListEditor::MarkerList markers; |
| 45 markers.push_back(CreateMarker(0, 10)); |
| 46 markers.push_back(CreateMarker(10, 20)); |
| 47 markers.push_back(CreateMarker(20, 30)); |
| 48 |
| 49 DocumentMarkerListEditor::RemoveMarkers(&markers, 9, 12); |
| 50 |
| 51 EXPECT_EQ(0u, markers.size()); |
| 52 } |
| 53 |
20 TEST_F(DocumentMarkerListEditorTest, | 54 TEST_F(DocumentMarkerListEditorTest, |
21 ContentDependentMarker_ReplaceStartOfMarker) { | 55 ContentDependentMarker_ReplaceStartOfMarker) { |
22 DocumentMarkerListEditor::MarkerList markers; | 56 DocumentMarkerListEditor::MarkerList markers; |
23 markers.push_back(CreateMarker(0, 10)); | 57 markers.push_back(CreateMarker(0, 10)); |
24 | 58 |
25 DocumentMarkerListEditor::ShiftMarkersContentDependent(&markers, 0, 5, 5); | 59 DocumentMarkerListEditor::ShiftMarkersContentDependent(&markers, 0, 5, 5); |
26 | 60 |
27 EXPECT_EQ(0u, markers.size()); | 61 EXPECT_EQ(0u, markers.size()); |
28 } | 62 } |
29 | 63 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 EXPECT_EQ(5u, markers[0]->EndOffset()); | 393 EXPECT_EQ(5u, markers[0]->EndOffset()); |
360 | 394 |
361 EXPECT_EQ(10u, markers[1]->StartOffset()); | 395 EXPECT_EQ(10u, markers[1]->StartOffset()); |
362 EXPECT_EQ(15u, markers[1]->EndOffset()); | 396 EXPECT_EQ(15u, markers[1]->EndOffset()); |
363 | 397 |
364 EXPECT_EQ(15u, markers[2]->StartOffset()); | 398 EXPECT_EQ(15u, markers[2]->StartOffset()); |
365 EXPECT_EQ(20u, markers[2]->EndOffset()); | 399 EXPECT_EQ(20u, markers[2]->EndOffset()); |
366 } | 400 } |
367 | 401 |
368 } // namespace blink | 402 } // namespace blink |
OLD | NEW |