Skip to content

Commit

Permalink
Fix StickyScrollingHandlerTest.testThrottledExecution on Mac
Browse files Browse the repository at this point in the history
The unit test StickyScrollingHandlerTest.testThrottledExecution was failing in the I build on MacOS. With this change, the test should run again.

Fixes eclipse-platform#2190
  • Loading branch information
Christopher-Hermann committed Aug 27, 2024
1 parent a801237 commit 4d5722b
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.List;
import java.util.StringJoiner;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -75,6 +76,11 @@ public void setup() {
stickyScrollingHandler = new StickyScrollingHandler(sourceViewer, ruler, store, linesProvider);
}

@After
public void teardown() {
shell.dispose();
}

@Test
public void testShowStickyLines() {
when(linesProvider.get(100, sourceViewer)).thenReturn(List.of(new StickyLine("line 10", 9)));
Expand Down Expand Up @@ -129,13 +135,19 @@ public void testPreferencesUpdated() {
@Test
public void testThrottledExecution() throws InterruptedException {
when(linesProvider.get(100, sourceViewer)).thenReturn(List.of(new StickyLine("line 10", 9)));
when(linesProvider.get(200, sourceViewer)).thenReturn(List.of(new StickyLine("line 10", 9)));
when(linesProvider.get(300, sourceViewer)).thenReturn(List.of(new StickyLine("line 10", 9)));
when(linesProvider.get(400, sourceViewer)).thenReturn(List.of(new StickyLine("line 10", 9)));

stickyScrollingHandler.viewportChanged(100);
waitInUi(10);
stickyScrollingHandler.viewportChanged(200);
waitInUi(10);
stickyScrollingHandler.viewportChanged(300);
waitInUi(10);
stickyScrollingHandler.viewportChanged(400);

waitInUi(200);
waitInUi(300);

// Call to lines provider should be throttled
verify(linesProvider, times(1)).get(100, sourceViewer);
Expand Down

0 comments on commit 4d5722b

Please sign in to comment.