OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 MarkerController().RemoveSpellingMarkersUnderWords({"foo"}); | 305 MarkerController().RemoveSpellingMarkersUnderWords({"foo"}); |
306 | 306 |
307 // RemoveSpellingMarkersUnderWords does not remove text match marker. | 307 // RemoveSpellingMarkersUnderWords does not remove text match marker. |
308 ASSERT_EQ(1u, MarkerController().Markers().size()); | 308 ASSERT_EQ(1u, MarkerController().Markers().size()); |
309 const DocumentMarker& marker = *MarkerController().Markers()[0]; | 309 const DocumentMarker& marker = *MarkerController().Markers()[0]; |
310 EXPECT_EQ(0u, marker.StartOffset()); | 310 EXPECT_EQ(0u, marker.StartOffset()); |
311 EXPECT_EQ(3u, marker.EndOffset()); | 311 EXPECT_EQ(3u, marker.EndOffset()); |
312 EXPECT_EQ(DocumentMarker::kTextMatch, marker.GetType()); | 312 EXPECT_EQ(DocumentMarker::kTextMatch, marker.GetType()); |
313 } | 313 } |
314 | 314 |
| 315 TEST_F(DocumentMarkerControllerTest, FirstMarkerIntersectingOffsetRange) { |
| 316 SetBodyContent("<div contenteditable>123456789</div>"); |
| 317 GetDocument().UpdateStyleAndLayout(); |
| 318 Element* div = GetDocument().QuerySelector("div"); |
| 319 Text* text = ToText(div->firstChild()); |
| 320 |
| 321 // Add a spelling marker on "123" |
| 322 MarkerController().AddSpellingMarker( |
| 323 EphemeralRange(Position(text, 0), Position(text, 3))); |
| 324 |
| 325 // Query for a spellcheck marker intersecting "3456" |
| 326 const DocumentMarker* const result = |
| 327 MarkerController().FirstMarkerIntersectingOffsetRange( |
| 328 *text, 2, 6, DocumentMarker::MisspellingMarkers()); |
| 329 |
| 330 EXPECT_EQ(DocumentMarker::kSpelling, result->GetType()); |
| 331 EXPECT_EQ(0u, result->StartOffset()); |
| 332 EXPECT_EQ(3u, result->EndOffset()); |
| 333 } |
| 334 |
| 335 TEST_F(DocumentMarkerControllerTest, |
| 336 FirstMarkerIntersectingOffsetRange_collapsed) { |
| 337 SetBodyContent("<div contenteditable>123456789</div>"); |
| 338 GetDocument().UpdateStyleAndLayout(); |
| 339 Element* div = GetDocument().QuerySelector("div"); |
| 340 Text* text = ToText(div->firstChild()); |
| 341 |
| 342 // Add a spelling marker on "123" |
| 343 MarkerController().AddSpellingMarker( |
| 344 EphemeralRange(Position(text, 0), Position(text, 3))); |
| 345 |
| 346 // Query for a spellcheck marker containing the position between "1" and "2" |
| 347 const DocumentMarker* const result = |
| 348 MarkerController().FirstMarkerIntersectingOffsetRange( |
| 349 *text, 1, 1, DocumentMarker::MisspellingMarkers()); |
| 350 |
| 351 EXPECT_EQ(DocumentMarker::kSpelling, result->GetType()); |
| 352 EXPECT_EQ(0u, result->StartOffset()); |
| 353 EXPECT_EQ(3u, result->EndOffset()); |
| 354 } |
| 355 |
315 } // namespace blink | 356 } // namespace blink |
OLD | NEW |