13
13
*******************************************************************************/
14
14
package org .eclipse .swt .tests .win32 ;
15
15
16
- import static org .junit .Assert .assertArrayEquals ;
17
- import static org .junit .Assert .assertEquals ;
18
- import static org .junit .Assert .assertNotNull ;
19
- import static org .junit .Assert .assertTrue ;
20
- import static org .junit .Assert .fail ;
16
+ import static org .junit .jupiter . api . Assertions .assertArrayEquals ;
17
+ import static org .junit .jupiter . api . Assertions .assertEquals ;
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 ;
21
21
22
22
import java .util .Random ;
23
23
import java .util .concurrent .atomic .AtomicBoolean ;
45
45
import org .eclipse .swt .widgets .Display ;
46
46
import org .eclipse .swt .widgets .Event ;
47
47
import org .eclipse .swt .widgets .Shell ;
48
- import org .junit .After ;
49
- import org .junit .Before ;
50
- import org .junit .Test ;
48
+ import org .junit .jupiter . api . AfterEach ;
49
+ import org .junit .jupiter . api . BeforeEach ;
50
+ import org .junit .jupiter . api . Test ;
51
51
52
52
/**
53
53
* Some simple tests for drag and drop.
@@ -64,7 +64,7 @@ public class Test_org_eclipse_swt_dnd_DND {
64
64
65
65
private Shell shell ;
66
66
67
- @ Before
67
+ @ BeforeEach
68
68
public void setUp () {
69
69
shell = new Shell ();
70
70
shell .setLayout (new RowLayout ());
@@ -75,10 +75,10 @@ public void setUp() {
75
75
} catch (InterruptedException e ) {
76
76
fail ("Initialization interrupted" );
77
77
}
78
- assertTrue ("Shell not visible." , shell . isVisible () );
78
+ assertTrue (shell . isVisible (), "Shell not visible." );
79
79
}
80
80
81
- @ After
81
+ @ AfterEach
82
82
public void tearDown () {
83
83
Display display = shell .getDisplay ();
84
84
display .dispose ();
@@ -108,7 +108,7 @@ protected int[] getTypeIds() {
108
108
return new int [] { TEST_ID };
109
109
}
110
110
}, drag );
111
- assertArrayEquals ("Drop received other data as we dragged." , drag , drop );
111
+ assertArrayEquals (drag , drop , "Drop received other data as we dragged." );
112
112
}
113
113
114
114
/**
@@ -120,7 +120,7 @@ public void testFileTransfer() throws InterruptedException {
120
120
final String [] drop ;
121
121
122
122
drop = testTransferRoundtrip (FileTransfer .getInstance (), drag );
123
- assertArrayEquals ("Drop received other data as we dragged." , drag , drop );
123
+ assertArrayEquals (drag , drop , "Drop received other data as we dragged." );
124
124
}
125
125
126
126
/**
@@ -132,7 +132,7 @@ public void testHtmlTransfer() throws InterruptedException {
132
132
final String drop ;
133
133
134
134
drop = testTransferRoundtrip (HTMLTransfer .getInstance (), drag );
135
- assertEquals ("Drop received other data as we dragged." , drag , drop );
135
+ assertEquals (drag , drop , "Drop received other data as we dragged." );
136
136
}
137
137
138
138
/**
@@ -208,7 +208,7 @@ public void testRtfTransfer() throws InterruptedException {
208
208
final String drop ;
209
209
210
210
drop = testTransferRoundtrip (RTFTransfer .getInstance (), drag );
211
- assertEquals ("Drop received other data as we dragged." , drag , drop );
211
+ assertEquals (drag , drop , "Drop received other data as we dragged." );
212
212
}
213
213
214
214
/**
@@ -220,7 +220,7 @@ public void testTextTransfer() throws InterruptedException {
220
220
final String drop ;
221
221
222
222
drop = testTransferRoundtrip (TextTransfer .getInstance (), drag );
223
- assertEquals ("Drop received other data as we dragged." , drag , drop );
223
+ assertEquals (drag , drop , "Drop received other data as we dragged." );
224
224
}
225
225
226
226
/**
@@ -232,7 +232,7 @@ public void testUrlTransfer() throws InterruptedException {
232
232
final String drop ;
233
233
234
234
drop = testTransferRoundtrip (URLTransfer .getInstance (), drag );
235
- assertEquals ("Drop received other data as we dragged." , drag , drop );
235
+ assertEquals (drag , drop , "Drop received other data as we dragged." );
236
236
}
237
237
238
238
/**
@@ -267,28 +267,28 @@ private Image createTestImage() {
267
267
*/
268
268
// This method is necessary because ImageData has no custom equals method and the default one isn't sufficient.
269
269
private void assertImageDataEqualsIgoringAlphaInData (final ImageData expected , final ImageData actual ) {
270
- assertNotNull ("expected data must not be null" , expected );
271
- assertNotNull ("actual data must not be null" , actual );
270
+ assertNotNull (expected , "expected data must not be null" );
271
+ assertNotNull (actual , "actual data must not be null" );
272
272
if (expected == actual ) {
273
273
return ;
274
274
}
275
- assertEquals ("height of expected image is different from actual image" , expected . height , actual . height );
275
+ assertEquals (expected . height , actual . height , "height of expected image is different from actual image" );
276
276
// Alpha values are taken from alpha data, so ignore whether data depth is 24 or 32 bits
277
277
int expectedNormalizedDepth = expected .depth == 32 ? 24 : expected .depth ;
278
278
int actualNormalizedDepth = expected .depth == 32 ? 24 : expected .depth ;
279
- assertEquals ("depth of image data to compare must be equal" , expectedNormalizedDepth , actualNormalizedDepth );
280
- assertEquals ("width of expected image is different from actual image" , expected . width , actual . width );
279
+ assertEquals (expectedNormalizedDepth , actualNormalizedDepth , "depth of image data to compare must be equal" );
280
+ assertEquals (expected . width , actual . width , "width of expected image is different from actual image" );
281
281
282
282
for (int y = 0 ; y < expected .height ; y ++) {
283
283
for (int x = 0 ; x < expected .width ; x ++) {
284
284
// FIXME win32: dragged ALPHA=FF, dropped ALPHA=00, but other transparencyType
285
285
// => alpha stored in ImageData.alphaData
286
286
String expectedPixel = String .format ("0x%08X" , expected .getPixel (x , y ) >> (expected .depth == 32 ? 8 : 0 ));
287
287
String actualPixel = String .format ("0x%08X" , actual .getPixel (x , y ) >> (actual .depth == 32 ? 8 : 0 ));
288
- assertEquals ("actual pixel at x=" + x + " y=" + y + " is different from expected pixel" , expectedPixel , actualPixel );
288
+ assertEquals (expectedPixel , actualPixel , "actual pixel at x=" + x + " y=" + y + " is different from expected pixel" );
289
289
int expectedAlpha = expected .getAlpha (x , y );
290
290
int actualAlpha = actual .getAlpha (x , y );
291
- assertEquals ("actual pixel alpha at x=" + x + " y=" + y + " is different from expected pixel" , expectedAlpha , actualAlpha );
291
+ assertEquals (expectedAlpha , actualAlpha , "actual pixel alpha at x=" + x + " y=" + y + " is different from expected pixel" );
292
292
}
293
293
}
294
294
}
@@ -327,8 +327,8 @@ private <T> T testTransferRoundtrip(Transfer transfer, T data) throws Interrupte
327
327
SwtWin32TestUtil .processEvents (shell .getDisplay (), 2000 , dropped ::get );
328
328
} while (!dropped .get () && --maxTries > 0 );
329
329
330
- assertTrue ("No drop received." , dropped . get () );
331
- assertNotNull ("No data was dropped." , droppedData . get () );
330
+ assertTrue (dropped . get (), "No drop received." );
331
+ assertNotNull (droppedData . get (), "No data was dropped." );
332
332
333
333
return droppedData .get ();
334
334
}
@@ -341,7 +341,7 @@ private <T> T testTransferRoundtrip(Transfer transfer, T data) throws Interrupte
341
341
*/
342
342
private void postDragAndDropEvents () {
343
343
shell .forceActive ();
344
- assertTrue ("Test shell requires input focus." , shell . forceFocus () );
344
+ assertTrue (shell . forceFocus (), "Test shell requires input focus." );
345
345
Event event = new Event ();
346
346
Point pt = shell .toDisplay (50 , 50 );
347
347
event .x = pt .x ;
0 commit comments