mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 22:35:43 +02:00
Improvements for automated UI-Tests
This commit is contained in:
parent
b61e9f2170
commit
04647950ec
4 changed files with 49 additions and 129 deletions
|
@ -21,6 +21,7 @@ import org.eclipse.core.resources.IFile;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.SWTException;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
|
@ -215,4 +216,51 @@ public class BaseUITestCase extends BaseTestCase {
|
|||
return null;
|
||||
}
|
||||
|
||||
final protected TreeItem checkTreeNode(Tree tree, int i0, String label) {
|
||||
TreeItem root= null;
|
||||
for (int i=0; i<200; i++) {
|
||||
try {
|
||||
root= tree.getItem(i0);
|
||||
if (label.equals(root.getText())) {
|
||||
return root;
|
||||
}
|
||||
}
|
||||
catch (SWTException e) {
|
||||
// in case widget was disposed, item may be replaced
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// item does not yet exist.
|
||||
}
|
||||
runEventQueue(10);
|
||||
}
|
||||
assertNotNull("Tree node " + label + "{" + i0 + "} does not exist!", root);
|
||||
assertEquals(label, root.getText());
|
||||
return root;
|
||||
}
|
||||
|
||||
final protected TreeItem checkTreeNode(Tree tree, int i0, int i1, String label) {
|
||||
TreeItem item= null;
|
||||
TreeItem root= tree.getItem(i0);
|
||||
for (int i=0; i<200; i++) {
|
||||
try {
|
||||
item= root.getItem(i1);
|
||||
if (!"...".equals(item.getText())) {
|
||||
break;
|
||||
}
|
||||
} catch (SWTException e) {
|
||||
// in case widget was disposed, item may be replaced
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
if (label == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
runEventQueue(10);
|
||||
}
|
||||
assertNotNull("Tree node " + label + "{" + i0 + "," + i1 + "} does not exist!", item);
|
||||
assertNotNull("Unexpected tree node " + item.getText(), label);
|
||||
assertEquals(label, item.getText());
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.core.resources.IProject;
|
|||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.swt.SWTException;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
|
@ -106,53 +105,6 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
|
|||
assertNotNull(ch);
|
||||
return ch.getTreeViewer();
|
||||
}
|
||||
|
||||
protected TreeItem checkTreeNode(Tree tree, int i0, String label) {
|
||||
TreeItem root= null;
|
||||
for (int i=0; i<200; i++) {
|
||||
try {
|
||||
root= tree.getItem(i0);
|
||||
if (label.equals(root.getText())) {
|
||||
return root;
|
||||
}
|
||||
}
|
||||
catch (SWTException e) {
|
||||
// in case widget was disposed, item may be replaced
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// item does not yet exist.
|
||||
}
|
||||
runEventQueue(10);
|
||||
}
|
||||
assertNotNull("Tree node " + label + "{" + i0 + "} does not exist!", root);
|
||||
assertEquals(label, root.getText());
|
||||
return root;
|
||||
}
|
||||
|
||||
protected TreeItem checkTreeNode(Tree tree, int i0, int i1, String label) {
|
||||
TreeItem item= null;
|
||||
TreeItem root= tree.getItem(i0);
|
||||
for (int i=0; i<200; i++) {
|
||||
try {
|
||||
item= root.getItem(i1);
|
||||
if (!"...".equals(item.getText())) {
|
||||
break;
|
||||
}
|
||||
} catch (SWTException e) {
|
||||
// in case widget was disposed, item may be replaced
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
if (label == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
runEventQueue(10);
|
||||
}
|
||||
assertNotNull("Tree node " + label + "{" + i0 + "," + i1 + "} does not exist!", item);
|
||||
assertNotNull("Unexpected tree node " + item.getText(), label);
|
||||
assertEquals(label, item.getText());
|
||||
return item;
|
||||
}
|
||||
|
||||
protected TreeItem checkTreeNode(TreeItem root, int i1, String label) {
|
||||
TreeItem item= null;
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeItem;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
@ -95,38 +94,4 @@ public class IncludeBrowserBaseTest extends BaseUITestCase {
|
|||
Tree tree= ib.getTreeViewer().getTree();
|
||||
return tree;
|
||||
}
|
||||
|
||||
protected void checkTreeNode(Tree tree, int i0, String label) {
|
||||
TreeItem root= null;
|
||||
try {
|
||||
for (int i=0; i<200; i++) {
|
||||
root= tree.getItem(i0);
|
||||
if (!"...".equals(root.getText())) {
|
||||
break;
|
||||
}
|
||||
runEventQueue(10);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertTrue("Tree node " + label + "{" + i0 + "} does not exist!", false);
|
||||
}
|
||||
assertEquals(label, root.getText());
|
||||
}
|
||||
|
||||
protected void checkTreeNode(Tree tree, int i0, int i1, String label) {
|
||||
try {
|
||||
TreeItem root= tree.getItem(i0);
|
||||
TreeItem item= root.getItem(i1);
|
||||
for (int i=0; i<200; i++) {
|
||||
if (!"...".equals(item.getText())) {
|
||||
break;
|
||||
}
|
||||
runEventQueue(10);
|
||||
}
|
||||
assertEquals(label, item.getText());
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
assertTrue("Tree node " + label + "{" + i0 + "," + i1 + "} does not exist!", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,52 +151,7 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
|
|||
assertNotNull(th);
|
||||
return th.getMemberViewer();
|
||||
}
|
||||
|
||||
protected TreeItem checkTreeNode(Tree tree, int i0, String label) {
|
||||
TreeItem root= null;
|
||||
try {
|
||||
for (int i=0; i<200; i++) {
|
||||
root= tree.getItem(i0);
|
||||
try {
|
||||
if (!"...".equals(root.getText())) {
|
||||
break;
|
||||
}
|
||||
} catch (SWTException e) {
|
||||
// in case widget was disposed, item may be replaced
|
||||
}
|
||||
runEventQueue(10);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
fail("Tree node " + label + "{" + i0 + "} does not exist!");
|
||||
}
|
||||
assertEquals(label, root.getText());
|
||||
return root;
|
||||
}
|
||||
|
||||
protected TreeItem checkTreeNode(Tree tree, int i0, int i1, String label) {
|
||||
TreeItem item= null;
|
||||
try {
|
||||
TreeItem root= tree.getItem(i0);
|
||||
for (int i=0; i<200; i++) {
|
||||
item= root.getItem(i1);
|
||||
try {
|
||||
if (!"...".equals(item.getText())) {
|
||||
break;
|
||||
}
|
||||
} catch (SWTException e) {
|
||||
// in case widget was disposed, item may be replaced
|
||||
}
|
||||
runEventQueue(10);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
fail("Tree node " + label + "{" + i0 + "," + i1 + "} does not exist!");
|
||||
}
|
||||
assertEquals(label, item.getText());
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
protected TreeItem checkTreeNode(TreeItem root, int i1, String label) {
|
||||
TreeItem item= null;
|
||||
try {
|
||||
|
|
Loading…
Add table
Reference in a new issue