You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve stability of Text cut/copy/paste tests on Windows
The tests for cut/copy/paste functionality of Text widgets in
Test_org_eclipse_swt_widgets_Text sporadically fail on Windows. Locally,
they fail on almost every execution. This seems to either be caused by
some timing issue at the OS or by the need to spin the event queue for
processing the cut/copy/paste operations at the OS.
In some tests, according event processing for spinning the event loop
and waiting for events have been implemented already for GTK. This
change adapts all calls to text.cut()/copy()/paste() such that the event
queue is spinned.
Fixes#106Fixes#876
Copy file name to clipboardExpand all lines: tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Text.java
+57-54Lines changed: 57 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -268,7 +268,7 @@ public void test_computeSizeIIZ() {
268
268
269
269
@Tag("clipboard")
270
270
@Test
271
-
publicvoidtest_copy() {
271
+
publicvoidtest_copy() throwsInterruptedException{
272
272
if (SwtTestUtil.isCocoa) {
273
273
// TODO Fix Cocoa failure.
274
274
if (SwtTestUtil.verbose) {
@@ -277,52 +277,45 @@ public void test_copy() {
277
277
}
278
278
return;
279
279
}
280
-
text.copy();
280
+
copyToClipboard(text);
281
281
282
282
text.selectAll();
283
-
text.copy();
283
+
copyToClipboard(text);
284
284
assertEquals("", text.getSelectionText());
285
285
286
286
text.setText("00000");
287
287
text.selectAll();
288
-
text.copy();
288
+
copyToClipboard(text);
289
289
text.setSelection(2);
290
290
assertEquals("", text.getSelectionText());
291
291
292
+
System.out.println(text.getText());
292
293
text.setText("");
293
-
text.paste();
294
-
// Spin the event loop to let GTK process the clipboard + entry update
295
-
Displaydisplay = text.getDisplay();
296
-
while (display.readAndDispatch()) {
297
-
// loop until no more events
298
-
}
294
+
pasteFromClipboard(text);
299
295
assertEquals("00000", text.getText());
300
296
301
297
// tests a SINGLE line text editor
302
298
makeCleanEnvironment(true);
303
299
304
-
text.copy();
300
+
copyToClipboard(text);
305
301
306
302
text.selectAll();
307
-
text.copy();
303
+
copyToClipboard(text);
308
304
assertEquals("", text.getSelectionText());
309
305
310
306
text.setText("00000");
311
307
text.selectAll();
312
-
text.copy();
308
+
copyToClipboard(text);
313
309
text.setSelection(2);
314
310
assertEquals("", text.getSelectionText());
315
311
316
312
text.setText("");
317
-
text.paste();
318
-
while (display.readAndDispatch()) {
319
-
// loop until no more events
320
-
}
313
+
pasteFromClipboard(text);
321
314
assertEquals("00000", text.getText());
322
315
}
323
316
324
317
@Test
325
-
publicvoidtest_cut() {
318
+
publicvoidtest_cut() throwsInterruptedException{
326
319
if (SwtTestUtil.isCocoa) {
327
320
// TODO Fix Cocoa failure.
328
321
if (SwtTestUtil.verbose) {
@@ -331,28 +324,28 @@ public void test_cut() {
331
324
}
332
325
return;
333
326
}
334
-
text.cut();
327
+
cutToClipboard(text);
335
328
text.setText("01234567890");
336
329
text.setSelection(2, 5);
337
-
text.cut();
330
+
cutToClipboard(text);
338
331
assertEquals("01567890", text.getText());
339
332
340
333
text.selectAll();
341
-
text.cut();
334
+
cutToClipboard(text);
342
335
assertEquals("", text.getText());
343
336
344
337
// tests a SINGLE line text editor
345
338
makeCleanEnvironment(true);
346
339
347
-
text.cut();
340
+
cutToClipboard(text);
348
341
349
342
text.setText("01234567890");
350
343
text.setSelection(2, 5);
351
-
text.cut();
344
+
cutToClipboard(text);
352
345
assertEquals("01567890", text.getText());
353
346
354
347
text.selectAll();
355
-
text.cut();
348
+
cutToClipboard(text);
356
349
assertEquals("", text.getText());
357
350
}
358
351
@@ -946,26 +939,21 @@ public void test_paste() throws InterruptedException {
0 commit comments