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