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/TextMatchMarkerListImpl.h" | 5 #include "core/editing/markers/TextMatchMarkerListImpl.h" |
6 | 6 |
7 #include "core/editing/EditingTestBase.h" | 7 #include "core/editing/EditingTestBase.h" |
8 #include "core/editing/markers/RenderedDocumentMarker.h" | 8 #include "core/editing/markers/RenderedDocumentMarker.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 class TextMatchMarkerListImplTest : public EditingTestBase { | 12 class TextMatchMarkerListImplTest : public EditingTestBase { |
13 protected: | 13 protected: |
14 TextMatchMarkerListImplTest() : marker_list_(new TextMatchMarkerListImpl()) {} | 14 TextMatchMarkerListImplTest() : marker_list_(new TextMatchMarkerListImpl()) {} |
15 | 15 |
16 DocumentMarker* CreateMarker(unsigned start_offset, unsigned end_offset) { | 16 DocumentMarker* CreateMarker(unsigned start_offset, unsigned end_offset) { |
17 return new DocumentMarker(start_offset, end_offset, | 17 return new DocumentMarker(start_offset, end_offset, |
18 DocumentMarker::MatchStatus::kInactive); | 18 DocumentMarker::MatchStatus::kInactive); |
19 } | 19 } |
20 | 20 |
21 Persistent<TextMatchMarkerListImpl> marker_list_; | 21 Persistent<TextMatchMarkerListImpl> marker_list_; |
22 }; | 22 }; |
23 | 23 |
| 24 TEST_F(TextMatchMarkerListImplTest, MarkerType) { |
| 25 EXPECT_EQ(DocumentMarker::kTextMatch, marker_list_->MarkerType()); |
| 26 } |
| 27 |
24 TEST_F(TextMatchMarkerListImplTest, Add) { | 28 TEST_F(TextMatchMarkerListImplTest, Add) { |
25 EXPECT_EQ(0u, marker_list_->GetMarkers().size()); | 29 EXPECT_EQ(0u, marker_list_->GetMarkers().size()); |
26 | 30 |
27 marker_list_->Add(CreateMarker(0, 1)); | 31 marker_list_->Add(CreateMarker(0, 1)); |
28 marker_list_->Add(CreateMarker(1, 2)); | 32 marker_list_->Add(CreateMarker(1, 2)); |
29 | 33 |
30 EXPECT_EQ(2u, marker_list_->GetMarkers().size()); | 34 EXPECT_EQ(2u, marker_list_->GetMarkers().size()); |
31 | 35 |
32 EXPECT_EQ(0u, marker_list_->GetMarkers()[0]->StartOffset()); | 36 EXPECT_EQ(0u, marker_list_->GetMarkers()[0]->StartOffset()); |
33 EXPECT_EQ(1u, marker_list_->GetMarkers()[0]->EndOffset()); | 37 EXPECT_EQ(1u, marker_list_->GetMarkers()[0]->EndOffset()); |
34 | 38 |
35 EXPECT_EQ(1u, marker_list_->GetMarkers()[1]->StartOffset()); | 39 EXPECT_EQ(1u, marker_list_->GetMarkers()[1]->StartOffset()); |
36 EXPECT_EQ(2u, marker_list_->GetMarkers()[1]->EndOffset()); | 40 EXPECT_EQ(2u, marker_list_->GetMarkers()[1]->EndOffset()); |
37 } | 41 } |
38 | 42 |
39 } // namespace blink | 43 } // namespace blink |
OLD | NEW |