|
|
|
@ -273,76 +273,6 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void TestNext() |
|
|
|
{ |
|
|
|
using (Start()) |
|
|
|
{ |
|
|
|
var defaultProperties = new GenericTextRunProperties(Typeface.Default); |
|
|
|
|
|
|
|
var textSource = new SingleBufferTextSource("Text from memory", defaultProperties); |
|
|
|
|
|
|
|
var formatter = new TextFormatterImpl(); |
|
|
|
|
|
|
|
var textLine = |
|
|
|
formatter.FormatLine(textSource, 0, double.PositiveInfinity, |
|
|
|
new GenericTextParagraphProperties(defaultProperties)); |
|
|
|
|
|
|
|
var characterHits = new List<CharacterHit>(); |
|
|
|
|
|
|
|
var currentCharacterHit = new CharacterHit(0); |
|
|
|
|
|
|
|
characterHits.Add(currentCharacterHit); |
|
|
|
|
|
|
|
var nextCharacterHit = textLine.GetNextCaretCharacterHit(currentCharacterHit); |
|
|
|
|
|
|
|
while (nextCharacterHit != currentCharacterHit) |
|
|
|
{ |
|
|
|
currentCharacterHit = nextCharacterHit; |
|
|
|
|
|
|
|
characterHits.Add(currentCharacterHit); |
|
|
|
|
|
|
|
nextCharacterHit = textLine.GetNextCaretCharacterHit(currentCharacterHit); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void TestPrevious() |
|
|
|
{ |
|
|
|
using (Start()) |
|
|
|
{ |
|
|
|
var defaultProperties = new GenericTextRunProperties(Typeface.Default); |
|
|
|
|
|
|
|
var text = "Text from memory"; |
|
|
|
|
|
|
|
var textSource = new SingleBufferTextSource(text, defaultProperties); |
|
|
|
|
|
|
|
var formatter = new TextFormatterImpl(); |
|
|
|
|
|
|
|
var textLine = |
|
|
|
formatter.FormatLine(textSource, 0, double.PositiveInfinity, |
|
|
|
new GenericTextParagraphProperties(defaultProperties)); |
|
|
|
|
|
|
|
var characterHits = new List<CharacterHit>(); |
|
|
|
|
|
|
|
var currentCharacterHit = new CharacterHit(text.Length); |
|
|
|
|
|
|
|
characterHits.Add(currentCharacterHit); |
|
|
|
|
|
|
|
var nextCharacterHit = textLine.GetPreviousCaretCharacterHit(currentCharacterHit); |
|
|
|
|
|
|
|
while (nextCharacterHit != currentCharacterHit) |
|
|
|
{ |
|
|
|
currentCharacterHit = nextCharacterHit; |
|
|
|
|
|
|
|
characterHits.Add(currentCharacterHit); |
|
|
|
|
|
|
|
nextCharacterHit = textLine.GetPreviousCaretCharacterHit(currentCharacterHit); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private static IDisposable Start() |
|
|
|
{ |
|
|
|
var disposable = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface |
|
|
|
|