Skip to content

Commit 929564c

Browse files
EcljpseB0Tjukzi
authored andcommitted
tests: take screenshot before dispose
eclipse-platform/eclipse.platform.swt#1518
1 parent 28c2d5d commit 929564c

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

tests/org.eclipse.e4.ui.tests/src/org/eclipse/e4/ui/tests/workbench/PartRenderingEngineTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2974,7 +2974,7 @@ public void testBug371100() {
29742974
}
29752975

29762976
@Rule
2977-
public TestWatcher screenshotRule = Screenshots.onFailure();
2977+
public TestWatcher screenshotRule = Screenshots.onFailure(null);
29782978

29792979
@Test
29802980
public void testBug372226() {

tests/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/TextViewerTest.java

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import java.util.concurrent.atomic.AtomicBoolean;
2525
import java.util.stream.Collectors;
2626

27-
import org.junit.After;
2827
import org.junit.Assume;
28+
import org.junit.Before;
2929
import org.junit.Rule;
3030
import org.junit.Test;
3131
import org.junit.rules.TestWatcher;
@@ -76,22 +76,18 @@
7676
*/
7777
public class TextViewerTest {
7878

79-
@Rule
80-
public TestWatcher screenshotRule= Screenshots.onFailure();
81-
8279
private Shell fShell;
8380

84-
@After
85-
public void tearDown() {
86-
if (fShell != null && !fShell.isDisposed()) {
87-
fShell.dispose();
88-
}
89-
fShell= null;
81+
@Before
82+
public void before() {
83+
fShell= new Shell();
9084
}
9185

86+
@Rule
87+
public TestWatcher screenshotRule= Screenshots.onFailure(() -> fShell);
88+
9289
@Test
9390
public void testSetRedraw_Bug441827() throws Exception {
94-
fShell= new Shell();
9591
TextViewer textViewer= new TextViewer(fShell, SWT.NONE);
9692
Document document= new Document("abc");
9793
textViewer.setDocument(document);
@@ -111,7 +107,6 @@ public void testSetRedraw_Bug441827() throws Exception {
111107

112108
@Test
113109
public void testCaretMoveChangesSelection() throws Exception {
114-
fShell= new Shell();
115110
TextViewer textViewer= new TextViewer(fShell, SWT.NONE);
116111
Document document= new Document("abc");
117112
textViewer.setDocument(document);
@@ -129,7 +124,6 @@ public void testCaretMoveChangesSelection() throws Exception {
129124

130125
@Test
131126
public void testGetCachedSelection() throws Exception {
132-
fShell= new Shell();
133127
TextViewer textViewer= new TextViewer(fShell, SWT.NONE);
134128
Document document= new Document("abc");
135129
textViewer.setDocument(document);
@@ -145,7 +139,6 @@ public void testGetCachedSelection() throws Exception {
145139

146140
@Test
147141
public void testBlockSelectionAccessors() throws Exception {
148-
fShell= new Shell();
149142
ITextViewer textViewer= new TextViewer(fShell, SWT.NONE);
150143
Document document= new Document("0123\n4567\n89ab\ncdef");
151144
textViewer.setDocument(document);
@@ -190,7 +183,6 @@ private void checkInAndOutUIThread(Runnable r) throws InterruptedException {
190183
@Test
191184
public void testCtrlHomeViewportListener() {
192185
Assume.assumeFalse("See bug 541415. For whatever reason, this shortcut doesn't work on Mac", Util.isMac());
193-
fShell= new Shell();
194186
fShell.setLayout(new FillLayout());
195187
fShell.setSize(500, 200);
196188
SourceViewer textViewer= new SourceViewer(fShell, null, SWT.NONE);
@@ -213,7 +205,6 @@ protected boolean condition() {
213205
@Test
214206
public void testCtrlEndViewportListener() {
215207
Assume.assumeFalse("See bug 541415. For whatever reason, this shortcut doesn't work on Mac", Util.isMac());
216-
fShell= new Shell();
217208
fShell.setLayout(new FillLayout());
218209
fShell.setSize(500, 200);
219210
SourceViewer textViewer= new SourceViewer(fShell, null, SWT.NONE);
@@ -237,7 +228,6 @@ protected boolean condition() {
237228
*/
238229
@Test
239230
public void testDefaultContentImplementation() {
240-
fShell= new Shell();
241231
final StyledTextContent content;
242232
try {
243233
final TextViewer textViewer= new TextViewer(fShell, SWT.NONE);
@@ -323,7 +313,6 @@ public static String generate5000Lines() {
323313

324314
@Test
325315
public void testShiftLeft() {
326-
fShell= new Shell();
327316
TextViewer textViewer= new TextViewer(fShell, SWT.NONE);
328317
{
329318
// Normal case, both lines match prefix
@@ -394,7 +383,6 @@ private void checkHyperlink(TextViewer textViewer, int pos, String text, String
394383

395384
@Test
396385
public void testURLHyperlinkDetector() {
397-
fShell= new Shell();
398386
TextViewer textViewer= new TextViewer(fShell, SWT.NONE);
399387
checkHyperlink(textViewer, 3, "https://foo ", "[https://foo]");
400388
checkHyperlink(textViewer, 0, "", "[]");
@@ -417,7 +405,6 @@ public void testURLHyperlinkDetector() {
417405

418406
@Test
419407
public void testPasteMultiLines() {
420-
fShell= new Shell();
421408
TextViewer textViewer= new TextViewer(fShell, SWT.NONE);
422409
Document document= new Document();
423410
textViewer.setDocument(document);
@@ -434,15 +421,13 @@ public void testPasteMultiLines() {
434421

435422
@Test
436423
public void testSetSelectionNoDoc() {
437-
fShell= new Shell();
438424
TextViewer textViewer= new TextViewer(fShell, SWT.NONE);
439425
textViewer.setSelection(TextSelection.emptySelection());
440426
// assert no exception is thrown
441427
}
442428

443429
@Test
444430
public void testSelectionFromViewerState() {
445-
fShell= new Shell();
446431
TextViewer textViewer= new TextViewer(fShell, SWT.NONE);
447432
textViewer.setDocument(new Document(
448433
"/**\n"

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class CodeMiningTest {
6969
private Shell fShell;
7070

7171
@Rule
72-
public TestWatcher screenshotRule= Screenshots.onFailure();
72+
public TestWatcher screenshotRule= Screenshots.onFailure(() -> fShell);
7373

7474
@Before
7575
public void setUp() {
@@ -117,7 +117,6 @@ protected boolean condition() {
117117

118118
@After
119119
public void tearDown() {
120-
fShell.dispose();
121120
fViewer = null;
122121
}
123122

0 commit comments

Comments
 (0)