You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2016/11/02 15:07:14 UTC
svn commit: r1767702 -
/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ui/sightly/SightlyAutocompletionTest.java
Author: rombert
Date: Wed Nov 2 15:07:14 2016
New Revision: 1767702
URL: http://svn.apache.org/viewvc?rev=1767702&view=rev
Log:
SLING-6231 - Sightly SWTBot tests are unstable
Remove hardcoded 1000 ms sleep in the Sightly tests. Instead, poll until
the project is visible.
Modified:
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ui/sightly/SightlyAutocompletionTest.java
Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ui/sightly/SightlyAutocompletionTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ui/sightly/SightlyAutocompletionTest.java?rev=1767702&r1=1767701&r2=1767702&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ui/sightly/SightlyAutocompletionTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ui/sightly/SightlyAutocompletionTest.java Wed Nov 2 15:07:14 2016
@@ -32,6 +32,7 @@ import org.eclipse.swtbot.eclipse.finder
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.junit.BeforeClass;
@@ -92,7 +93,7 @@ public class SightlyAutocompletionTest {
public List<String> call() throws Exception {
// create faceted project
- IProject contentProject = projectRule.getProject();
+ final IProject contentProject = projectRule.getProject();
ProjectAdapter project = new ProjectAdapter(contentProject);
project.addNatures(JavaCore.NATURE_ID, "org.eclipse.wst.common.project.facet.core.nature");
@@ -104,13 +105,31 @@ public class SightlyAutocompletionTest {
// create basic html file
project.createOrUpdateFile(Path.fromOSString("jcr_root/index.html"), new ByteArrayInputStream("".getBytes()));
- Thread.sleep(1000); // TODO - wait for project to be registered in the UI
-
// ensure that we get the tree from the project explorer
SWTBotView projectExplorer = bot.viewByTitle("Project Explorer");
projectExplorer.setFocus();
- SWTBotTree explorerTree = projectExplorer.bot().tree();
+ final SWTBotTree explorerTree = projectExplorer.bot().tree();
+
+ // wait until the project is displayed in the project explorer
+ bot.waitUntil(new DefaultCondition() {
+ @Override
+ public boolean test() throws Exception {
+ SWTBotTreeItem[] treeItems = explorerTree.getAllItems();
+
+ for (SWTBotTreeItem treeItem : treeItems) {
+ if ( contentProject.getName().equals(treeItem.getText()) ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ @Override
+ public String getFailureMessage() {
+ return "No project named '" + contentProject.getName() + "' found in the Project Explorer.";
+ }
+ });
// open editor
SWTBotTreeItem projectItem = explorerTree.expandNode(contentProject.getName());