Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRolf Theunissen2019-04-07 13:20:36 -0400
committerRolf Theunissen2019-04-07 13:20:36 -0400
commitec88489807a92d066267929e843ec0c8f8dbd1ab (patch)
tree27e244693b04592378469e408aae5ecbaacb3c2a
parent5b7073780d98c4c02c5ea412cc75da1194e74292 (diff)
downloadeclipse.platform.swt-ec88489807a92d066267929e843ec0c8f8dbd1ab.tar.gz
eclipse.platform.swt-ec88489807a92d066267929e843ec0c8f8dbd1ab.tar.xz
eclipse.platform.swt-ec88489807a92d066267929e843ec0c8f8dbd1ab.zip
Bug 297510 - Wait for the shell to become active in focus test cases
Fix failing tests in Cocoa, on GTK it replaces forceActivate of the shell Change-Id: Ifd27c4885f65a8aa2576977283a9b63a10d7abc2 Signed-off-by: Rolf Theunissen <rolf.theunissen@gmail.com>
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java2
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_TableTree.java16
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Composite.java14
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java7
4 files changed, 17 insertions, 22 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java
index ac8cbf7169..a413e1ed61 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_CCombo.java
@@ -118,7 +118,7 @@ public void test_getChildren() {
@Test
@Override
-public void test_isFocusControl() {
+public void test_isFocusControl() throws InterruptedException {
if (SwtTestUtil.isGTK) {
// TODO forceFocus returns false, while isFocusControl returns true
assertFalse(control.isFocusControl());
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_TableTree.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_TableTree.java
index 96846558dc..cea5a95627 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_TableTree.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_TableTree.java
@@ -85,7 +85,7 @@ public void test_getChildren() {
@Test
@Override
-public void test_isFocusControl() {
+public void test_isFocusControl() throws InterruptedException {
if (SwtTestUtil.isCocoa) {
// TODO forceFocus returns true, while isFocusControl returns false
assertFalse(control.isFocusControl());
@@ -122,11 +122,10 @@ public void test_selectAll() {
@Override
@Test
-public void test_setFocus_toChild_afterOpen() {
+public void test_setFocus_toChild_afterOpen() throws InterruptedException {
shell.open();
- if (SwtTestUtil.isGTK) {
- shell.forceActive();
- }
+ // Wait for the shell to become active
+ processEvents(500, () -> shell.getDisplay().getActiveShell() == shell);
assertEquals(shell, shell.getDisplay().getActiveShell());
composite.setFocus();
assertTrue("First child widget should have focus", tableTree.getTable().isFocusControl());
@@ -134,12 +133,11 @@ public void test_setFocus_toChild_afterOpen() {
@Override
@Test
-public void test_setFocus_toChild_beforeOpen() {
+public void test_setFocus_toChild_beforeOpen() throws InterruptedException {
composite.setFocus();
shell.open();
- if (SwtTestUtil.isGTK) {
- shell.forceActive();
- }
+ // Wait for the shell to become active
+ processEvents(500, () -> shell.getDisplay().getActiveShell() == shell);
assertEquals(shell, shell.getDisplay().getActiveShell());
assertTrue("First child widget should have focus", tableTree.getTable().isFocusControl());
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Composite.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Composite.java
index 80ff839746..1d1d32efb4 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Composite.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Composite.java
@@ -118,25 +118,23 @@ public void test_setVisibility_and_sizing() {
}
@Test
-public void test_setFocus_toChild_afterOpen() {
+public void test_setFocus_toChild_afterOpen() throws InterruptedException {
Text focusChild = new Text(composite, SWT.NONE);
shell.open();
- if (SwtTestUtil.isGTK) {
- shell.forceActive();
- }
+ // Wait for the shell to become active
+ processEvents(500, () -> shell.getDisplay().getActiveShell() == shell);
assertEquals(shell, shell.getDisplay().getActiveShell());
composite.setFocus();
assertTrue("First child widget should have focus", focusChild.isFocusControl());
}
@Test
-public void test_setFocus_toChild_beforeOpen() {
+public void test_setFocus_toChild_beforeOpen() throws InterruptedException {
Text focusChild = new Text(composite, SWT.NONE);
composite.setFocus();
shell.open();
- if (SwtTestUtil.isGTK) {
- shell.forceActive();
- }
+ // Wait for the shell to become active
+ processEvents(500, () -> shell.getDisplay().getActiveShell() == shell);
assertEquals(shell, shell.getDisplay().getActiveShell());
assertTrue("First child widget should have focus", focusChild.isFocusControl());
}
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
index c45b1f4a17..63f9ceb81c 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Control.java
@@ -520,12 +520,11 @@ public void test_isEnabled() {
assertFalse(control.isEnabled());
}
@Test
-public void test_isFocusControl() {
+public void test_isFocusControl() throws InterruptedException {
assertFalse(control.isFocusControl());
shell.open();
- if (SwtTestUtil.isGTK) {
- shell.forceActive();
- }
+ // Wait for the shell to become active
+ processEvents(500, () -> shell.getDisplay().getActiveShell() == shell);
assertEquals(shell, shell.getDisplay().getActiveShell());
assertEquals("Unexpected focus", control.forceFocus(), control.isFocusControl());
}

Back to the top