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/active_suggestion_marker_list_impl.h"
6
7 #include "third_party/blink/renderer/core/editing/markers/active_suggestion_marker.h"
8 #include "third_party/blink/renderer/core/editing/testing/editing_test_base.h"
9
10 namespace blink {
11
12 class ActiveSuggestionMarkerListImplTest : public EditingTestBase {
13 protected:
ActiveSuggestionMarkerListImplTest()14 ActiveSuggestionMarkerListImplTest()
15 : marker_list_(MakeGarbageCollected<ActiveSuggestionMarkerListImpl>()) {}
16
CreateMarker(unsigned start_offset,unsigned end_offset)17 DocumentMarker* CreateMarker(unsigned start_offset, unsigned end_offset) {
18 return MakeGarbageCollected<ActiveSuggestionMarker>(
19 start_offset, end_offset, Color::kTransparent,
20 ui::mojom::ImeTextSpanThickness::kThin,
21 ui::mojom::ImeTextSpanUnderlineStyle::kSolid, Color::kBlack,
22 Color::kBlack);
23 }
24
25 Persistent<ActiveSuggestionMarkerListImpl> marker_list_;
26 };
27
28 // ActiveSuggestionMarkerListImpl shouldn't merge markers with touching
29 // endpoints
TEST_F(ActiveSuggestionMarkerListImplTest,Add)30 TEST_F(ActiveSuggestionMarkerListImplTest, Add) {
31 EXPECT_EQ(0u, marker_list_->GetMarkers().size());
32
33 marker_list_->Add(CreateMarker(0, 1));
34 marker_list_->Add(CreateMarker(1, 2));
35
36 EXPECT_EQ(2u, marker_list_->GetMarkers().size());
37
38 EXPECT_EQ(0u, marker_list_->GetMarkers()[0]->StartOffset());
39 EXPECT_EQ(1u, marker_list_->GetMarkers()[0]->EndOffset());
40
41 EXPECT_EQ(1u, marker_list_->GetMarkers()[1]->StartOffset());
42 EXPECT_EQ(2u, marker_list_->GetMarkers()[1]->EndOffset());
43 }
44
45 } // namespace blink
46