|
26 | 26 | import java.io.IOException; |
27 | 27 | import java.util.ArrayList; |
28 | 28 | import java.util.List; |
| 29 | +import java.util.concurrent.atomic.AtomicBoolean; |
29 | 30 |
|
30 | 31 | import org.eclipse.swt.SWT; |
31 | 32 | import org.eclipse.swt.events.SelectionAdapter; |
|
43 | 44 | import org.eclipse.swt.widgets.Shell; |
44 | 45 | import org.eclipse.swt.widgets.Text; |
45 | 46 | import org.junit.jupiter.api.BeforeEach; |
| 47 | +import org.junit.jupiter.api.RepeatedTest; |
46 | 48 | import org.junit.jupiter.api.Test; |
47 | 49 |
|
48 | 50 | /** |
@@ -652,21 +654,33 @@ public void test_setBoundsLorg_eclipse_swt_graphics_Rectangle() { |
652 | 654 | * Regression test for Bug 436841 - [GTK3] FocusOut/In and Activate/Deactivate |
653 | 655 | * events when opening context menu. Only applicable on GTK x11. |
654 | 656 | */ |
655 | | -@Test |
656 | | -public void test_activateEventSend() { |
| 657 | +@RepeatedTest(value = 1000) |
| 658 | +public void test_activateEventSend() throws InterruptedException { |
657 | 659 | if (SwtTestUtil.isGTK && SwtTestUtil.isX11) { |
| 660 | + AtomicBoolean activateCalled = new AtomicBoolean(); |
| 661 | + AtomicBoolean deactivateCalled = new AtomicBoolean(); |
658 | 662 | Shell testShell = new Shell(shell, SWT.SHELL_TRIM); |
659 | 663 | testShell.addListener(SWT.Activate, e -> { |
660 | | - listenerCalled = true; |
| 664 | + activateCalled.set(true); |
| 665 | + }); |
| 666 | + testShell.addListener(SWT.Deactivate, e -> { |
| 667 | + deactivateCalled.set(true); |
661 | 668 | }); |
| 669 | + activateCalled.set(false); |
662 | 670 | testShell.open(); |
| 671 | + SwtTestUtil.processEvents(10000, () -> activateCalled.get()); |
| 672 | + assertTrue(activateCalled.get()); |
663 | 673 | int[] styles = {SWT.ON_TOP, SWT.APPLICATION_MODAL, SWT.PRIMARY_MODAL, SWT.SYSTEM_MODAL, SWT.NO_TRIM, SWT.BORDER, SWT.SHELL_TRIM}; |
664 | 674 | for (int style : styles) { |
| 675 | + deactivateCalled.set(false); |
665 | 676 | Shell childShell = new Shell(testShell, style); |
666 | | - listenerCalled = false; |
667 | 677 | childShell.open(); |
| 678 | + SwtTestUtil.processEvents(10000, () -> deactivateCalled.get()); |
| 679 | + assertTrue(deactivateCalled.get()); |
| 680 | + activateCalled.set(false); |
668 | 681 | childShell.dispose(); |
669 | | - assertTrue(listenerCalled); |
| 682 | + SwtTestUtil.processEvents(10000, () -> activateCalled.get()); |
| 683 | + assertTrue(activateCalled.get()); |
670 | 684 | } |
671 | 685 | } |
672 | 686 | } |
|
0 commit comments