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