From 633131bfe3d097fa4d9fb4a8eb4790a1d2be2587 Mon Sep 17 00:00:00 2001 From: Martin Szuc Date: Thu, 19 Sep 2024 12:37:53 +0200 Subject: [PATCH 01/11] feat: added IU-2024.2 to IntelliJVersion Signed-off-by: Martin Szuc --- .../intellij/commonuitest/utils/runner/IntelliJVersion.java | 4 +++- src/test-project/gradle.properties | 2 +- .../devtools/intellij/commonuitest/LibraryTestBase.java | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/runner/IntelliJVersion.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/runner/IntelliJVersion.java index c1f410a8..4a2b95aa 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/runner/IntelliJVersion.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/runner/IntelliJVersion.java @@ -27,12 +27,14 @@ public enum IntelliJVersion { COMMUNITY_V_2023_1("IC-2023.1"), COMMUNITY_V_2023_2("IC-2023.2"), COMMUNITY_V_2024_1("IC-2024.1"), + COMMUNITY_V_2024_2("IC-2024.2"), ULTIMATE_V_2020_2("IU-2020.2"), ULTIMATE_V_2020_3("IU-2020.3"), ULTIMATE_V_2021_1("IU-2021.1"), ULTIMATE_V_2021_2("IU-2021.2"), ULTIMATE_V_2023_2("IU-2023.2"), - ULTIMATE_V_2024_1("IU-2024.1"); + ULTIMATE_V_2024_1("IU-2024.1"), + ULTIMATE_V_2024_2("IU-2024.2"); private final String ideaVersionStringRepresentation; private final int ideaVersionIntRepresentation; diff --git a/src/test-project/gradle.properties b/src/test-project/gradle.properties index fcd82065..9b9a9072 100644 --- a/src/test-project/gradle.properties +++ b/src/test-project/gradle.properties @@ -1 +1 @@ -ideaVersion=IC-2024.1 +ideaVersion=IC-2024.2 diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java index 180102b6..2e34d871 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java @@ -32,8 +32,8 @@ @ExtendWith(ScreenshotAfterTestFailExtension.class) public class LibraryTestBase { protected static final Logger LOGGER = Logger.getLogger(LibraryTestBase.class.getName()); - private static final IntelliJVersion communityIdeaVersion = IntelliJVersion.COMMUNITY_V_2024_1; - private static final IntelliJVersion ultimateIdeaVersion = IntelliJVersion.ULTIMATE_V_2024_1; + private static final IntelliJVersion communityIdeaVersion = IntelliJVersion.COMMUNITY_V_2024_2; + private static final IntelliJVersion ultimateIdeaVersion = IntelliJVersion.ULTIMATE_V_2024_2; protected static RemoteRobot remoteRobot; protected static int ideaVersionInt; private static boolean intelliJHasStarted = false; From ccc44fc719225283fe1e3cd927216c3c63b01e45 Mon Sep 17 00:00:00 2001 From: Martin Szuc Date: Fri, 20 Sep 2024 10:02:53 +0200 Subject: [PATCH 02/11] fix: getSetModule in JavaNewProjectFinalPage updated for 2024.2 Signed-off-by: Martin Szuc --- .../dialogs/project/pages/JavaNewProjectFinalPage.java | 10 ++++++++-- .../dialogs/project/pages/NewProjectFirstPage.java | 2 +- .../commonuitest/utils/constants/XPathDefinitions.java | 9 +++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectFinalPage.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectFinalPage.java index 4a08c8a3..ea0a62f5 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectFinalPage.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectFinalPage.java @@ -70,7 +70,10 @@ public void closeMoreSettings() { * @return name of the module currently inserted in the input field */ public String getModuleName() { - if (UITestRunner.getIdeaVersionInt() >= 20221) { + if (UITestRunner.getIdeaVersionInt() >= 20242) { + return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME_2024_2_AND_NEWER)).getText(); + } + else if (UITestRunner.getIdeaVersionInt() >= 20221) { return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME)).getText(); } else { return textField("Module name:", true).getText(); @@ -83,7 +86,10 @@ public String getModuleName() { * @param moduleName name of the module that will be set into the input field */ public void setModuleName(String moduleName) { - if (UITestRunner.getIdeaVersionInt() >= 20221) { + if (UITestRunner.getIdeaVersionInt() >= 20242) { + find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME_2024_2_AND_NEWER)).setText(moduleName); + } + else if (UITestRunner.getIdeaVersionInt() >= 20221) { find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME)).setText(moduleName); } else { textField("Module name:", true).setText(moduleName); diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java index c7094df4..882f68d6 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java @@ -97,7 +97,7 @@ public void setLanguage(String language) { */ public void setBuildSystem(String buildSystem) { if (ideaVersion >= 20241) { - find(JLabelFixture.class, byXpath(XPathDefinitions.SET_BUILD_SYSTEM_2024_1_AND_NEWER)).findText(buildSystem).click(); + find(JLabelFixture.class, byXpath(XPathDefinitions.SET_BUILD_SYSTEM_2024_2_AND_NEWER)).findText(buildSystem).click(); } else { find(JLabelFixture.class, byXpath(XPathDefinitions.SET_BUILD_SYSTEM)).findText(buildSystem).click(); } diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java index 57baa504..b18d65b0 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java @@ -80,10 +80,11 @@ public class XPathDefinitions { public static final String REMOVE_PROJECT_BUTTON = "//div[contains(@text.key, 'button.remove')]"; public static final String SET_LANGUAGE = "//div[@class='SegmentedButtonComponent'][.//div[contains(@action.key, 'language.groovy')]]"; public static final String SET_BUILD_SYSTEM = "//div[@class='SegmentedButtonComponent'][.//div[@action.key='buildsystem.type.intellij']]"; - public static final String SET_BUILD_SYSTEM_2024_1_AND_NEWER = "//div[@accessiblename='Build system:' and @class='SegmentedButtonComponent']"; // works for IntelliJ Idea 2024.1 and higher - public static final String GET_SET_MODULE_NAME = "//div[@accessiblename='Module name:' and @accessiblename.key='label.project.wizard.new.project.module.name' and @class='JBTextField']"; - public static final String GET_SET_CONTENT_ROOT = "//div[@accessiblename='Content root:' and @accessiblename.key='label.project.wizard.new.project.content.root' and @class='ExtendableTextField']"; - public static final String GET_SET_MODULE_FILE_LOCATION = "//div[@accessiblename='Module file location:' and @accessiblename.key='label.project.wizard.new.project.module.file.location' and @class='ExtendableTextField']"; + public static final String SET_BUILD_SYSTEM_2024_2_AND_NEWER = "//div[@accessiblename='Build system:' and @class='SegmentedButtonComponent']"; // works for IntelliJ Idea 2024.1 and higher + public static final String GET_SET_MODULE_NAME = "//div[@accessiblename='Module name:' and @class='JBTextField']"; + public static final String GET_SET_MODULE_NAME_2024_2_AND_NEWER = "//div[@accessiblename='Module name:' and @class='JBTextField']"; + public static final String GET_SET_CONTENT_ROOT = "//div[@accessiblename='Content root:' and @class='ExtendableTextField']"; + public static final String GET_SET_MODULE_FILE_LOCATION = "//div[@accessiblename='Module file location:' and @class='ExtendableTextField']"; public static final String CREATE_NEW_PROJECT = "//div[@defaulticon='createNewProjectTab.svg']"; // works for IntelliJ Idea 2024.1 and higher private XPathDefinitions() { From 695dec0c576bf955431e4219d2e44e36247c4263 Mon Sep 17 00:00:00 2001 From: Martin Szuc Date: Fri, 20 Sep 2024 11:47:40 +0200 Subject: [PATCH 03/11] fix: MenuBar navigation updated for 2024.2 Signed-off-by: Martin Szuc --- .../fixtures/mainidewindow/menubar/MenuBar.java | 11 ++++++++++- .../utils/constants/XPathDefinitions.java | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/menubar/MenuBar.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/menubar/MenuBar.java index d8da2dad..e219b53a 100755 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/menubar/MenuBar.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/menubar/MenuBar.java @@ -11,6 +11,7 @@ package com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.menubar; import com.intellij.remoterobot.RemoteRobot; +import com.intellij.remoterobot.fixtures.ActionButtonFixture; import com.intellij.remoterobot.fixtures.CommonContainerFixture; import com.intellij.remoterobot.fixtures.JButtonFixture; import com.intellij.remoterobot.fixtures.JPopupMenuFixture; @@ -47,10 +48,18 @@ public void navigateTo(String... path) { if (path.length == 0) { return; } + if (UITestRunner.getIdeaVersionInt() >= 20242) { + remoteRobot.find(ActionButtonFixture.class, byXpath(XPathDefinitions.MAIN_MENU)).click(); + } JButtonFixture mainMenuFirstItem = mainMenuItem(path[0]); if (mainMenuFirstItem != null) { - mainMenuFirstItem.click(); + if (UITestRunner.getIdeaVersionInt() >= 20242) { + mainMenuFirstItem.moveMouse(); + } else { + mainMenuFirstItem.click(); + } + // Wait for the JPopupMenuFixture to appear waitFor(Duration.ofSeconds(5), Duration.ofSeconds(1), "JPopupMenu to appear", () -> !remoteRobot.findAll(JPopupMenuFixture.class, JPopupMenuFixture.Companion.byType()).isEmpty() diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java index b18d65b0..549080e9 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java @@ -55,6 +55,7 @@ public class XPathDefinitions { public static final String TREE = "//div[@class='Tree']"; public static final String TOOLTIP_TEXT_PROJECT = "//div[@tooltiptext='Project']"; public static final String TOOLTIP_TEXT_HIDE = "//div[contains(@myvisibleactions, 'View),')]//div[@tooltiptext='Hide']"; + public static final String MAIN_MENU = "//div[@tooltiptext='Main Menu']"; public static final String MY_ICON_GEAR_PLAIN = "//div[contains(@myvisibleactions, 'View),')]//div[@myicon='gearPlain.svg']"; public static final String MY_ICON_COLLAPSE_ALL = "//div[contains(@myvisibleactions, 'View),')]//div[@myicon='collapseall.svg']"; public static final String MY_ICON_COLLAPSE_ALL_FOR = "//div[contains(@myvisibleactions, 'For')]//div[@myicon='collapseall.svg']"; From 17d372558f633cf8b6d3423b2c908d23c46e65bc Mon Sep 17 00:00:00 2001 From: Martin Szuc Date: Sun, 22 Sep 2024 21:05:13 +0200 Subject: [PATCH 04/11] feat: Right & Left ToolWindowToolbars refactor: ToolWinToolbars redundant isPaneOpened usage removed Signed-off-by: Martin Szuc Signed-off-by: Martin Szuc --- .../toolwindowspane/AbstractToolWinPane.java | 50 ++++++++++++++++--- .../ToolWindowLeftToolbar.java | 36 +++++++++++++ .../ToolWindowRightToolbar.java | 38 ++++++++++++++ .../openclose/AbstractToolWinPane.java | 36 +++++++++++-- 4 files changed, 149 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ToolWindowLeftToolbar.java create mode 100644 src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ToolWindowRightToolbar.java diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/AbstractToolWinPane.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/AbstractToolWinPane.java index 095f7c19..6a87f0f5 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/AbstractToolWinPane.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/AbstractToolWinPane.java @@ -138,24 +138,58 @@ private boolean isPaneOpened(Class fixtureClass) { } private void clickOnStripeButton(String label, boolean isPaneOpened) { - waitFor(Duration.ofSeconds(30), Duration.ofSeconds(2), "The '" + label + "' stripe button is not available.", () -> isStripeButtonAvailable(label, isPaneOpened)); - if (UITestRunner.getIdeaVersionInt() >= 20221) { - remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)).stripeButton(label, isPaneOpened).click(); + waitFor(Duration.ofSeconds(30), Duration.ofSeconds(2), + "The '" + label + "' stripe button is not available.", + () -> isStripeButtonAvailable(label, isPaneOpened)); + + if (UITestRunner.getIdeaVersionInt() >= 20242) { + // For IntelliJ IDEA 2024.2 and newer + if (isRightToolbarButton(label)) { + ToolWindowRightToolbar toolWindowRightToolbar = remoteRobot.find(ToolWindowRightToolbar.class, Duration.ofSeconds(10)); + toolWindowRightToolbar.clickStripeButton(label); + } else { + ToolWindowLeftToolbar toolWindowLeftToolbar = remoteRobot.find(ToolWindowLeftToolbar.class, Duration.ofSeconds(10)); + toolWindowLeftToolbar.clickStripeButton(label); + } + } else if (UITestRunner.getIdeaVersionInt() >= 20221) { + // For IntelliJ IDEA 2022.1 to 2024.1 + ToolWindowPane toolWindowPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); + toolWindowPane.stripeButton(label, isPaneOpened).click(); } else { - remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)).stripeButton(label, isPaneOpened).click(); + // For older versions + ToolWindowsPane toolWindowsPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); + toolWindowsPane.stripeButton(label, isPaneOpened).click(); } } private boolean isStripeButtonAvailable(String label, boolean isPaneOpened) { try { - if (UITestRunner.getIdeaVersionInt() >= 20221) { - remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(2)).stripeButton(label, isPaneOpened); + if (UITestRunner.getIdeaVersionInt() >= 20242) { + // For IntelliJ IDEA 2024.2 and newer + if (isRightToolbarButton(label)) { + ToolWindowRightToolbar toolWindowRightToolbar = remoteRobot.find(ToolWindowRightToolbar.class, Duration.ofSeconds(2)); + toolWindowRightToolbar.findStripeButton(label); + } else { + ToolWindowLeftToolbar toolWindowLeftToolbar = remoteRobot.find(ToolWindowLeftToolbar.class, Duration.ofSeconds(2)); + toolWindowLeftToolbar.findStripeButton(label); + } + } else if (UITestRunner.getIdeaVersionInt() >= 20221) { + // For IntelliJ IDEA 2022.1 to 2024.1 + ToolWindowPane toolWindowPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(2)); + toolWindowPane.stripeButton(label, isPaneOpened); } else { - remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(2)).stripeButton(label, isPaneOpened); + // For older versions + ToolWindowsPane toolWindowsPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(2)); + toolWindowsPane.stripeButton(label, isPaneOpened); } + return true; } catch (WaitForConditionTimeoutException e) { return false; } - return true; + } + + private boolean isRightToolbarButton(String label) { + return label.equals(ButtonLabels.MAVEN_STRIPE_BUTTON_LABEL) || + label.equals(ButtonLabels.GRADLE_STRIPE_BUTTON_LABEL); } } diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ToolWindowLeftToolbar.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ToolWindowLeftToolbar.java new file mode 100644 index 00000000..66a93720 --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ToolWindowLeftToolbar.java @@ -0,0 +1,36 @@ +package com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane; + +import com.intellij.remoterobot.RemoteRobot; +import com.intellij.remoterobot.data.RemoteComponent; +import com.intellij.remoterobot.fixtures.CommonContainerFixture; +import com.intellij.remoterobot.fixtures.DefaultXpath; +import com.intellij.remoterobot.fixtures.FixtureName; +import com.intellij.remoterobot.fixtures.JButtonFixture; +import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; +import org.jetbrains.annotations.NotNull; + +import java.time.Duration; + +import static com.intellij.remoterobot.search.locators.Locators.byXpath; + +@DefaultXpath(by = "ToolWindowLeftToolbar type", xpath = "//div[@class='ToolWindowLeftToolbar']") +@FixtureName(name = "Tool Window Left Toolbar") +public class ToolWindowLeftToolbar extends CommonContainerFixture { + + public ToolWindowLeftToolbar(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) { + super(remoteRobot, remoteComponent); + } + + public JButtonFixture stripeButton(String label) { + // For IntelliJ IDEA 2024.2 and newer, use the tooltiptext attribute + return button(byXpath(XPathDefinitions.toolWindowButton(label)), Duration.ofSeconds(2)); + } + + public void clickStripeButton(String label) { + stripeButton(label).click(); + } + + public void findStripeButton(String label) { + stripeButton(label); + } +} \ No newline at end of file diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ToolWindowRightToolbar.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ToolWindowRightToolbar.java new file mode 100644 index 00000000..3a866d28 --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ToolWindowRightToolbar.java @@ -0,0 +1,38 @@ +package com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane; + +import com.intellij.remoterobot.RemoteRobot; +import com.intellij.remoterobot.data.RemoteComponent; +import com.intellij.remoterobot.fixtures.CommonContainerFixture; +import com.intellij.remoterobot.fixtures.DefaultXpath; +import com.intellij.remoterobot.fixtures.FixtureName; +import com.intellij.remoterobot.fixtures.JButtonFixture; +import com.redhat.devtools.intellij.commonuitest.UITestRunner; +import com.redhat.devtools.intellij.commonuitest.utils.constants.ButtonLabels; +import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; +import org.jetbrains.annotations.NotNull; + +import java.time.Duration; + +import static com.intellij.remoterobot.search.locators.Locators.byXpath; +import static org.assertj.swing.core.MouseClickInfo.button; + +@DefaultXpath(by = "ToolWindowRightToolbar type", xpath = "//div[@class='ToolWindowRightToolbar']") +@FixtureName(name = "Tool Window Right Toolbar") +public class ToolWindowRightToolbar extends CommonContainerFixture { + + public ToolWindowRightToolbar(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) { + super(remoteRobot, remoteComponent); + } + + public JButtonFixture stripeButton(String label) { + return button(byXpath(XPathDefinitions.toolWindowButton(label)), Duration.ofSeconds(2)); + } + + public void clickStripeButton(String label) { + stripeButton(label).click(); + } + + public void findStripeButton(String label) { + stripeButton(label); + } +} \ No newline at end of file diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/AbstractToolWinPane.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/AbstractToolWinPane.java index aae15c91..550d7bec 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/AbstractToolWinPane.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/AbstractToolWinPane.java @@ -14,8 +14,11 @@ import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; import com.redhat.devtools.intellij.commonuitest.LibraryTestBase; import com.redhat.devtools.intellij.commonuitest.UITestRunner; +import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowLeftToolbar; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; +import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowRightToolbar; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane; +import com.redhat.devtools.intellij.commonuitest.utils.constants.ButtonLabels; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; import org.junit.jupiter.api.AfterAll; @@ -61,15 +64,42 @@ protected void closePane(String label, Class f protected void clickOnStripeButton(String label, boolean isPaneOpened) { waitFor(Duration.ofSeconds(30), Duration.ofSeconds(2), "The '" + label + "' stripe button is not available.", () -> isStripeButtonAvailable(label, isPaneOpened)); - toolWinPane.stripeButton(label, isPaneOpened).click(); + + if (UITestRunner.getIdeaVersionInt() >= 20242) { // For IntelliJ IDEA 2024.2 and newer + if (isRightToolbarButton(label)) { + ToolWindowRightToolbar toolWindowRightToolbar = remoteRobot.find(ToolWindowRightToolbar.class, Duration.ofSeconds(10)); + toolWindowRightToolbar.clickStripeButton(label); + } else { + ToolWindowLeftToolbar toolWindowLeftToolbar = remoteRobot.find(ToolWindowLeftToolbar.class, Duration.ofSeconds(10)); + toolWindowLeftToolbar.clickStripeButton(label); + } + } else { // For older versions + toolWinPane.stripeButton(label, isPaneOpened).click(); + } } protected boolean isStripeButtonAvailable(String label, boolean isPaneOpened) { try { - toolWinPane.stripeButton(label, isPaneOpened); + if (UITestRunner.getIdeaVersionInt() >= 20242) { // For IntelliJ IDEA 2024.2 and newer + if (isRightToolbarButton(label)) { + ToolWindowRightToolbar toolWindowRightToolbar = remoteRobot.find(ToolWindowRightToolbar.class, Duration.ofSeconds(2)); + toolWindowRightToolbar.findStripeButton(label); + } else { + ToolWindowLeftToolbar toolWindowLeftToolbar = remoteRobot.find(ToolWindowLeftToolbar.class, Duration.ofSeconds(2)); + toolWindowLeftToolbar.findStripeButton(label); + } + } else { // For older versions + toolWinPane.stripeButton(label, isPaneOpened); + } + return true; } catch (WaitForConditionTimeoutException e) { return false; } - return true; + } + + private boolean isRightToolbarButton(String label) { + // Determine if the stripe button is on the right toolbar + return label.equals(ButtonLabels.MAVEN_STRIPE_BUTTON_LABEL) || + label.equals(ButtonLabels.GRADLE_STRIPE_BUTTON_LABEL); } } \ No newline at end of file From b202d9cb810f0b656308df6534644bd936a24405 Mon Sep 17 00:00:00 2001 From: Martin Szuc Date: Sun, 22 Sep 2024 22:06:57 +0200 Subject: [PATCH 05/11] fix: ProjectExplorer new icons for 2024.2 Signed-off-by: Martin Szuc --- .../toolwindowspane/ProjectExplorer.java | 31 +++++++++++++++---- .../utils/constants/XPathDefinitions.java | 3 ++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ProjectExplorer.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ProjectExplorer.java index 0a87e8e8..8933763a 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ProjectExplorer.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ProjectExplorer.java @@ -18,6 +18,7 @@ import com.intellij.remoterobot.fixtures.JPopupMenuFixture; import com.intellij.remoterobot.fixtures.JTreeFixture; import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; +import com.redhat.devtools.intellij.commonuitest.UITestRunner; import com.redhat.devtools.intellij.commonuitest.exceptions.UITestException; import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; import org.jetbrains.annotations.NotNull; @@ -86,7 +87,8 @@ public JPopupMenuFixture openContextMenuOn(String... path) { * @return Views popup fixture */ public JPopupMenuFixture openViewsPopup() { - actionButton(byXpath(XPathDefinitions.CONTENT_COMBO_LABEL), Duration.ofSeconds(2)).click(); + projectViewTree().moveMouse(); + actionButton(byXpath(XPathDefinitions.CONTENT_COMBO_LABEL), Duration.ofSeconds(5)).click(); try { return remoteRobot.find(JPopupMenuFixture.class, byXpath(XPathDefinitions.HEAVY_WEIGHT_WINDOW), Duration.ofSeconds(10)); } catch (WaitForConditionTimeoutException e) { @@ -98,21 +100,32 @@ public JPopupMenuFixture openViewsPopup() { * Locate and select opened file */ public void selectOpenedFile() { - actionButton(byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG), Duration.ofSeconds(2)).click(); + projectViewTree().moveMouse(); + actionButton(byXpath(XPathDefinitions.MY_ICON_LOCATE_SVG), Duration.ofSeconds(5)).click(); } /** * Expand all */ public void expandAll() { - actionButton(byXpath(XPathDefinitions.MY_ICON_EXPAND_ALL), Duration.ofSeconds(2)).click(); + projectViewTree().moveMouse(); + if (UITestRunner.getIdeaVersionInt() >= 20242) { + actionButton(byXpath(XPathDefinitions.MY_ICON_EXPAND_ALL_2024_2), Duration.ofSeconds(5)).click(); + } else { + actionButton(byXpath(XPathDefinitions.MY_ICON_EXPAND_ALL), Duration.ofSeconds(5)).click(); + } } /** * Collapse all */ public void collapseAll() { - actionButton(byXpath(XPathDefinitions.MY_ICON_COLLAPSE_ALL), Duration.ofSeconds(2)).click(); + projectViewTree().moveMouse(); + if (UITestRunner.getIdeaVersionInt() >= 20242) { + actionButton(byXpath(XPathDefinitions.MY_ICON_COLLAPSE_ALL_2024_2), Duration.ofSeconds(5)).click(); + } else { + actionButton(byXpath(XPathDefinitions.MY_ICON_COLLAPSE_ALL), Duration.ofSeconds(5)).click(); + } } /** @@ -121,7 +134,12 @@ public void collapseAll() { * @return settings popup fixture */ public JPopupMenuFixture openSettingsPopup() { - actionButton(byXpath(XPathDefinitions.MY_ICON_GEAR_PLAIN), Duration.ofSeconds(2)).click(); + projectViewTree().moveMouse(); + if (UITestRunner.getIdeaVersionInt() >= 20242) { + actionButton(byXpath(XPathDefinitions.MY_ICON_MORE_VERTICAL), Duration.ofSeconds(5)).click(); + } else { + actionButton(byXpath(XPathDefinitions.MY_ICON_GEAR_PLAIN), Duration.ofSeconds(5)).click(); + } try { return remoteRobot.find(JPopupMenuFixture.class, byXpath(XPathDefinitions.HEAVY_WEIGHT_WINDOW), Duration.ofSeconds(10)); } catch (WaitForConditionTimeoutException e) { @@ -133,7 +151,8 @@ public JPopupMenuFixture openSettingsPopup() { * Hide Project Explorer */ public void hide() { - actionButton(byXpath(XPathDefinitions.TOOLTIP_TEXT_HIDE), Duration.ofSeconds(2)).click(); + projectViewTree().moveMouse(); + actionButton(byXpath(XPathDefinitions.TOOLTIP_TEXT_HIDE), Duration.ofSeconds(5)).click(); } /** diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java index 549080e9..63d511ba 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/XPathDefinitions.java @@ -57,10 +57,13 @@ public class XPathDefinitions { public static final String TOOLTIP_TEXT_HIDE = "//div[contains(@myvisibleactions, 'View),')]//div[@tooltiptext='Hide']"; public static final String MAIN_MENU = "//div[@tooltiptext='Main Menu']"; public static final String MY_ICON_GEAR_PLAIN = "//div[contains(@myvisibleactions, 'View),')]//div[@myicon='gearPlain.svg']"; + public static final String MY_ICON_MORE_VERTICAL = "//div[@myicon='moreVertical.svg']"; public static final String MY_ICON_COLLAPSE_ALL = "//div[contains(@myvisibleactions, 'View),')]//div[@myicon='collapseall.svg']"; + public static final String MY_ICON_COLLAPSE_ALL_2024_2 = "//div[@myicon='collapseAll.svg']"; public static final String MY_ICON_COLLAPSE_ALL_FOR = "//div[contains(@myvisibleactions, 'For')]//div[@myicon='collapseall.svg']"; public static final String MY_ICON_COLLAPSE_ALL_IDE = "//div[contains(@myvisibleactions, 'IDE')]//div[@myicon='collapseall.svg']"; public static final String MY_ICON_EXPAND_ALL = "//div[contains(@myvisibleactions, 'View),')]//div[@myicon='expandall.svg']"; + public static final String MY_ICON_EXPAND_ALL_2024_2 = "//div[@myicon='expandAll.svg']"; public static final String MY_ICON_EXPAND_ALL_IDE = "//div[contains(@myvisibleactions, 'IDE')]//div[@myicon='expandall.svg']"; public static final String MY_ICON_LOCATE_SVG = "//div[@myicon='locate.svg']"; public static final String MY_ICON_REFRESH = "//div[@myicon='refresh.svg']"; From 11137378afe313b44792555ab00de643104e8197 Mon Sep 17 00:00:00 2001 From: Martin Szuc Date: Tue, 24 Sep 2024 14:26:53 +0200 Subject: [PATCH 06/11] fix: resize settings dialog for MacOS Signed-off-by: Martin Szuc --- .../fixtures/dialogs/FlatWelcomeFrame.java | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java index 4eb33036..c79eae51 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java @@ -31,7 +31,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; -import java.nio.file.NoSuchFileException; import java.nio.file.Paths; import java.time.Duration; import java.util.List; @@ -150,7 +149,46 @@ public void openSettingsDialog() { } else { JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE)); jTreeFixture.findText("Customize").click(); - remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click(); + + if (remoteRobot.isMac()) { + resizeWelcomeWindow(remoteRobot, 900); + } + + remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)) + .findText("All settings" + '\u2026') + .click(); + } + } + + /** + * Resize the Welcome to IntelliJ IDEA window + * + * @param remoteRobot Valid instance of remote robot + * @param newHeight Integer of new height to use + */ + private void resizeWelcomeWindow(RemoteRobot remoteRobot, int newHeight) { + try { + remoteRobot.callJs(String.format(""" + importClass(java.awt.Frame); + importClass(javax.swing.SwingUtilities); + var frames = Frame.getFrames(); + var resized = false; + for (var i = 0; i < frames.length; i++) { + var frame = frames[i]; + if (frame.isShowing() && frame.getClass().getName().contains("FlatWelcomeFrame")) { + SwingUtilities.invokeLater(function() { + frame.setSize(frame.getWidth(), %d); + frame.validate(); + }); + resized = true; + break; + } + } + resized; + """, newHeight)); + Thread.sleep(5000); + } catch (Exception e) { + LOGGER.log(Level.WARNING, "Failed to resize the Welcome window: " + e.getMessage()); } } From d4b58e269c234fef891cd6efbcce29e7183004bf Mon Sep 17 00:00:00 2001 From: Martin Szuc Date: Wed, 25 Sep 2024 13:54:26 +0200 Subject: [PATCH 07/11] fix(test): use java 17 Signed-off-by: Martin Szuc --- .../fixtures/test/dialogs/information/CodeWithMeDialogTest.java | 2 +- .../test/dialogs/project_manipulation/NewProjectDialogTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/CodeWithMeDialogTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/CodeWithMeDialogTest.java index b6524a8d..183a5f7f 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/CodeWithMeDialogTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/CodeWithMeDialogTest.java @@ -53,7 +53,7 @@ public static void prepareProject() { newProjectFirstPage.setProjectSdkIfAvailable("11"); } else { newProjectFirstPage.selectNewProjectType("Java"); - newProjectFirstPage.setProjectSdkIfAvailable("11"); + newProjectFirstPage.setProjectSdkIfAvailable("17"); newProjectDialogWizard.next(); newProjectDialogWizard.next(); AbstractNewProjectFinalPage finalPage = getFinalPage(newProjectDialogWizard, CreateCloseUtils.NewProjectType.PLAIN_JAVA); diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/project_manipulation/NewProjectDialogTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/project_manipulation/NewProjectDialogTest.java index eb1a911b..773224a9 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/project_manipulation/NewProjectDialogTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/project_manipulation/NewProjectDialogTest.java @@ -311,7 +311,7 @@ public void nextButtonTest() { public void finishButtonTest() { if (UITestRunner.getIdeaVersionInt() < 20221) { newProjectFirstPage.selectNewProjectType(CreateCloseUtils.NewProjectType.PLAIN_JAVA.toString()); - newProjectFirstPage.setProjectSdkIfAvailable("11"); + newProjectFirstPage.setProjectSdkIfAvailable("17"); assertThrows(UITestException.class, () -> newProjectDialogWizard.finish(), "The 'UITestException' should be thrown because the 'Finish' button is not available on the first page of the 'New Project' wizard for java project."); newProjectDialogWizard.next(); From 4d35e78e5406140c97f282603e71553791db14e4 Mon Sep 17 00:00:00 2001 From: Martin Szuc Date: Wed, 25 Sep 2024 14:40:45 +0200 Subject: [PATCH 08/11] fix(test): expandAllTest expands selected subtree Signed-off-by: Martin Szuc --- .../test/mainidewindow/toolwindowspane/ProjectExplorerTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ProjectExplorerTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ProjectExplorerTest.java index b1f0d48a..03a73f52 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ProjectExplorerTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ProjectExplorerTest.java @@ -133,6 +133,7 @@ public void selectOpenedFileTest() { public void expandAllTest() { projectExplorer.collapseAll(); int itemsInTreeBeforeExpanding = projectExplorer.projectViewTree().collectRows().size(); + projectExplorer.projectViewTree().clickRow(0); // Newer versions expands selected subtree (not all rows) projectExplorer.expandAll(); int itemsInTreeAfterExpanding = projectExplorer.projectViewTree().collectRows().size(); assertTrue(itemsInTreeAfterExpanding > itemsInTreeBeforeExpanding, "Expanding of the 'Project View' tree was not successful."); From 86aaccc7c438a271a40ac0ef264cce852cf0df57 Mon Sep 17 00:00:00 2001 From: Martin Szuc Date: Thu, 26 Sep 2024 09:33:07 +0200 Subject: [PATCH 09/11] fix: Gradle & Maven new icons for 2024.2 Signed-off-by: Martin Szuc --- .../buildtoolpane/GradleBuildToolPane.java | 12 ++++++++++-- .../buildtoolpane/MavenBuildToolPane.java | 7 ++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/buildtoolpane/GradleBuildToolPane.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/buildtoolpane/GradleBuildToolPane.java index 3c94460b..bd8efadf 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/buildtoolpane/GradleBuildToolPane.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/buildtoolpane/GradleBuildToolPane.java @@ -58,14 +58,22 @@ public void reloadAllGradleProjects() { * Expand all */ public void expandAll() { - actionButton(byXpath(XPathDefinitions.MY_ICON_EXPAND_ALL_IDE), Duration.ofSeconds(2)).click(); + if (UITestRunner.getIdeaVersionInt() >= 20242) { // Code for IntelliJ version 2024.2 and newer + actionButton(byXpath(XPathDefinitions.MY_ICON_EXPAND_ALL_2024_2), Duration.ofSeconds(2)).click(); + } else { // Code for IntelliJ version 2024.1 and older + actionButton(byXpath(XPathDefinitions.MY_ICON_EXPAND_ALL_IDE), Duration.ofSeconds(2)).click(); + } } /** * Collapse all */ public void collapseAll() { - actionButton(byXpath(XPathDefinitions.MY_ICON_COLLAPSE_ALL_IDE), Duration.ofSeconds(2)).click(); + if (UITestRunner.getIdeaVersionInt() >= 20242) { // Code for IntelliJ version 2024.2 and newer + actionButton(byXpath(XPathDefinitions.MY_ICON_COLLAPSE_ALL_2024_2), Duration.ofSeconds(2)).click(); + } else { // Code for IntelliJ version 2024.1 and older + actionButton(byXpath(XPathDefinitions.MY_ICON_COLLAPSE_ALL_IDE), Duration.ofSeconds(2)).click(); + } } /** diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/buildtoolpane/MavenBuildToolPane.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/buildtoolpane/MavenBuildToolPane.java index 8eb7c6d0..40641e55 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/buildtoolpane/MavenBuildToolPane.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/buildtoolpane/MavenBuildToolPane.java @@ -57,7 +57,12 @@ public void reloadAllMavenProjects() { * Collapse all */ public void collapseAll() { - actionButton(byXpath(XPathDefinitions.MY_ICON_COLLAPSE_ALL_FOR), Duration.ofSeconds(2)).click(); + if (UITestRunner.getIdeaVersionInt() >= 20242) { + actionButton(byXpath(XPathDefinitions.MY_ICON_COLLAPSE_ALL_2024_2), Duration.ofSeconds(2)).click(); + + } else { + actionButton(byXpath(XPathDefinitions.MY_ICON_COLLAPSE_ALL_FOR), Duration.ofSeconds(2)).click(); + } } /** From de77c6742723185ea43f5e0b084c90ddd81659db Mon Sep 17 00:00:00 2001 From: Martin Szuc Date: Fri, 27 Sep 2024 15:45:12 +0200 Subject: [PATCH 10/11] fix(test): ProjectExplorerPaneTest updated for 2024.2 Signed-off-by: Martin Szuc --- .../toolwindowspane/openclose/PEPaneAndStripeButtonTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/PEPaneAndStripeButtonTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/PEPaneAndStripeButtonTest.java index 81452f36..24ec520c 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/PEPaneAndStripeButtonTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/PEPaneAndStripeButtonTest.java @@ -20,6 +20,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import java.time.Duration; @@ -59,6 +60,7 @@ public void projectExplorerPaneOpenCloseTest() { } @Test + @DisabledIfSystemProperty(named = "uitestlib.idea.version", matches = "20242") public void stripeButtonTest() { try { toolWinPane.stripeButton(ButtonLabels.MAVEN_STRIPE_BUTTON_LABEL, false); From 7ff78ac17a409a5aaecc6b422e9d3e89d2122a73 Mon Sep 17 00:00:00 2001 From: Martin Szuc Date: Sat, 28 Sep 2024 19:47:01 +0200 Subject: [PATCH 11/11] fix(test): setprojectsdk test for windows Signed-off-by: Martin Szuc --- .../project/pages/NewProjectFirstPage.java | 21 ++++++++---- .../NewProjectDialogTest.java | 32 ++++++++++++------- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java index 882f68d6..28deff58 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/NewProjectFirstPage.java @@ -121,12 +121,21 @@ public ComboBoxFixture getProjectJdkComboBox() { * @param targetSdkName name of the SDK to which will be changed the current settings */ public void setProjectSdkIfAvailable(String targetSdkName) { - step("Select the '" + targetSdkName + "' as new project SDK", () -> { - ComboBoxFixture projectJdkComboBox = getProjectJdkComboBox(); - String currentlySelectedProjectSdk = TextUtils.listOfRemoteTextToString(projectJdkComboBox.findAllText()); - if (currentlySelectedProjectSdk.contains(targetSdkName)) { - return; - } + step("Select the '" + targetSdkName + "' as new project SDK", () -> { + + waitFor( + Duration.ofSeconds(20), + Duration.ofSeconds(5), + "Waiting for 'resolving jdk' dialog to disappear.", + () -> "Expected exactly one dialog but found " + remoteRobot.findAll(CommonContainerFixture.class, byXpath(XPathDefinitions.MY_DIALOG)).size(), + () -> remoteRobot.findAll(CommonContainerFixture.class, byXpath(XPathDefinitions.MY_DIALOG)).size() == 1 + ); + + ComboBoxFixture projectJdkComboBox = getProjectJdkComboBox(); + String currentlySelectedProjectSdk = TextUtils.listOfRemoteTextToString(projectJdkComboBox.findAllText()); + if (currentlySelectedProjectSdk.contains(targetSdkName)) { + return; + } if (UITestRunner.getIdeaVersionInt() >= 20221) { projectJdkComboBox.click(); diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/project_manipulation/NewProjectDialogTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/project_manipulation/NewProjectDialogTest.java index 773224a9..2026541e 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/project_manipulation/NewProjectDialogTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/project_manipulation/NewProjectDialogTest.java @@ -10,11 +10,7 @@ ******************************************************************************/ package com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.project_manipulation; -import com.intellij.remoterobot.fixtures.ComboBoxFixture; -import com.intellij.remoterobot.fixtures.ComponentFixture; -import com.intellij.remoterobot.fixtures.ContainerFixture; -import com.intellij.remoterobot.fixtures.JLabelFixture; -import com.intellij.remoterobot.fixtures.JListFixture; +import com.intellij.remoterobot.fixtures.*; import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; import com.redhat.devtools.intellij.commonuitest.LibraryTestBase; import com.redhat.devtools.intellij.commonuitest.UITestRunner; @@ -28,8 +24,10 @@ import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.pages.NewProjectFirstPage; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.MainIdeWindow; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.idestatusbar.IdeStatusBar; +import com.redhat.devtools.intellij.commonuitest.utils.constants.ButtonLabels; import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; +import com.redhat.devtools.intellij.commonuitest.utils.screenshot.ScreenshotUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -333,13 +331,23 @@ public void cancelButtonTest() { @Test public void setProjectSdkIfAvailableTest() { - newProjectFirstPage.setProjectSdkIfAvailable("11"); - ComboBoxFixture projectJdkComboBox = newProjectFirstPage.getProjectJdkComboBox(); - String currentlySelectedProjectSdk = listOfRemoteTextToString(projectJdkComboBox.findAllText()); - assertTrue(currentlySelectedProjectSdk.contains("11"), "Selected project SDK should be Java 11 but is '" + currentlySelectedProjectSdk + "'"); - newProjectFirstPage.setProjectSdkIfAvailable("17"); - currentlySelectedProjectSdk = listOfRemoteTextToString(projectJdkComboBox.findAllText()); - assertTrue(currentlySelectedProjectSdk.contains("17"), "Selected project SDK should be Java 17 but is '" + currentlySelectedProjectSdk + "'"); + if (ideaVersionInt >= 20242 && remoteRobot.isWin()) { + newProjectFirstPage.setProjectSdkIfAvailable("Download JDK"); + try { + ContainerFixture downloadJdkDialog = remoteRobot.find(ContainerFixture.class, byXpath("//div[@title='Download JDK']"), Duration.ofSeconds(10)); + downloadJdkDialog.find(ActionButtonFixture.class, byXpath(XPathDefinitions.label(ButtonLabels.CANCEL_LABEL)), Duration.ofSeconds(5)).click(); + } catch (WaitForConditionTimeoutException e) { + fail("Download JDK button was not pressed and Download JDK dialog was not found"); + } + } else { + newProjectFirstPage.setProjectSdkIfAvailable("11"); + ComboBoxFixture projectJdkComboBox = newProjectFirstPage.getProjectJdkComboBox(); + String currentlySelectedProjectSdk = listOfRemoteTextToString(projectJdkComboBox.findAllText()); + assertTrue(currentlySelectedProjectSdk.contains("11"), "Selected project SDK should be Java 11 but is '" + currentlySelectedProjectSdk + "'"); + newProjectFirstPage.setProjectSdkIfAvailable("17"); + currentlySelectedProjectSdk = listOfRemoteTextToString(projectJdkComboBox.findAllText()); + assertTrue(currentlySelectedProjectSdk.contains("17"), "Selected project SDK should be Java 17 but is '" + currentlySelectedProjectSdk + "'"); + } } @Test