Skip to content

Commit d5377b7

Browse files
committed
Tests for #115
1 parent b56be1b commit d5377b7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

CSharpMath.Editor.Tests/CaretTests.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,30 @@ public async Task Test() {
150150
Assert.Equal(MathKeyboardCaretState.TemporarilyHidden, keyboard.CaretState);
151151
}
152152
}
153+
public class CaretCanStartAndStopBlinking {
154+
// https://github.com/verybadcat/CSharpMath/issues/115
155+
[Fact]
156+
public async Task Test() {
157+
var keyboard = new MathKeyboard<TestFont, char>(TestTypesettingContexts.Instance, new TestFont()) {
158+
CaretState = MathKeyboardCaretState.Shown
159+
};
160+
Assert.Equal(MathKeyboardCaretState.Shown, keyboard.CaretState);
161+
162+
keyboard.StopBlinking();
163+
await Task.Delay((int)MathKeyboard<TestFont, char>.DefaultBlinkMilliseconds + CaretBlinks.MillisecondBuffer);
164+
Assert.Equal(MathKeyboardCaretState.Shown, keyboard.CaretState);
165+
166+
keyboard.StartBlinking();
167+
await Task.Delay((int)MathKeyboard<TestFont, char>.DefaultBlinkMilliseconds + CaretBlinks.MillisecondBuffer);
168+
Assert.Equal(MathKeyboardCaretState.TemporarilyHidden, keyboard.CaretState);
169+
170+
keyboard.StopBlinking();
171+
await Task.Delay((int)MathKeyboard<TestFont, char>.DefaultBlinkMilliseconds + CaretBlinks.MillisecondBuffer);
172+
Assert.Equal(MathKeyboardCaretState.TemporarilyHidden, keyboard.CaretState);
173+
174+
keyboard.StartBlinking();
175+
await Task.Delay((int)MathKeyboard<TestFont, char>.DefaultBlinkMilliseconds + CaretBlinks.MillisecondBuffer);
176+
Assert.Equal(MathKeyboardCaretState.Shown, keyboard.CaretState);
177+
}
178+
}
153179
}

0 commit comments

Comments
 (0)