Skip to content

Commit b7b6b77

Browse files
committed
Use TestUtil.cleanUp across the tests
- This ensures that the tests don't leak jobs that are only detected by a subsequent test. - Use editor.close(false) rather than editor.dispose() to clean up the thread/job properly. #3025
1 parent a71bf2c commit b7b6b77

File tree

9 files changed

+43
-10
lines changed

9 files changed

+43
-10
lines changed

tests/org.eclipse.ui.editors.tests/src/org/eclipse/jface/text/tests/codemining/CodeMiningTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
import org.eclipse.ui.PlatformUI;
5656
import org.eclipse.ui.ide.IDE;
5757

58+
import org.eclipse.ui.editors.tests.TestUtil;
59+
5860
public class CodeMiningTest {
5961
private static String PROJECT_NAME = "test_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
6062

@@ -78,6 +80,7 @@ public void after() {
7880
drainEventQueue();
7981
CodeMiningTestProvider.provideContentMiningAtOffset = -1;
8082
CodeMiningTestProvider.provideHeaderMiningAtLine = -1;
83+
TestUtil.cleanUp();
8184
}
8285

8386
private static void closeAllEditors() {

tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/StatusEditorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public void after() {
6868
window.close();
6969
page = null;
7070
processEvents();
71+
TestUtil.cleanUp();
7172
}
7273

7374
/*

tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/TextMultiCaretNavigationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ public void setUpBeforeClass() throws IOException, PartInitException, CoreExcept
6161

6262
@After
6363
public void tearDown() {
64-
editor.dispose();
64+
editor.close(false);
6565
file.delete();
66+
TestUtil.cleanUp();
6667
}
6768

6869

tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/TextMultiCaretSelectionCommandsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ public void setUpBeforeClass() throws IOException, PartInitException, CoreExcept
8585

8686
@After
8787
public void tearDown() {
88-
editor.dispose();
88+
editor.close(false);
8989
file.delete();
90+
TestUtil.cleanUp();
9091
}
9192

9293
@Test

tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/TextNavigationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ public void setUp() throws IOException, PartInitException, CoreException {
6868

6969
@After
7070
public void tearDown() {
71-
editor.dispose();
71+
editor.close(false);
7272
file.delete();
73+
TestUtil.cleanUp();
7374
}
7475

7576
@Test

tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/DefaultStickyLinesProviderTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.util.List;
2323

24+
import org.junit.After;
2425
import org.junit.Before;
2526
import org.junit.Test;
2627

@@ -41,6 +42,8 @@
4142
import org.eclipse.ui.texteditor.stickyscroll.IStickyLine;
4243
import org.eclipse.ui.texteditor.stickyscroll.IStickyLinesProvider.StickyLinesProperties;
4344

45+
import org.eclipse.ui.editors.tests.TestUtil;
46+
4447
public class DefaultStickyLinesProviderTest {
4548

4649
private Shell shell;
@@ -61,6 +64,11 @@ public void setup() {
6164
stickyLinesProperties = new StickyLinesProperties(4, editorPart);
6265
}
6366

67+
@After
68+
public void teardown() {
69+
TestUtil.cleanUp();
70+
}
71+
6472
@Test
6573
public void testEmptySourceCode() {
6674
List<IStickyLine> stickyLines = stickyLinesProvider.getStickyLines(sourceViewer, 0, stickyLinesProperties);

tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyLinesProviderRegistryTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import static org.mockito.Mockito.mock;
99
import static org.mockito.Mockito.when;
1010

11+
import org.junit.After;
1112
import org.junit.Before;
1213
import org.junit.Test;
1314

@@ -19,6 +20,8 @@
1920
import org.eclipse.ui.texteditor.ITextEditor;
2021
import org.eclipse.ui.texteditor.stickyscroll.IStickyLinesProvider;
2122

23+
import org.eclipse.ui.editors.tests.TestUtil;
24+
2225
public class StickyLinesProviderRegistryTest {
2326

2427
private StickyLinesProviderDescriptor stickyLinesProviderDescriptor;
@@ -40,6 +43,11 @@ public void setup() {
4043
cut = new StickyLinesProviderRegistry(extensionRegistry, e -> stickyLinesProviderDescriptor);
4144
}
4245

46+
@After
47+
public void teardown() {
48+
TestUtil.cleanUp();
49+
}
50+
4351
@Test
4452
public void testGetDefaultProviderIfNoMatch() {
4553
when(stickyLinesProviderDescriptor.matches(viewer, editor)).thenReturn(false);

tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingControlTest.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848

4949
import org.eclipse.ui.texteditor.stickyscroll.IStickyLine;
5050

51+
import org.eclipse.ui.editors.tests.TestUtil;
52+
5153
public class StickyScrollingControlTest {
5254

5355
private Shell shell;
@@ -86,6 +88,7 @@ public void teardown() {
8688
lineNumberColor.dispose();
8789
hoverColor.dispose();
8890
backgroundColor.dispose();
91+
TestUtil.cleanUp();
8992
}
9093

9194
@Test
@@ -183,13 +186,17 @@ public void testCopyStyleRangesWithLimitedStickyLines() {
183186

184187
@Test
185188
public void testWithoutVerticalRuler() {
186-
sourceViewer = new SourceViewer(shell, null, SWT.None);
187-
settings = new StickyScrollingControlSettings(5, lineNumberColor, hoverColor, backgroundColor, separatorColor,
188-
true);
189-
stickyScrollingControl = new StickyScrollingControl(sourceViewer, settings);
190-
191-
StyledText stickyLineNumber = getStickyLineNumber();
192-
assertFalse(stickyLineNumber.isVisible());
189+
SourceViewer sourceViewerWithoutRuler = new SourceViewer(shell, null, SWT.None);
190+
StickyScrollingControl stickyScrollingControlWithoutRuler = new StickyScrollingControl(sourceViewerWithoutRuler,
191+
new StickyScrollingControlSettings(5, lineNumberColor, hoverColor, backgroundColor, separatorColor,
192+
true));
193+
try {
194+
StyledText stickyLineNumber = getStickyLineNumber();
195+
assertFalse(stickyLineNumber.isVisible());
196+
} finally {
197+
sourceViewerWithoutRuler.getControl().dispose();
198+
stickyScrollingControlWithoutRuler.dispose();
199+
}
193200
}
194201

195202
@Test

tests/org.eclipse.ui.editors.tests/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyScrollingHandlerTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
import org.eclipse.ui.texteditor.stickyscroll.IStickyLinesProvider;
6060
import org.eclipse.ui.texteditor.stickyscroll.IStickyLinesProvider.StickyLinesProperties;
6161

62+
import org.eclipse.ui.editors.tests.TestUtil;
63+
6264
public class StickyScrollingHandlerTest {
6365

6466
private Shell shell;
@@ -99,6 +101,7 @@ public void setup() {
99101
@After
100102
public void teardown() {
101103
shell.dispose();
104+
TestUtil.cleanUp();
102105
}
103106

104107
@Test

0 commit comments

Comments
 (0)