[gui-test] add 30sec pause to path()

This commit is contained in:
Sergey Karashevich
2017-07-21 08:09:27 +03:00
parent 16b9b96272
commit 640cb63d4a
@@ -65,6 +65,7 @@ import java.util.concurrent.atomic.AtomicReference;
import static com.intellij.ide.projectView.BaseProjectTreeBuilder.getBuilderFor;
import static com.intellij.testGuiFramework.framework.GuiTestUtil.SHORT_TIMEOUT;
import static com.intellij.testGuiFramework.framework.GuiTestUtil.THIRTY_SEC_TIMEOUT;
import static org.fest.assertions.Assertions.assertThat;
import static org.fest.reflect.core.Reflection.field;
import static org.fest.swing.timing.Pause.pause;
@@ -181,6 +182,24 @@ public class ProjectViewFixture extends ToolWindowFixture {
*/
@NotNull
public NodeFixture path(String... pathTo) {
Ref<NodeFixture> nodeFixtureRef = new Ref<>();
pause(new Condition("Waiting for a node by path: " + pathTo) {
@Override
public boolean test() {
try {
nodeFixtureRef.set(getNodeFixtureByPath(pathTo));
return true;
}
catch (ComponentLookupException e) {
return false;
}
}
}, THIRTY_SEC_TIMEOUT);
return nodeFixtureRef.get();
}
@NotNull
private NodeFixture getNodeFixtureByPath(String[] pathTo) {
if (pathTo.length == 1) {
if (pathTo[0].contains("/")) {
String[] newPath = pathTo[0].split("/");
@@ -191,7 +210,7 @@ public class ProjectViewFixture extends ToolWindowFixture {
}
public boolean containsPath(String... pathTo) {
return path(pathTo) == null;
return getNodeFixtureByPath(pathTo) != null;
}
public class PaneFixture {