|
14 | 14 | package org.eclipse.swt.tests.junit; |
15 | 15 |
|
16 | 16 |
|
17 | | -import static org.hamcrest.CoreMatchers.is; |
18 | | -import static org.hamcrest.MatcherAssert.assertThat; |
19 | | -import static org.junit.Assert.assertEquals; |
20 | | -import static org.junit.Assert.assertTrue; |
21 | | -import static org.junit.Assert.fail; |
| 17 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
22 | 18 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 19 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 20 | +import static org.junit.jupiter.api.Assertions.fail; |
23 | 21 |
|
24 | 22 | import java.io.IOException; |
25 | 23 | import java.io.InputStream; |
|
49 | 47 | import org.eclipse.swt.widgets.Listener; |
50 | 48 | import org.eclipse.swt.widgets.Shell; |
51 | 49 | import org.eclipse.test.Screenshots; |
52 | | -import org.junit.rules.TemporaryFolder; |
53 | 50 |
|
54 | 51 | public class SwtTestUtil { |
55 | 52 | /** |
@@ -130,19 +127,19 @@ public class SwtTestUtil { |
130 | 127 | public static void assertSWTProblem(String message, int expectedCode, Throwable actualThrowable) { |
131 | 128 | if (actualThrowable instanceof SWTError) { |
132 | 129 | SWTError error = (SWTError) actualThrowable; |
133 | | - assertEquals(message, expectedCode, error.code); |
| 130 | + assertEquals(expectedCode, error.code, message); |
134 | 131 | } else if (actualThrowable instanceof SWTException) { |
135 | 132 | SWTException exception = (SWTException) actualThrowable; |
136 | | - assertEquals(message, expectedCode, exception.code); |
| 133 | + assertEquals(expectedCode, exception.code, message); |
137 | 134 | } else { |
138 | 135 | try { |
139 | 136 | SWT.error(expectedCode); |
140 | 137 | } catch (Throwable expectedThrowable) { |
141 | 138 | if (actualThrowable.getMessage().length() > expectedThrowable.getMessage().length()) { |
142 | | - assertTrue(message, actualThrowable.getMessage().startsWith(expectedThrowable.getMessage())); |
| 139 | + assertTrue(actualThrowable.getMessage().startsWith(expectedThrowable.getMessage()), message); |
143 | 140 | } |
144 | 141 | else { |
145 | | - assertEquals(message, expectedThrowable.getMessage(), actualThrowable.getMessage()); |
| 142 | + assertEquals(expectedThrowable.getMessage(), actualThrowable.getMessage(), message); |
146 | 143 | } |
147 | 144 | } |
148 | 145 | } |
@@ -369,7 +366,7 @@ public static void assertSimilarBrightness(String message, int expected, int act |
369 | 366 | // 2) and ensure brightness is within 12.5% of the range. |
370 | 367 | double expectedIntensity = getBrightness(expected); |
371 | 368 | double actualIntensity = getBrightness(actual); |
372 | | - assertEquals(message, expectedIntensity, actualIntensity, 255f / 8); |
| 369 | + assertEquals(expectedIntensity, actualIntensity, 255f / 8, message); |
373 | 370 | } |
374 | 371 | } |
375 | 372 |
|
@@ -478,7 +475,7 @@ public static void waitShellActivate(Runnable trigger, Shell shell) { |
478 | 475 | // Something went wrong? Get more info to diagnose |
479 | 476 | Screenshots.takeScreenshot(SwtTestUtil.class, "waitShellActivate-" + System.currentTimeMillis()); |
480 | 477 | dumpShellState(System.out); |
481 | | - assertThat("Shell did not activate", shell.getDisplay().getActiveShell(), is(shell)); |
| 478 | + assertEquals(shell.getDisplay().getActiveShell(), shell, "Shell did not activate"); |
482 | 479 | fail("SWT.Activate was not received but Shell is (incorrectly?) reported active"); |
483 | 480 | } |
484 | 481 |
|
@@ -586,13 +583,12 @@ public static boolean hasPixelNotMatching(Image image, Color nonMatchingColor, R |
586 | 583 | return false; |
587 | 584 | } |
588 | 585 |
|
589 | | -public static Path getPath(String fileName, TemporaryFolder tempFolder) { |
590 | | - Path path = tempFolder.getRoot().toPath(); |
591 | | - Path filePath = path.resolve("image-resources").resolve(Path.of(fileName)); |
592 | | - return getPath(fileName, filePath); |
| 586 | +public static Path getPath(String fileName, Path tempFolder) { |
| 587 | + Path filePath = tempFolder.resolve("image-resources").resolve(Path.of(fileName)); |
| 588 | + return copyFile(fileName, filePath); |
593 | 589 | } |
594 | 590 |
|
595 | | -public static Path getPath(String sourceFilename, Path destinationPath) { |
| 591 | +public static Path copyFile(String sourceFilename, Path destinationPath) { |
596 | 592 | if (!Files.isRegularFile(destinationPath)) { |
597 | 593 | // Extract resource on the classpath to a temporary file to ensure it's |
598 | 594 | // available as plain file, even if this bundle is packed as jar |
|
0 commit comments