aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2011-08-09 16:05:32 (EDT)
committerOleg Besedin2011-08-09 16:05:32 (EDT)
commit639db407ff88cffb47e5a22294be004f09c50885 (patch)
tree95a7084f31e1bdf1a30882876938f59d9e841ff4
parent3cada61d6d530c03ead871da73ede2b6b443b316 (diff)
downloadeclipse.platform.ui-639db407ff88cffb47e5a22294be004f09c50885.zip
eclipse.platform.ui-639db407ff88cffb47e5a22294be004f09c50885.tar.gz
eclipse.platform.ui-639db407ff88cffb47e5a22294be004f09c50885.tar.bz2
Bug 118919 - [Viewers] Failure in
SimpleVirtualLazyTreeViewerTest.testCreation
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java35
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualLazyTreeViewerTest.java40
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTableViewerTest.java32
3 files changed, 100 insertions, 7 deletions
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 63b6e4d..e05a072 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
@@ -21,6 +21,7 @@ import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
@@ -37,6 +38,8 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
private boolean printCallbacks = false;
private int offset = 0;
+ private int updateElementCallCount = 0;
+
private class LazyTreeContentProvider implements ILazyTreeContentProvider {
/**
*
@@ -79,8 +82,6 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
}
}
- private int updateElementCallCount = 0;
-
public SimpleVirtualLazyTreeViewerTest(String name) {
super(name);
}
@@ -88,7 +89,22 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
public TreeViewer getTreeViewer() {
return (TreeViewer) fViewer;
}
-
+
+ /**
+ * Checks if the virtual tree / table functionality can be tested in the current settings.
+ * The virtual trees and tables rely on SWT.SetData event which is only sent if OS requests
+ * information about the tree / table. If the window is not visible (obscured by another window,
+ * outside of visible area, or OS determined that it can skip drawing), then OS request won't
+ * be send, causing automated tests to fail.
+ * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=118919 .
+ */
+ protected boolean setDataCalled = false;
+
+ public void setUp() {
+ super.setUp();
+ processEvents(); // run events for SetData precondition test
+ }
+
protected void setInput() {
String letterR = "R";
getTreeViewer().setInput(letterR);
@@ -98,12 +114,21 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
Tree tree = new Tree(fShell, SWT.VIRTUAL | SWT.MULTI);
TreeViewer treeViewer = new TreeViewer(tree);
treeViewer.setContentProvider(new LazyTreeContentProvider());
+ tree.addListener(SWT.SetData, new Listener() {
+ public void handleEvent(Event event) {
+ setDataCalled = true;
+ }
+ });
return treeViewer;
}
public void testCreation() {
if (disableTestsBug347491)
return;
+ if (!setDataCalled) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
processEvents();
assertTrue("tree should have items", getTreeViewer().getTree()
.getItemCount() > 0);
@@ -160,6 +185,10 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
public void testRemoveAt() {
if (disableTestsBug347491)
return;
+ if (!setDataCalled) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
TreeViewer treeViewer = (TreeViewer) fViewer;
// correct what the content provider is answering with
treeViewer.getTree().update();
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 5dd7dda..efee60a 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
@@ -121,42 +121,78 @@ public class VirtualLazyTreeViewerTest extends TreeViewerTest {
public void testRefreshWithAddedChildren() {
if (disableTestsBug347491)
return;
+ if (setDataCalls == 0) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
super.testRefreshWithAddedChildren();
}
public void testDeleteSibling() {
if (disableTestsBug347491)
return;
- super.testDeleteSibling();
+ if (setDataCalls == 0) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
+ super.testDeleteSibling();
+ }
+
+ public void testExpandToLevel() {
+ if (setDataCalls == 0) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
+ super.testExpandToLevel();
}
public void testInsertSibling() {
if (disableTestsBug347491)
return;
+ if (setDataCalls == 0) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
super.testInsertSibling();
}
public void testInsertSiblings() {
if (disableTestsBug347491)
return;
- super.testInsertSiblings();
+ if (setDataCalls == 0) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
+ super.testInsertSiblings();
}
public void testSetInput() {
if (disableTestsBug347491)
return;
+ if (setDataCalls == 0) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
super.testSetInput();
}
public void testSomeChildrenChanged() {
if (disableTestsBug347491)
return;
+ if (setDataCalls == 0) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
super.testSomeChildrenChanged();
}
public void testWorldChanged() {
if (disableTestsBug347491)
return;
+ if (setDataCalls == 0) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
super.testWorldChanged();
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTableViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTableViewerTest.java
index 84b6406..67f0f23 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTableViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTableViewerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -35,6 +35,16 @@ public class VirtualTableViewerTest extends TableViewerTest {
Set visibleItems = new HashSet();
/**
+ * Checks if the virtual tree / table functionality can be tested in the current settings.
+ * The virtual trees and tables rely on SWT.SetData event which is only sent if OS requests
+ * information about the tree / table. If the window is not visible (obscured by another window,
+ * outside of visible area, or OS determined that it can skip drawing), then OS request won't
+ * be send, causing automated tests to fail.
+ * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=118919 .
+ */
+ protected boolean setDataCalled = false;
+
+ /**
* Create a new instance of the receiver.
*
* @param name
@@ -42,7 +52,12 @@ public class VirtualTableViewerTest extends TableViewerTest {
public VirtualTableViewerTest(String name) {
super(name);
}
-
+
+ public void setUp() {
+ super.setUp();
+ processEvents(); // run events for SetData precondition test
+ }
+
protected int getShellStyle() {
return super.getShellStyle() | SWT.ON_TOP;
}
@@ -64,6 +79,7 @@ public class VirtualTableViewerTest extends TableViewerTest {
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
*/
public void handleEvent(Event event) {
+ setDataCalled = true;
TableItem item = (TableItem) event.item;
visibleItems.add(item);
}
@@ -106,6 +122,10 @@ public class VirtualTableViewerTest extends TableViewerTest {
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testFilter()
*/
public void testFilter() {
+ if (!setDataCalled) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
ViewerFilter filter = new TestLabelFilter();
visibleItems = new HashSet();
@@ -120,6 +140,10 @@ public class VirtualTableViewerTest extends TableViewerTest {
}
public void testSetFilters() {
+ if (!setDataCalled) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
ViewerFilter filter = new TestLabelFilter();
visibleItems = new HashSet();
@@ -209,6 +233,10 @@ public class VirtualTableViewerTest extends TableViewerTest {
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testRenameWithFilter()
*/
public void testRenameWithFilter() {
+ if (!setDataCalled) {
+ System.err.println("SWT.SetData is not received. Cancelled test " + getName());
+ return;
+ }
fViewer.addFilter(new TestLabelFilter());
((TableViewer) fViewer).getControl().update();
TestElement first = fRootElement.getFirstChild();