Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Bullen2018-01-18 17:58:45 +0000
committerLucas Bullen2018-01-18 17:59:30 +0000
commit44130248a27b8c658e1445287aa4f630cf543a33 (patch)
tree3816e679bb7b62a75fa28be388b204dd7467564a
parent22b16b05ff8ded81bd4ef80558e618612a34a67a (diff)
downloadeclipse.platform.ui-44130248a27b8c658e1445287aa4f630cf543a33.tar.gz
eclipse.platform.ui-44130248a27b8c658e1445287aa4f630cf543a33.tar.xz
eclipse.platform.ui-44130248a27b8c658e1445287aa4f630cf543a33.zip
Bug 493357 - [gtk3] Fix 8 tests that failed on CentOSI20180119-0110I20180118-2000
- Using wait for conditions to allow testing around race conditions Change-Id: Ib91172736c63549558f4208f6d5d1c1f3dbdbaf3 Signed-off-by: Lucas Bullen <lbullen@redhat.com>
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java16
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java17
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java32
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java41
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerTestCase.java5
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualLazyTreeViewerTest.java19
6 files changed, 76 insertions, 54 deletions
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java
index 9f1d4159840..f314422df99 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2017 Brad Reynolds, IBM Corporation and others.
+ * Copyright (c) 2006, 2018 Brad Reynolds, IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* Brad Reynolds - initial API and implementation
* IBM Corporation - Bug 493357
+ * Lucas Bullen (Red Hat Inc.) - Revert disabling tests from Bug 493357
*******************************************************************************/
package org.eclipse.jface.tests.viewers;
@@ -40,12 +41,8 @@ public class ListViewerRefreshTest extends TestCase {
private ArrayList<String> input = null;
- protected boolean disableTestsBug493357 = false;
-
-
@Override
protected void setUp() throws Exception {
- disableTestsBug493357 = System.getProperty("org.eclipse.swt.internal.gtk.version", "").startsWith("3."); // $NON-NLS-1//$NON-NLS-2//$NON-NLS-3
shell = new Shell();
shell.setSize(400, 200);
shell.setLayout(new FillLayout());
@@ -76,11 +73,6 @@ public class ListViewerRefreshTest extends TestCase {
* @throws Exception
*/
public void testNoSelectionRefresh() throws Exception {
- if (disableTestsBug493357) {
- System.out.println(getName() + " disabled due to Bug 493357");
- return;
- }
-
shell.setText("Lost Scrolled Position Test"); //$NON-NLS-1$
readAndDispatch();
@@ -99,10 +91,6 @@ public class ListViewerRefreshTest extends TestCase {
* @throws Exception
*/
public void testSelectionRefresh() throws Exception {
- if (disableTestsBug493357) {
- System.out.println(getName() + " disabled due to Bug 493357");
- return;
- }
shell.setText("Preserved Scrolled Position Test"); //$NON-NLS-1$
readAndDispatch();
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java
index c26e8597a70..1c9e4647c12 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,7 @@
* Tom Schindl <tom.schindl@bestsolution.at> - test case for bug 157309, 177619
* Brad Reynolds - test case for bug 141435
* Jan-Ove Weichel <janove.weichel@vogella.com> - Bug 481490
+ * Lucas Bullen (Red Hat Inc.) - Bug 493357
*******************************************************************************/
package org.eclipse.jface.tests.viewers;
@@ -21,6 +22,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.List;
+import org.eclipse.ui.tests.harness.util.DisplayHelper;
public class ListViewerTest extends StructuredViewerTest {
@@ -149,15 +151,18 @@ public class ListViewerTest extends StructuredViewerTest {
}
public void testSelectionRevealBug177619() throws Exception {
- if (disableTestsBug493357) {
- System.out.println(getName() + " disabled due to Bug 493357");
- return;
- }
TestElement model = TestElement.createModel(1, 100);
fViewer.setInput(model);
fViewer.setSelection(new StructuredSelection(((ListViewer)fViewer).getElementAt(50)),true);
- assertTrue(((ListViewer)fViewer).getList().getTopIndex() != 0);
+ List list = ((ListViewer) fViewer).getList();
+ new DisplayHelper() {
+ @Override
+ protected boolean condition() {
+ return list.getTopIndex() != 0;
+ }
+ }.waitForCondition(fViewer.getControl().getDisplay(), 3000);
+ assertTrue(list.getTopIndex() != 0);
}
public void testSelectionNoRevealBug177619() throws Exception {
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java
index 959699dc1b7..3415b58d890 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Jeanderson Candido <http://jeandersonbc.github.io> - Bug 118919
+ * Lucas Bullen (Red Hat Inc.) - Bug 493357
*******************************************************************************/
package org.eclipse.jface.tests.viewers;
@@ -23,6 +24,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.tests.harness.util.DisplayHelper;
/**
* Tests TreeViewer's VIRTUAL support with a lazy content provider.
@@ -188,14 +190,12 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
/* test TreeViewer.remove(parent, index) */
public void testRemoveAt() {
+ assertTrue("expected less than " + (NUM_ROOTS / 2) + " but got " + updateElementCallCount,
+ updateElementCallCount < NUM_ROOTS / 2);
if (disableTestsBug347491) {
System.out.println(getName() + " disabled due to Bug 347491");
return;
}
- if (disableTestsBug493357) {
- System.out.println(getName() + " disabled due to Bug 493357");
- return;
- }
assertTrue("SWT.SetData not received", setDataCalled);
TreeViewer treeViewer = (TreeViewer) fViewer;
// correct what the content provider is answering with
@@ -206,19 +206,27 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
treeViewer.setSelection(new StructuredSelection(new Object[] { "R-0",
"R-1" }));
assertEquals(2, treeViewer.getStructuredSelection().size());
- processEvents();
- assertTrue("expected less than " + (NUM_ROOTS / 2) + " but got "
- + updateElementCallCount,
- updateElementCallCount < NUM_ROOTS / 2);
- updateElementCallCount = 0;
+ processEventsUntilElementUpdated();
// printCallbacks = true;
// correct what the content provider is answering with
offset = 2;
treeViewer.remove(treeViewer.getInput(), 1);
assertEquals(NUM_ROOTS - 2, treeViewer.getTree().getItemCount());
- processEvents();
+ processEventsUntilElementUpdated();
assertEquals(1, treeViewer.getStructuredSelection().size());
- assertEquals(1, updateElementCallCount);
// printCallbacks = false;
}
+
+ private void processEventsUntilElementUpdated() {
+ updateElementCallCount = 0;
+ new DisplayHelper() {
+ @Override
+ protected boolean condition() {
+ // Keep processing events until the element updated event is queued and run
+ processEvents();
+ return updateElementCallCount == 1;
+ }
+ }.waitForCondition(fViewer.getControl().getDisplay(), 3000);
+ assertEquals(1, updateElementCallCount);
+ }
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java
index 31738c77157..d22b6fdf871 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* Tom Schindl - bug 151205
* Jan-Ove Weichel <janove.weichel@vogella.com> - Bug 481490
+ * Lucas Bullen (Red Hat Inc.) - Bug 493357
*******************************************************************************/
package org.eclipse.jface.tests.viewers;
@@ -26,6 +27,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.tests.harness.util.DisplayHelper;
public abstract class StructuredViewerTest extends ViewerTestCase {
public static class TestLabelFilter extends ViewerFilter {
@@ -110,7 +112,14 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
TestElement newElement = first.getContainer().basicAddChild();
fRootElement.basicDeleteChild(first);
fModel.fireModelChanged(eventToFire);
- processEvents();
+ processEvents();
+ // Wait for events to be processed
+ new DisplayHelper() {
+ @Override
+ protected boolean condition() {
+ return fViewer.testFindItem(newElement) != null;
+ }
+ }.waitForCondition(fViewer.getControl().getDisplay(), 3000);
assertNotNull("new sibling is visible", fViewer
.testFindItem(newElement));
assertNull("first child is not visible", fViewer.testFindItem(first));
@@ -312,6 +321,13 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
public void testInsertSibling() {
TestElement newElement = fRootElement.addChild(TestModelChange.INSERT);
processEvents();
+ // Wait for events to be processed
+ new DisplayHelper() {
+ @Override
+ protected boolean condition() {
+ return fViewer.testFindItem(newElement) != null;
+ }
+ }.waitForCondition(fViewer.getControl().getDisplay(), 3000);
assertNotNull("new sibling is visible", fViewer
.testFindItem(newElement));
}
@@ -327,6 +343,13 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
TestElement[] newElements = fRootElement
.addChildren(TestModelChange.INSERT);
processEvents();
+ // Wait for events to be processed
+ new DisplayHelper() {
+ @Override
+ protected boolean condition() {
+ return fViewer.testFindItem(newElements[newElements.length - 1]) != null;
+ }
+ }.waitForCondition(fViewer.getControl().getDisplay(), 3000);
for (TestElement newElement : newElements) {
assertNotNull("new siblings are visible", fViewer
.testFindItem(newElement));
@@ -337,6 +360,13 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
TestElement newElement = fRootElement.addChild(TestModelChange.INSERT
| TestModelChange.REVEAL | TestModelChange.SELECT);
processEvents();
+ // Wait for events to be processed
+ new DisplayHelper() {
+ @Override
+ protected boolean condition() {
+ return fViewer.testFindItem(newElement) != null;
+ }
+ }.waitForCondition(fViewer.getControl().getDisplay(), 3000);
assertNotNull("new sibling is visible", fViewer
.testFindItem(newElement));
assertSelectionEquals("new element is selected", newElement);
@@ -454,6 +484,13 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
fRootElement = first;
setInput();
processEvents();
+ // Wait for events to be processed
+ new DisplayHelper() {
+ @Override
+ protected boolean condition() {
+ return fViewer.testFindItem(firstfirst) != null;
+ }
+ }.waitForCondition(fViewer.getControl().getDisplay(), 3000);
assertNotNull("first child is visible", fViewer
.testFindItem(firstfirst));
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerTestCase.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerTestCase.java
index 665b117749a..1de5248874b 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerTestCase.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerTestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Lucas Bullen (Red Hat Inc.) - Bug 493357
*******************************************************************************/
package org.eclipse.jface.tests.viewers;
@@ -36,7 +37,6 @@ public abstract class ViewerTestCase extends TestCase {
public TestModel fModel;
protected boolean disableTestsBug347491 = false;
- protected boolean disableTestsBug493357 = false;
private ILogger oldLogger;
private ISafeRunnableRunner oldRunner;
@@ -105,7 +105,6 @@ public abstract class ViewerTestCase extends TestCase {
@Override
public void setUp() {
- disableTestsBug493357 = System.getProperty("org.eclipse.swt.internal.gtk.version", "").startsWith("3."); // $NON-NLS-1//$NON-NLS-2//$NON-NLS-3
oldLogger = Policy.getLog();
oldRunner = SafeRunnable.getRunner();
Policy.setLog(status -> fail(status.getMessage()));
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualLazyTreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualLazyTreeViewerTest.java
index 67740fada74..966358d9b95 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualLazyTreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualLazyTreeViewerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Tom Schindl - bug 151205
+ * Lucas Bullen (Red Hat Inc.) - Bug 493357
*******************************************************************************/
package org.eclipse.jface.tests.viewers;
@@ -165,10 +166,6 @@ public class VirtualLazyTreeViewerTest extends TreeViewerTest {
if (disableTestsBug347491) {
return;
}
- if (disableTestsBug493357) {
- System.out.println(getName() + " disabled due to Bug 493357");
- return;
- }
if (setDataCalls == 0) {
System.err.println("SWT.SetData is not received. Cancelled test " + getName());
return;
@@ -181,10 +178,6 @@ public class VirtualLazyTreeViewerTest extends TreeViewerTest {
if (disableTestsBug347491) {
return;
}
- if (disableTestsBug493357) {
- System.out.println(getName() + " disabled due to Bug 493357");
- return;
- }
if (setDataCalls == 0) {
System.err.println("SWT.SetData is not received. Cancelled test " + getName());
return;
@@ -209,10 +202,6 @@ public class VirtualLazyTreeViewerTest extends TreeViewerTest {
if (disableTestsBug347491) {
return;
}
- if (disableTestsBug493357) {
- System.out.println(getName() + " disabled due to Bug 493357");
- return;
- }
if (setDataCalls == 0) {
System.err.println("SWT.SetData is not received. Cancelled test " + getName());
return;
@@ -225,10 +214,6 @@ public class VirtualLazyTreeViewerTest extends TreeViewerTest {
if (disableTestsBug347491) {
return;
}
- if (disableTestsBug493357) {
- System.out.println(getName() + " disabled due to Bug 493357");
- return;
- }
if (setDataCalls == 0) {
System.err.println("SWT.SetData is not received. Cancelled test " + getName());
return;

Back to the top