[gui-test] unified using of timeouts

This commit is contained in:
Viktoria.Shirunova
2018-08-03 14:15:53 +03:00
parent 79c24333c7
commit dbef3be466
56 changed files with 341 additions and 293 deletions
@@ -3,6 +3,7 @@ package com.intellij.ide.projectWizard.kotlin.installKotlinPlugin
import com.intellij.ide.projectWizard.kotlin.model.KotlinGuiTestCase
import com.intellij.ide.projectWizard.kotlin.model.KotlinTestProperties
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.*
import com.intellij.testGuiFramework.util.logInfo
import com.intellij.testGuiFramework.util.logTestStep
@@ -50,7 +51,7 @@ class CreateSdksGuiTest : KotlinGuiTestCase() {
jList("SDKs").clickItem("SDKs")
val kotlinSdk = "Kotlin SDK"
try{
jTree(kotlinSdk, timeout = 1L)
jTree(kotlinSdk, timeout = Timeouts.noTimeout)
logInfo("$kotlinSdk exists")
}
catch (e: ComponentLookupException){
@@ -58,7 +59,7 @@ class CreateSdksGuiTest : KotlinGuiTestCase() {
actionButton("Add New SDK").click()
popupMenu(kotlinSdk).clickSearchedItem()
logUIStep("Going to check whether $kotlinSdk created")
jTree(kotlinSdk, timeout = 1L)
jTree(kotlinSdk, timeout = Timeouts.seconds05)
}
finally {
logUIStep("Close `$dialogName` dialog with OK")
@@ -1,21 +1,20 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ide.projectWizard.kotlin.model
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.jTree
import com.intellij.testGuiFramework.impl.selectWithKeyboard
import com.intellij.testGuiFramework.util.logError
import com.intellij.testGuiFramework.util.logUIStep
import com.intellij.testGuiFramework.util.scenarios.*
const val localTimeout = 2L // default timeout is 2 minutes and it's too big for most of tasks here
// Attention: it's supposed that Project Structure dialog is open both before the function
// executed and after
fun ProjectStructureDialogModel.checkFacetInOneModule(expectedFacet: FacetStructure, vararg path: String) {
checkModule {
with(guiTestCase) {
try {
jTree(path[0], timeout = localTimeout).selectWithKeyboard(this, *path)
jTree(path[0], timeout = Timeouts.seconds05).selectWithKeyboard(this, *path)
logUIStep("Check facet for module `${path.joinToString(" -> ")}`")
(this as KotlinGuiTestCase).checkFacetState(expectedFacet)
}
@@ -3,13 +3,14 @@ package com.intellij.ide.projectWizard.kotlin.model
import com.intellij.openapi.application.PathManager
import com.intellij.testGuiFramework.fixtures.JDialogFixture
import com.intellij.testGuiFramework.framework.GuiTestUtil.defaultTimeout
import com.intellij.testGuiFramework.framework.Timeouts.defaultTimeout
import com.intellij.testGuiFramework.framework.GuiTestUtil.fileSearchAndReplace
import com.intellij.testGuiFramework.impl.*
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.waitUntil
import com.intellij.testGuiFramework.util.*
import com.intellij.testGuiFramework.util.scenarios.*
import org.fest.swing.exception.ComponentLookupException
import org.fest.swing.timing.Timeout
import java.io.File
import java.nio.file.Path
import java.nio.file.Paths
@@ -618,7 +619,7 @@ fun KotlinGuiTestCase.checkFacetState(facet: FacetStructure) {
// TODO: remove it after GUI-59 fixing
fun KotlinGuiTestCase.dialogWithoutClosing(title: String? = null,
ignoreCaseTitle: Boolean = false,
timeout: Long = defaultTimeout,
timeout: Timeout = defaultTimeout,
func: JDialogFixture.() -> Unit) {
val dialog = dialog(title, ignoreCaseTitle, timeout)
func(dialog)
@@ -3,6 +3,7 @@ package com.intellij.testGuiFramework.tests.community
import com.intellij.ide.IdeBundle
import com.intellij.openapi.diagnostic.Logger
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.*
import com.intellij.testGuiFramework.util.Key.A
import com.intellij.testGuiFramework.util.Key.V
@@ -53,7 +54,7 @@ class CommunityProjectCreator(guiTestCase: GuiTestCase) : TestUtilsClass(guiTest
private fun GuiTestCase.checkFileAlreadyExistsDialog() {
try {
val dialogFixture = dialog(IdeBundle.message("title.file.already.exists"), false, 10L)
val dialogFixture = dialog(IdeBundle.message("title.file.already.exists"), false, Timeouts.seconds10)
dialogFixture.button("Yes").click()
} catch (cle: ComponentLookupException) { /*do nothing here */ }
}
@@ -2,6 +2,7 @@
package com.intellij.testGuiFramework.tests.community
import com.intellij.testGuiFramework.framework.RunWithIde
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.typeMatcher
import com.intellij.testGuiFramework.impl.actionLink
import com.intellij.testGuiFramework.impl.button
@@ -24,7 +25,7 @@ class IdeaUpdateGuiTest : SystemPropertiesTestCase() {
@Test
fun testIdeaUpdate() {
restartIdeWithSystemProperties(arrayOf(Pair("idea.updates.url", customUpdatesXml.toString())))
welcomeFrame { actionLink("Events", timeout = 60).click() }
welcomeFrame { actionLink("Events", timeout = Timeouts.minutes01).click() }
clickTextInJEditorPane()
dialog("IDE and Plugin Updates") { button("Remind Me Later").click() }
}
@@ -2,7 +2,7 @@
package com.intellij.testGuiFramework.tests.community.focus
import com.intellij.ide.actions.searcheverywhere.SearchEverywhereUI
import com.intellij.testGuiFramework.framework.GuiTestUtil.defaultTimeout
import com.intellij.testGuiFramework.framework.Timeouts.defaultTimeout
import com.intellij.testGuiFramework.framework.GuiTestUtil.textfield
import com.intellij.testGuiFramework.impl.GuiRobotHolder
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
@@ -6,7 +6,7 @@ import com.intellij.testGuiFramework.fixtures.IdeFrameFixture
import com.intellij.testGuiFramework.framework.GuiTestUtil.textfield
import com.intellij.testGuiFramework.impl.GuiTestCase
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
import com.intellij.testGuiFramework.framework.GuiTestUtil.defaultTimeout
import com.intellij.testGuiFramework.framework.Timeouts.defaultTimeout
import com.intellij.testGuiFramework.tests.community.CommunityProjectCreator
import com.intellij.testGuiFramework.util.Key.ESCAPE
import org.fest.swing.core.SmartWaitRobot
@@ -18,6 +18,7 @@ import org.fest.swing.driver.JTreeLocation
import org.fest.swing.exception.ActionFailedException
import org.fest.swing.exception.LocationUnavailableException
import org.fest.swing.exception.WaitTimedOutError
import org.fest.swing.timing.Timeout
import org.fest.swing.util.Pair
import org.fest.swing.util.Triple
import java.awt.Point
@@ -109,9 +110,9 @@ open class ExtendedJTreeDriver(robot: Robot = GuiRobotHolder.robot) : JTreeDrive
}
private fun JTree.waitForChildrenToShowUp(path: TreePath) {
val timeoutInSeconds = robot.settings().timeoutToBeVisible() * 1000 // convert ms to s
try {
GuiTestUtilKt.waitUntil("Waiting for children are shown up", timeoutInSeconds) { this.childCount(path) != 0 }
GuiTestUtilKt.waitUntil( "Waiting for children are shown up",
Timeout.timeout(robot.settings().timeoutToBeVisible().toLong())) { this.childCount(path) != 0 }
}
catch (waitTimedOutError: WaitTimedOutError) {
throw LocationUnavailableException(waitTimedOutError.message!!)
@@ -19,7 +19,7 @@ import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.impl.ActionButton;
import com.intellij.openapi.util.Ref;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import org.fest.swing.core.GenericTypeMatcher;
import org.fest.swing.core.Robot;
import org.fest.swing.edt.GuiQuery;
@@ -102,7 +102,7 @@ public class ActionButtonFixture extends JComponentFixture<ActionButtonFixture,
public static ActionButtonFixture findByActionId(@NotNull final String actionId,
@NotNull final Robot robot,
@NotNull final Container container) {
return findByActionId(actionId, robot, container, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
return findByActionId(actionId, robot, container, Timeouts.INSTANCE.getMinutes02());
}
public ActionButtonFixture waitEnabledAndShowing() {
@@ -117,13 +117,13 @@ public class ActionButtonFixture extends JComponentFixture<ActionButtonFixture,
}
});
}
}, GuiTestUtil.INSTANCE.getTHIRTY_SEC_TIMEOUT());
}, Timeouts.INSTANCE.getSeconds30());
return this;
}
@NotNull
public static ActionButtonFixture findByText(@NotNull final String text, @NotNull Robot robot, @NotNull Container container) {
return findByText(text, robot, container, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
return findByText(text, robot, container, Timeouts.INSTANCE.getMinutes02());
}
@NotNull
@@ -18,7 +18,7 @@ package com.intellij.testGuiFramework.fixtures;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.util.Ref;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import com.intellij.ui.components.labels.ActionLink;
import org.fest.swing.core.GenericTypeMatcher;
import org.fest.swing.core.MouseButton;
@@ -64,7 +64,7 @@ public class ActionLinkFixture extends JComponentFixture<ActionLinkFixture, Acti
}
return false;
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
ActionLink actionLink = actionLinkRef.get();
if (actionLink == null) {
@@ -110,7 +110,7 @@ public class ActionLinkFixture extends JComponentFixture<ActionLinkFixture, Acti
public static ActionLinkFixture findActionLinkByName(@NotNull final String actionName,
@NotNull final Robot robot,
@NotNull final Container container) {
return findActionLinkByName(actionName, robot, container, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
return findActionLinkByName(actionName, robot, container, Timeouts.INSTANCE.getMinutes02());
}
private ActionLinkFixture(@NotNull Robot robot, @NotNull ActionLink target) {
@@ -4,13 +4,14 @@ package com.intellij.testGuiFramework.fixtures
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
import com.intellij.util.ui.AsyncProcessIcon
import org.fest.swing.core.Robot
import org.fest.swing.timing.Timeout
class AsyncProcessIconFixture(robot: Robot,
target: AsyncProcessIcon)
: JComponentFixture<AsyncProcessIconFixture, AsyncProcessIcon>(AsyncProcessIconFixture::class.java, robot, target) {
fun waitUntilStop(timeoutInSeconds: Int) {
GuiTestUtilKt.waitUntil("async process icon will stop", timeoutInSeconds) { !target().isRunning }
fun waitUntilStop(timeout: Timeout) {
GuiTestUtilKt.waitUntil("async process icon will stop", timeout) { !target().isRunning }
}
}
@@ -16,7 +16,7 @@
package com.intellij.testGuiFramework.fixtures;
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import com.intellij.ui.JBListWithHintProvider;
import com.intellij.ui.popup.PopupFactoryImpl;
import com.intellij.ui.popup.list.ListPopupModel;
@@ -104,7 +104,7 @@ public class ComboBoxActionFixture {
}
});
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
comboBoxButtonFixture.click();
}
@@ -127,7 +127,7 @@ public class ComboBoxActionFixture {
}
return false;
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
final Integer appIndex = execute(new GuiQuery<Integer>() {
@Override
@@ -15,11 +15,13 @@
*/
package com.intellij.testGuiFramework.fixtures
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.waitUntil
import org.fest.swing.core.Robot
import org.fest.swing.exception.ComponentLookupException
import org.fest.swing.exception.LocationUnavailableException
import org.fest.swing.fixture.JComboBoxFixture
import org.fest.swing.timing.Timeout
import javax.swing.JButton
import javax.swing.JComboBox
@@ -34,23 +36,23 @@ class ComboBoxFixture(robot: Robot, comboBox: JComboBox<*>) : JComboBoxFixture(r
}
//We are waiting for a item to be shown in dropdown list. It is necessary for a async comboboxes
fun selectItem(itemName: String, timeoutInSeconds: Int = 30): ComboBoxFixture {
waitUntil("item '$itemName' will be appeared in dropdown list", timeoutInSeconds) {
fun selectItem(itemName: String, timeout: Timeout = Timeouts.defaultTimeout): ComboBoxFixture {
waitUntil("item '$itemName' will be appeared in dropdown list", timeout) {
doSelectItem { super.selectItem(itemName) }
}
return this
}
//We are waiting for a item to be shown in dropdown list. It is necessary for a async comboboxes
fun selectItem(itemIndex: Int, timeoutInSeconds: Int = 30): ComboBoxFixture {
waitUntil("item with index $itemIndex will be appeared in dropdown list", timeoutInSeconds) {
fun selectItem(itemIndex: Int, timeout: Timeout = Timeouts.defaultTimeout): ComboBoxFixture {
waitUntil("item with index $itemIndex will be appeared in dropdown list", timeout) {
doSelectItem { super.selectItem(itemIndex) }
}
return this
}
override fun selectItem(index: Int): ComboBoxFixture {
return selectItem(index, 30)
return selectItem(index)
}
/**
@@ -16,6 +16,7 @@
package com.intellij.testGuiFramework.fixtures;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import org.fest.swing.core.Robot;
import org.fest.swing.core.matcher.DialogMatcher;
import org.fest.swing.fixture.DialogFixture;
@@ -36,7 +37,7 @@ public class ConfigureProjectSubsetDialogFixture {
@NotNull
public static ConfigureProjectSubsetDialogFixture find(@NotNull Robot robot) {
DialogMatcher matcher = withTitle("Select Modules to Include in Project Subset").andShowing();
DialogFixture dialog = findDialog(matcher).withTimeout(GuiTestUtil.INSTANCE.getSHORT_TIMEOUT().duration()).using(robot);
DialogFixture dialog = findDialog(matcher).withTimeout(Timeouts.INSTANCE.getMinutes02().duration()).using(robot);
return new ConfigureProjectSubsetDialogFixture(dialog);
}
@@ -19,6 +19,7 @@ import com.intellij.openapi.actionSystem.impl.ActionButton
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl
import com.intellij.openapi.editor.impl.EditorComponentImpl
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
import com.intellij.ui.content.Content
import com.intellij.util.ui.UIUtil.findComponentOfType
@@ -26,6 +27,7 @@ import com.intellij.util.ui.UIUtil.findComponentsOfType
import org.fest.swing.core.GenericTypeMatcher
import org.fest.swing.core.Robot
import org.fest.swing.exception.ComponentLookupException
import org.fest.swing.timing.Timeout
import org.fest.swing.util.TextMatcher
import org.junit.Assert.assertNotNull
import javax.swing.JComponent
@@ -61,14 +63,15 @@ class CustomToolWindowFixture(val toolWindowId: String, val ideFrame: IdeFrameFi
return ContentFixture(this, myRobot, content!!)
}
private fun findContent(tabName: String, timeoutInSeconds: Int): ContentFixture {
selectContentWithTimeout(tabName, timeoutInSeconds)
val content = getContent(tabName) ?: throw ComponentLookupException("Unable to find content with a tab name: \"$tabName\" for a toolwindow with id: \"$toolWindowId\"")
private fun findContent(tabName: String, timeout: Timeout): ContentFixture {
selectContentWithTimeout(tabName, timeout)
val content = getContent(tabName) ?: throw ComponentLookupException(
"Unable to find content with a tab name: \"$tabName\" for a toolwindow with id: \"$toolWindowId\"")
return ContentFixture(this, myRobot, content)
}
private fun selectContentWithTimeout(tabName: String, timeoutInSeconds: Int) {
GuiTestUtilKt.waitUntil("content with a tab name '$tabName' is appeared for a toolwindow with id: \"$toolWindowId\"", timeoutInSeconds) {
private fun selectContentWithTimeout(tabName: String, timeout: Timeout) {
GuiTestUtilKt.waitUntil("content with a tab name '$tabName' is appeared for a toolwindow with id: \"$toolWindowId\"", timeout) {
try {
selectContent(tabName)
true
@@ -87,7 +90,7 @@ class CustomToolWindowFixture(val toolWindowId: String, val ideFrame: IdeFrameFi
/**----------EXTENSION FUNCTIONS FOR GuiTestCase APi----------**/
fun content(tabName: String, timeoutInSeconds: Int = 30, func: ContentFixture.() -> Unit) {
fun content(tabName: String, timeoutInSeconds: Timeout = Timeouts.seconds30, func: ContentFixture.() -> Unit) {
func.invoke(findContent(tabName, timeoutInSeconds))
}
@@ -21,7 +21,7 @@ import com.intellij.openapi.keymap.Keymap;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.TextRange;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import com.intellij.testGuiFramework.impl.ComponentFixtureUtilsKt;
import com.intellij.testGuiFramework.util.Predicate;
import org.fest.swing.core.ComponentDragAndDrop;
@@ -396,7 +396,7 @@ public class EditorFixture {
public boolean test() {
return editor.getContentComponent().isShowing();
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
if (editor != null) {
JComponent contentComponent = editor.getContentComponent();
@@ -776,13 +776,13 @@ public class EditorFixture {
public EditorFixture invokeIntentionAction(@NotNull String labelPrefix) {
invokeAction(EditorFixture.EditorAction.SHOW_INTENTION_ACTIONS);
ComponentFixtureUtilsKt
.popupMenu(labelPrefix, robot, null, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT(), Predicate.INSTANCE.getEquality())
.popupMenu(labelPrefix, robot, null, Timeouts.INSTANCE.getMinutes02(), Predicate.INSTANCE.getEquality())
.clickSearchedItem();
return this;
}
public EditorNotificationPanelFixture notificationPanel() {
return EditorNotificationPanelFixture.Companion.findEditorNotificationPanel(robot, 30);
return EditorNotificationPanelFixture.Companion.findEditorNotificationPanel(robot, Timeouts.INSTANCE.getSeconds30());
}
/**
@@ -15,10 +15,12 @@
*/
package com.intellij.testGuiFramework.fixtures
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
import com.intellij.ui.EditorNotificationPanel
import com.intellij.ui.HyperlinkLabel
import org.fest.swing.core.Robot
import org.fest.swing.timing.Timeout
import javax.swing.JLabel
class EditorNotificationPanelFixture(val robot: Robot,
@@ -52,8 +54,8 @@ class EditorNotificationPanelFixture(val robot: Robot,
private fun JLabel.nonNullSize() = this.height > 0 && this.width > 0
companion object {
fun findEditorNotificationPanel(robot: Robot, timeoutInSeconds: Int = 30): EditorNotificationPanelFixture {
val panel = GuiTestUtilKt.withPauseWhenNull(timeoutInSeconds = timeoutInSeconds) { findEditorNotificationPanel(robot) }
fun findEditorNotificationPanel(robot: Robot, timeout: Timeout = Timeouts.seconds30): EditorNotificationPanelFixture {
val panel = GuiTestUtilKt.withPauseWhenNull(timeout = timeout) { findEditorNotificationPanel(robot) }
return EditorNotificationPanelFixture(robot, panel)
}
@@ -30,6 +30,7 @@
*/
package com.intellij.testGuiFramework.fixtures
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.findAllWithBFS
import com.intellij.ui.InplaceButton
@@ -37,6 +38,7 @@ import com.intellij.ui.SimpleColoredComponent
import com.intellij.ui.tabs.impl.JBEditorTabs
import com.intellij.ui.tabs.impl.TabLabel
import org.fest.swing.core.Robot
import org.fest.swing.timing.Timeout
import java.awt.Container
import java.awt.Point
import java.awt.Rectangle
@@ -72,7 +74,7 @@ class EditorTabsFixture(val robot: Robot, val ideFrameFixture: IdeFrameFixture)
robot.click(closeButton)
}
fun waitTab(tabName: String, timeoutInSeconds: Int = 30): EditorTabsFixture {
fun waitTab(tabName: String, timeoutInSeconds: Timeout = Timeouts.seconds30): EditorTabsFixture {
GuiTestUtilKt.waitUntil("editor tab with name '$tabName' has appeared", timeoutInSeconds) { hasTab(tabName) }
return this
}
@@ -18,8 +18,7 @@ package com.intellij.testGuiFramework.fixtures
import com.intellij.openapi.fileChooser.ex.FileChooserDialogImpl
import com.intellij.openapi.fileChooser.ex.FileSystemTreeImpl
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.GuiTestUtil.SHORT_TIMEOUT
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.framework.GuiTestUtil.findAndClickOkButton
import org.fest.reflect.core.Reflection.field
import org.fest.swing.core.GenericTypeMatcher
@@ -61,7 +60,7 @@ class FileChooserDialogFixture private constructor(robot: Robot,
override fun test(): Boolean {
return fileSelected.get()
}
}, SHORT_TIMEOUT)
}, Timeouts.minutes02)
return this
}
@@ -86,7 +85,7 @@ class FileChooserDialogFixture private constructor(robot: Robot,
val text = textFieldFixture.text()
return text != null && text.isNotEmpty()
}
}, GuiTestUtil.THIRTY_SEC_TIMEOUT)
}, Timeouts.seconds30)
return this
}
@@ -12,7 +12,7 @@ import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import org.fest.swing.core.Robot;
import org.fest.swing.edt.GuiQuery;
import org.fest.swing.edt.GuiTask;
@@ -163,7 +163,7 @@ public class FileEditorFixture extends EditorFixture {
}
});
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
// TODO: Maybe find a better way to keep Documents in sync with their VirtualFiles.
invokeActionViaKeystroke("Synchronize");
@@ -275,7 +275,7 @@ public class FileEditorFixture extends EditorFixture {
}));
return virtualFileReference.get() != null;
}
}, GuiTestUtil.INSTANCE.getTHIRTY_SEC_TIMEOUT());
}, Timeouts.INSTANCE.getSeconds30());
return new FileFixture(myFrame.getProject(), virtualFileReference.get());
}
@@ -346,7 +346,7 @@ public class FileEditorFixture extends EditorFixture {
* Selects the editor with a given tab name.
*/
public FileEditorFixture selectTab(@NotNull final String tabName) {
tabs.waitTab(tabName, 5).selectTab(tabName);
tabs.waitTab(tabName, Timeouts.INSTANCE.getSeconds05()).selectTab(tabName);
return this;
}
@@ -29,7 +29,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import com.intellij.util.CommonProcessors;
import org.fest.swing.edt.GuiQuery;
import org.fest.swing.timing.Condition;
@@ -73,7 +73,7 @@ public class FileFixture {
}
});
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
return this;
}
@@ -111,7 +111,7 @@ public class FileFixture {
}
});
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
return this;
}
@@ -168,7 +168,7 @@ public class FileFixture {
assertNotNull(highlightInfos);
return highlightInfos.size() == expected;
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
return this;
}
@@ -40,6 +40,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.impl.IdeFrameImpl;
import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import com.intellij.ui.EditorNotificationPanel;
import com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode;
import org.fest.swing.core.GenericTypeMatcher;
@@ -408,7 +409,7 @@ public class IdeFrameFixture extends ComponentFixture<IdeFrameFixture, IdeFrameI
// }
// return myGradleProjectEventListener.isBuildFinished(buildMode);
// }
// }, LONG_TIMEOUT);
// }, Timeouts.INSTANCE.getMinutes05);
//
// waitForBackgroundTasksToFinish();
// robot().waitForIdle();
@@ -465,7 +466,7 @@ public class IdeFrameFixture extends ComponentFixture<IdeFrameFixture, IdeFrameI
RunConfigurationComboBoxFixture runConfigurationComboBox = RunConfigurationComboBoxFixture.find(IdeFrameFixture.this);
return isNotEmpty(runConfigurationComboBox.getText());
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
waitForBackgroundTasksToFinish();
findGradleSyncAction().waitEnabledAndShowing();
@@ -502,7 +503,7 @@ public class IdeFrameFixture extends ComponentFixture<IdeFrameFixture, IdeFrameI
// public boolean test() {
// return myGradleProjectEventListener.isSyncStarted();
// }
// }, SHORT_TIMEOUT);
// }, Timeouts.INSTANCE.getMinutes02);
// }
// return this;
//}
@@ -531,7 +532,7 @@ public class IdeFrameFixture extends ComponentFixture<IdeFrameFixture, IdeFrameI
// }
// return syncFinished;
// }
// }, LONG_TIMEOUT);
// }, Timeouts.INSTANCE.getMinutes05);
//
// findGradleSyncAction().waitEnabledAndShowing();
//
@@ -559,7 +560,7 @@ public class IdeFrameFixture extends ComponentFixture<IdeFrameFixture, IdeFrameI
!progressManager.hasUnsafeProgressIndicator();
}
}
, GuiTestUtil.INSTANCE.getFIFTEEN_MIN_TIMEOUT());
, Timeouts.INSTANCE.getMinutes15());
robot().waitForIdle();
return this;
}
@@ -17,14 +17,16 @@ class InplaceButtonFixture(selfType: Class<InplaceButtonFixture>,
companion object {
fun findInplaceButtonFixture(root: Container, robot: Robot, icon: Icon, timeoutInSeconds: Long): InplaceButtonFixture {
if (timeoutInSeconds < 0L) throw Exception("Unable to wait less than 0 seconds")
val inplaceButton = if (timeoutInSeconds == 0L) {
fun findInplaceButtonFixture(root: Container, robot: Robot, icon: Icon, timeout: Timeout): InplaceButtonFixture {
val inplaceButton = if (timeout.duration() == 0L) {
findInplaceButton(root, robot, icon)
}
else {
GuiTestUtil.waitUntilFound(robot, root, GuiTestUtilKt.typeMatcher(InplaceButton::class.java, { it.icon == icon }),
Timeout.timeout((timeoutInSeconds), TimeUnit.SECONDS))
GuiTestUtil.waitUntilFound(
robot,
root,
GuiTestUtilKt.typeMatcher(InplaceButton::class.java) { it.icon == icon },
timeout)
}
return InplaceButtonFixture(InplaceButtonFixture::class.java, robot, inplaceButton)
}
@@ -19,6 +19,7 @@ import com.intellij.openapi.actionSystem.impl.ActionMenu;
import com.intellij.openapi.actionSystem.impl.ActionMenuItem;
import com.intellij.openapi.ui.JBPopupMenu;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import com.intellij.util.ArrayUtil;
import org.fest.swing.core.GenericTypeMatcher;
import org.fest.swing.core.MouseButton;
@@ -54,7 +55,7 @@ public class JBPopupMenuFixture extends JComponentFixture<JBPopupMenuFixture, JB
final JBPopupMenu contextMenu = robot.finder().findByType(JBPopupMenu.class);
return contextMenu != null;
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
} catch (WaitTimedOutError e) {
throw new ComponentLookupException("Unable to find context menu for JBPopupFixture");
}
@@ -117,7 +118,7 @@ public class JBPopupMenuFixture extends JComponentFixture<JBPopupMenuFixture, JB
return false;
}
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
final Point locationOnScreen = myContextMenu.getLocationOnScreen();
final Rectangle bounds = actionMenuItem.getBounds();
final Point point =
@@ -15,7 +15,7 @@
*/
package com.intellij.testGuiFramework.fixtures;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import org.fest.swing.core.GenericTypeMatcher;
import org.fest.swing.core.Robot;
import org.fest.swing.fixture.ContainerFixture;
@@ -47,7 +47,7 @@ public class JDialogFixture extends ComponentFixture<JDialogFixture, JDialog> im
@NotNull
public static JDialogFixture find(@NotNull Robot robot, String title) {
return find(robot, title, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
return find(robot, title, Timeouts.INSTANCE.getMinutes02());
}
@NotNull
@@ -18,8 +18,7 @@ package com.intellij.testGuiFramework.fixtures
import com.intellij.openapi.util.Ref
import com.intellij.openapi.wm.impl.IdeFrameImpl
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.GuiTestUtil.defaultTimeout
import com.intellij.testGuiFramework.framework.GuiTestUtil.toMs
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.typeMatcher
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.waitUntil
import org.fest.assertions.Assertions.assertThat
@@ -143,7 +142,7 @@ class MenuFixture internal constructor(private val myRobot: Robot, private val m
//wait for component showing on screen, as a workaround for IDEA-195830
class MenuItemFixtureDriver(robot: Robot) : JComponentDriver<JMenuItem>(robot) {
override fun click(jMenuItem: JMenuItem) {
waitForShowing(jMenuItem, defaultTimeout.toMs())
waitForShowing(jMenuItem, Timeouts.defaultTimeout.duration())
robot.click(jMenuItem)
}
}
@@ -20,6 +20,7 @@ import com.intellij.openapi.ui.messages.MessageDialog;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import org.fest.swing.core.GenericTypeMatcher;
import org.fest.swing.core.Robot;
import org.fest.swing.edt.GuiQuery;
@@ -34,7 +35,7 @@ public class MessageDialogFixture extends IdeaDialogFixture<DialogWrapper> imple
@NotNull
static MessageDialogFixture findByTitle(@NotNull Robot robot, @NotNull final String title) {
return findByTitle(robot, title, GuiTestUtil.INSTANCE.getLONG_TIMEOUT());
return findByTitle(robot, title, Timeouts.INSTANCE.getMinutes05());
}
@NotNull
@@ -53,7 +54,7 @@ public class MessageDialogFixture extends IdeaDialogFixture<DialogWrapper> imple
}
static MessageDialogFixture findAny(@NotNull Robot robot) {
return findAny(robot, GuiTestUtil.INSTANCE.getLONG_TIMEOUT());
return findAny(robot, Timeouts.INSTANCE.getMinutes05());
}
static MessageDialogFixture findAny(@NotNull Robot robot, @NotNull Timeout timeout) {
@@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import com.intellij.ui.messages.SheetController;
import com.intellij.util.JdomKt;
import org.fest.swing.core.GenericTypeMatcher;
@@ -61,7 +62,7 @@ public class MessagesFixture {
@NotNull
public static MessagesFixture findAny(@NotNull Robot robot, @NotNull Container root) {
return findAny(robot, root, GuiTestUtil.INSTANCE.getLONG_TIMEOUT());
return findAny(robot, root, Timeouts.INSTANCE.getMinutes05());
}
@NotNull
@@ -124,7 +125,7 @@ public class MessagesFixture {
@NotNull
static JPanelFixture findMacSheetByTitle(@NotNull Robot robot, @NotNull Container root, @NotNull String title) {
return findMacSheetByTitle(robot, root, title, GuiTestUtil.INSTANCE.getLONG_TIMEOUT());
return findMacSheetByTitle(robot, root, title, Timeouts.INSTANCE.getMinutes05());
}
@NotNull
@@ -139,7 +140,7 @@ public class MessagesFixture {
private static JPanelFixture findMacSheetAny(@NotNull Robot robot, @NotNull Container root) {
return findMacSheetAny(robot, root, GuiTestUtil.INSTANCE.getLONG_TIMEOUT());
return findMacSheetAny(robot, root, Timeouts.INSTANCE.getMinutes05());
}
private static JPanelFixture findMacSheetAny(@NotNull Robot robot, @NotNull Container root, @NotNull Timeout timeout) {
@@ -149,7 +150,7 @@ public class MessagesFixture {
@NotNull
private static JPanel getSheetPanel(@NotNull Robot robot, @NotNull Container root) {
return getSheetPanel(robot, root, GuiTestUtil.INSTANCE.getLONG_TIMEOUT());
return getSheetPanel(robot, root, Timeouts.INSTANCE.getMinutes05());
}
@NotNull
@@ -6,10 +6,10 @@ import com.intellij.ide.plugins.PluginManagerConfigurableNew.CellPluginComponent
import com.intellij.ide.plugins.PluginManagerConfigurableNew.TabHeaderComponent
import com.intellij.openapi.actionSystem.impl.ActionButton
import com.intellij.openapi.options.ex.ConfigurableCardPanel
import com.intellij.testGuiFramework.framework.GuiTestUtil.defaultTimeout
import com.intellij.testGuiFramework.framework.GuiTestUtil.findAndClickButtonWhenEnabled
import com.intellij.testGuiFramework.framework.GuiTestUtil.findAndClickCancelButton
import com.intellij.testGuiFramework.framework.GuiTestUtil.findAndClickOkButton
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.*
import com.intellij.ui.components.BasicOptionButtonUI.ArrowButton
import com.intellij.ui.components.JBOptionButton
@@ -43,14 +43,14 @@ class PluginDialogFixture(robot: Robot, pluginDialog: JDialog): JDialogFixture(r
}
fun showInstallPluginFromDiskDialog() {
val actionButton: ActionButton = waitUntilFound(findTabHeader(), ActionButton::class.java, defaultTimeout) { true }
val actionButton: ActionButton = waitUntilFound(findTabHeader(), ActionButton::class.java, Timeouts.defaultTimeout) { true }
robot().click(actionButton)
popupMenu("Install Plugin from Disk...").clickSearchedItem()
}
fun installPluginFromDiskDialog(func: InstallPluginFromDiskFixture.() -> Unit) {
val installPluginFromDiskDialog: JDialog =
waitUntilFound(target(), JDialog::class.java, defaultTimeout) { it.title == "Choose Plugin File" }
waitUntilFound(target(), JDialog::class.java, Timeouts.defaultTimeout) { it.title == "Choose Plugin File" }
func(InstallPluginFromDiskFixture(robot(), installPluginFromDiskDialog))
}
@@ -59,27 +59,27 @@ class PluginDialogFixture(robot: Robot, pluginDialog: JDialog): JDialogFixture(r
fun cancel() = findAndClickCancelButton(this)
fun findPluginsAppearedOnTheScreen(): Iterable<IdeaPluginDescriptor> =
waitUntilFoundList(findPluginCardsPanel(), CellPluginComponent::class.java, defaultTimeout) { it.isShowing }.map { it.pluginDescriptor }
waitUntilFoundList(findPluginCardsPanel(), CellPluginComponent::class.java, Timeouts.defaultTimeout) { it.isShowing }.map { it.pluginDescriptor }
private fun findCheckBox(pluginName: String) =
waitUntilFound(findCellPluginComponent(pluginName), JCheckBox::class.java, defaultTimeout) { true }
waitUntilFound(findCellPluginComponent(pluginName), JCheckBox::class.java, Timeouts.defaultTimeout) { true }
private fun findTabHeader(): TabHeaderComponent =
waitUntilFound(target(), TabHeaderComponent::class.java, defaultTimeout) { true }
waitUntilFound(target(), TabHeaderComponent::class.java, Timeouts.defaultTimeout) { true }
private fun findPluginCardsPanel(): ConfigurableCardPanel =
waitUntilFound(target(), ConfigurableCardPanel::class.java, defaultTimeout) { true }
waitUntilFound(target(), ConfigurableCardPanel::class.java, Timeouts.defaultTimeout) { true }
private fun findCellPluginComponent(pluginName: String): CellPluginComponent =
waitUntilFound(findPluginCardsPanel(), CellPluginComponent::class.java, defaultTimeout) { it.isShowing && it.pluginDescriptor.name == pluginName }
waitUntilFound(findPluginCardsPanel(), CellPluginComponent::class.java, Timeouts.defaultTimeout) { it.isShowing && it.pluginDescriptor.name == pluginName }
private fun findPluginDetailsLink(pluginName: String): JLabel =
waitUntilFound(findCellPluginComponent(pluginName), JLabel::class.java, defaultTimeout) { it.text == pluginName }
waitUntilFound(findCellPluginComponent(pluginName), JLabel::class.java, Timeouts.defaultTimeout) { it.text == pluginName }
class PluginDetailsFixture(robot: Robot, dialog: JDialog): JDialogFixture(robot, dialog) {
fun pluginVersion(): String =
waitUntilFound(target(), JTextField::class.java, defaultTimeout) { it.text.startsWith("v") || it.text == "bundled" }.text
waitUntilFound(target(), JTextField::class.java, Timeouts.defaultTimeout) { it.text.startsWith("v") || it.text == "bundled" }.text
fun isPluginEnabled(): Boolean = findEnableDisableButton().text == "Disable"
@@ -105,22 +105,22 @@ class PluginDialogFixture(robot: Robot, pluginDialog: JDialog): JDialogFixture(r
}
fun uninstall() {
val arrowButton: ArrowButton = waitUntilFound(target(), ArrowButton::class.java, defaultTimeout) { true }
val arrowButton: ArrowButton = waitUntilFound(target(), ArrowButton::class.java, Timeouts.defaultTimeout) { true }
robot().click(arrowButton)
val list : JList<*> = waitUntilFound(target(), JList::class.java, defaultTimeout) {
val list : JList<*> = waitUntilFound(target(), JList::class.java, Timeouts.defaultTimeout) {
it.isShowing && it.isVisible && getUninstallItemIndex(it) != -1
}
robot().click(list, list.indexToLocation(getUninstallItemIndex(list)))
}
fun back() {
val backButton: JButton = waitUntilFound(target(), JButton::class.java, defaultTimeout) { it.text == "Plugins" }
val backButton: JButton = waitUntilFound(target(), JButton::class.java, Timeouts.defaultTimeout) { it.text == "Plugins" }
robot().click(backButton)
}
private fun findEnableDisableButton(): JButton =
waitUntilFound(target(), JButton::class.java, defaultTimeout) { it !is JBOptionButton && (it.text == "Enable" || it.text == "Disable") }
waitUntilFound(target(), JButton::class.java, Timeouts.defaultTimeout) { it !is JBOptionButton && (it.text == "Enable" || it.text == "Disable") }
private fun getUninstallItemIndex(list: JList<*>): Int = list.getNextMatch("Uninstall", 0, Position.Bias.Forward)
}
@@ -129,7 +129,7 @@ class PluginDialogFixture(robot: Robot, pluginDialog: JDialog): JDialogFixture(r
ContainerFixture<JDialog> {
fun setPath(pluginPath: String) {
val pluginPathTextField: JTextField =
waitUntilFound(target(), JTextField::class.java, defaultTimeout) { true }
waitUntilFound(target(), JTextField::class.java, Timeouts.defaultTimeout) { true }
pluginPathTextField.text = pluginPath
}
@@ -16,7 +16,7 @@
package com.intellij.testGuiFramework.fixtures
import com.intellij.ide.plugins.PluginTable
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.Timeouts
import org.fest.swing.core.GenericTypeMatcher
import org.fest.swing.core.Robot
import org.fest.swing.timing.Condition
@@ -53,7 +53,7 @@ class PluginTableFixture(robot: Robot, pluginTable: PluginTable) : ComponentFixt
val pluginTable = this.target()
Pause.pause(object: Condition("wait until row appeared") {
override fun test() = (findRow(pluginName) != null)
}, GuiTestUtil.SHORT_TIMEOUT)
}, Timeouts.minutes02)
val cellRect = pluginTable.getCellRect(findRow(pluginName)!!, 0, false)
robot().click(pluginTable, Point(cellRect.centerX.toInt(), cellRect.centerY.toInt()))
}
@@ -28,6 +28,7 @@ import com.intellij.openapi.projectRoots.JavaSdk
import com.intellij.openapi.roots.JdkOrderEntry
import com.intellij.openapi.util.Ref
import com.intellij.openapi.util.text.StringUtil
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.computeOnEdt
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.runOnEdt
@@ -65,7 +66,7 @@ class ProjectViewFixture internal constructor(project: Project, robot: Robot) :
}
private fun assertProjectViewIsInitialized(projectView: ProjectView) {
GuiTestUtilKt.waitUntil("Project view is initialized", 120) {
GuiTestUtilKt.waitUntil("Project view is initialized", Timeouts.defaultTimeout) {
field("isInitialized").ofType(Boolean::class.javaPrimitiveType!!).`in`(projectView).get() ?: throw Exception(
"Unable to get 'isInitialized' field from projectView")
}
@@ -88,7 +89,7 @@ class ProjectViewFixture internal constructor(project: Project, robot: Robot) :
private fun getNodeFixture(pathTo: Array<out String>): NodeFixture? {
return try {
withPauseWhenNull(timeoutInSeconds = 30) {
withPauseWhenNull(timeout = Timeouts.seconds30) {
try {
getNodeFixtureByPath(pathTo as Array<String>)
}
@@ -136,7 +137,7 @@ class ProjectViewFixture internal constructor(project: Project, robot: Robot) :
if (childCount == 0) throw Exception("${pathItem} node has no more children")
if (childCount == 1 && children[0] is LoadingNode) {
runOnEdt { TreeUtil.selectPath(tree, TreeUtil.getPathFromRoot(children[0]!!)) }
waitUntil("children will be loaded", 30) {
waitUntil("children will be loaded", Timeouts.seconds30) {
val updatedChildrenAndCount = getChildrenAndCountOnEdt(tree, pivotRoot)
childCount = updatedChildrenAndCount.first
children = updatedChildrenAndCount.second
@@ -177,7 +178,7 @@ class ProjectViewFixture internal constructor(project: Project, robot: Robot) :
get() {
val tree = myPane.tree
val boundsRef = Ref<Rectangle>()
waitUntil("bounds of tree node with a tree path $myTreePath will be not null", 120) {
waitUntil("bounds of tree node with a tree path $myTreePath will be not null", Timeouts.defaultTimeout) {
return@waitUntil computeOnEdt {
val bounds = tree.getPathBounds(myTreePath)
if (bounds != null) boundsRef.set(bounds)
@@ -2,7 +2,7 @@
package com.intellij.testGuiFramework.fixtures
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.popupMenu
import com.intellij.ui.popup.PopupFactoryImpl
import org.fest.swing.core.Robot
@@ -43,7 +43,7 @@ class RunConfigurationListFixture(val myRobot: Robot, val myIde: IdeFrameFixture
*/
fun configuration(name: String): RunActionFixture {
showPopup()
myIde.popupMenu(name, GuiTestUtil.SHORT_TIMEOUT).clickSearchedItem()
myIde.popupMenu(name, Timeouts.minutes02).clickSearchedItem()
return RunActionFixture()
}
@@ -63,7 +63,7 @@ class RunConfigurationListFixture(val myRobot: Robot, val myIde: IdeFrameFixture
//Close popup
showPopup()
}
myIde.popupMenu(EDIT_CONFIGURATIONS, GuiTestUtil.SHORT_TIMEOUT).clickSearchedItem()
myIde.popupMenu(EDIT_CONFIGURATIONS, Timeouts.minutes02).clickSearchedItem()
}
@@ -18,6 +18,7 @@ package com.intellij.testGuiFramework.fixtures;
import com.intellij.ide.util.treeView.AbstractTreeBuilder;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import com.intellij.ui.treeStructure.Tree;
import org.fest.swing.core.GenericTypeMatcher;
import org.fest.swing.core.Robot;
@@ -77,7 +78,7 @@ public class SelectSdkDialogFixture implements ContainerFixture<JDialog>{
}
});
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
return this;
}
@@ -88,7 +89,7 @@ public class SelectSdkDialogFixture implements ContainerFixture<JDialog>{
JButton button = GuiTestUtil.INSTANCE.findButton(SelectSdkDialogFixture.this, "OK", myRobot);
return button.isEnabled();
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
GuiTestUtil.INSTANCE.findAndClickOkButton(this);
}
@@ -18,6 +18,7 @@ package com.intellij.testGuiFramework.fixtures
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.project.Project
import com.intellij.terminal.JBTerminalPanel
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.waitUntil
import com.intellij.ui.content.Content
@@ -25,6 +26,7 @@ import com.jediterm.terminal.model.TerminalTextBuffer
import org.fest.swing.core.Robot
import org.fest.swing.exception.ComponentLookupException
import org.fest.swing.exception.WaitTimedOutError
import org.fest.swing.timing.Timeout
class TerminalFixture(project: Project, robot: Robot, toolWindowId: String) : ToolWindowFixture(toolWindowId, project, robot) {
@@ -54,9 +56,9 @@ class TerminalFixture(project: Project, robot: Robot, toolWindowId: String) : To
return terminalTextBuffer.getLine(lastLineIndex).text
}
fun waitUntilTextAppeared(text: String, timeoutInSeconds: Int = 60) {
fun waitUntilTextAppeared(text: String, timeout: Timeout = Timeouts.defaultTimeout) {
try {
waitUntil(condition = "'$text' appeared in terminal", timeoutInSeconds = timeoutInSeconds) {
waitUntil(condition = "'$text' appeared in terminal", timeout = timeout) {
terminalTextBuffer.screenLines.contains(text)
}
}
@@ -67,8 +69,8 @@ class TerminalFixture(project: Project, robot: Robot, toolWindowId: String) : To
}
fun waitUntilRegExAppeared(regex: Regex, timeoutInSeconds: Int = 60) {
waitUntil(condition = "'$regex' appeared in terminal", timeoutInSeconds = timeoutInSeconds) {
fun waitUntilRegExAppeared(regex: Regex, timeout: Timeout = Timeouts.defaultTimeout) {
waitUntil(condition = "'$regex' appeared in terminal", timeout = timeout) {
terminalTextBuffer.screenLines.contains(regex)
}
}
@@ -22,7 +22,7 @@ import com.intellij.openapi.wm.StatusBarWidget;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.openapi.wm.impl.StripeButton;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import com.intellij.ui.content.Content;
import org.fest.swing.core.GenericTypeMatcher;
import org.fest.swing.core.Robot;
@@ -62,7 +62,7 @@ public abstract class ToolWindowFixture {
toolWindowRef.set(toolWindow);
return toolWindow != null;
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
myRobot = robot;
myToolWindow = toolWindowRef.get();
}
@@ -84,7 +84,7 @@ public abstract class ToolWindowFixture {
}
return false;
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
} catch (WaitTimedOutError e) {
throw new ComponentLookupException("Cannot find content with " + displayName);
}
@@ -123,7 +123,7 @@ public abstract class ToolWindowFixture {
@Nullable
protected Content getContent(@NotNull final TextMatcher displayNameMatcher) {
return getContent(displayNameMatcher, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
return getContent(displayNameMatcher, Timeouts.INSTANCE.getMinutes02());
}
@Nullable
@@ -152,7 +152,7 @@ public abstract class ToolWindowFixture {
}
private void activateAndWaitUntilIsVisible() {
activateAndWaitUntilIsVisible(GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
activateAndWaitUntilIsVisible(Timeouts.INSTANCE.getMinutes02());
}
private void activateAndWaitUntilIsVisible(@NotNull Timeout timeout) {
@@ -196,11 +196,11 @@ public abstract class ToolWindowFixture {
public boolean test() {
return callback.finished;
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
}
protected void waitUntilIsVisible() {
waitUntilIsVisible(GuiTestUtil.INSTANCE.getTHIRTY_SEC_TIMEOUT());
waitUntilIsVisible(Timeouts.INSTANCE.getSeconds30());
}
protected void waitUntilIsVisible(@NotNull Timeout timeout) {
@@ -2,7 +2,7 @@
package com.intellij.testGuiFramework.fixtures
import com.intellij.openapi.wm.impl.welcomeScreen.FlatWelcomeFrame
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.*
import org.fest.swing.core.Robot
import org.fest.swing.exception.ComponentLookupException
@@ -55,7 +55,7 @@ class WelcomeFrameFixture private constructor(robot: Robot,
}
return false
}
}, GuiTestUtil.LONG_TIMEOUT)
}, Timeouts.minutes05)
for (frame in Frame.getFrames()) {
if (frame is FlatWelcomeFrame && frame.isShowing()) {
@@ -15,21 +15,24 @@
*/
package com.intellij.testGuiFramework.fixtures.extended
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.framework.toSec
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.waitUntil
import org.fest.swing.core.Robot
import org.fest.swing.fixture.JButtonFixture
import org.fest.swing.timing.Timeout
import javax.swing.JButton
class ExtendedButtonFixture(robot: Robot, button: JButton) : JButtonFixture(robot, button) {
fun waitEnabled(timeoutInSeconds: Int = 30): ExtendedButtonFixture {
waitUntil("Waiting $timeoutInSeconds sec until button with text ${target().text} will be enabled",
timeoutInSeconds = timeoutInSeconds) { isEnabled }
fun waitEnabled(timeout: Timeout = Timeouts.seconds30): ExtendedButtonFixture {
waitUntil("Waiting ${timeout.toSec()} sec until button with text ${target().text} will be enabled",
timeout = timeout) { isEnabled }
return this
}
fun clickWhenEnabled(timeoutInSeconds: Int = 30) {
waitEnabled(timeoutInSeconds)
fun clickWhenEnabled(timeout: Timeout = Timeouts.seconds30) {
waitEnabled(timeout)
super.click()
}
@@ -4,6 +4,7 @@ package com.intellij.testGuiFramework.fixtures.extended
import com.intellij.openapi.externalSystem.service.execution.NotSupportedException
import com.intellij.testGuiFramework.driver.ExtendedJTreeDriver
import com.intellij.testGuiFramework.driver.ExtendedJTreePathFinder
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.util.FinderPredicate
import com.intellij.testGuiFramework.impl.GuiRobotHolder
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
@@ -97,7 +98,7 @@ open class ExtendedJTreePathFixture(
if (!cachePaths.containsKey(stringPath)){
var partialPath: TreePath? = null
for (partialList in stringPath.list2tree()) {
GuiTestUtilKt.waitUntil(condition = "correct path to click is found", timeoutInSeconds = 2) {
GuiTestUtilKt.waitUntil(condition = "correct path to click is found", timeout = Timeouts.seconds02) {
try {
partialPath = ExtendedJTreePathFinder(tree)
.findMatchingPathByPredicate(predicate = predicate, pathStrings = *partialList.toTypedArray())
@@ -20,6 +20,7 @@ import com.intellij.openapi.roots.ui.configuration.JdkComboBox;
import com.intellij.testGuiFramework.fixtures.FrameworksTreeFixture;
import com.intellij.testGuiFramework.fixtures.SelectSdkDialogFixture;
import com.intellij.testGuiFramework.framework.GuiTestUtil;
import com.intellij.testGuiFramework.framework.Timeouts;
import com.intellij.ui.components.JBList;
import org.fest.swing.core.GenericTypeMatcher;
import org.fest.swing.core.Robot;
@@ -49,7 +50,7 @@ public class NewProjectWizardFixture extends AbstractWizardFixture<NewProjectWiz
protected boolean isMatching(@NotNull JDialog dialog) {
return IdeBundle.message("title.new.project").equals(dialog.getTitle()) && dialog.isShowing();
}
}).withTimeout(GuiTestUtil.INSTANCE.getLONG_TIMEOUT().duration()).using(robot);
}).withTimeout(Timeouts.INSTANCE.getMinutes05().duration()).using(robot);
return new NewProjectWizardFixture(robot, (JDialog)newProjectDialog.target());
@@ -89,7 +90,7 @@ public class NewProjectWizardFixture extends AbstractWizardFixture<NewProjectWiz
public boolean test() {
return target().isFocused();
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
return this;
}
@@ -109,7 +110,7 @@ public class NewProjectWizardFixture extends AbstractWizardFixture<NewProjectWiz
}
return true;
}
}, GuiTestUtil.INSTANCE.getSHORT_TIMEOUT());
}, Timeouts.INSTANCE.getMinutes02());
final JTextComponentFixture textField = findTextField(labelText);
robot().click(textField.target());
textField.setText(projectName);
@@ -33,11 +33,8 @@ import com.intellij.testGuiFramework.impl.GuiRobotHolder
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.getComponentText
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.isTextComponent
import com.intellij.testGuiFramework.impl.toFestTimeout
import com.intellij.testGuiFramework.matcher.ClassNameMatcher
import com.intellij.testGuiFramework.util.Clipboard
import com.intellij.testGuiFramework.util.Key
import com.intellij.testGuiFramework.util.Shortcut
import com.intellij.testGuiFramework.util.*
import com.intellij.ui.KeyStrokeAdapter
import com.intellij.util.JdkBundle
import com.intellij.util.PathUtil
@@ -63,7 +60,6 @@ import org.fest.swing.fixture.JTreeFixture
import org.fest.swing.timing.Condition
import org.fest.swing.timing.Pause
import org.fest.swing.timing.Timeout
import org.fest.swing.timing.Timeout.timeout
import org.fest.util.Strings.isNullOrEmpty
import org.fest.util.Strings.quote
import org.junit.Assert.assertNotNull
@@ -75,8 +71,6 @@ import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardCopyOption
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeUnit.MINUTES
import java.util.concurrent.TimeUnit.SECONDS
import java.util.concurrent.atomic.AtomicReference
import java.util.concurrent.atomic.AtomicReferenceArray
import javax.annotation.Nonnull
@@ -84,17 +78,6 @@ import javax.swing.*
import javax.swing.text.JTextComponent
object GuiTestUtil {
/**
* default timeout to find target component for fixture. Using seconds as time unit.
*/
const val defaultTimeout = 120L
val THIRTY_SEC_TIMEOUT = timeout(30, SECONDS)
val MINUTE_TIMEOUT = timeout(1, MINUTES)
val SHORT_TIMEOUT = timeout(2, MINUTES)
val LONG_TIMEOUT = timeout(5, MINUTES)
val FIFTEEN_MIN_TIMEOUT = timeout(15, MINUTES)
val GUI_TESTS_RUNNING_IN_SUITE_PROPERTY = "gui.tests.running.in.suite"
private val LOG = Logger.getInstance("#com.intellij.tests.gui.framework.GuiTestUtil")
@@ -227,7 +210,7 @@ object GuiTestUtil {
}
return false
}
}).withTimeout(LONG_TIMEOUT.duration()).using(robot)
}).withTimeout(Timeouts.minutes05.duration()).using(robot)
//TODO: clarify why we are skipping event here?
// We know the IDE event queue was pushed in front of the AWT queue. Some JDKs will leave a dummy event in the AWT queue, which
@@ -261,7 +244,7 @@ object GuiTestUtil {
}
return false
}
}, LONG_TIMEOUT)
}, Timeouts.minutes05)
}
}
finally {
@@ -287,7 +270,7 @@ object GuiTestUtil {
override fun isMatching(dialog: JDialog): Boolean {
return if (dialog.title == null) false else dialog.title.contains(policyAgreement) && dialog.isShowing
}
}).withTimeout(LONG_TIMEOUT.duration()).using(robot)
}).withTimeout(Timeouts.minutes05.duration()).using(robot)
val buttonText = "Accept"
val acceptButton = privacyDialogFixture.button(object : GenericTypeMatcher<JButton>(JButton::class.java) {
override fun isMatching(button: JButton): Boolean {
@@ -312,7 +295,7 @@ object GuiTestUtil {
val dialogName = ApplicationBundle.message("title.complete.installation")
try {
val completeInstallationDialog = findDialog(dialogName)
.withTimeout(THIRTY_SEC_TIMEOUT.duration()).using(robot)
.withTimeout(Timeouts.seconds30.duration()).using(robot)
completeInstallationDialog.button("OK").click()
}
catch (we: WaitTimedOutError) {
@@ -325,7 +308,7 @@ object GuiTestUtil {
val dialogName = ApplicationNamesInfo.getInstance().fullProductName + " License Activation"
try {
val completeInstallationDialog = findDialog(dialogName)
.withTimeout(THIRTY_SEC_TIMEOUT.duration()).using(robot)
.withTimeout(Timeouts.seconds30.duration()).using(robot)
completeInstallationDialog.button("Evaluate for free for 30 days").click()
}
catch (we: WaitTimedOutError) {
@@ -338,7 +321,7 @@ object GuiTestUtil {
val dialogName = "License Agreement for" + ApplicationInfoImpl.getShadowInstance().fullApplicationName
try {
val completeInstallationDialog = findDialog(dialogName)
.withTimeout(THIRTY_SEC_TIMEOUT.duration()).using(robot)
.withTimeout(Timeouts.seconds30.duration()).using(robot)
completeInstallationDialog.button("Evaluate for free for 30 days").click()
}
@@ -352,7 +335,7 @@ object GuiTestUtil {
val dialogName = "Customize " + ApplicationNamesInfo.getInstance().fullProductName
try {
val completeInstallationDialog = findDialog(dialogName)
.withTimeout(THIRTY_SEC_TIMEOUT.duration()).using(robot)
.withTimeout(Timeouts.seconds30.duration()).using(robot)
completeInstallationDialog.button("Skip All and Set Defaults").click()
}
@@ -432,7 +415,7 @@ object GuiTestUtil {
override fun test(): Boolean {
return button.isEnabled && button.isVisible && button.isShowing
}
}, SHORT_TIMEOUT)
}, Timeouts.minutes02)
robot.click(button)
}
@@ -510,7 +493,7 @@ object GuiTestUtil {
val buttons = robot.finder().findAll(matcher)
return !buttons.isEmpty()
}
}, SHORT_TIMEOUT)
}, Timeouts.minutes02)
return robot.finder().find(container.target(), matcher)
}
@@ -541,7 +524,7 @@ object GuiTestUtil {
fun <T : Component> waitUntilFound(robot: Robot,
root: Container?,
matcher: GenericTypeMatcher<T>): T {
return waitUntilFound(robot, root, matcher, SHORT_TIMEOUT)
return waitUntilFound(robot, root, matcher, Timeouts.minutes02)
}
/**
@@ -609,21 +592,21 @@ object GuiTestUtil {
val allFound = if (root == null) GuiRobotHolder.robot.finder().findAll(matcher) else GuiRobotHolder.robot.finder().findAll(root, matcher)
return allFound.isEmpty()
}
}, SHORT_TIMEOUT)
}, Timeouts.minutes02)
}
/**
* Waits until no components match the given criteria under the given root
*/
fun <T : Component> waitUntilGone(root: Container?,
timeoutInSeconds: Int,
timeout: Timeout,
matcher: GenericTypeMatcher<T>) {
Pause.pause(object : Condition("Find component using " + matcher.toString()) {
override fun test(): Boolean {
val allFound = if (root == null) GuiRobotHolder.robot.finder().findAll(matcher) else GuiRobotHolder.robot.finder().findAll(root, matcher)
return allFound.isEmpty()
}
}, timeout(timeoutInSeconds.toLong(), SECONDS))
}, timeout)
}
@@ -680,7 +663,7 @@ object GuiTestUtil {
override fun isMatching(@Nonnull button: JRadioButton): Boolean {
return button.text != null && button.text == text
}
}, SHORT_TIMEOUT)
}, Timeouts.minutes02)
return RadioButtonFixture(GuiRobotHolder.robot, radioButton)
}
@@ -719,7 +702,7 @@ object GuiTestUtil {
return (list as JList<Any>).cellRenderer.getListCellRendererComponent(list, value, index, true, true)
}
fun textfield(textLabel: String?, container: Container, timeout: Long): JTextComponentFixture {
fun textfield(textLabel: String?, container: Container, timeout: Timeout): JTextComponentFixture {
if (textLabel.isNullOrEmpty()) {
val jTextField = com.intellij.testGuiFramework.impl.waitUntilFound(container, JTextField::class.java,
timeout) { jTextField -> jTextField.isShowing }
@@ -734,20 +717,20 @@ object GuiTestUtil {
}
fun jTreeComponent(container: Container,
timeout: Long,
timeout: Timeout,
vararg pathStrings: String,
predicate: FinderPredicate = Predicate.equality): JTree {
val myTree: JTree?
try {
myTree = if (pathStrings.isEmpty()) {
waitUntilFound(GuiRobotHolder.robot, container, GuiTestUtilKt.typeMatcher(JTree::class.java) { true }, timeout.toFestTimeout())
waitUntilFound(GuiRobotHolder.robot, container, GuiTestUtilKt.typeMatcher(JTree::class.java) { true }, timeout)
}
else {
waitUntilFound(GuiRobotHolder.robot, container,
GuiTestUtilKt.typeMatcher(JTree::class.java) {
ExtendedJTreePathFixture(it, pathStrings.toList(), predicate).hasPath()
},
timeout.toFestTimeout())
timeout)
}
}
catch (e: WaitTimedOutError) {
@@ -0,0 +1,26 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.testGuiFramework.framework
import org.fest.swing.timing.Timeout
import java.util.concurrent.TimeUnit
object Timeouts {
val defaultTimeout = Timeout.timeout(2, TimeUnit.MINUTES)
val noTimeout = Timeout.timeout(0, TimeUnit.SECONDS)
val seconds01 = Timeout.timeout(1, TimeUnit.SECONDS)
val seconds02 = Timeout.timeout(2, TimeUnit.SECONDS)
val seconds03 = Timeout.timeout(3, TimeUnit.SECONDS)
val seconds05 = Timeout.timeout(5, TimeUnit.SECONDS)
val seconds10 = Timeout.timeout(10, TimeUnit.SECONDS)
val seconds30 = Timeout.timeout(30, TimeUnit.SECONDS)
val minutes01 = Timeout.timeout(1, TimeUnit.MINUTES)
val minutes02 = Timeout.timeout(2, TimeUnit.MINUTES)
val minutes05 = Timeout.timeout(5, TimeUnit.MINUTES)
val minutes10 = Timeout.timeout(10, TimeUnit.MINUTES)
val minutes15 = Timeout.timeout(15, TimeUnit.MINUTES)
val hours01 = Timeout.timeout(1, TimeUnit.HOURS)
}
fun Timeout.toSec(): Long = duration() / 1000
@@ -11,7 +11,7 @@ import com.intellij.testGuiFramework.fixtures.extended.ExtendedButtonFixture
import com.intellij.testGuiFramework.fixtures.extended.ExtendedJTreePathFixture
import com.intellij.testGuiFramework.fixtures.extended.ExtendedTableFixture
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.GuiTestUtil.defaultTimeout
import com.intellij.testGuiFramework.framework.Timeouts.defaultTimeout
import com.intellij.testGuiFramework.util.Predicate
import com.intellij.ui.CheckboxTree
import com.intellij.ui.HyperlinkLabel
@@ -42,7 +42,7 @@ import javax.swing.*
* @timeout in seconds to find JList component
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.jList(containingItem: String? = null, timeout: Long = defaultTimeout): JListFixture =
fun <S, C : Component> ComponentFixture<S, C>.jList(containingItem: String? = null, timeout: Timeout = defaultTimeout): JListFixture =
if (target() is Container) {
val extCellReader = ExtendedJListCellReader()
val myJList = waitUntilFound(target() as Container, JList::class.java, timeout) { jList: JList<*> ->
@@ -64,7 +64,7 @@ fun <S, C : Component> ComponentFixture<S, C>.jList(containingItem: String? = nu
* @timeout in seconds to find JButton component
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.button(name: String, timeout: Long = defaultTimeout): ExtendedButtonFixture =
fun <S, C : Component> ComponentFixture<S, C>.button(name: String, timeout: Timeout = defaultTimeout): ExtendedButtonFixture =
if (target() is Container) {
val jButton = waitUntilFound(target() as Container, JButton::class.java, timeout) {
it.isShowing && it.isVisible && it.text == name
@@ -81,7 +81,7 @@ fun <S, C : Component> ComponentFixture<S, C>.button(name: String, timeout: Long
* @throws ComponentLookupException if no component has not been found or timeout exceeded
* @return list of JButton components sorted by locationOnScreen (left to right, top to down)
*/
fun <S, C : Component> ComponentFixture<S, C>.buttons(name: String, timeout: Long = defaultTimeout): List<ExtendedButtonFixture> =
fun <S, C : Component> ComponentFixture<S, C>.buttons(name: String, timeout: Timeout = defaultTimeout): List<ExtendedButtonFixture> =
if (target() is Container) {
val jButtons = waitUntilFoundList(target() as Container, JButton::class.java, timeout) {
it.isShowing && it.isVisible && it.text == name
@@ -94,7 +94,7 @@ fun <S, C : Component> ComponentFixture<S, C>.buttons(name: String, timeout: Lon
else throw unableToFindComponent("""JButton named by $name""")
fun <S, C : Component> ComponentFixture<S, C>.componentWithBrowseButton(boundedLabelText: String,
timeout: Long = defaultTimeout): ComponentWithBrowseButtonFixture {
timeout: Timeout = defaultTimeout): ComponentWithBrowseButtonFixture {
if (target() is Container) {
val boundedLabel = waitUntilFound(target() as Container, JLabel::class.java, timeout) {
it.text == boundedLabelText && it.isShowing
@@ -107,11 +107,11 @@ fun <S, C : Component> ComponentFixture<S, C>.componentWithBrowseButton(boundedL
throw unableToFindComponent("ComponentWithBrowseButton with labelFor=$boundedLabelText")
}
fun <S, C : Component> ComponentFixture<S, C>.treeTable(timeout: Long = defaultTimeout): TreeTableFixture {
fun <S, C : Component> ComponentFixture<S, C>.treeTable(timeout: Timeout = defaultTimeout): TreeTableFixture {
if (target() is Container) {
val table = GuiTestUtil.waitUntilFound(robot(), target() as Container,
GuiTestUtilKt.typeMatcher(TreeTable::class.java) { true },
timeout.toFestTimeout()
timeout
)
return TreeTableFixture(robot(), table)
}
@@ -119,7 +119,7 @@ fun <S, C : Component> ComponentFixture<S, C>.treeTable(timeout: Long = defaultT
"Sorry, unable to find inspections tree with ${target()} as a Container")
}
fun <S, C : Component> ComponentFixture<S, C>.spinner(boundedLabelText: String, timeout: Long = defaultTimeout): JSpinnerFixture {
fun <S, C : Component> ComponentFixture<S, C>.spinner(boundedLabelText: String, timeout: Timeout = defaultTimeout): JSpinnerFixture {
if (target() is Container) {
val boundedLabel = waitUntilFound(target() as Container, JLabel::class.java, timeout) { it.text == boundedLabelText }
val component = boundedLabel.labelFor
@@ -135,7 +135,7 @@ fun <S, C : Component> ComponentFixture<S, C>.spinner(boundedLabelText: String,
* @timeout in seconds to find JComboBox component
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.combobox(labelText: String, timeout: Long = defaultTimeout): ComboBoxFixture =
fun <S, C : Component> ComponentFixture<S, C>.combobox(labelText: String, timeout: Timeout = defaultTimeout): ComboBoxFixture =
if (target() is Container) {
val comboBox = GuiTestUtilKt.findBoundedComponentByText(robot(), target() as Container, labelText, JComboBox::class.java)
val comboboxFixture = ComboBoxFixture(robot(), comboBox)
@@ -151,7 +151,7 @@ fun <S, C : Component> ComponentFixture<S, C>.combobox(labelText: String, timeou
* @timeout in seconds to find JCheckBox component
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.checkbox(labelText: String, timeout: Long = defaultTimeout): CheckBoxFixture =
fun <S, C : Component> ComponentFixture<S, C>.checkbox(labelText: String, timeout: Timeout = defaultTimeout): CheckBoxFixture =
if (target() is Container) {
val jCheckBox = waitUntilFound(target() as Container, JCheckBox::class.java, timeout) {
it.isShowing && it.isVisible && it.text == labelText
@@ -166,9 +166,9 @@ fun <S, C : Component> ComponentFixture<S, C>.checkbox(labelText: String, timeou
* @timeout in seconds to find ActionLink component
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.actionLink(name: String, timeout: Long = defaultTimeout): ActionLinkFixture =
fun <S, C : Component> ComponentFixture<S, C>.actionLink(name: String, timeout: Timeout = defaultTimeout): ActionLinkFixture =
if (target() is Container) {
ActionLinkFixture.findActionLinkByName(name, robot(), target() as Container, timeout.toFestTimeout())
ActionLinkFixture.findActionLinkByName(name, robot(), target() as Container, timeout)
}
else throw unableToFindComponent("""ActionLink by name "$name"""")
@@ -179,13 +179,13 @@ fun <S, C : Component> ComponentFixture<S, C>.actionLink(name: String, timeout:
* @timeout in seconds to find ActionButton component
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.actionButton(actionName: String, timeout: Long = defaultTimeout): ActionButtonFixture =
fun <S, C : Component> ComponentFixture<S, C>.actionButton(actionName: String, timeout: Timeout = defaultTimeout): ActionButtonFixture =
if (target() is Container) {
try {
ActionButtonFixture.findByText(actionName, robot(), target() as Container, timeout.toFestTimeout())
ActionButtonFixture.findByText(actionName, robot(), target() as Container, timeout)
}
catch (componentLookupException: ComponentLookupException) {
ActionButtonFixture.findByActionId(actionName, robot(), target() as Container, timeout.toFestTimeout())
ActionButtonFixture.findByActionId(actionName, robot(), target() as Container, timeout)
}
}
else throw unableToFindComponent("""ActionButton by action name "$actionName"""")
@@ -198,7 +198,7 @@ fun <S, C : Component> ComponentFixture<S, C>.actionButton(actionName: String, t
* @timeout in seconds to find InplaceButton component. It is better to use static cached icons from (@see com.intellij.openapi.util.IconLoader.AllIcons)
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.inplaceButton(icon: Icon, timeout: Long = defaultTimeout): InplaceButtonFixture {
fun <S, C : Component> ComponentFixture<S, C>.inplaceButton(icon: Icon, timeout: Timeout = defaultTimeout): InplaceButtonFixture {
val target = target()
return if (target is Container) {
InplaceButtonFixture.findInplaceButtonFixture(target, robot(), icon, timeout)
@@ -214,9 +214,9 @@ fun <S, C : Component> ComponentFixture<S, C>.inplaceButton(icon: Icon, timeout:
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.actionButtonByClass(actionClassName: String,
timeout: Long = defaultTimeout): ActionButtonFixture =
timeout: Timeout = defaultTimeout): ActionButtonFixture =
if (target() is Container) {
ActionButtonFixture.findByActionClassName(actionClassName, robot(), target() as Container, timeout.toFestTimeout())
ActionButtonFixture.findByActionClassName(actionClassName, robot(), target() as Container, timeout)
}
else throw unableToFindComponent("""ActionButton by action class name "$actionClassName"""")
@@ -226,8 +226,8 @@ fun <S, C : Component> ComponentFixture<S, C>.actionButtonByClass(actionClassNam
* @timeout in seconds to find JRadioButton component
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.radioButton(textLabel: String, timeout: Long = defaultTimeout): RadioButtonFixture =
if (target() is Container) GuiTestUtil.findRadioButton(target() as Container, textLabel, timeout.toFestTimeout())
fun <S, C : Component> ComponentFixture<S, C>.radioButton(textLabel: String, timeout: Timeout = defaultTimeout): RadioButtonFixture =
if (target() is Container) GuiTestUtil.findRadioButton(target() as Container, textLabel, timeout)
else throw unableToFindComponent("""RadioButton by label "$textLabel"""")
/**
@@ -237,7 +237,7 @@ fun <S, C : Component> ComponentFixture<S, C>.radioButton(textLabel: String, tim
* @timeout in seconds to find JTextComponent component
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.textfield(textLabel: String?, timeout: Long = defaultTimeout): JTextComponentFixture {
fun <S, C : Component> ComponentFixture<S, C>.textfield(textLabel: String?, timeout: Timeout = defaultTimeout): JTextComponentFixture {
val target = target()
if (target is Container) {
return GuiTestUtil.textfield(textLabel, target, timeout)
@@ -254,7 +254,7 @@ fun <S, C : Component> ComponentFixture<S, C>.textfield(textLabel: String?, time
*/
fun <S, C : Component> ComponentFixture<S, C>.jTree(
vararg pathStrings: String,
timeout: Long = defaultTimeout,
timeout: Timeout = defaultTimeout,
predicate: FinderPredicate = Predicate.equality
): ExtendedJTreePathFixture =
if (target() is Container) ExtendedJTreePathFixture(GuiTestUtil.jTreeComponent(
@@ -274,7 +274,7 @@ fun <S, C : Component> ComponentFixture<S, C>.jTree(
*/
fun <S, C : Component> ComponentFixture<S, C>.checkboxTree(
vararg pathStrings: String,
timeout: Long = defaultTimeout,
timeout: Timeout = defaultTimeout,
predicate: FinderPredicate = Predicate.equality
): CheckboxTreeFixture =
if (target() is Container) {
@@ -294,7 +294,7 @@ fun <S, C : Component> ComponentFixture<S, C>.checkboxTree(
* @timeout in seconds to find JTable component
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.table(cellText: String, timeout: Long = defaultTimeout): ExtendedTableFixture =
fun <S, C : Component> ComponentFixture<S, C>.table(cellText: String, timeout: Timeout = defaultTimeout): ExtendedTableFixture =
if (target() is Container) {
var tableFixture: ExtendedTableFixture? = null
waitUntilFound(target() as Container, JTable::class.java, timeout) {
@@ -315,7 +315,7 @@ fun popupMenu(
item: String,
robot: Robot,
root: Container? = null,
timeout: Timeout = GuiTestUtil.defaultTimeout.toFestTimeout(),
timeout: Timeout = defaultTimeout,
predicate: FinderPredicate = Predicate.equality
): JBListPopupFixture{
val jbList = GuiTestUtil.waitUntilFound(
@@ -333,7 +333,7 @@ fun popupMenu(
fun <S, C : Component> ComponentFixture<S, C>.popupMenu(
item: String,
timeout: Timeout = GuiTestUtil.defaultTimeout.toFestTimeout(),
timeout: Timeout = defaultTimeout,
predicate: FinderPredicate = Predicate.equality
): JBListPopupFixture {
if (target() is Container) {
@@ -351,23 +351,23 @@ fun <S, C : Component> ComponentFixture<S, C>.popupMenu(
* @timeout in seconds to find LinkLabel component
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.linkLabel(linkName: String, timeout: Long = defaultTimeout) =
fun <S, C : Component> ComponentFixture<S, C>.linkLabel(linkName: String, timeout: Timeout = defaultTimeout) =
if (target() is Container) {
val myLinkLabel = GuiTestUtil.waitUntilFound(
robot(), target() as Container,
GuiTestUtilKt.typeMatcher(LinkLabel::class.java) { it.isShowing && (it.text == linkName) },
timeout.toFestTimeout())
timeout)
ComponentFixture(ComponentFixture::class.java, robot(), myLinkLabel)
}
else throw unableToFindComponent("LinkLabel")
fun <S, C : Component> ComponentFixture<S, C>.hyperlinkLabel(labelText: String, timeout: Long = defaultTimeout): HyperlinkLabelFixture =
fun <S, C : Component> ComponentFixture<S, C>.hyperlinkLabel(labelText: String, timeout: Timeout = defaultTimeout): HyperlinkLabelFixture =
if (target() is Container) {
val hyperlinkLabel = GuiTestUtil.waitUntilFound(robot(), target() as Container,
GuiTestUtilKt.typeMatcher(HyperlinkLabel::class.java) {
it.isShowing && (it.text == labelText)
}, timeout.toFestTimeout())
}, timeout)
HyperlinkLabelFixture(robot(), hyperlinkLabel)
}
else throw unableToFindComponent("""HyperlinkLabel by label text: "$labelText"""")
@@ -378,8 +378,8 @@ fun <S, C : Component> ComponentFixture<S, C>.hyperlinkLabel(labelText: String,
* @timeout in seconds to find table of plugins component
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.pluginTable(timeout: Long = defaultTimeout) =
if (target() is Container) PluginTableFixture.find(robot(), target() as Container, timeout.toFestTimeout())
fun <S, C : Component> ComponentFixture<S, C>.pluginTable(timeout: Timeout = defaultTimeout) =
if (target() is Container) PluginTableFixture.find(robot(), target() as Container, timeout)
else throw unableToFindComponent("PluginTable")
/**
@@ -388,8 +388,8 @@ fun <S, C : Component> ComponentFixture<S, C>.pluginTable(timeout: Long = defaul
* @timeout in seconds to find component for Message
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.message(title: String, timeout: Long = defaultTimeout) =
if (target() is Container) MessagesFixture.findByTitle(robot(), target() as Container, title, timeout.toFestTimeout())
fun <S, C : Component> ComponentFixture<S, C>.message(title: String, timeout: Timeout = defaultTimeout) =
if (target() is Container) MessagesFixture.findByTitle(robot(), target() as Container, title, timeout)
else throw unableToFindComponent("Message")
@@ -399,8 +399,8 @@ fun <S, C : Component> ComponentFixture<S, C>.message(title: String, timeout: Lo
* @timeout in seconds to find component for Message
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.message(title: String, timeout: Long = defaultTimeout, func: MessagesFixture.() -> Unit) {
if (target() is Container) func(MessagesFixture.findByTitle(robot(), target() as Container, title, timeout.toFestTimeout()))
fun <S, C : Component> ComponentFixture<S, C>.message(title: String, timeout: Timeout = defaultTimeout, func: MessagesFixture.() -> Unit) {
if (target() is Container) func(MessagesFixture.findByTitle(robot(), target() as Container, title, timeout))
else throw unableToFindComponent("Message")
}
@@ -410,12 +410,12 @@ fun <S, C : Component> ComponentFixture<S, C>.message(title: String, timeout: Lo
* @timeout in seconds to find JBLabel component
* @throws ComponentLookupException if component has not been found or timeout exceeded
*/
fun <S, C : Component> ComponentFixture<S, C>.label(labelName: String, timeout: Long = defaultTimeout): JLabelFixture =
fun <S, C : Component> ComponentFixture<S, C>.label(labelName: String, timeout: Timeout = defaultTimeout): JLabelFixture =
if (target() is Container) {
val jbLabel = GuiTestUtil.waitUntilFound(
robot(), target() as Container,
GuiTestUtilKt.typeMatcher(JBLabel::class.java) { it.isShowing && (it.text == labelName || labelName in it.text) },
timeout.toFestTimeout())
timeout)
JLabelFixture(robot(), jbLabel)
}
else throw unableToFindComponent("JBLabel")
@@ -429,7 +429,7 @@ private fun <S, C : Component> ComponentFixture<S, C>.unableToFindComponent(comp
*
* @timeout timeout in seconds to find AsyncProcessIcon
*/
fun <S, C : Component> ComponentFixture<S, C>.asyncProcessIcon(timeout: Long = defaultTimeout): AsyncProcessIconFixture {
fun <S, C : Component> ComponentFixture<S, C>.asyncProcessIcon(timeout: Timeout = defaultTimeout): AsyncProcessIconFixture {
val indexingProcessIconTooltipText = ActionsBundle.message("action.ShowProcessWindow.double.click")
val asyncProcessIcon = GuiTestUtil.waitUntilFound(
robot(),
@@ -439,7 +439,7 @@ fun <S, C : Component> ComponentFixture<S, C>.asyncProcessIcon(timeout: Long = d
it.isVisible &&
it.toolTipText != indexingProcessIconTooltipText
},
timeout.toFestTimeout())
timeout)
return AsyncProcessIconFixture(robot(), asyncProcessIcon)
}
@@ -448,15 +448,15 @@ else Timeout.timeout(this, TimeUnit.SECONDS)
fun <ComponentType : Component> waitUntilFound(container: Container?,
componentClass: Class<ComponentType>,
timeout: Long,
timeout: Timeout,
matcher: (ComponentType) -> Boolean): ComponentType {
return GuiTestUtil.waitUntilFound(GuiRobotHolder.robot, container, GuiTestUtilKt.typeMatcher(componentClass) { matcher(it) },
timeout.toFestTimeout())
timeout)
}
fun <ComponentType : Component> waitUntilFoundList(container: Container?,
componentClass: Class<ComponentType>,
timeout: Long,
timeout: Timeout,
matcher: (ComponentType) -> Boolean): List<ComponentType> {
return GuiTestUtil.waitUntilFoundList(container, timeout.toFestTimeout(), GuiTestUtilKt.typeMatcher(componentClass) { matcher(it) })
return GuiTestUtil.waitUntilFoundList(container, timeout, GuiTestUtilKt.typeMatcher(componentClass) { matcher(it) })
}
@@ -8,7 +8,7 @@ import com.intellij.openapi.application.PathManager
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.util.SystemInfo
import com.intellij.testGuiFramework.fixtures.JDialogFixture
import com.intellij.testGuiFramework.framework.GuiTestUtil.defaultTimeout
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.FirstStart.Utils.button
import com.intellij.testGuiFramework.impl.FirstStart.Utils.dialog
import com.intellij.testGuiFramework.impl.FirstStart.Utils.radioButton
@@ -31,7 +31,6 @@ import java.awt.Component
import java.awt.Container
import java.awt.Frame
import java.io.File
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicReference
import javax.swing.*
import kotlin.concurrent.thread
@@ -90,10 +89,6 @@ abstract class FirstStart(val ideType: IdeType) {
robotThread.start()
}
companion object {
var DEFAULT_TIMEOUT: Long = defaultTimeout
}
// In case we found WelcomeFrame we don't need to make completeInstallation.
private fun completeFirstStart() {
@@ -125,7 +120,7 @@ abstract class FirstStart(val ideType: IdeType) {
private fun findPrivacyPolicyDialogOrLicenseAgreement(): JDialog {
return GuiTestUtilKt.withPauseWhenNull(timeoutInSeconds = 120) {
return GuiTestUtilKt.withPauseWhenNull(timeout = Timeouts.defaultTimeout) {
try {
myRobot.finder().find {
it is JDialog && (it.title.contains("License Agreement") || it.title.contains("Privacy Policy"))
@@ -181,7 +176,7 @@ abstract class FirstStart(val ideType: IdeType) {
LOG.info("Accepting Data Sharing")
val title = "Data Sharing"
try {
dialog(title, timeoutSeconds = 5)
dialog(title, timeout = Timeouts.seconds05)
button("Send Usage Statistics").click()
LOG.info("Data sharing accepted")
}
@@ -216,7 +211,7 @@ abstract class FirstStart(val ideType: IdeType) {
LOG.info("Click '${evaluateButton.text()}'")
evaluateButton.click()
dialog(10) { it.startsWith("License Agreement for") }
dialog(timeout = Timeouts.seconds10) { it.startsWith("License Agreement for") }
button("Accept").click()
}
catch (waitTimedOutError: WaitTimedOutError) {
@@ -239,55 +234,55 @@ abstract class FirstStart(val ideType: IdeType) {
}
object Utils {
fun Robot.dialog(title: String? = null, timeoutSeconds: Long = DEFAULT_TIMEOUT): JDialogFixture {
val jDialog = waitUntilFound(this, null, JDialog::class.java, timeoutSeconds) { dialog ->
fun Robot.dialog(title: String? = null, timeout: Timeout = Timeouts.defaultTimeout): JDialogFixture {
val jDialog = waitUntilFound(this, null, JDialog::class.java, timeout) { dialog ->
if (title != null) dialog.title == title else true
}
return JDialogFixture(this, jDialog)
}
fun Robot.dialog(timeoutSeconds: Long = DEFAULT_TIMEOUT, titleMatcher: (String) -> Boolean): JDialogFixture {
val jDialog = waitUntilFound(this, null, JDialog::class.java, timeoutSeconds) { dialog ->
fun Robot.dialog(timeout: Timeout = Timeouts.defaultTimeout, titleMatcher: (String) -> Boolean): JDialogFixture {
val jDialog = waitUntilFound(this, null, JDialog::class.java, timeout) { dialog ->
titleMatcher(dialog.title)
}
return JDialogFixture(this, jDialog)
}
fun Robot.radioButton(text: String, timeoutSeconds: Long = DEFAULT_TIMEOUT): JRadioButtonFixture {
val jRadioButton = waitUntilFound(this, null, JRadioButton::class.java, timeoutSeconds) { radioButton ->
fun Robot.radioButton(text: String, timeout: Timeout = Timeouts.defaultTimeout): JRadioButtonFixture {
val jRadioButton = waitUntilFound(this, null, JRadioButton::class.java, timeout) { radioButton ->
radioButton.text == text && radioButton.isShowing && radioButton.isEnabled
}
return JRadioButtonFixture(this, jRadioButton)
}
fun Robot.button(text: String, timeoutSeconds: Long = DEFAULT_TIMEOUT): JButtonFixture {
val jButton = waitUntilFound(this, null, JButton::class.java, timeoutSeconds) { button ->
fun Robot.button(text: String, timeout: Timeout = Timeouts.defaultTimeout): JButtonFixture {
val jButton = waitUntilFound(this, null, JButton::class.java, timeout) { button ->
button.isShowing && button.text == text
}
return JButtonFixture(this, jButton)
}
fun Robot.checkbox(text: String, timeoutSeconds: Long = DEFAULT_TIMEOUT): JCheckBoxFixture {
val jCheckBox = waitUntilFound(this, null, JCheckBox::class.java, timeoutSeconds) { checkBox ->
fun Robot.checkbox(text: String, timeout: Timeout = Timeouts.defaultTimeout): JCheckBoxFixture {
val jCheckBox = waitUntilFound(this, null, JCheckBox::class.java, timeout) { checkBox ->
checkBox.text == text && checkBox.isShowing && checkBox.isEnabled
}
return JCheckBoxFixture(this, jCheckBox)
}
fun Robot.waitFrame(title: String, timeoutInSeconds: Int = 10, titleMatching: (String?) -> Boolean) {
fun Robot.waitFrame(title: String, timeout: Timeout = Timeouts.seconds30, titleMatching: (String?) -> Boolean) {
GuiTestUtilKt.waitUntil("frame with title '$title' will appear",
timeoutInSeconds) { this.hierarchy().roots().any { it is JFrame && titleMatching(it.title) } }
timeout) { this.hierarchy().roots().any { it is JFrame && titleMatching(it.title) } }
}
fun <ComponentType : Component> waitUntilFound(myRobot: Robot,
container: Container?,
componentClass: Class<ComponentType>,
timeoutSeconds: Long,
timeout: Timeout,
matcher: (ComponentType) -> Boolean): ComponentType {
return waitUntilFound(myRobot, container, object : GenericTypeMatcher<ComponentType>(componentClass) {
override fun isMatching(cmp: ComponentType): Boolean = matcher(cmp)
}, Timeout.timeout(timeoutSeconds, TimeUnit.SECONDS))
}, timeout)
}
fun <T : Component> waitUntilFound(robot: Robot,
@@ -23,8 +23,9 @@ import com.intellij.testGuiFramework.fixtures.extended.RowFixture
import com.intellij.testGuiFramework.fixtures.newProjectWizard.NewProjectWizardFixture
import com.intellij.testGuiFramework.framework.GuiTestLocalRunner
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.GuiTestUtil.defaultTimeout
import com.intellij.testGuiFramework.framework.IdeTestApplication.getTestScreenshotDirPath
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.framework.toSec
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.typeMatcher
import com.intellij.testGuiFramework.launcher.system.SystemInfo
import com.intellij.testGuiFramework.launcher.system.SystemInfo.isMac
@@ -39,6 +40,7 @@ import org.fest.swing.fixture.JTableFixture
import org.fest.swing.image.ScreenshotTaker
import org.fest.swing.timing.Condition
import org.fest.swing.timing.Pause
import org.fest.swing.timing.Timeout
import org.junit.Rule
import org.junit.runner.RunWith
import java.awt.Component
@@ -114,7 +116,7 @@ open class GuiTestCase {
*/
fun dialog(title: String? = null,
ignoreCaseTitle: Boolean = false,
timeout: Long = defaultTimeout,
timeout: Timeout = Timeouts.defaultTimeout,
needToKeepDialog: Boolean = false,
func: JDialogFixture.() -> Unit) {
val dialog = dialog(title, ignoreCaseTitle, timeout)
@@ -122,7 +124,7 @@ open class GuiTestCase {
if (!needToKeepDialog) dialog.waitTillGone()
}
fun pluginDialog(timeout: Long = defaultTimeout, needToKeepDialog: Boolean = false, func: PluginDialogFixture.() -> Unit) {
fun pluginDialog(timeout: Timeout = Timeouts.defaultTimeout, needToKeepDialog: Boolean = false, func: PluginDialogFixture.() -> Unit) {
val pluginDialog = PluginDialogFixture(robot(), findDialog("Plugins", false, timeout))
func(pluginDialog)
if (!needToKeepDialog) pluginDialog.waitTillGone()
@@ -132,7 +134,7 @@ open class GuiTestCase {
* Waits for a native file chooser, types the path in a textfield and closes it by clicking OK button. Or runs AppleScript if the file chooser
* is a Mac native.
*/
fun chooseFileInFileChooser(path: String, timeout: Long = defaultTimeout) {
fun chooseFileInFileChooser(path: String, timeout: Timeout = Timeouts.defaultTimeout) {
val macNativeFileChooser = SystemInfo.isMac() && (System.getProperty("ide.mac.file.chooser.native", "true").toLowerCase() == "false")
if (macNativeFileChooser) {
MacFileChooserDialogFixture(robot()).selectByPath(path)
@@ -140,7 +142,7 @@ open class GuiTestCase {
else {
val fileChooserDialog: JDialog
try {
fileChooserDialog = GuiTestUtilKt.withPauseWhenNull(timeoutInSeconds = timeout.toInt()) {
fileChooserDialog = GuiTestUtilKt.withPauseWhenNull(timeout = timeout) {
robot().finder()
.findAll(GuiTestUtilKt.typeMatcher(JDialog::class.java) { true })
.firstOrNull {
@@ -151,11 +153,11 @@ open class GuiTestCase {
}
}
catch (timeoutError: WaitTimedOutError) {
throw ComponentLookupException("Unable to find file chooser dialog in ${timeout.toInt()} seconds")
throw ComponentLookupException("Unable to find file chooser dialog in ${timeout.toSec()} seconds")
}
val dialogFixture = JDialogFixture(robot(), fileChooserDialog)
with(dialogFixture) {
asyncProcessIcon().waitUntilStop(20)
asyncProcessIcon().waitUntilStop(Timeouts.seconds30)
textfield("")
invokeAction("\$SelectAll")
typeText(path)
@@ -313,14 +315,14 @@ open class GuiTestCase {
/**
* Finds JDialog with a specific title (if title is null showing dialog should be only one) and returns created JDialogFixture
*/
fun dialog(title: String? = null, ignoreCaseTitle: Boolean, timeoutInSeconds: Long): JDialogFixture {
fun dialog(title: String? = null, ignoreCaseTitle: Boolean, timeout: Timeout = Timeouts.defaultTimeout): JDialogFixture {
if (title == null) {
val jDialog = waitUntilFound(null, JDialog::class.java, timeoutInSeconds) { true }
val jDialog = waitUntilFound(null, JDialog::class.java, timeout) { true }
return JDialogFixture(robot(), jDialog)
}
else {
try {
val dialog = GuiTestUtilKt.withPauseWhenNull(timeoutInSeconds = timeoutInSeconds.toInt()) {
val dialog = GuiTestUtilKt.withPauseWhenNull(timeout = timeout) {
val allMatchedDialogs = robot().finder().findAll(typeMatcher(JDialog::class.java) {
if (ignoreCaseTitle) it.title.toLowerCase() == title.toLowerCase() else it.title == title
}).filter { it.isShowing && it.isEnabled && it.isVisible }
@@ -331,7 +333,7 @@ open class GuiTestCase {
return JDialogFixture(robot(), dialog)
}
catch (timeoutError: WaitTimedOutError) {
throw ComponentLookupException("Timeout error for finding JDialog by title \"$title\" for $timeoutInSeconds seconds")
throw ComponentLookupException("Timeout error for finding JDialog by title \"$title\" for ${timeout.toSec()} seconds")
}
}
}
@@ -339,8 +341,8 @@ open class GuiTestCase {
/**
* Finds JDialog with a specific title (if title is null showing dialog should be only one)
*/
private fun findDialog(title: String?, ignoreCaseTitle: Boolean, timeoutInSeconds: Long): JDialog =
waitUntilFound(null, JDialog::class.java, timeoutInSeconds) {
private fun findDialog(title: String?, ignoreCaseTitle: Boolean, timeout: Timeout): JDialog =
waitUntilFound(null, JDialog::class.java, timeout) {
title?.equals(it.title, ignoreCaseTitle)?.and(it.isShowing && it.isEnabled && it.isVisible) ?: true
}
@@ -2,10 +2,10 @@
package com.intellij.testGuiFramework.impl
import com.intellij.testGuiFramework.fixtures.GutterFixture
import com.intellij.testGuiFramework.fixtures.JDialogFixture
import com.intellij.testGuiFramework.fixtures.extended.ExtendedJTreePathFixture
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.util.*
import org.fest.swing.exception.ComponentLookupException
import org.fest.swing.timing.Condition
import org.fest.swing.timing.Pause
import org.hamcrest.Matcher
import org.junit.After
@@ -152,7 +152,15 @@ fun GuiTestCase.mavenReimport() {
ideFrame {
toolwindow(id = "Maven") {
content(tabName = "") {
actionButton("Reimport All Maven Projects").click()
val button = actionButton("Reimport All Maven Projects")
Pause.pause(object : Condition("Wait for button Reimport All Maven Projects to be enabled.") {
override fun test(): Boolean {
return button.isEnabled
}
}, Timeouts.minutes02)
robot().waitForIdle()
button.click()
robot().waitForIdle()
}
}
}
@@ -22,6 +22,7 @@ import com.intellij.testGuiFramework.fixtures.IdeFrameFixture
import com.intellij.testGuiFramework.fixtures.WelcomeFrameFixture
import com.intellij.testGuiFramework.fixtures.newProjectWizard.NewProjectWizardFixture
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.framework.IdeTestApplication.getFailedTestVideoDirPath
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.computeOnEdt
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.runOnEdt
@@ -232,7 +233,7 @@ class GuiTestRule : TestRule {
// We close all modal dialogs left over, because they block the AWT thread and could trigger a deadlock in the next test.
val closedModalDialogSet = hashSetOf<Dialog>()
try {
waitUntil("all modal dialogs will be closed", timeoutInSeconds = 10) {
waitUntil("all modal dialogs will be closed", timeout = Timeouts.seconds10) {
val modalDialog: Dialog = getActiveModalDialog() ?: return@waitUntil true
if (closedModalDialogSet.contains(modalDialog)) {
//wait a second to let a dialog be closed
@@ -319,7 +320,7 @@ class GuiTestRule : TestRule {
}
fun closeAllProjects() {
waitUntil("close all projects", 120) {
waitUntil("close all projects", Timeouts.defaultTimeout) {
val openProjects = ProjectManager.getInstance().openProjects
runOnEdt {
TransactionGuard.submitTransaction(ApplicationManager.getApplication(), Runnable {
@@ -346,7 +347,7 @@ class GuiTestRule : TestRule {
} ?: false
if (welcomeFrameShown) {
waitUntil("Welcome frame to show up", 120) {
waitUntil("Welcome frame to show up", Timeouts.defaultTimeout) {
Frame.getFrames().any { it === WelcomeFrame.getInstance() && it.isShowing }
}
}
@@ -4,6 +4,8 @@ package com.intellij.testGuiFramework.impl
import com.intellij.diagnostic.MessagePool
import com.intellij.openapi.progress.ProgressManager
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.framework.toSec
import com.intellij.ui.EngravedLabel
import org.fest.swing.core.ComponentMatcher
import org.fest.swing.core.GenericTypeMatcher
@@ -196,21 +198,21 @@ object GuiTestUtilKt {
/**
* waits for 30 sec timeout when functionProbeToNull() not return null
*
* @throws WaitTimedOutError with the text: "Timed out waiting for $timeoutInSeconds second(s) until {@code conditionText} will be not null"
* @throws WaitTimedOutError with the text: "Timed out waiting for $timeout second(s) until {@code conditionText} will be not null"
*/
fun <ReturnType> withPauseWhenNull(conditionText: String = "function to probe will", timeoutInSeconds: Int = 30, functionProbeToNull: () -> ReturnType?): ReturnType {
fun <ReturnType> withPauseWhenNull(conditionText: String = "function to probe will", timeout: Timeout = Timeouts.defaultTimeout, functionProbeToNull: () -> ReturnType?): ReturnType {
var result: ReturnType? = null
waitUntil("$conditionText will be not null", timeoutInSeconds) {
waitUntil("$conditionText will be not null", timeout) {
result = functionProbeToNull()
result != null
}
return result!!
}
fun waitUntil(condition: String, timeoutInSeconds: Int = 60, conditionalFunction: () -> Boolean) {
Pause.pause(object : Condition("$timeoutInSeconds second(s) until $condition") {
fun waitUntil(condition: String, timeout: Timeout = Timeouts.defaultTimeout, conditionalFunction: () -> Boolean) {
Pause.pause(object : Condition("${timeout.toSec()} second(s) until $condition") {
override fun test() = conditionalFunction()
}, Timeout.timeout(timeoutInSeconds.toLong(), TimeUnit.SECONDS))
}, timeout)
}
fun silentWaitUntil(condition: String, timeoutInSeconds: Int = 60, conditionalFunction: () -> Boolean) {
@@ -244,24 +246,24 @@ object GuiTestUtilKt {
}
fun <ComponentType : Component> waitUntilGone(robot: Robot,
timeoutInSeconds: Int = 30,
timeout: Timeout = Timeouts.seconds30,
root: Container? = null,
matcher: GenericTypeMatcher<ComponentType>) {
return GuiTestUtil.waitUntilGone(root, timeoutInSeconds, matcher)
return GuiTestUtil.waitUntilGone(root, timeout, matcher)
}
fun GuiTestCase.waitProgressDialogUntilGone(dialogTitle: String, timeoutToAppearInSeconds: Int = 5, timeoutToGoneInSeconds: Int = 60) {
waitProgressDialogUntilGone(this.robot(), dialogTitle, timeoutToAppearInSeconds, timeoutToGoneInSeconds)
fun GuiTestCase.waitProgressDialogUntilGone(dialogTitle: String, timeoutToAppear: Timeout = Timeouts.seconds05, timeoutToGone: Timeout = Timeouts.defaultTimeout) {
waitProgressDialogUntilGone(this.robot(), dialogTitle, timeoutToAppear, timeoutToGone)
}
fun waitProgressDialogUntilGone(robot: Robot,
progressTitle: String,
timeoutToAppearInSeconds: Int = 5,
timeoutToGoneInSeconds: Int = 60) {
timeoutToAppear: Timeout = Timeouts.seconds30,
timeoutToGone: Timeout = Timeouts.defaultTimeout) {
//wait dialog appearance. In a bad case we could pass dialog appearance.
var dialog: JDialog? = null
try {
waitUntil("progress dialog with title $progressTitle will appear", timeoutToAppearInSeconds) {
waitUntil("progress dialog with title $progressTitle will appear", timeoutToAppear) {
dialog = findProgressDialog(robot, progressTitle)
dialog != null
}
@@ -269,7 +271,7 @@ object GuiTestUtilKt {
catch (timeoutError: WaitTimedOutError) {
return
}
waitUntil("progress dialog with title $progressTitle will gone", timeoutToGoneInSeconds) { dialog == null || !dialog!!.isShowing }
waitUntil("progress dialog with title $progressTitle will gone", timeoutToGone) { dialog == null || !dialog!!.isShowing }
}
fun findProgressDialog(robot: Robot, progressTitle: String): JDialog? {
@@ -16,6 +16,7 @@
package com.intellij.testGuiFramework.testCases
import com.intellij.testGuiFramework.fixtures.JDialogFixture
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.*
import com.intellij.testGuiFramework.impl.GuiTestUtilKt.waitProgressDialogUntilGone
import com.intellij.testGuiFramework.launcher.GuiTestOptions
@@ -51,7 +52,7 @@ open class PluginTestCase : GuiTestCase() {
GuiTestThread.client?.send(TransportMessage(MessageType.RESTART_IDE_AND_RESUME, RestartIdeAndResumeContainer(RestartIdeCause.PLUGIN_INSTALLED))) ?: throw Exception(
"Unable to get the client instance to send message.")
//wait until IDE is going to restart
GuiTestUtilKt.waitUntil("IDE will be closed", timeoutInSeconds = 120) { false }
GuiTestUtilKt.waitUntil("IDE will be closed", timeout = Timeouts.defaultTimeout) { false }
}
}
@@ -81,7 +82,7 @@ open class PluginTestCase : GuiTestCase() {
dialog("Plugins") {
//Check if plugin has already been installed
try {
table(pluginName, timeout = 1L).cell(pluginName).click()
table(pluginName, timeout = Timeouts.seconds05).cell(pluginName).click()
button("OK").click()
ensureButtonOkHasPressed(this@PluginTestCase)
}
@@ -93,7 +94,7 @@ open class PluginTestCase : GuiTestCase() {
}
}
try {
message("IDE and Plugin Updates", timeout = 5L) {
message("IDE and Plugin Updates", timeout = Timeouts.seconds05) {
button("Postpone").click()
}
}
@@ -106,7 +107,7 @@ open class PluginTestCase : GuiTestCase() {
val dialogTitle = "Plugins"
try {
GuiTestUtilKt.waitUntilGone(robot = guiTestCase.robot(),
timeoutInSeconds = 2,
timeout = Timeouts.seconds05,
matcher = GuiTestUtilKt.typeMatcher(
JDialog::class.java) { it.isShowing && it.title == dialogTitle })
}
@@ -1,6 +1,7 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.testGuiFramework.testCases
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.GuiTestCase
import com.intellij.testGuiFramework.impl.GuiTestThread
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
@@ -27,7 +28,7 @@ open class SystemPropertiesTestCase : GuiTestCase() {
setUpBlock(systemProperties)
GuiTestThread.client?.send(createTransportMessage(systemProperties)) ?: throw Exception(
"Unable to get the client instance to send message.")
GuiTestUtilKt.waitUntil("IDE will be closed", timeoutInSeconds = 120) { false }
GuiTestUtilKt.waitUntil("IDE will be closed", timeout = Timeouts.minutes02) { false }
}
private fun createTransportMessage(systemProperties: Array<Pair<String, String>>) =
@@ -2,7 +2,7 @@
package com.intellij.testGuiFramework.util.scenarios
import com.intellij.testGuiFramework.fixtures.JDialogFixture
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.GuiTestCase
import com.intellij.testGuiFramework.impl.actionButton
import com.intellij.testGuiFramework.impl.button
@@ -32,7 +32,7 @@ class EnvironmentVariablesModel(val testCase: GuiTestCase) : TestUtilsClass(test
val GuiTestCase.envVarsModel by EnvironmentVariablesModel
fun EnvironmentVariablesModel.connectDialog(): JDialogFixture =
testCase.dialog(EnvironmentVariablesModel.Constants.envVarsTitle, true, GuiTestUtil.defaultTimeout)
testCase.dialog(EnvironmentVariablesModel.Constants.envVarsTitle, true, Timeouts.defaultTimeout)
fun EnvironmentVariablesModel.paste(property: String) {
assert(property.contains(EnvironmentVariablesModel.Constants.pattern))
@@ -2,8 +2,8 @@
package com.intellij.testGuiFramework.util.scenarios
import com.intellij.testGuiFramework.fixtures.JDialogFixture
import com.intellij.testGuiFramework.framework.GuiTestUtil.defaultTimeout
import com.intellij.testGuiFramework.framework.GuiTestUtil.typeText
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.*
import com.intellij.testGuiFramework.util.*
import com.intellij.testGuiFramework.util.scenarios.NewProjectDialogModel.Constants.buttonCancel
@@ -194,7 +194,7 @@ class NewProjectDialogModel(val testCase: GuiTestCase) : TestUtilsClass(testCase
val GuiTestCase.newProjectDialogModel by NewProjectDialogModel
fun NewProjectDialogModel.connectDialog(): JDialogFixture =
testCase.dialog(NewProjectDialogModel.Constants.newProjectTitle, true, defaultTimeout)
testCase.dialog(NewProjectDialogModel.Constants.newProjectTitle, true, Timeouts.defaultTimeout)
typealias LibrariesSet = Set<NewProjectDialogModel.LibraryOrFramework>
fun LibrariesSet.isSetEmpty() = isEmpty() || all { it.isEmpty() }
@@ -470,7 +470,7 @@ fun NewProjectDialogModel.assertGroupPresent(group: NewProjectDialogModel.Groups
with(guiTestCase) {
with(connectDialog()) {
// Group `Java` always exists
val list: JListFixture = jList(groupJava, timeout = 2L)
val list: JListFixture = jList(groupJava, timeout = Timeouts.seconds05)
logTestStep("Check ${group} is present in the New Project dialog")
assert(list.contents().contains(group.toString())) {
"${group} group is absent (may be plugin not installed or Community edition runs instead of Ultimate)"
@@ -3,7 +3,7 @@ package com.intellij.testGuiFramework.util.scenarios
import com.intellij.testGuiFramework.fixtures.JDialogFixture
import com.intellij.testGuiFramework.fixtures.extended.ExtendedButtonFixture
import com.intellij.testGuiFramework.framework.GuiTestUtil.defaultTimeout
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.*
import com.intellij.testGuiFramework.util.logInfo
import com.intellij.testGuiFramework.util.logTestStep
@@ -23,14 +23,14 @@ class PluginsDialogModel(val testCase: GuiTestCase) : TestUtilsClass(testCase) {
val GuiTestCase.pluginsDialogModel: PluginsDialogModel by PluginsDialogModel
fun PluginsDialogModel.connectDialog(): JDialogFixture =
testCase.dialog("Plugins", true, defaultTimeout)
testCase.dialog("Plugins", true, Timeouts.defaultTimeout)
fun PluginsDialogModel.isPluginInstalled(pluginName: String): Boolean {
val result = try {
with(testCase) {
logTestStep("Search `$pluginName` plugin")
val dialog = connectDialog()
dialog.table(pluginName, timeout = 1L).cell(pluginName).click()
dialog.table(pluginName, timeout = Timeouts.seconds05).cell(pluginName).click()
}
true
}
@@ -49,7 +49,7 @@ fun PluginsDialogModel.getPluginVersion(pluginName: String): String {
with(testCase) {
logTestStep("Search `$pluginName` plugin")
val dialog = connectDialog()
dialog.table(pluginName, timeout = 1L).cell(pluginName).click()
dialog.table(pluginName, timeout = Timeouts.seconds05).cell(pluginName).click()
logUIStep("Get installed version of `$pluginName` plugin")
dialog.label("Version").text()?.removePrefix("version:")?.trim() ?: ""
}
@@ -67,7 +67,7 @@ fun PluginsDialogModel.getPluginButton(pluginName: String, buttonName: String):
with(testCase) {
logTestStep("Search `$pluginName` plugin")
val dialog = connectDialog()
dialog.table(pluginName, timeout = 1L).cell(pluginName).click()
dialog.table(pluginName, timeout = Timeouts.seconds05).cell(pluginName).click()
logUIStep("Search `$buttonName` button")
dialog.button(buttonName)
}
@@ -111,8 +111,8 @@ fun PluginsDialogModel.ensureButtonOkHasPressed() {
try {
testCase.logTestStep("Check that `Plugins` dialog closed")
GuiTestUtilKt.waitUntilGone(robot = testCase.robot(),
timeoutInSeconds = 2,
matcher = GuiTestUtilKt.typeMatcher(
timeout = Timeouts.seconds05,
matcher = GuiTestUtilKt.typeMatcher(
JDialog::class.java) { it.isShowing && it.title == dialogTitle })
}
catch (timeoutError: WaitTimedOutError) {
@@ -1,6 +1,7 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.testGuiFramework.util.scenarios
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.GuiTestCase
import com.intellij.testGuiFramework.impl.GuiTestThread
import com.intellij.testGuiFramework.impl.GuiTestUtilKt
@@ -36,7 +37,7 @@ fun PluginsDialogScenarios.uninstallPlugin(pluginName: String) {
else {
pluginsDialogModel.pressCancel()
}
dialog("IDE and Plugin Updates", timeout = 5L) { button("Postpone").click() }
dialog("IDE and Plugin Updates", timeout = Timeouts.seconds05) { button("Postpone").click() }
}
else
pluginsDialogModel.pressCancel()
@@ -58,7 +59,7 @@ fun PluginsDialogScenarios.actionAndRestart(actionFunction: () -> Unit) {
RestartIdeCause.PLUGIN_INSTALLED))) ?: throw Exception(
"Unable to get the client instance to send message.")
//wait until IDE is going to restart
GuiTestUtilKt.waitUntil("IDE will be closed", timeoutInSeconds = 120) { false }
GuiTestUtilKt.waitUntil("IDE will be closed", timeout = Timeouts.defaultTimeout) { false }
}
}
@@ -66,7 +67,7 @@ fun PluginsDialogScenarios.installPluginFromDisk(pluginFileName: String) {
with(testCase) {
welcomePageDialogModel.openPluginsDialog()
pluginsDialogModel.installPluginFromDisk(pluginFileName)
dialog("IDE and Plugin Updates", timeout = 5L) { button("Postpone").click() }
dialog("IDE and Plugin Updates", timeout = Timeouts.seconds05) { button("Postpone").click() }
}
}
@@ -2,7 +2,7 @@
package com.intellij.testGuiFramework.util.scenarios
import com.intellij.testGuiFramework.fixtures.JDialogFixture
import com.intellij.testGuiFramework.framework.GuiTestUtil.defaultTimeout
import com.intellij.testGuiFramework.framework.Timeouts.defaultTimeout
import com.intellij.testGuiFramework.impl.GuiTestCase
import com.intellij.testGuiFramework.impl.button
import com.intellij.testGuiFramework.impl.jList
@@ -3,7 +3,7 @@ package com.intellij.testGuiFramework.util.scenarios
import com.intellij.testGuiFramework.util.FinderPredicate
import com.intellij.testGuiFramework.fixtures.JDialogFixture
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.*
import com.intellij.testGuiFramework.util.Predicate
import com.intellij.testGuiFramework.util.logTestStep
@@ -35,7 +35,7 @@ class RunConfigurationModel(testCase: GuiTestCase) : TestUtilsClass(testCase) {
val envVarsField = CustomConfigurationField(
actionIsPresent = { model: RunConfigurationModel, title: String ->
with(model.connectDialog()) {
model.guiTestCase.exists { textfield(title, timeout = 1) }
model.guiTestCase.exists { textfield(title, timeout = Timeouts.noTimeout) }
}
},
actionSetValue = { model, title: String, value: String ->
@@ -74,12 +74,12 @@ class RunConfigurationModel(testCase: GuiTestCase) : TestUtilsClass(testCase) {
fun RunConfigurationModel.isFieldPresent(): Boolean {
with(connectDialog()) {
return when (kind) {
RunConfigurationModel.FieldKind.Text -> guiTestCase.exists { textfield(title, timeout = 1) }
RunConfigurationModel.FieldKind.Check -> guiTestCase.exists { checkbox(title, timeout = 1) }
RunConfigurationModel.FieldKind.Text -> guiTestCase.exists { textfield(title, timeout = Timeouts.noTimeout) }
RunConfigurationModel.FieldKind.Check -> guiTestCase.exists { checkbox(title, timeout = Timeouts.noTimeout) }
RunConfigurationModel.FieldKind.Choice -> TODO()
RunConfigurationModel.FieldKind.List -> TODO()
RunConfigurationModel.FieldKind.Tree -> TODO()
RunConfigurationModel.FieldKind.Combo -> guiTestCase.exists { combobox(title, timeout = 1) }
RunConfigurationModel.FieldKind.Combo -> guiTestCase.exists { combobox(title, timeout = Timeouts.noTimeout) }
RunConfigurationModel.FieldKind.Custom -> custom?.actionIsPresent?.invoke(this@isFieldPresent, title)
?: throw IllegalStateException(
"Handler for field '$title' not set")
@@ -162,7 +162,7 @@ class RunConfigurationModel(testCase: GuiTestCase) : TestUtilsClass(testCase) {
val GuiTestCase.runConfigModel by RunConfigurationModel
fun RunConfigurationModel.connectDialog(): JDialogFixture =
guiTestCase.dialog(RunConfigurationModel.Constants.runConfigTitle, true, GuiTestUtil.defaultTimeout)
guiTestCase.dialog(RunConfigurationModel.Constants.runConfigTitle, true, Timeouts.defaultTimeout)
fun RunConfigurationModel.checkConfigurationExistsAndSelect(vararg configuration: String) {
with(connectDialog()) {
@@ -1,7 +1,7 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.testGuiFramework.util.scenarios
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.testGuiFramework.framework.Timeouts
import com.intellij.testGuiFramework.impl.*
import com.intellij.testGuiFramework.util.Key
import com.intellij.testGuiFramework.util.logTestStep
@@ -28,10 +28,10 @@ fun RunConfigurationScenarios.openRunConfiguration(vararg configuration: String)
navigationBar {
assert(exists { button(configurationName) }) { "Button `$configurationName` not found on Navigation bar" }
}
GuiTestUtilKt.waitUntil("Menu item '${RunConfigurationScenarios.Constants.editConfigurationMenuItem}' is enabled", GuiTestUtil.LONG_TIMEOUT.duration().toInt()){
GuiTestUtilKt.waitUntil("Menu item '${RunConfigurationScenarios.Constants.editConfigurationMenuItem}' is enabled", Timeouts.minutes05){
shortcut(Key.ESCAPE)
button(configurationName).click()
popupMenu(RunConfigurationScenarios.Constants.editConfigurationMenuItem, GuiTestUtil.NO_TIMEOUT).isSearchedItemEnable()
popupMenu(RunConfigurationScenarios.Constants.editConfigurationMenuItem, Timeouts.noTimeout).isSearchedItemEnable()
}
popupMenu(RunConfigurationScenarios.Constants.editConfigurationMenuItem).clickSearchedItem()
}