Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
package org.eclipse.swt.graphics;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

import org.eclipse.swt.internal.DPIUtil;
import org.eclipse.swt.widgets.Display;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Automated Tests for class org.eclipse.swt.graphics.Image
Expand All @@ -32,7 +32,7 @@
public class ImageWin32Tests {
private Display display;

@Before
@BeforeEach
public void setUp() {
display = Display.getDefault();
}
Expand All @@ -45,10 +45,10 @@ public void testImageDataForDifferentFractionalZoomsShouldBeDifferent() {
int zoom2 = 150;
ImageData imageDataAtZoom1 = image.getImageData(zoom1);
ImageData imageDataAtZoom2 = image.getImageData(zoom2);
assertNotEquals("ImageData::height should not be the same for imageData at different zoom levels",
imageDataAtZoom1.height, imageDataAtZoom2.height);
assertNotEquals("ImageData::width should not be the same for imageData at different zoom levels",
imageDataAtZoom1.width, imageDataAtZoom2.width);
assertNotEquals(imageDataAtZoom1.height, imageDataAtZoom2.height,
"ImageData::height should not be the same for imageData at different zoom levels");
assertNotEquals(imageDataAtZoom1.width, imageDataAtZoom2.width,
"ImageData::width should not be the same for imageData at different zoom levels");
}

@Test
Expand All @@ -59,11 +59,12 @@ public void testImageShouldHaveDimesionAsPerZoomLevel() {
Image image = new Image(display, noOpGcDrawer, 10, 10);
try {
ImageData baseImageData = image.getImageData(zoom);
assertEquals("Width should equal the initial width on the same zoom", 10, baseImageData.width);
assertEquals(10, baseImageData.width, "Width should equal the initial width on the same zoom");
ImageData scaledImageData = image.getImageData(zoom * scalingFactor);
assertEquals("Width should be doubled on doubled zoom", 10*2, scaledImageData.width);
assertEquals(10*2, scaledImageData.width, "Width should be doubled on doubled zoom");
} finally {
image.dispose();
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,16 @@
import org.eclipse.swt.graphics.ImageWin32Tests;
import org.eclipse.swt.tests.win32.widgets.TestTreeColumn;
import org.eclipse.swt.tests.win32.widgets.Test_org_eclipse_swt_widgets_Display;
import org.junit.runner.JUnitCore;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses({
ImageWin32Tests.class,
Test_org_eclipse_swt_dnd_DND.class,
Test_org_eclipse_swt_events_KeyEvent.class,
Test_org_eclipse_swt_widgets_Display.class,
TestTreeColumn.class,
Win32DPIUtilTests.class
})
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.Suite;

@Suite
@SelectClasses({ ImageWin32Tests.class, //
Test_org_eclipse_swt_dnd_DND.class, //
Test_org_eclipse_swt_events_KeyEvent.class, //
Test_org_eclipse_swt_widgets_Display.class, //
TestTreeColumn.class, //
Win32DPIUtilTests.class })
public class AllWin32Tests {

public static void main(String[] args) {
JUnitCore.main(AllWin32Tests.class.getName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.swt.tests.win32;

import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.ArrayList;

Expand All @@ -25,10 +25,9 @@
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;

/**
* Supporting code for testing keyboard layouts
Expand All @@ -46,8 +45,7 @@ public class KeyboardLayoutTest {
boolean collectKeyErrors;
ArrayList<AssertionError> keyErrors;

@Rule
public TestName testName = new TestName();
private String testName;

// Hardware scan codes, with names according to English US layout
protected enum UsScan {
Expand Down Expand Up @@ -222,8 +220,9 @@ public boolean isExtended() {
A___,
};

@Before
public void setUp() {
@BeforeEach
public void setUp(TestInfo testInfo) {
this.testName = testInfo.getDisplayName();
display = new Display();
shell = new Shell();

Expand Down Expand Up @@ -253,7 +252,7 @@ public void setUp() {
shell.forceFocus();
}

@After
@AfterEach
public void tearDown() {
if (shell != null) {
shell.dispose();
Expand Down Expand Up @@ -496,7 +495,7 @@ protected void onKeyError(AssertionError error) {
if (keyErrors == null)
keyErrors = new ArrayList<>();

System.out.println(testName.getMethodName() + " : " + error.getMessage());
System.out.println(testName + " : " + error.getMessage());
keyErrors.add(error);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
*******************************************************************************/
package org.eclipse.swt.tests.win32;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -45,9 +45,9 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Some simple tests for drag and drop.
Expand All @@ -64,7 +64,7 @@ public class Test_org_eclipse_swt_dnd_DND {

private Shell shell;

@Before
@BeforeEach
public void setUp() {
shell = new Shell();
shell.setLayout(new RowLayout());
Expand All @@ -75,10 +75,10 @@ public void setUp() {
} catch (InterruptedException e) {
fail("Initialization interrupted");
}
assertTrue("Shell not visible.", shell.isVisible());
assertTrue(shell.isVisible(), "Shell not visible.");
}

@After
@AfterEach
public void tearDown() {
Display display = shell.getDisplay();
display.dispose();
Expand Down Expand Up @@ -108,7 +108,7 @@ protected int[] getTypeIds() {
return new int[] { TEST_ID };
}
}, drag);
assertArrayEquals("Drop received other data as we dragged.", drag, drop);
assertArrayEquals(drag, drop, "Drop received other data as we dragged.");
}

/**
Expand All @@ -120,7 +120,7 @@ public void testFileTransfer() throws InterruptedException {
final String[] drop;

drop = testTransferRoundtrip(FileTransfer.getInstance(), drag);
assertArrayEquals("Drop received other data as we dragged.", drag, drop);
assertArrayEquals(drag, drop, "Drop received other data as we dragged.");
}

/**
Expand All @@ -132,7 +132,7 @@ public void testHtmlTransfer() throws InterruptedException {
final String drop;

drop = testTransferRoundtrip(HTMLTransfer.getInstance(), drag);
assertEquals("Drop received other data as we dragged.", drag, drop);
assertEquals(drag, drop, "Drop received other data as we dragged.");
}

/**
Expand Down Expand Up @@ -208,7 +208,7 @@ public void testRtfTransfer() throws InterruptedException {
final String drop;

drop = testTransferRoundtrip(RTFTransfer.getInstance(), drag);
assertEquals("Drop received other data as we dragged.", drag, drop);
assertEquals(drag, drop, "Drop received other data as we dragged.");
}

/**
Expand All @@ -220,7 +220,7 @@ public void testTextTransfer() throws InterruptedException {
final String drop;

drop = testTransferRoundtrip(TextTransfer.getInstance(), drag);
assertEquals("Drop received other data as we dragged.", drag, drop);
assertEquals(drag, drop, "Drop received other data as we dragged.");
}

/**
Expand All @@ -232,7 +232,7 @@ public void testUrlTransfer() throws InterruptedException {
final String drop;

drop = testTransferRoundtrip(URLTransfer.getInstance(), drag);
assertEquals("Drop received other data as we dragged.", drag, drop);
assertEquals(drag, drop, "Drop received other data as we dragged.");
}

/**
Expand Down Expand Up @@ -267,28 +267,28 @@ private Image createTestImage() {
*/
// This method is necessary because ImageData has no custom equals method and the default one isn't sufficient.
private void assertImageDataEqualsIgoringAlphaInData(final ImageData expected, final ImageData actual) {
assertNotNull("expected data must not be null", expected);
assertNotNull("actual data must not be null", actual);
assertNotNull(expected, "expected data must not be null");
assertNotNull(actual, "actual data must not be null");
if (expected == actual) {
return;
}
assertEquals("height of expected image is different from actual image", expected.height, actual.height);
assertEquals(expected.height, actual.height, "height of expected image is different from actual image");
// Alpha values are taken from alpha data, so ignore whether data depth is 24 or 32 bits
int expectedNormalizedDepth = expected.depth == 32 ? 24 : expected.depth;
int actualNormalizedDepth = expected.depth == 32 ? 24 : expected.depth;
assertEquals("depth of image data to compare must be equal", expectedNormalizedDepth, actualNormalizedDepth);
assertEquals("width of expected image is different from actual image", expected.width, actual.width);
assertEquals(expectedNormalizedDepth, actualNormalizedDepth, "depth of image data to compare must be equal");
assertEquals(expected.width, actual.width, "width of expected image is different from actual image");

for (int y = 0; y < expected.height; y++) {
for (int x = 0; x < expected.width; x++) {
// FIXME win32: dragged ALPHA=FF, dropped ALPHA=00, but other transparencyType
// => alpha stored in ImageData.alphaData
String expectedPixel = String.format("0x%08X", expected.getPixel(x, y) >> (expected.depth == 32 ? 8 : 0));
String actualPixel = String.format("0x%08X", actual.getPixel(x, y) >> (actual.depth == 32 ? 8 : 0));
assertEquals("actual pixel at x=" + x + " y=" + y + " is different from expected pixel", expectedPixel, actualPixel);
assertEquals(expectedPixel, actualPixel, "actual pixel at x=" + x + " y=" + y + " is different from expected pixel");
int expectedAlpha = expected.getAlpha(x, y);
int actualAlpha = actual.getAlpha(x, y);
assertEquals("actual pixel alpha at x=" + x + " y=" + y + " is different from expected pixel", expectedAlpha, actualAlpha);
assertEquals(expectedAlpha, actualAlpha, "actual pixel alpha at x=" + x + " y=" + y + " is different from expected pixel");
}
}
}
Expand Down Expand Up @@ -327,8 +327,8 @@ private <T> T testTransferRoundtrip(Transfer transfer, T data) throws Interrupte
SwtWin32TestUtil.processEvents(shell.getDisplay(), 2000, dropped::get);
} while(!dropped.get() && --maxTries > 0);

assertTrue("No drop received.", dropped.get());
assertNotNull("No data was dropped.", droppedData.get());
assertTrue(dropped.get(), "No drop received.");
assertNotNull(droppedData.get(), "No data was dropped.");

return droppedData.get();
}
Expand All @@ -341,7 +341,7 @@ private <T> T testTransferRoundtrip(Transfer transfer, T data) throws Interrupte
*/
private void postDragAndDropEvents() {
shell.forceActive();
assertTrue("Test shell requires input focus.", shell.forceFocus());
assertTrue(shell.forceFocus(), "Test shell requires input focus.");
Event event = new Event();
Point pt = shell.toDisplay(50, 50);
event.x = pt.x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.widgets.Event;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
* Automated Test Suite for class org.eclipse.swt.events.KeyEvent
Expand Down Expand Up @@ -166,7 +166,7 @@ private boolean isSystemHotkey(int state, UsScan scanCode) {
/**
* Extensive test for English US layout
*/
@Test
@org.junit.jupiter.api.Test
public void testEnglishUs_stdKeys() {
// This table intentionally provides "naive" expected values. Actual
// expected values have some discrepancies from that, see code below.
Expand Down Expand Up @@ -921,7 +921,7 @@ public void testEnglishInternational_deadKey_Shift6() {
* release that isn't paired with key press (due to RegisterHotKey()
* or hook or pressing in other app and releasing in SWT).
*/
@Ignore("Have been broken for ages, maybe not worth fixing")
@Disabled("Have been broken for ages, maybe not worth fixing")
@Test
public void testEnglishUs_unpairedKeyUp() {
runWithLayout(LAYOUT_ENGLISH_US, () -> {
Expand Down Expand Up @@ -959,7 +959,7 @@ public void testEnglishUs_unpairedKeyUp() {
* released first. Specifically, it didn't produce SWT.KeyUp for 'C' at all,
* and also produced SWT.KeyUp for 'Ctrl' with incorrect 'character = 0x03'.
*/
@Ignore("Have been broken for ages, maybe not worth fixing")
@Disabled("Have been broken for ages, maybe not worth fixing")
@Test
public void testEnglishUs_unorderedCtrlC() {
runWithLayout(LAYOUT_ENGLISH_US, () -> {
Expand All @@ -981,7 +981,7 @@ public void testEnglishUs_unorderedCtrlC() {
* Not yet fixed: SWT doesn't report second SWT.KeyUp when two letters
* were pressed and released out of order
*/
@Ignore("Have been broken for ages, maybe not worth fixing")
@Disabled("Have been broken for ages, maybe not worth fixing")
@Test
public void testEnglishUs_multipleLetters() {
runWithLayout(LAYOUT_ENGLISH_US, () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.internal.Win32DPIUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* Automated Test Suite for class org.eclipse.swt.internal.Win32DPIUtils
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.swt.tests.win32.widgets;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand All @@ -24,7 +24,7 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class TestTreeColumn {

Expand Down
Loading
Loading