Skip to content

Commit

Permalink
StickyScrollingHandlerTest: Improve expectation to the throttler
Browse files Browse the repository at this point in the history
The calls to the lines provider should be throttled. Expect at least one call and at most 3 calls.

Fixes: #2190
  • Loading branch information
Christopher-Hermann authored and BeckerWdf committed Oct 11, 2024
1 parent 859c687 commit a022116
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
import static org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -159,8 +160,10 @@ public void testThrottledExecution() throws InterruptedException {

waitInUi(300);

// Call to lines provider should be throttled
verify(linesProvider, times(2)).getStickyLines(sourceViewer, stickyLinesProperties);
// Call to lines provider should be throttled, at least one and at most
// 3 calls expected
verify(linesProvider, atMost(3)).getStickyLines(sourceViewer, stickyLinesProperties);
verify(linesProvider, atLeastOnce()).getStickyLines(sourceViewer, stickyLinesProperties);
}

private void waitInUi(int ms) throws InterruptedException {
Expand Down

0 comments on commit a022116

Please sign in to comment.