From 9fc293272ef054cacdd05f81457ec026582f27b3 Mon Sep 17 00:00:00 2001 From: Stephane Bouchet Date: Wed, 4 Jun 2025 16:25:59 +0200 Subject: [PATCH 1/5] fix: fix CodeWithMe on 2023.1 and starting for other versions Signed-off-by: Stephane Bouchet --- .../commonuitest/fixtures/mainidewindow/menubar/MenuBar.java | 4 ++++ 1 file changed, 4 insertions(+) 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 3a70588a..e545e763 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 @@ -47,6 +47,10 @@ public MenuBar(RemoteRobot remoteRobot) { * @param path path to navigate in the main menu */ public void navigateTo(String... path) { + if (!isVisible()) { + LOGGER.severe("Main Menu is not visible."); + return; + } if (path.length == 0) { return; } From 8ba212eec6dd7142e98f1339bdde581a716f31ee Mon Sep 17 00:00:00 2001 From: Stephane Bouchet Date: Thu, 5 Jun 2025 18:44:06 +0200 Subject: [PATCH 2/5] fix: fix Main Menu Signed-off-by: Stephane Bouchet --- .../commonuitest/fixtures/mainidewindow/menubar/MenuBar.java | 4 ---- 1 file changed, 4 deletions(-) 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 e545e763..3a70588a 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 @@ -47,10 +47,6 @@ public MenuBar(RemoteRobot remoteRobot) { * @param path path to navigate in the main menu */ public void navigateTo(String... path) { - if (!isVisible()) { - LOGGER.severe("Main Menu is not visible."); - return; - } if (path.length == 0) { return; } From 2f77bc1ad3cd15f10462ff3bb3c8bff271376824 Mon Sep 17 00:00:00 2001 From: Stephane Bouchet Date: Wed, 11 Jun 2025 15:04:42 +0200 Subject: [PATCH 3/5] chore: bump minimal version to 2022.3, due to IJ gradle plugin 2.x used. see https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#requirements fixes #287 Signed-off-by: Stephane Bouchet --- .github/workflows/ci.yml | 18 -- .github/workflows/validate.yml | 17 +- .gitignore | 3 +- build.gradle.kts | 1 + gradle/libs.versions.toml | 2 + .../intellij/commonuitest/UITestRunner.java | 22 +- .../fixtures/dialogs/FlatWelcomeFrame.java | 126 +++------- .../dialogs/information/CodeWithMeDialog.java | 3 +- .../project/NewProjectDialogWizard.java | 7 +- .../pages/AbstractNewProjectFinalPage.java | 65 +---- .../pages/JavaNewProjectFinalPage.java | 94 +------ .../pages/MavenGradleNewProjectFinalPage.java | 33 --- .../project/pages/NewProjectFirstPage.java | 28 ++- .../fixtures/mainidewindow/MainIdeWindow.java | 2 +- .../mainidewindow/menubar/MenuBar.java | 21 +- .../toolwindowspane/AbstractToolWinPane.java | 28 +-- .../toolwindowspane/ToolWindowsPane.java | 31 --- .../buildtoolpane/GradleBuildToolPane.java | 7 +- .../buildtoolpane/MavenBuildToolPane.java | 7 +- .../utils/constants/ButtonLabels.java | 5 - .../utils/constants/XPathDefinitions.java | 32 +-- .../utils/project/CreateCloseUtils.java | 86 ++----- .../utils/project/NewProjectType.java | 23 ++ .../utils/runner/IntelliJVersion.java | 14 +- .../utils/screenshot/ScreenshotUtils.java | 10 +- .../commonuitest/AbstractLibraryBaseTest.java | 3 +- .../test/dialogs/FlatWelcomeFrameTest.java | 23 +- .../information/CodeWithMeDialogTest.java | 54 ++-- .../ProjectStructureDialogTest.java | 3 +- .../dialogs/information/TipDialogTest.java | 10 +- .../NewProjectDialogTest.java | 230 ++++-------------- .../idestatusbar/IdeStatusBarTest.java | 22 +- .../mainidewindow/menubar/MenuBarTest.java | 10 +- .../toolwindowspane/BuildViewTest.java | 10 +- .../toolwindowspane/ProjectExplorerTest.java | 19 +- .../ToolWindowsPaneGradleTest.java | 11 +- .../ToolWindowsPaneMavenTest.java | 11 +- .../GradleBuildToolPaneTest.java | 11 +- .../buildtoolpane/MavenBuildToolPaneTest.java | 11 +- .../openclose/AbstractToolWinPane.java | 7 +- .../openclose/GradlePaneTest.java | 11 +- .../openclose/MavenPaneTest.java | 11 +- .../openclose/PEPaneAndStripeButtonTest.java | 11 +- .../test/screenshot/ScreenshotUtilsTest.java | 21 +- 44 files changed, 284 insertions(+), 890 deletions(-) delete mode 100644 src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ToolWindowsPane.java create mode 100644 src/main/java/com/redhat/devtools/intellij/commonuitest/utils/project/NewProjectType.java diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d6b2855..e372a42d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,12 +56,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 # Java 11 is only used for test NewProjectDialogTest/setProjectSdkIfAvailableTest - uses: actions/setup-java@v4 - with: - java-version: 11 - distribution: 'temurin' - cache: 'gradle' - name: Set up JDK 17 uses: actions/setup-java@v4 with: @@ -104,12 +98,6 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 # Java 11 is only used for test NewProjectDialogTest/setProjectSdkIfAvailableTest - uses: actions/setup-java@v4 - with: - java-version: 11 - distribution: 'temurin' - cache: 'gradle' - name: Set up JDK 17 uses: actions/setup-java@v4 with: @@ -144,12 +132,6 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 # Java 11 is only used for test NewProjectDialogTest/setProjectSdkIfAvailableTest - uses: actions/setup-java@v4 - with: - java-version: 11 - distribution: 'temurin' - cache: 'gradle' - name: Set up JDK 17 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 48547c5a..fe179c13 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -1,8 +1,6 @@ name: Validate against IJ versions on: - push: - branches: [ main ] pull_request: branches: [ main ] @@ -13,29 +11,16 @@ jobs: strategy: matrix: IJ: - - 2020.2 - - 2020.3 - - 2021.1 - - 2021.2 - - 2021.3 - - 2022.1 - - 2022.2 - 2022.3 - 2023.1 - 2023.2 - 2023.3 - 2024.1 - 2024.2 - - 2024.3 + # - 2024.3 is the current one steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 # Java 11 is only used for test NewProjectDialogTest/setProjectSdkIfAvailableTest - uses: actions/setup-java@v4 - with: - java-version: 11 - distribution: 'temurin' - cache: 'gradle' - name: Set up JDK 17 uses: actions/setup-java@v4 with: diff --git a/.gitignore b/.gitignore index 7ff38414..429cdc22 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,5 @@ build/ target/ pom.xml -/src/test-project/.intellijPlatform/self-update.lock +/src/test-project/.intellijPlatform/ +/.intellijPlatform/ diff --git a/build.gradle.kts b/build.gradle.kts index 1548a896..aeb02c3f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,6 +18,7 @@ repositories { dependencies { implementation(libs.kotlin.reflect) + implementation(libs.openapi) api(libs.junit.jupiter.api) api(libs.remote.robot) api(libs.remote.fixtures) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 49686957..fdabfc4f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,6 +3,7 @@ remote-robot = "0.11.23" kotlin = "2.1.0" junit-jupiter = "5.12.2" +openapi = "7.0.3" # plugins sonarqube = "5.1.0.4882" @@ -12,6 +13,7 @@ kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", vers junit-jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit-jupiter" } remote-robot = { group = "com.intellij.remoterobot", name = "remote-robot", version.ref = "remote-robot" } remote-fixtures = { group = "com.intellij.remoterobot", name = "remote-fixtures", version.ref = "remote-robot" } +openapi = { group = "com.intellij", name = "openapi", version.ref = "openapi" } [plugins] sonarqube = { id = "org.sonarqube", version.ref = "sonarqube" } \ No newline at end of file diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java index 35d0a19e..99ef63b5 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java @@ -10,6 +10,7 @@ ******************************************************************************/ package com.redhat.devtools.intellij.commonuitest; +import com.intellij.openapi.util.SystemInfo; import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.stepsProcessing.StepLogger; import com.intellij.remoterobot.stepsProcessing.StepWorker; @@ -47,7 +48,6 @@ public class UITestRunner { private static final String ACCEPTED_SOURCE_LOCATION = "accepted"; private static final String COPY_ACCEPTED_FILE_STEP_DESCRIPTION = "Copy the 'accepted' file to the appropriate location"; private static final Logger LOGGER = Logger.getLogger(UITestRunner.class.getName()); - private static final String OS_NAME = System.getProperty("os.name").toLowerCase(); private static final String USER_HOME = System.getProperty("user.home"); private static final String NEW_ITEM_PROPERTY = "New-ItemProperty"; private static final String NAME_PARAM = "-Name"; @@ -74,11 +74,10 @@ public static RemoteRobot runIde(IntelliJVersion ideaVersionUnderTest, int port) } return step("Start IntelliJ Idea ('" + ideaVersion + "') listening on port " + port, () -> { - System.setProperty("uitestlib.idea.version", Integer.toString(ideaVersion.toInt())); acceptAllTermsAndConditions(); - String fileExtension = OS_NAME.contains("windows") ? ".bat" : ""; + String fileExtension = SystemInfo.isWindows ? ".bat" : ""; String platformVersion = generatePlatformVersion(); ProcessBuilder pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-PideaVersion=" + platformVersion, "-Drobot-server.port=" + port); @@ -116,22 +115,13 @@ public static void closeIde() { ideProcess.destroy(); } - /** - * Return the IdeaVersion representation of the currently running IntelliJ Idea version - * - * @return version of the currently running IntelliJ Idea - */ - public static IntelliJVersion getIdeaVersion() { - return ideaVersion; - } - /** * Return the integer representation of the currently running IntelliJ Idea version * * @return version of the currently running IntelliJ Idea */ public static int getIdeaVersionInt() { - return getIdeaVersion().toInt(); + return ideaVersion.toInt(); } /** @@ -172,7 +162,7 @@ private static void acceptAllTermsAndConditions() { linuxPrefsXmlSourceLocation = "prefs_xml/2022_1/prefs.xml"; } - if (OS_NAME.contains("linux")) { + if (SystemInfo.isLinux) { step("Copy the 'prefs.xml' file to the appropriate location", () -> { String prefsXmlDir = USER_HOME + "/.java/.userPrefs/jetbrains/_!(!!cg\"p!(}!}@\"j!(k!|w\"w!'8!b!\"p!':!e@=="; createDirectoryHierarchy(prefsXmlDir); @@ -184,7 +174,7 @@ private static void acceptAllTermsAndConditions() { createDirectoryHierarchy(acceptedDir); copyFileFromJarResourceDir(ACCEPTED_SOURCE_LOCATION, acceptedDir + "/accepted"); }); - } else if (OS_NAME.contains("os x")) { + } else if (SystemInfo.isMac) { step("Copy the 'com.apple.java.util.prefs.plist' file to the appropriate location", () -> { String plistDir = USER_HOME + "/Library/Preferences"; copyFileFromJarResourceDir(osxPlistSourceLocation, plistDir + "/com.apple.java.util.prefs.plist"); @@ -205,7 +195,7 @@ private static void acceptAllTermsAndConditions() { Thread.currentThread().interrupt(); } }); - } else if (OS_NAME.contains("windows")) { + } else if (SystemInfo.isWindows) { step(COPY_ACCEPTED_FILE_STEP_DESCRIPTION, () -> { String acceptedDir = USER_HOME + "\\AppData\\Roaming\\JetBrains\\consentOptions"; createDirectoryHierarchy(acceptedDir); 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 f050617d..4ae7307e 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 @@ -17,9 +17,7 @@ import com.intellij.remoterobot.fixtures.ContainerFixture; import com.intellij.remoterobot.fixtures.DefaultXpath; import com.intellij.remoterobot.fixtures.FixtureName; -import com.intellij.remoterobot.fixtures.HeavyWeightWindowFixture; import com.intellij.remoterobot.fixtures.JButtonFixture; -import com.intellij.remoterobot.fixtures.JListFixture; import com.intellij.remoterobot.fixtures.JPopupMenuFixture; import com.intellij.remoterobot.fixtures.JTreeFixture; import com.intellij.remoterobot.utils.UtilsKt; @@ -91,14 +89,7 @@ public void openProject(String projectName) { * @param label label of the link to click on */ public void clickOnLink(String label) { - // Code for IntelliJ IDEA 2020.3 or newer - if (ideaVersionInt >= 20203) { - welcomeFrameLink(label).click(); - } - // Code for IntelliJ IDEA 2020.2 or earlier - else { - actionLink(label).click(); - } + welcomeFrameLink(label).click(); } /** @@ -134,11 +125,11 @@ public void clearWorkspace() { public void clearExceptions() { try { ideErrorsIcon().click(); - find(IdeFatalErrorsDialog.class, Duration.ofSeconds(10)).clearAll(); + find(IdeFatalErrorsDialog.class, Duration.ofSeconds(5)).clearAll(); } catch (WaitForConditionTimeoutException e) { LOGGER.log(Level.INFO, "No fatal errors dialog found to clear."); try { - find(IdeFatalErrorsDialog.class, Duration.ofSeconds(10)).clearAll(); + find(IdeFatalErrorsDialog.class, Duration.ofSeconds(5)).clearAll(); } catch (Exception e2) { LOGGER.log(Level.INFO, "Second attempt to clear fatal errors dialog also failed."); } @@ -149,22 +140,18 @@ public void clearExceptions() { * Open the 'Preferences' dialog */ public void openSettingsDialog() { - if (ideaVersionInt <= 20202) { - clickOnLink("Configure"); - HeavyWeightWindowFixture heavyWeightWindowFixture = find(HeavyWeightWindowFixture.class, Duration.ofSeconds(5)); - heavyWeightWindowFixture.findText("Preferences").click(); - } else if (ideaVersionInt <= 20212) { - JListFixture jListFixture = remoteRobot.find(JListFixture.class, byXpath(XPathDefinitions.JBLIST)); - jListFixture.clickItem("Customize", false); - remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click(); - } else { - JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE)); - jTreeFixture.findText("Customize").click(); - if (remoteRobot.isMac()) { - resizeWelcomeWindow(); - } - remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click(); + JTreeFixture jTreeFixture; + try { + jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE)); + } catch (WaitForConditionTimeoutException e) { + // workaround for 2022.3 + jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath("//div[@accessiblename='Welcome screen categories']")); + } + jTreeFixture.findText("Customize").click(); + if (remoteRobot.isMac()) { + resizeWelcomeWindow(); } + remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click(); } /** @@ -204,25 +191,10 @@ private void resizeWelcomeWindow() { * @return fixture for the 'Tip Of the Day' dialog */ public TipDialog openTipDialog() { - if (ideaVersionInt >= 20211) { - FlatWelcomeFrame flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(2)); - if (ideaVersionInt >= 20223) { // COMMUNITY_V_2022_3 and higher version have different labels for Learn button - flatWelcomeFrame.findText(ButtonLabels.LEARN_LABEL).click(); - } else { - flatWelcomeFrame.findText(ButtonLabels.LEARN_INTELLIJ_IDEA_LABEL).click(); - } - SharedSteps.waitForComponentByXpath(remoteRobot, 2, 200, byXpath(XPathDefinitions.TIP_DIALOG_2)); - flatWelcomeFrame.findText(TIP_OF_THE_DAY).click(); - } else if (ideaVersionInt <= 20202) { - clickOnLink("Get Help"); - HeavyWeightWindowFixture heavyWeightWindowFixture = find(HeavyWeightWindowFixture.class, Duration.ofSeconds(5)); - heavyWeightWindowFixture.findText(TIP_OF_THE_DAY).click(); - } else if (ideaVersionInt == 20203) { // IJ 2020.3 - actionLink("Help").click(); - HeavyWeightWindowFixture heavyWeightWindowFixture = find(HeavyWeightWindowFixture.class, Duration.ofSeconds(5)); - heavyWeightWindowFixture.findText(TIP_OF_THE_DAY).click(); - } - + FlatWelcomeFrame flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(2)); + flatWelcomeFrame.findText(ButtonLabels.LEARN_LABEL).click(); + SharedSteps.waitForComponentByXpath(remoteRobot, 2, 200, byXpath(XPathDefinitions.TIP_DIALOG_2)); + flatWelcomeFrame.findText(TIP_OF_THE_DAY).click(); return remoteRobot.find(TipDialog.class, Duration.ofSeconds(10)); } @@ -239,45 +211,26 @@ public void disableNotifications() { switchToProjectsPage(); } - /** - * Prevent the 'Tip of the Day' dialog from opening after project import - */ - public void preventTipDialogFromOpening() { - TipDialog tipDialog = openTipDialog(); - tipDialog.dontShowTipsCheckBox().setValue(true); - tipDialog.close(); - switchToProjectsPage(); - } - /** * Switch to the 'Projects' page of flat welcome frame */ public void switchToProjectsPage() { - if (ideaVersionInt >= 20213) { - JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE)); - jTreeFixture.findText(PROJECTS_BUTTON).click(); - } else if (ideaVersionInt >= 20203) { - JListFixture jListFixture = remoteRobot.find(JListFixture.class, byXpath(XPathDefinitions.JBLIST)); - jListFixture.clickItem(PROJECTS_BUTTON, false); + JTreeFixture jTreeFixture; + try { + jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE)); + } catch (WaitForConditionTimeoutException e) { + // workaround for 2022.3 + jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath("//div[@accessiblename='Welcome screen categories']")); } + jTreeFixture.findText(PROJECTS_BUTTON).click(); } private int projectsCount() { - if (ideaVersionInt >= 20222) { - try { - JTreeFixture projects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0); - return projects.findAllText().size() / 2; - } catch (IndexOutOfBoundsException e) { - return 0; - } - } else { - try { - ContainerFixture projectWrapper = find(ContainerFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW)); - JListFixture projectList = projectWrapper.find(JListFixture.class, byXpath(XPathDefinitions.MY_LIST)); - return projectList.collectItems().size(); - } catch (WaitForConditionTimeoutException e) { - return 0; - } + try { + JTreeFixture projects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0); + return projects.findAllText().size() / 2; + } catch (IndexOutOfBoundsException e) { + return 0; } } @@ -293,16 +246,11 @@ private JButtonFixture welcomeFrameLink(String label) { } private ComponentFixture ideErrorsIcon() { - return find(ComponentFixture.class, byXpath(XPathDefinitions.IDE_ERROR_ICON), Duration.ofSeconds(10)); + return find(ComponentFixture.class, byXpath(XPathDefinitions.IDE_ERROR_ICON), Duration.ofSeconds(5)); } private void removeTopProjectFromRecentProjects() { - ComponentFixture recentProjects; - if (ideaVersionInt >= 20222) { - recentProjects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0); - } else { - recentProjects = jLists(byXpath(XPathDefinitions.RECENT_PROJECTS)).get(0); - } + ComponentFixture recentProjects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0); // Clicks on X on first recent project to remove it from the recent projects list (visible only when hovered over with cursor) recentProjects.runJs("const horizontal_offset = component.getWidth()-22;\n" + @@ -311,16 +259,12 @@ private void removeTopProjectFromRecentProjects() { if (ideaVersionInt >= 20231) { ComponentFixture removeDialog = remoteRobot.find(ComponentFixture.class, byXpath(XPathDefinitions.MY_DIALOG), Duration.ofSeconds(10)); removeDialog.findText(ButtonLabels.REMOVE_FROM_LIST_LABEL).click(); - } else if (ideaVersionInt >= 20203) { // Code for IntelliJ Idea 2020.3 or newer + } else { List jPopupMenuFixtures = jPopupMenus(JPopupMenuFixture.Companion.byType()); if (!jPopupMenuFixtures.isEmpty()) { JPopupMenuFixture contextMenu = jPopupMenuFixtures.get(0); - if (ideaVersionInt >= 20222) { - contextMenu.select("Remove from Recent Projects" + '\u2026'); - button(byXpath(XPathDefinitions.REMOVE_PROJECT_BUTTON)).click(); - } else { - contextMenu.select("Remove from Recent Projects"); - } + contextMenu.select("Remove from Recent Projects" + '\u2026'); + button(byXpath(XPathDefinitions.REMOVE_PROJECT_BUTTON)).click(); } } } diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/information/CodeWithMeDialog.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/information/CodeWithMeDialog.java index 49e0a9f9..0e8c177c 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/information/CodeWithMeDialog.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/information/CodeWithMeDialog.java @@ -48,9 +48,8 @@ public CodeWithMeDialog(@NotNull RemoteRobot remoteRobot, @NotNull RemoteCompone */ public static void closeCodeWithMePopupIfItAppears(RemoteRobot remoteRobot) { CodeWithMeDialog codeWithMeDialog; - int ideaVersionInt = UITestRunner.getIdeaVersionInt(); try { - if (ideaVersionInt <= 20231) { + if (UITestRunner.getIdeaVersionInt() <= 20231) { codeWithMeDialog = remoteRobot.find(CodeWithMeDialog.class, byXpath("//div[@class='Wrapper']//div[@class='JPanel']"), Duration.ofSeconds(10)); } else { codeWithMeDialog = remoteRobot.find(CodeWithMeDialog.class, Duration.ofSeconds(10)); diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/NewProjectDialogWizard.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/NewProjectDialogWizard.java index efb5e614..ab4ad664 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/NewProjectDialogWizard.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/NewProjectDialogWizard.java @@ -17,7 +17,6 @@ import com.intellij.remoterobot.fixtures.FixtureName; import com.intellij.remoterobot.fixtures.JButtonFixture; 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.ButtonLabels; import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; @@ -53,11 +52,7 @@ public void next() { * Finish the 'New Project' dialog */ public void finish() { - if (UITestRunner.getIdeaVersionInt() >= 20221) { - clickOnButton(ButtonLabels.CREATE_LABEL); - } else { - clickOnButton(ButtonLabels.FINISH_LABEL); - } + clickOnButton(ButtonLabels.CREATE_LABEL); } /** diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java index c6dca6a8..77207121 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java @@ -17,7 +17,6 @@ import com.intellij.remoterobot.fixtures.DefaultXpath; import com.intellij.remoterobot.fixtures.FixtureName; import com.intellij.remoterobot.fixtures.JTextFieldFixture; -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; @@ -36,8 +35,6 @@ @FixtureName(name = "New Project Dialog") public abstract class AbstractNewProjectFinalPage extends CommonContainerFixture { - private final int ideaVersionInt = UITestRunner.getIdeaVersionInt(); - protected AbstractNewProjectFinalPage(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) { super(remoteRobot, remoteComponent); } @@ -48,11 +45,7 @@ protected AbstractNewProjectFinalPage(@NotNull RemoteRobot remoteRobot, @NotNull * @return currently set new project name */ public String getProjectName() { - if (ideaVersionInt >= 20221) { - return textFields(byXpath(XPathDefinitions.JBTEXT_FIELD)).get(0).getText(); - } else { - return textFields(JTextFieldFixture.Companion.byType()).get(0).getText(); - } + return textFields(byXpath(XPathDefinitions.JBTEXT_FIELD)).get(0).getText(); } /** @@ -61,11 +54,7 @@ public String getProjectName() { * @param projectName name of the new project */ public void setProjectName(String projectName) { - if (ideaVersionInt >= 20221) { - textFields(byXpath(XPathDefinitions.JBTEXT_FIELD)).get(0).setText(projectName); - } else { - textFields(JTextFieldFixture.Companion.byType()).get(0).setText(projectName); - } + textFields(byXpath(XPathDefinitions.JBTEXT_FIELD)).get(0).setText(projectName); } /** @@ -74,11 +63,7 @@ public void setProjectName(String projectName) { * @return currently set new project location */ public String getProjectLocation() { - if (ideaVersionInt >= 20221) { - return find(JTextFieldFixture.class, byXpath(XPathDefinitions.EXTENDABLE_TEXT_FIELD)).getText(); - } else { - return textFields(JTextFieldFixture.Companion.byType()).get(1).getText(); - } + return find(JTextFieldFixture.class, byXpath(XPathDefinitions.EXTENDABLE_TEXT_FIELD)).getText(); } /** @@ -87,11 +72,7 @@ public String getProjectLocation() { * @param projectLocation project location of the new project */ public void setProjectLocation(String projectLocation) { - if (ideaVersionInt >= 20221) { - find(JTextFieldFixture.class, byXpath(XPathDefinitions.EXTENDABLE_TEXT_FIELD)).setText(projectLocation); - } else { - textFields(JTextFieldFixture.Companion.byType()).get(1).setText(projectLocation); - } + find(JTextFieldFixture.class, byXpath(XPathDefinitions.EXTENDABLE_TEXT_FIELD)).setText(projectLocation); } /** @@ -99,11 +80,7 @@ public void setProjectLocation(String projectLocation) { */ public void openAdvanceSettings() { if (!isAdvancedSettingsOpened()) { - if (ideaVersionInt >= 20222) { - find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW)).click(); - } else { - find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR)).click(); - } + find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW)).click(); } } @@ -112,22 +89,12 @@ public void openAdvanceSettings() { */ public void closeAdvanceSettings() { if (isAdvancedSettingsOpened()) { - if (ideaVersionInt >= 20222) { - find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW)).click(); - } else { - find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR)).click(); - } + find(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW)).click(); } } private boolean isAdvancedSettingsOpened() { - List cf; - - if (ideaVersionInt >= 20222) { - cf = findAll(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW_SIBLINGS)); - } else { - cf = findAll(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_SIBLINGS)); - } + List cf = findAll(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW_SIBLINGS)); for (int i = 0; i < cf.size(); i++) { if (listOfRemoteTextToString(cf.get(i).findAllText()).contains("Advanced Settings")) { @@ -137,22 +104,4 @@ private boolean isAdvancedSettingsOpened() { throw new UITestException("Wizard does not contain 'Advanced Settings' section."); } - /** - * Enumeration defining values of the 'Project format' combo box - */ - public enum ProjectFormatType { - IDEA_DIRECTORY_BASED(".idea"), - IPR_FILE_BASED(".ipr"); - - private final String textRepresentation; - - ProjectFormatType(String textRepresentation) { - this.textRepresentation = textRepresentation; - } - - @Override - public String toString() { - return this.textRepresentation; - } - } } \ No newline at end of file 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 fa4ae54e..d3ac788d 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 @@ -12,21 +12,14 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.ComboBoxFixture; -import com.intellij.remoterobot.fixtures.ContainerFixture; import com.intellij.remoterobot.fixtures.DefaultXpath; import com.intellij.remoterobot.fixtures.FixtureName; import com.intellij.remoterobot.fixtures.JTextFieldFixture; import com.redhat.devtools.intellij.commonuitest.UITestRunner; -import com.redhat.devtools.intellij.commonuitest.exceptions.UITestException; -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 com.intellij.remoterobot.stepsProcessing.StepWorkerKt.step; /** * New Project dialog java project third page fixture @@ -43,30 +36,6 @@ public JavaNewProjectFinalPage(@NotNull RemoteRobot remoteRobot, @NotNull Remote super(remoteRobot, remoteComponent); } - /** - * Open the 'More settings' options - */ - public void openMoreSettings() { - step("Open the 'More settings' options", () -> { - boolean isAlreadyOpened = isMoreSettingOpened(); - if (!isAlreadyOpened) { - jLabel(ButtonLabels.MORE_SETTINGS).click(); - } - }); - } - - /** - * Close the 'More settings' options - */ - public void closeMoreSettings() { - step("Close the 'More settings' options", () -> { - boolean isAlreadyOpened = isMoreSettingOpened(); - if (isAlreadyOpened) { - jLabel(ButtonLabels.MORE_SETTINGS).click(); - } - }); - } - /** * Get the name of the module currently inserted in the 'Module name' input field * @@ -75,10 +44,8 @@ public void closeMoreSettings() { public String getModuleName() { if (ideaVersionInt >= 20242) { return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME_2024_2_AND_NEWER)).getText(); - } else if (ideaVersionInt >= 20221) { - return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME)).getText(); } else { - return textField("Module name:", true).getText(); + return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME)).getText(); } } @@ -90,10 +57,8 @@ public String getModuleName() { public void setModuleName(String moduleName) { if (ideaVersionInt >= 20242) { find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME_2024_2_AND_NEWER)).setText(moduleName); - } else if (ideaVersionInt >= 20221) { - find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME)).setText(moduleName); } else { - textField("Module name:", true).setText(moduleName); + find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME)).setText(moduleName); } } @@ -103,11 +68,7 @@ public void setModuleName(String moduleName) { * @return location of the content root currently inserted in the input field */ public String getContentRoot() { - if (ideaVersionInt >= 20221) { - return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_CONTENT_ROOT)).getText(); - } else { - return textField("Content root:", true).getText(); - } + return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_CONTENT_ROOT)).getText(); } /** @@ -116,11 +77,7 @@ public String getContentRoot() { * @param contentRoot location of the content root that will be set into the input field */ public void setContentRoot(String contentRoot) { - if (ideaVersionInt >= 20221) { - find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_CONTENT_ROOT)).setText(contentRoot); - } else { - textField("Content root:", true).setText(contentRoot); - } + find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_CONTENT_ROOT)).setText(contentRoot); } /** @@ -129,11 +86,7 @@ public void setContentRoot(String contentRoot) { * @return location of the module file currently inserted in the input field */ public String getModuleFileLocation() { - if (ideaVersionInt >= 20221) { - return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_FILE_LOCATION)).getText(); - } else { - return textField("Module file location:", true).getText(); - } + return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_FILE_LOCATION)).getText(); } /** @@ -142,42 +95,7 @@ public String getModuleFileLocation() { * @param moduleFileLocation location of the module file that will be set into the input field */ public void setModuleFileLocation(String moduleFileLocation) { - if (ideaVersionInt >= 20221) { - find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_FILE_LOCATION)).setText(moduleFileLocation); - } else { - textField("Module file location:", true).setText(moduleFileLocation); - } + find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_FILE_LOCATION)).setText(moduleFileLocation); } - /** - * Get the project format currently set in the 'Project format' combo box - * - * @return project format currently set in the combo box - * @throws UITestException when there is set another value than defined by the 'ProjectFormatType' enumeration in the combo box - */ - public ProjectFormatType getProjectFormat() { - ComboBoxFixture projectFormatComboBox = comboBox(byXpath(XPathDefinitions.JCOMBOBOX), Duration.ofSeconds(10)); - - if (projectFormatComboBox.selectedText().contains(ProjectFormatType.IDEA_DIRECTORY_BASED.toString())) { - return ProjectFormatType.IDEA_DIRECTORY_BASED; - } else if (projectFormatComboBox.selectedText().contains(ProjectFormatType.IPR_FILE_BASED.toString())) { - return ProjectFormatType.IPR_FILE_BASED; - } else { - throw new UITestException("Currently selected project format is not supported."); - } - } - - /** - * Set the project format into the 'Project format' combo box - * - * @param projectFormatType project format that will be set into the combo box - */ - public void setProjectFormat(ProjectFormatType projectFormatType) { - ComboBoxFixture projectFormatComboBox = comboBox(byXpath(XPathDefinitions.JCOMBOBOX), Duration.ofSeconds(10)); - projectFormatComboBox.selectItemContains(projectFormatType.toString()); - } - - private boolean isMoreSettingOpened() { - return findAll(ContainerFixture.class, byXpath(XPathDefinitions.MORE_SETTINGS_TITLED_SEPARATOR)).size() == 2; - } } \ No newline at end of file diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/MavenGradleNewProjectFinalPage.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/MavenGradleNewProjectFinalPage.java index 86e623ae..93a2eb30 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/MavenGradleNewProjectFinalPage.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/MavenGradleNewProjectFinalPage.java @@ -12,18 +12,11 @@ import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.data.RemoteComponent; -import com.intellij.remoterobot.fixtures.ContainerFixture; import com.intellij.remoterobot.fixtures.DefaultXpath; import com.intellij.remoterobot.fixtures.FixtureName; -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.util.List; - -import static com.intellij.remoterobot.search.locators.Locators.byXpath; -import static com.intellij.remoterobot.stepsProcessing.StepWorkerKt.step; - /** * New Project dialog maven project second page fixture * @@ -36,28 +29,6 @@ public MavenGradleNewProjectFinalPage(@NotNull RemoteRobot remoteRobot, @NotNull super(remoteRobot, remoteComponent); } - /** - * Open the 'Artifact Coordinates' options - */ - public void openArtifactCoordinates() { - step("Open the 'Artifact Coordinates' options", () -> { - if (!isArtifactCoordinatesOpened()) { - jLabel(ButtonLabels.ARTIFACT_COORDINATES).click(); - } - }); - } - - /** - * Close the 'Artifact Coordinates' options - */ - public void closeArtifactCoordinates() { - step("Close the 'Artifact Coordinates' options", () -> { - if (isArtifactCoordinatesOpened()) { - jLabel(ButtonLabels.ARTIFACT_COORDINATES).click(); - } - }); - } - /** * Get the group ID currently inserted in the 'GroupId' input field * @@ -112,8 +83,4 @@ public void setVersion(String version) { textField("Version:", true).setText(version); } - private boolean isArtifactCoordinatesOpened() { - List cf = findAll(ContainerFixture.class, byXpath(XPathDefinitions.ARTIFACTS_COORDINATES_DIALOG_PANEL)); - return cf.size() > 5; - } } \ No newline at end of file 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 c36bdc17..432e8c13 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 @@ -24,6 +24,7 @@ import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; import com.redhat.devtools.intellij.commonuitest.UITestRunner; import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; +import com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import com.redhat.devtools.intellij.commonuitest.utils.screenshot.ScreenshotUtils; import com.redhat.devtools.intellij.commonuitest.utils.texttranformation.TextUtils; import org.jetbrains.annotations.NotNull; @@ -60,8 +61,13 @@ public NewProjectFirstPage(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComp * * @param projectType name of the project type to which will be changed the current settings */ - public void selectNewProjectType(String projectType) { - jLists(JListFixture.Companion.byType()).get(0).findText(projectType).click(); + public void selectNewProjectType(NewProjectType projectType) { + if (ideaVersionInt == 20223 && projectType != NewProjectType.NEW_PROJECT && projectType != NewProjectType.EMPTY_PROJECT) { + jLists(JListFixture.Companion.byType()).get(0).findText(NewProjectType.NEW_PROJECT.toString()).click(); + setLanguage(projectType.toString()); + } else { + jLists(JListFixture.Companion.byType()).get(0).findText(projectType.toString()).click(); + } } /** @@ -139,17 +145,15 @@ public void setProjectSdkIfAvailable(String targetSdkName) { return; } - if (ideaVersionInt >= 20221) { + projectJdkComboBox.click(); + boolean popupOpenedPermanently = false; + try { + waitFor(Duration.ofSeconds(10), Duration.ofMillis(250), "HeavyWeightWindow still visible.", this::noHeavyWeightWindowVisible); + } catch (WaitForConditionTimeoutException e) { + popupOpenedPermanently = true; + } + if (!popupOpenedPermanently) { projectJdkComboBox.click(); - boolean popupOpenedPermanently = false; - try { - waitFor(Duration.ofSeconds(10), Duration.ofMillis(250), "HeavyWeightWindow still visible.", this::noHeavyWeightWindowVisible); - } catch (WaitForConditionTimeoutException e) { - popupOpenedPermanently = true; - } - if (!popupOpenedPermanently) { - projectJdkComboBox.click(); - } } CommonContainerFixture parentFixture = waitFor(Duration.ofSeconds(20), Duration.ofSeconds(2), "Wait for the 'Project SDK' list to finish loading all items.", "The project JDK list did not load all items in 20 seconds.", this::didProjectSdkListLoadAllItems); diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/MainIdeWindow.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/MainIdeWindow.java index 367a5b9b..4e6c104c 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/MainIdeWindow.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/MainIdeWindow.java @@ -78,7 +78,7 @@ public void maximizeIdeWindow() { * Close the currently opened project */ public void closeProject() { - if (UITestRunner.getIdeaVersionInt() == 20233 && remoteRobot.isLinux()) { + if (UITestRunner.getIdeaVersionInt() == 20233) { invokeCmdUsingSearchEverywherePopup("Close Project"); } else { new MenuBar(remoteRobot).navigateTo("File", "Close Project"); 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 3a70588a..1a7ff964 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 @@ -18,7 +18,6 @@ import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; import com.redhat.devtools.intellij.commonuitest.UITestRunner; import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; -import org.jetbrains.annotations.NotNull; import java.time.Duration; import java.util.List; @@ -92,22 +91,19 @@ private JButtonFixture mainMenuItem(String label) { if (remoteRobot.isMac()) { return null; } - return getMainMenu().button(byXpath(XPathDefinitions.label(label)), Duration.ofSeconds(10)); + return getMainMenu().button(byXpath(XPathDefinitions.label(label)), Duration.ofSeconds(5)); } - @NotNull public CommonContainerFixture getMainMenu() { - CommonContainerFixture cf; + CommonContainerFixture cf = null; if (remoteRobot.isLinux() && ideaVersionInt <= 20242) { - cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.LINUX_MAIN_MENU), Duration.ofSeconds(10)); + cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.LINUX_MAIN_MENU), Duration.ofSeconds(5)); } else if ((remoteRobot.isWin() && ideaVersionInt >= 20241) || (remoteRobot.isLinux() && ideaVersionInt > 20242)) { - cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2024_1_AND_NEWER), Duration.ofSeconds(10)); - } else if (remoteRobot.isWin() && ideaVersionInt >= 20222) { - cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2022_2_TO_2023_2), Duration.ofSeconds(10)); - } else if (remoteRobot.isWin() && ideaVersionInt >= 20203) { - cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2020_3_TO_2022_1), Duration.ofSeconds(10)); + cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2024_1_AND_NEWER), Duration.ofSeconds(5)); + } else if (remoteRobot.isWin()) { + cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2022_2_TO_2023_2), Duration.ofSeconds(5)); } else { - cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2020_2_AND_OLDER), Duration.ofSeconds(10)); + LOGGER.severe("Can't get main menu. System OS is %s / IdeaVersion is %d".formatted(remoteRobot.getOs(), ideaVersionInt)); } return cf; } @@ -115,8 +111,7 @@ public CommonContainerFixture getMainMenu() { public boolean isVisible() { // check menu already visible try { - getMainMenu(); - return true; + return (getMainMenu() != null); } catch (WaitForConditionTimeoutException e) { return false; } 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 ec42012d..3bc66b95 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 @@ -94,11 +94,7 @@ public void closeGradleBuildToolPane() { public JButtonFixture stripeButton(String label, boolean isPaneOpened) { if (isPaneOpened) { if (label.equals(ButtonLabels.MAVEN_STRIPE_BUTTON_LABEL) || label.equals(ButtonLabels.GRADLE_STRIPE_BUTTON_LABEL)) { - if (ideaVersionInt >= 20223) { // Code for IntelliJ version 2022.3 and newer - return button(byXpath(XPathDefinitions.toolWindowButton(label)), Duration.ofSeconds(2)); - } else { // Code for IntelliJ versions 2022.2 and older - return button(byXpath(XPathDefinitions.toolWindowSvg(label)), Duration.ofSeconds(2)); - } + return button(byXpath(XPathDefinitions.toolWindowButton(label)), Duration.ofSeconds(2)); } else if (label.equals(ButtonLabels.PROJECT_STRIPE_BUTTON_LABEL)) { return button(byXpath(XPathDefinitions.TOOLTIP_TEXT_PROJECT), Duration.ofSeconds(2)); } @@ -116,7 +112,11 @@ protected void togglePane(String label, Class fixtureClass, b private boolean isPaneOpened(Class fixtureClass) { try { - return find(fixtureClass, Duration.ofSeconds(10)).isShowing(); + if (ideaVersionInt <= 20223) { + return find(fixtureClass, Duration.ofSeconds(10)).isShowing(); + } else { + return find(CommonContainerFixture.class, byXpath("//div[@class='MavenProjectsNavigatorPanel']"), Duration.ofSeconds(10)).isShowing(); + } } catch (WaitForConditionTimeoutException e) { return false; } @@ -136,14 +136,10 @@ private void clickOnStripeButton(String label, boolean isPaneOpened) { ToolWindowLeftToolbar toolWindowLeftToolbar = remoteRobot.find(ToolWindowLeftToolbar.class, Duration.ofSeconds(10)); toolWindowLeftToolbar.clickStripeButton(label); } - } else if (ideaVersionInt >= 20221) { - // For IntelliJ IDEA 2022.1 to 2024.1 + } else { + // For IntelliJ IDEA 2022.3 to 2024.1 ToolWindowPane toolWindowPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); toolWindowPane.stripeButton(label, isPaneOpened).click(); - } else { - // For older versions - ToolWindowsPane toolWindowsPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); - toolWindowsPane.stripeButton(label, isPaneOpened).click(); } } @@ -158,14 +154,10 @@ private boolean isStripeButtonAvailable(String label, boolean isPaneOpened) { ToolWindowLeftToolbar toolWindowLeftToolbar = remoteRobot.find(ToolWindowLeftToolbar.class, Duration.ofSeconds(2)); toolWindowLeftToolbar.findStripeButton(label); } - } else if (ideaVersionInt >= 20221) { - // For IntelliJ IDEA 2022.1 to 2024.1 + } else { + // For IntelliJ IDEA 2022.3 to 2024.1 ToolWindowPane toolWindowPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(2)); toolWindowPane.stripeButton(label, isPaneOpened); - } else { - // For older versions - ToolWindowsPane toolWindowsPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(2)); - toolWindowsPane.stripeButton(label, isPaneOpened); } return true; } catch (WaitForConditionTimeoutException e) { diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ToolWindowsPane.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ToolWindowsPane.java deleted file mode 100644 index 42324b8e..00000000 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/toolwindowspane/ToolWindowsPane.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2020 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, - * and is available at https://www.eclipse.org/legal/epl-v20.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -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.DefaultXpath; -import com.intellij.remoterobot.fixtures.FixtureName; -import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; -import org.jetbrains.annotations.NotNull; - -/** - * Tool Windows Pane fixture - * - * @author zcervink@redhat.com - */ -@DefaultXpath(by = "ToolWindowsPane type", xpath = XPathDefinitions.TOOL_WINDOWS_PANE) -@FixtureName(name = "Tool Windows Pane") -public class ToolWindowsPane extends AbstractToolWinPane { - public ToolWindowsPane(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) { - super(remoteRobot, remoteComponent); - } -} \ No newline at end of file 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 6386074b..cda16894 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 @@ -20,7 +20,6 @@ import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.idestatusbar.IdeStatusBar; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.BuildView; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane; import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; import com.redhat.devtools.intellij.commonuitest.utils.texttranformation.TextUtils; import org.jetbrains.annotations.NotNull; @@ -84,11 +83,7 @@ public void buildProject() { waitFor(Duration.ofSeconds(30), Duration.ofSeconds(2), "The Gradle tasks tree did not appear in 30 seconds.", this::isGradleTreeVisible); expandAll(); gradleTaskTree().doubleClickPath(new String[]{"Tasks", "build", "build"}, true); - if (ideaVersionInt >= 20221) { - remoteRobot.find(ToolWindowPane.class).find(BuildView.class).waitUntilBuildHasFinished(); - } else { - remoteRobot.find(ToolWindowsPane.class).find(BuildView.class).waitUntilBuildHasFinished(); - } + remoteRobot.find(ToolWindowPane.class).find(BuildView.class).waitUntilBuildHasFinished(); remoteRobot.find(IdeStatusBar.class, Duration.ofSeconds(10)).waitUntilAllBgTasksFinish(); } 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 3ad11234..d75ea79e 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 @@ -20,7 +20,6 @@ import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.idestatusbar.IdeStatusBar; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.BuildView; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane; import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; import com.redhat.devtools.intellij.commonuitest.utils.texttranformation.TextUtils; import org.jetbrains.annotations.NotNull; @@ -77,11 +76,7 @@ public void buildProject(String goal, String projectName) { tree.doubleClickRowWithText(projectName, true); // expand root tree.doubleClickRowWithText("Lifecycle", true); // expand Lifecycle tree.doubleClickRowWithText(goal, true); - if (ideaVersionInt >= 20221) { - remoteRobot.find(ToolWindowPane.class).find(BuildView.class).waitUntilBuildHasFinished(); - } else { - remoteRobot.find(ToolWindowsPane.class).find(BuildView.class).waitUntilBuildHasFinished(); - } + remoteRobot.find(ToolWindowPane.class).find(BuildView.class).waitUntilBuildHasFinished(); remoteRobot.find(IdeStatusBar.class, Duration.ofSeconds(30)).waitUntilAllBgTasksFinish(); } diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/ButtonLabels.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/ButtonLabels.java index d1e4e964..1bd3f036 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/ButtonLabels.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/ButtonLabels.java @@ -25,18 +25,13 @@ public class ButtonLabels { public static final String APPLY_LABEL = "Apply"; public static final String NEXT_LABEL = "Next"; public static final String PREVIOUS_LABEL = "Previous"; - public static final String FINISH_LABEL = "Finish"; public static final String CREATE_LABEL = "Create"; public static final String PROJECT_STRIPE_BUTTON_LABEL = "Project"; public static final String MAVEN_STRIPE_BUTTON_LABEL = "Maven"; public static final String GRADLE_STRIPE_BUTTON_LABEL = "Gradle"; public static final String GOT_IT_LABEL = "Got It"; - public static final String MORE_SETTINGS = "More Settings"; - public static final String ARTIFACT_COORDINATES = "Artifact Coordinates"; - public static final String LEARN_INTELLIJ_IDEA_LABEL = "Learn IntelliJ IDEA"; public static final String LEARN_LABEL = "Learn"; public static final String REMOVE_FROM_LIST_LABEL = "Remove From List"; - public static final String NEW_PROJECT = "New Project"; private ButtonLabels() { throw new UITestException("Utility class with static methods."); 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 5b7ab0b0..70d7435e 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 @@ -20,7 +20,6 @@ */ public class XPathDefinitions { public static final String MAIN_IDE_WINDOW = "//div[@class='IdeFrameImpl']"; - public static final String TOOL_WINDOWS_PANE = "//div[@class='ToolWindowsPane']"; public static final String PROJECT_TOOL_WINDOW = "//div[@accessiblename='Project Tool Window']"; public static final String BUILD_VIEW = "//div[@class='BuildView']"; public static final String MAVEN_TOOL_WINDOW = "//div[@accessiblename='Maven Tool Window']"; @@ -31,10 +30,6 @@ public class XPathDefinitions { public static final String WINDOWS_MAIN_MENU_2024_1_AND_NEWER = "//div[@class='IdeJMenuBar']"; @Language("XPath") public static final String WINDOWS_MAIN_MENU_2022_2_TO_2023_2 = "//div[@class='IdeMenuBar']"; - @Language("XPath") - public static final String WINDOWS_MAIN_MENU_2020_3_TO_2022_1 = "//div[@class='MenuFrameHeader']"; - @Language("XPath") - public static final String WINDOWS_MAIN_MENU_2020_2_AND_OLDER = "//div[@class='CustomHeaderMenuBar']"; public static final String IDE_STATUS_BAR = "//div[@class='IdeStatusBarImpl']"; @Language("XPath") public static final String INLINE_PROGRESS_PANEL = "//div[@class='InlineProgressPanel']"; @@ -52,8 +47,6 @@ public class XPathDefinitions { @Language("XPath") public static final String TIP_DIALOG_2 = "//div[@text='Tip of the Day']"; @Language("XPath") - public static final String RECENT_PROJECTS = "//div[@accessiblename='Recent Projects']"; - @Language("XPath") public static final String RECENT_PROJECT_PANEL_NEW = "//div[@class='NewRecentProjectPanel']"; @Language("XPath") public static final String RECENT_PROJECT_PANEL_NEW_2 = "//div[@class='JBViewport']/*"; @@ -62,12 +55,6 @@ public class XPathDefinitions { @Language("XPath") public static final String BUILD_VIEW_EDITOR = "//div[@accessiblename='Editor']"; @Language("XPath") - public static final String JCOMBOBOX = "//div[@class='JComboBox']"; - @Language("XPath") - public static final String MORE_SETTINGS_TITLED_SEPARATOR = "//div[@class='TitledSeparator']/../../*"; - @Language("XPath") - public static final String ARTIFACTS_COORDINATES_DIALOG_PANEL = "//div[@class='DialogPanel']/*"; - @Language("XPath") public static final String HEAVY_WEIGHT_WINDOW = "//div[@class='HeavyWeightWindow']"; @Language("XPath") public static final String JDK_COMBOBOX = "//div[@class='JdkComboBox']"; @@ -111,22 +98,14 @@ public class XPathDefinitions { public static final String JBLIST = "//div[@class='JBList']"; @Language("XPath") public static final String DIALOG_PANEL = "//div[@class='DialogPanel']"; - @Language("XPath") - public static final String MY_LIST = "//div[@class='MyList']"; public static final String CODE_WITH_ME_JPANEL = "//div[@class='Wrapper'][.//div[@class='JBLabel']]//div[@class='JPanel']"; @Language("XPath") public static final String BREAD_CRUMBS = "//div[@class='Breadcrumbs']"; @Language("XPath") - public static final String EMPTY_PROJECT = "//div[@visible_text='Empty Project']"; - @Language("XPath") public static final String SINGLE_HEIGHT_LABEL = "//div[@class='SingleHeightLabel']"; @Language("XPath") - public static final String COLLAPSIBLE_TITLED_SEPARATOR = "//div[@class='CollapsibleTitledSeparator']"; - @Language("XPath") public static final String COLLAPSIBLE_TITLED_SEPARATOR_NEW = "//div[@class='CollapsibleTitledSeparatorImpl']"; @Language("XPath") - public static final String COLLAPSIBLE_TITLED_SEPARATOR_SIBLINGS = COLLAPSIBLE_TITLED_SEPARATOR + "/../*"; - @Language("XPath") public static final String COLLAPSIBLE_TITLED_SEPARATOR_NEW_SIBLINGS = COLLAPSIBLE_TITLED_SEPARATOR_NEW + "/../*"; @Language("XPath") public static final String EXTENDABLE_TEXT_FIELD = "//div[@class='ExtendableTextField']"; @@ -151,6 +130,9 @@ public class XPathDefinitions { @Language("XPath") public static final String CREATE_NEW_PROJECT = "//div[@defaulticon='createNewProjectTab.svg']"; // works for IntelliJ Idea 2024.1 and higher + @Language("XPath") + public static final String PROJECT_LABEL = "//div[@accessiblename='.gitignore' and @class='EditorTabLabel']//div[@class='ActionPanel']"; + private XPathDefinitions() { throw new UITestException("Utility class with static methods."); } @@ -167,14 +149,6 @@ public static String nonOpaquePanel(String label) { return "//div[@class='NonOpaquePanel'][./div[@text='" + label + "']]"; } - public static String editorTabLabel(String label) { - return "//div[@accessiblename='" + label + "' and @class='EditorTabLabel']"; - } - - public static String toolWindowSvg(String label) { - return "//div[@disabledicon='toolWindow" + label + ".svg']"; - } - public static String toolWindowButton(String label) { return "//div[@tooltiptext='" + label + "']"; } diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/project/CreateCloseUtils.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/project/CreateCloseUtils.java index 1843d790..6dbba5a0 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/project/CreateCloseUtils.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/project/CreateCloseUtils.java @@ -37,7 +37,9 @@ * * @author zcervink@redhat.com */ -public class CreateCloseUtils { +public final class CreateCloseUtils { + + private CreateCloseUtils() {throw new UITestException("Utility class with static methods.");} /** * Create new project with given project name according to given project type @@ -48,41 +50,25 @@ public class CreateCloseUtils { */ public static void createNewProject(RemoteRobot remoteRobot, String projectName, NewProjectType newProjectType) { NewProjectDialogWizard newProjectDialogWizard = openNewProjectDialogFromWelcomeDialog(remoteRobot); + NewProjectFirstPage newProjectFirstPage = newProjectDialogWizard.find(NewProjectFirstPage.class, Duration.ofSeconds(10)); - int ideaVersionInt = UITestRunner.getIdeaVersionInt(); - if (ideaVersionInt >= 20221) { - newProjectFirstPage.selectNewProjectType("New Project"); - newProjectFirstPage.setLanguage("Java"); - switch (newProjectType) { - case PLAIN_JAVA: - newProjectFirstPage.setBuildSystem("IntelliJ"); - break; - case MAVEN, GRADLE: - newProjectFirstPage.setBuildSystem(newProjectType.toString()); - break; - case EMPTY_PROJECT: - default: - throw new IllegalStateException("Unexpected value: " + newProjectType); - } - } else { - newProjectFirstPage.selectNewProjectType(newProjectType.toString()); + newProjectFirstPage.selectNewProjectType(NewProjectType.NEW_PROJECT); + newProjectFirstPage.setLanguage("Java"); + switch (newProjectType) { + case PLAIN_JAVA: + newProjectFirstPage.setBuildSystem("IntelliJ"); + break; + case MAVEN, GRADLE: + newProjectFirstPage.setBuildSystem(newProjectType.toString()); + break; + case EMPTY_PROJECT: + default: + throw new IllegalStateException("Unexpected value: " + newProjectType); } - newProjectFirstPage.setProjectSdkIfAvailable("17"); - - if (ideaVersionInt >= 20221) { - newProjectFirstPage.getProjectNameTextField().click(); // Click to gain focus on newProjectFirstPage - newProjectFirstPage.setProjectName(projectName); - newProjectFirstPage.setProjectLocation(ProjectLocation.PROJECT_LOCATION); - } else { - newProjectDialogWizard.next(); - // Plain java project has more pages in the 'New project' dialog - if (newProjectType.equals(NewProjectType.PLAIN_JAVA)) { - newProjectDialogWizard.next(); - } - AbstractNewProjectFinalPage finalPage = getFinalPage(newProjectDialogWizard, newProjectType); - finalPage.setProjectName(projectName); - } + newProjectFirstPage.getProjectNameTextField().click(); // Click to gain focus on newProjectFirstPage + newProjectFirstPage.setProjectName(projectName); + newProjectFirstPage.setProjectLocation(ProjectLocation.PROJECT_LOCATION); newProjectDialogWizard.finish(); @@ -99,7 +85,7 @@ public static void createEmptyProject(RemoteRobot remoteRobot, String projectNam NewProjectDialogWizard newProjectDialogWizard = openNewProjectDialogFromWelcomeDialog(remoteRobot); NewProjectFirstPage newProjectFirstPage = newProjectDialogWizard.find(NewProjectFirstPage.class, Duration.ofSeconds(10)); - newProjectFirstPage.selectNewProjectType(NewProjectType.EMPTY_PROJECT.toString()); + newProjectFirstPage.selectNewProjectType(NewProjectType.EMPTY_PROJECT); ensureEmptyProjectPageIsOpened(newProjectFirstPage, remoteRobot); newProjectFirstPage.setProjectName(projectName); @@ -117,10 +103,8 @@ public static void createEmptyProject(RemoteRobot remoteRobot, String projectNam public static void waitAfterOpeningProject(RemoteRobot remoteRobot) { IdeStatusBar ideStatusBar = remoteRobot.find(IdeStatusBar.class, Duration.ofSeconds(10)); ideStatusBar.waitUntilProjectImportIsComplete(); - if (UITestRunner.getIdeaVersionInt() > 20233) { - MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(5)); - mainIdeWindow.maximizeIdeWindow(); - } + MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(5)); + mainIdeWindow.maximizeIdeWindow(); ideStatusBar.waitUntilAllBgTasksFinish(500); CodeWithMeDialog.closeCodeWithMePopupIfItAppears(remoteRobot); } @@ -146,7 +130,6 @@ public static NewProjectDialogWizard openNewProjectDialogFromWelcomeDialog(Remot public static void closeProject(RemoteRobot remoteRobot) { MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(10)); mainIdeWindow.closeProject(); - remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10)); } /** @@ -186,10 +169,9 @@ public static AbstractNewProjectFinalPage getFinalPage(NewProjectDialogWizard ne * @param remoteRobot reference to the RemoteRobot instance */ private static void ensureEmptyProjectPageIsOpened(NewProjectFirstPage newProjectFirstPage, RemoteRobot remoteRobot) { - final int ideaVersionInt = UITestRunner.getIdeaVersionInt(); boolean isEmptyProjectPageDisplayed; - if (ideaVersionInt >= 20231) { // For IntelliJ IDEA version 2023.1 and newer + if (UITestRunner.getIdeaVersionInt() >= 20231) { // For IntelliJ IDEA version 2023.1 and newer isEmptyProjectPageDisplayed = newProjectFirstPage.hasText("A basic project with free structure."); } else { // For IntelliJ IDEA version 2022.1 and newer isEmptyProjectPageDisplayed = newProjectFirstPage.hasText("A basic project that allows working with separate files and compiling Java and Kotlin classes."); @@ -198,7 +180,7 @@ private static void ensureEmptyProjectPageIsOpened(NewProjectFirstPage newProjec if (!isEmptyProjectPageDisplayed) { // If the expected text is not found, wait for dialogs to disappear and reselect the Empty Project type waitForDialogsToDisappear(remoteRobot, Duration.ofSeconds(20)); - newProjectFirstPage.selectNewProjectType(NewProjectType.EMPTY_PROJECT.toString()); + newProjectFirstPage.selectNewProjectType(NewProjectType.EMPTY_PROJECT); } } @@ -223,24 +205,4 @@ private static void waitForDialogsToDisappear(RemoteRobot remoteRobot, Duration ); } - /** - * Enumeration for new project type - */ - public enum NewProjectType { - PLAIN_JAVA("Java"), - MAVEN("Maven"), - GRADLE("Gradle"), - EMPTY_PROJECT("Empty Project"); - - private final String projectType; - - NewProjectType(String projectType) { - this.projectType = projectType; - } - - @Override - public String toString() { - return this.projectType; - } - } } diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/project/NewProjectType.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/project/NewProjectType.java new file mode 100644 index 00000000..23a4b88b --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/project/NewProjectType.java @@ -0,0 +1,23 @@ +package com.redhat.devtools.intellij.commonuitest.utils.project; + +/** + * Enumeration for new project type + */ +public enum NewProjectType { + PLAIN_JAVA("Java"), + MAVEN("Maven"), + GRADLE("Gradle"), + NEW_PROJECT("New Project"), + EMPTY_PROJECT("Empty Project"); + + private final String projectType; + + NewProjectType(String projectType) { + this.projectType = projectType; + } + + @Override + public String toString() { + return this.projectType; + } +} 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 d1e07587..69bca38b 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 @@ -17,13 +17,13 @@ */ public enum IntelliJVersion { UNSUPPORTED("unsupported.version"), - COMMUNITY_V_2020_2("IC-2020.2"), - COMMUNITY_V_2020_3("IC-2020.3"), - COMMUNITY_V_2021_1("IC-2021.1"), - COMMUNITY_V_2021_2("IC-2021.2"), - COMMUNITY_V_2021_3("IC-2021.3"), - COMMUNITY_V_2022_1("IC-2022.1"), - COMMUNITY_V_2022_2("IC-2022.2"), + COMMUNITY_V_2020_2(UNSUPPORTED.toString()), + COMMUNITY_V_2020_3(UNSUPPORTED.toString()), + COMMUNITY_V_2021_1(UNSUPPORTED.toString()), + COMMUNITY_V_2021_2(UNSUPPORTED.toString()), + COMMUNITY_V_2021_3(UNSUPPORTED.toString()), + COMMUNITY_V_2022_1(UNSUPPORTED.toString()), + COMMUNITY_V_2022_2(UNSUPPORTED.toString()), COMMUNITY_V_2022_3("IC-2022.3"), COMMUNITY_V_2023_1("IC-2023.1"), COMMUNITY_V_2023_2("IC-2023.2"), diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/screenshot/ScreenshotUtils.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/screenshot/ScreenshotUtils.java index f27033cb..1d23d66a 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/screenshot/ScreenshotUtils.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/screenshot/ScreenshotUtils.java @@ -44,9 +44,8 @@ private ScreenshotUtils() { * * @param remoteRobot reference to the RemoteRobot instance * @param comment message to add at the end of the screenshot's filename - * @return the screenshot as a File object */ - public static File takeScreenshot(RemoteRobot remoteRobot, String comment) { + public static void takeScreenshot(RemoteRobot remoteRobot, String comment) { try { BufferedImage screenshotBufferedImage = remoteRobot.getScreenshot(); Path path = Paths.get(SCREENSHOT_LOCATION); @@ -59,21 +58,18 @@ public static File takeScreenshot(RemoteRobot remoteRobot, String comment) { String screenshotPathname = SCREENSHOT_LOCATION + screenshotFilename + screenshotComment + "." + FILETYPE; File screenshotFile = new File(screenshotPathname); ImageIO.write(screenshotBufferedImage, FILETYPE, screenshotFile); - return screenshotFile; } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } - return null; } /** * Take screenshot of the entire screen and save it on disk * * @param remoteRobot reference to the RemoteRobot instance - * @return the screenshot as a File object */ - public static File takeScreenshot(RemoteRobot remoteRobot) { - return takeScreenshot(remoteRobot, ""); + public static void takeScreenshot(RemoteRobot remoteRobot) { + takeScreenshot(remoteRobot, ""); } private static String getTimeNow() { diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/AbstractLibraryBaseTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/AbstractLibraryBaseTest.java index f3d86268..169c42d3 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/AbstractLibraryBaseTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/AbstractLibraryBaseTest.java @@ -14,6 +14,7 @@ import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.FlatWelcomeFrame; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.MainIdeWindow; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; +import com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import com.redhat.devtools.intellij.commonuitest.utils.runner.IntelliJVersion; import com.redhat.devtools.intellij.commonuitest.utils.testextension.ScreenshotAfterTestFailExtension; import org.junit.jupiter.api.AfterAll; @@ -59,7 +60,7 @@ static void finishTestRun() { } protected void prepareWorkspace(String projectName) { - CreateCloseUtils.createNewProject(remoteRobot, projectName, CreateCloseUtils.NewProjectType.PLAIN_JAVA); + CreateCloseUtils.createNewProject(remoteRobot, projectName, NewProjectType.PLAIN_JAVA); MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(10)); mainIdeWindow.closeProject(); } diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java index 1b97732e..5a6db688 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java @@ -10,9 +10,7 @@ ******************************************************************************/ package com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs; -import com.intellij.remoterobot.fixtures.JListFixture; import com.intellij.remoterobot.fixtures.JTreeFixture; -import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.FlatWelcomeFrame; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.NewProjectDialogWizard; @@ -88,22 +86,11 @@ private int getNumberOfProjectsOnDisk() { } private int getNumberOfProjectLinks() { - if (ideaVersionInt >= 20222) { - try { - JTreeFixture projects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0); - return projects.findAllText().size() / 2; - } catch (IndexOutOfBoundsException e) { - return 0; - } - } else { - try { - flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10)); - JListFixture recentProjectsList = flatWelcomeFrame.find(JListFixture.class, byXpath(XPathDefinitions.RECENT_PROJECTS), Duration.ofSeconds(10)); - return recentProjectsList.findAllText().size() / 2; // 2 items per 1 project link (project path and project name) - } catch (WaitForConditionTimeoutException e) { - // the list with accessible name 'Recent Projects' is not available -> 0 links in the 'Welcome to IntelliJ IDEA' dialog - return 0; - } + try { + JTreeFixture projects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0); + return projects.findAllText().size() / 2; + } catch (IndexOutOfBoundsException e) { + return 0; } } } \ No newline at end of file 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 96ac0268..082f7ce5 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 @@ -13,19 +13,18 @@ import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.information.CodeWithMeDialog; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.NewProjectDialogWizard; -import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.pages.AbstractNewProjectFinalPage; 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.ProjectLocation; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; +import com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import java.time.Duration; -import static com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils.getFinalPage; import static com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils.openNewProjectDialogFromWelcomeDialog; /** @@ -35,51 +34,36 @@ */ class CodeWithMeDialogTest extends AbstractLibraryBaseTest { private static final String PROJECT_NAME = "code_with_me_java_project"; - private static final boolean IDEA_VERSION_WITH_CWM_DIALOG_OPENED = ideaVersionInt >= 20212; @BeforeAll static void prepareProject() { - if (IDEA_VERSION_WITH_CWM_DIALOG_OPENED) { - NewProjectDialogWizard newProjectDialogWizard = openNewProjectDialogFromWelcomeDialog(remoteRobot); - NewProjectFirstPage newProjectFirstPage = newProjectDialogWizard.find(NewProjectFirstPage.class, Duration.ofSeconds(10)); + NewProjectDialogWizard newProjectDialogWizard = openNewProjectDialogFromWelcomeDialog(remoteRobot); + NewProjectFirstPage newProjectFirstPage = newProjectDialogWizard.find(NewProjectFirstPage.class, Duration.ofSeconds(10)); - if (ideaVersionInt >= 20221) { - newProjectFirstPage.selectNewProjectType("New Project"); - newProjectFirstPage.getProjectNameTextField().click(); // Click to gain focus on newProjectFirstPage - newProjectFirstPage.setProjectName(PROJECT_NAME); - newProjectFirstPage.setProjectLocation(ProjectLocation.PROJECT_LOCATION); - newProjectFirstPage.setLanguage("Java"); - newProjectFirstPage.setBuildSystem("IntelliJ"); - newProjectFirstPage.setProjectSdkIfAvailable("17"); - } else { - newProjectFirstPage.selectNewProjectType("Java"); - newProjectFirstPage.setProjectSdkIfAvailable("11"); - newProjectDialogWizard.next(); - newProjectDialogWizard.next(); - AbstractNewProjectFinalPage finalPage = getFinalPage(newProjectDialogWizard, CreateCloseUtils.NewProjectType.PLAIN_JAVA); - finalPage.setProjectName(PROJECT_NAME); - } + newProjectFirstPage.selectNewProjectType(NewProjectType.NEW_PROJECT); + newProjectFirstPage.getProjectNameTextField().click(); // Click to gain focus on newProjectFirstPage + newProjectFirstPage.setProjectName(PROJECT_NAME); + newProjectFirstPage.setProjectLocation(ProjectLocation.PROJECT_LOCATION); + newProjectFirstPage.setLanguage("Java"); + newProjectFirstPage.setBuildSystem("IntelliJ"); + newProjectFirstPage.setProjectSdkIfAvailable("17"); - newProjectDialogWizard.finish(); - IdeStatusBar ideStatusBar = remoteRobot.find(IdeStatusBar.class, Duration.ofSeconds(10)); - ideStatusBar.waitUntilProjectImportIsComplete(); - MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(5)); - mainIdeWindow.maximizeIdeWindow(); - ideStatusBar.waitUntilAllBgTasksFinish(); - } + newProjectDialogWizard.finish(); + IdeStatusBar ideStatusBar = remoteRobot.find(IdeStatusBar.class, Duration.ofSeconds(10)); + ideStatusBar.waitUntilProjectImportIsComplete(); + MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(5)); + mainIdeWindow.maximizeIdeWindow(); + ideStatusBar.waitUntilAllBgTasksFinish(); } + @AfterAll static void closeCurrentProject() { - if (IDEA_VERSION_WITH_CWM_DIALOG_OPENED) { - CreateCloseUtils.closeProject(remoteRobot); - } + CreateCloseUtils.closeProject(remoteRobot); } @Test void closeCodeWithMe() { - if (IDEA_VERSION_WITH_CWM_DIALOG_OPENED) { - CodeWithMeDialog.closeCodeWithMePopupIfItAppears(remoteRobot); - } + CodeWithMeDialog.closeCodeWithMePopupIfItAppears(remoteRobot); } } \ No newline at end of file diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/ProjectStructureDialogTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/ProjectStructureDialogTest.java index fd0e537f..3bb76c7f 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/ProjectStructureDialogTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/ProjectStructureDialogTest.java @@ -17,6 +17,7 @@ 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.project.CreateCloseUtils; +import com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -36,7 +37,7 @@ class ProjectStructureDialogTest extends AbstractLibraryBaseTest { @BeforeAll static void prepareProject() { - CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, CreateCloseUtils.NewProjectType.PLAIN_JAVA); + CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, NewProjectType.PLAIN_JAVA); } @AfterAll diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/TipDialogTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/TipDialogTest.java index f01d9ed3..ce143d24 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/TipDialogTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/TipDialogTest.java @@ -10,7 +10,6 @@ ******************************************************************************/ package com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.information; -import com.intellij.remoterobot.fixtures.JListFixture; import com.intellij.remoterobot.fixtures.JTreeFixture; import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; @@ -38,13 +37,8 @@ class TipDialogTest extends AbstractLibraryBaseTest { @AfterAll static void cleanUp() { - if (ideaVersionInt >= 20213) { - JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE)); - jTreeFixture.findText("Projects").click(); - } else if (ideaVersionInt >= 20203) { - JListFixture jListFixture = remoteRobot.find(JListFixture.class, byXpath(XPathDefinitions.JBLIST)); - jListFixture.clickItem("Projects", false); - } + JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE)); + jTreeFixture.findText("Projects").click(); } @BeforeEach 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 d3d7ae17..2667e276 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 @@ -15,7 +15,6 @@ 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.utils.WaitForConditionTimeoutException; import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; import com.redhat.devtools.intellij.commonuitest.UITestRunner; @@ -32,10 +31,10 @@ 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.project.NewProjectType; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import java.time.Duration; import java.util.Arrays; @@ -57,11 +56,8 @@ */ class NewProjectDialogTest extends AbstractLibraryBaseTest { private static final String PLAIN_JAVA_PROJECT_NAME = "plain_java_project_name_test"; - private static final String MORE_SETTINGS_SHOULD_BE_VISIBLE = "The 'More Settings' should be visible."; - private static final String MORE_SETTINGS_SHOULD_BE_HIDDEN = "The 'More Settings' should be hidden."; private static final String ADVANCED_SETTINGS_SHOULD_BE_OPENED_MSG = "The 'Advanced Settings' section should be opened but is not"; private static final String ADVANCED_SETTINGS_SHOULD_BE_CLOSED_MSG = "The 'Advanced Settings' section should be closed but is not"; - private static final String BUT_IS = "but is"; private final int ideaVersionInt = UITestRunner.getIdeaVersionInt(); private NewProjectDialogWizard newProjectDialogWizard; @@ -98,49 +94,20 @@ void cleanUp() { @Test void setProjectNamePlainJavaProjectTest() { - testProjectNameAndLocationInputField(CreateCloseUtils.NewProjectType.PLAIN_JAVA); + testProjectNameAndLocationInputField(NewProjectType.PLAIN_JAVA); } @Test - @EnabledIfSystemProperty(named = "uitestlib.idea.version", matches = "2020.|2021.") void setProjectNameMavenProjectTest() { - testProjectNameAndLocationInputField(CreateCloseUtils.NewProjectType.MAVEN); + testProjectNameAndLocationInputField(NewProjectType.MAVEN); } @Test - @EnabledIfSystemProperty(named = "uitestlib.idea.version", matches = "2020.|2021.") void setProjectNameGradleProjectTest() { - testProjectNameAndLocationInputField(CreateCloseUtils.NewProjectType.GRADLE); + testProjectNameAndLocationInputField(NewProjectType.GRADLE); } @Test - @EnabledIfSystemProperty(named = "uitestlib.idea.version", matches = "2020.|2021.") - void openMoreSettingsTest() { - navigateToSetProjectNamePage(CreateCloseUtils.NewProjectType.PLAIN_JAVA); - JavaNewProjectFinalPage javaFinalPage = newProjectDialogWizard.find(JavaNewProjectFinalPage.class, Duration.ofSeconds(10)); - javaFinalPage.closeMoreSettings(); - assertFalse(isMoreSettingsOpened(javaFinalPage), MORE_SETTINGS_SHOULD_BE_HIDDEN); - javaFinalPage.openMoreSettings(); - assertTrue(isMoreSettingsOpened(javaFinalPage), MORE_SETTINGS_SHOULD_BE_VISIBLE); - javaFinalPage.openMoreSettings(); - assertTrue(isMoreSettingsOpened(javaFinalPage), MORE_SETTINGS_SHOULD_BE_VISIBLE); - } - - @Test - @EnabledIfSystemProperty(named = "uitestlib.idea.version", matches = "2020.|2021.") - void closeMoreSettingsTest() { - navigateToSetProjectNamePage(CreateCloseUtils.NewProjectType.PLAIN_JAVA); - JavaNewProjectFinalPage javaFinalPage = newProjectDialogWizard.find(JavaNewProjectFinalPage.class, Duration.ofSeconds(10)); - javaFinalPage.openMoreSettings(); - assertTrue(isMoreSettingsOpened(javaFinalPage), MORE_SETTINGS_SHOULD_BE_VISIBLE); - javaFinalPage.closeMoreSettings(); - assertFalse(isMoreSettingsOpened(javaFinalPage), MORE_SETTINGS_SHOULD_BE_HIDDEN); - javaFinalPage.closeMoreSettings(); - assertFalse(isMoreSettingsOpened(javaFinalPage), MORE_SETTINGS_SHOULD_BE_HIDDEN); - } - - @Test - @EnabledIfSystemProperty(named = "uitestlib.idea.version", matches = "2020.|2021.") void openAdvancedSettingsTest() { newProjectFirstPage.closeAdvanceSettings(); assertFalse(isAdvancedSettingsOpened(), ADVANCED_SETTINGS_SHOULD_BE_CLOSED_MSG); @@ -151,7 +118,6 @@ void openAdvancedSettingsTest() { } @Test - @EnabledIfSystemProperty(named = "uitestlib.idea.version", matches = "2020.|2021.") void closeAdvancedSettingsTest() { newProjectFirstPage.openAdvanceSettings(); assertTrue(isAdvancedSettingsOpened(), ADVANCED_SETTINGS_SHOULD_BE_OPENED_MSG); @@ -163,114 +129,71 @@ void closeAdvancedSettingsTest() { @Test void getSetModuleNameTest() { - navigateToSetProjectNamePage(CreateCloseUtils.NewProjectType.PLAIN_JAVA); + navigateToSetProjectNamePage(NewProjectType.PLAIN_JAVA); JavaNewProjectFinalPage javaFinalPage = newProjectDialogWizard.find(JavaNewProjectFinalPage.class, Duration.ofSeconds(10)); - if (ideaVersionInt >= 20221) { - javaFinalPage.openAdvanceSettings(); - } else { - javaFinalPage.openMoreSettings(); - } + javaFinalPage.openAdvanceSettings(); String currentModuleName = javaFinalPage.getModuleName(); String newModuleName = currentModuleName + "1"; javaFinalPage.setModuleName(newModuleName); currentModuleName = javaFinalPage.getModuleName(); - assertEquals(currentModuleName, newModuleName, "Currently set module name should be '" + newModuleName + BUT_IS + currentModuleName + "'."); + assertEquals(currentModuleName, newModuleName, "Currently set module name doesn't match."); } @Test void getSetContentRootTest() { - navigateToSetProjectNamePage(CreateCloseUtils.NewProjectType.PLAIN_JAVA); + navigateToSetProjectNamePage(NewProjectType.PLAIN_JAVA); JavaNewProjectFinalPage javaFinalPage = newProjectDialogWizard.find(JavaNewProjectFinalPage.class, Duration.ofSeconds(10)); - if (ideaVersionInt >= 20221) { - javaFinalPage.openAdvanceSettings(); - } else { - javaFinalPage.openMoreSettings(); - } + javaFinalPage.openAdvanceSettings(); String currentContentRoot = javaFinalPage.getContentRoot(); String newContentRoot = currentContentRoot + "1"; javaFinalPage.setContentRoot(newContentRoot); currentContentRoot = javaFinalPage.getContentRoot(); - assertEquals(currentContentRoot, newContentRoot, "Currently set content root location should be '" + newContentRoot + BUT_IS + currentContentRoot + "'."); + assertEquals(currentContentRoot, newContentRoot, "Currently set content root location doesn't match."); } @Test void getSetModuleFileLocationTest() { - navigateToSetProjectNamePage(CreateCloseUtils.NewProjectType.PLAIN_JAVA); + navigateToSetProjectNamePage(NewProjectType.PLAIN_JAVA); JavaNewProjectFinalPage javaFinalPage = newProjectDialogWizard.find(JavaNewProjectFinalPage.class, Duration.ofSeconds(10)); - if (ideaVersionInt >= 20221) { - javaFinalPage.openAdvanceSettings(); - } else { - javaFinalPage.openMoreSettings(); - } + javaFinalPage.openAdvanceSettings(); String currentModuleFileLocation = javaFinalPage.getModuleFileLocation(); String newModuleFileLocation = currentModuleFileLocation + "1"; javaFinalPage.setModuleFileLocation(newModuleFileLocation); currentModuleFileLocation = javaFinalPage.getModuleFileLocation(); - assertEquals(currentModuleFileLocation, newModuleFileLocation, "Currently set module file location should be '" + newModuleFileLocation + BUT_IS + currentModuleFileLocation + "'."); - } - - @Test - @EnabledIfSystemProperty(named = "uitestlib.idea.version", matches = "2020.|2021.") - void getSetProjectFormat() { - navigateToSetProjectNamePage(CreateCloseUtils.NewProjectType.PLAIN_JAVA); - JavaNewProjectFinalPage javaFinalPage = newProjectDialogWizard.find(JavaNewProjectFinalPage.class, Duration.ofSeconds(10)); - javaFinalPage.openMoreSettings(); - - javaFinalPage.setProjectFormat(AbstractNewProjectFinalPage.ProjectFormatType.IPR_FILE_BASED); - AbstractNewProjectFinalPage.ProjectFormatType currentlySetProjectFormatType = javaFinalPage.getProjectFormat(); - assertEquals(AbstractNewProjectFinalPage.ProjectFormatType.IPR_FILE_BASED, currentlySetProjectFormatType, "Currently set value in the 'Project format' combo box should be '" + AbstractNewProjectFinalPage.ProjectFormatType.IPR_FILE_BASED + BUT_IS + currentlySetProjectFormatType + "'."); - javaFinalPage.setProjectFormat(AbstractNewProjectFinalPage.ProjectFormatType.IDEA_DIRECTORY_BASED); - currentlySetProjectFormatType = javaFinalPage.getProjectFormat(); - assertEquals(AbstractNewProjectFinalPage.ProjectFormatType.IDEA_DIRECTORY_BASED, currentlySetProjectFormatType, "Currently set value in the 'Project format' combo box should be '" + AbstractNewProjectFinalPage.ProjectFormatType.IDEA_DIRECTORY_BASED + BUT_IS + currentlySetProjectFormatType + "'."); - } - - @Test - void openArtifactCoordinatesMavenTest() { - testOpenArtifactCoordinatesMavenGradle(CreateCloseUtils.NewProjectType.MAVEN); - } - - @Test - void openArtifactCoordinatesGradleTest() { - testOpenArtifactCoordinatesMavenGradle(CreateCloseUtils.NewProjectType.GRADLE); + assertEquals(currentModuleFileLocation, newModuleFileLocation, "Currently set module file location doesn't match."); } @Test void getSetGroupIdMavenTest() { - testArtifactCoordinatesAttributes(CreateCloseUtils.NewProjectType.MAVEN, ArtifactCoordinatesAttributes.GROUP_ID); + testArtifactCoordinatesAttributes(NewProjectType.MAVEN, ArtifactCoordinatesAttributes.GROUP_ID); } @Test void getSetGroupIdGradleTest() { - testArtifactCoordinatesAttributes(CreateCloseUtils.NewProjectType.GRADLE, ArtifactCoordinatesAttributes.GROUP_ID); + testArtifactCoordinatesAttributes(NewProjectType.GRADLE, ArtifactCoordinatesAttributes.GROUP_ID); } @Test void getSetArtifactIdMavenTest() { - testArtifactCoordinatesAttributes(CreateCloseUtils.NewProjectType.MAVEN, ArtifactCoordinatesAttributes.ARTIFACT_ID); + testArtifactCoordinatesAttributes(NewProjectType.MAVEN, ArtifactCoordinatesAttributes.ARTIFACT_ID); } @Test void getSetArtifactIdGradleTest() { - testArtifactCoordinatesAttributes(CreateCloseUtils.NewProjectType.GRADLE, ArtifactCoordinatesAttributes.ARTIFACT_ID); - } - - @Test - void getSetVersionMavenTest() { - testArtifactCoordinatesAttributes(CreateCloseUtils.NewProjectType.MAVEN, ArtifactCoordinatesAttributes.VERSION); + testArtifactCoordinatesAttributes(NewProjectType.GRADLE, ArtifactCoordinatesAttributes.ARTIFACT_ID); } @Test void getSetVersionGradleTest() { - testArtifactCoordinatesAttributes(CreateCloseUtils.NewProjectType.GRADLE, ArtifactCoordinatesAttributes.VERSION); + testArtifactCoordinatesAttributes(NewProjectType.GRADLE, ArtifactCoordinatesAttributes.VERSION); } @Test - @EnabledIfSystemProperty(named = "uitestlib.idea.version", matches = "2020.|2021.") void toggleFromTemplateTest() { - newProjectFirstPage.selectNewProjectType(CreateCloseUtils.NewProjectType.PLAIN_JAVA.toString()); + newProjectFirstPage.selectNewProjectType(NewProjectType.PLAIN_JAVA); newProjectDialogWizard.next(); JavaNewProjectSecondPage javaNewProjectSecondPage = newProjectDialogWizard.find(JavaNewProjectSecondPage.class, Duration.ofSeconds(10)); boolean isSelected = javaNewProjectSecondPage.fromTemplateCheckBox().isSelected(); @@ -278,15 +201,14 @@ void toggleFromTemplateTest() { javaNewProjectSecondPage.fromTemplateCheckBox().setValue(false); } javaNewProjectSecondPage.toggleFromTemplate(true); - assertTrue(javaNewProjectSecondPage.fromTemplateCheckBox().isSelected(), "The 'Create project from template' checkbox should be checked " + BUT_IS + " not."); + assertTrue(javaNewProjectSecondPage.fromTemplateCheckBox().isSelected(), "The 'Create project from template' checkbox should be checked but is not."); javaNewProjectSecondPage.fromTemplateCheckBox().setValue(isSelected); } @Test - @EnabledIfSystemProperty(named = "uitestlib.idea.version", matches = "2020.|2021.") void previousButtonTest() { - newProjectFirstPage.selectNewProjectType(CreateCloseUtils.NewProjectType.PLAIN_JAVA.toString()); - newProjectFirstPage.setProjectSdkIfAvailable("11"); + newProjectFirstPage.selectNewProjectType(NewProjectType.PLAIN_JAVA); + newProjectFirstPage.setProjectSdkIfAvailable("17"); assertThrows(UITestException.class, () -> newProjectDialogWizard.previous(), "The 'UITestException' should be thrown because the 'Previous' button is not enabled on the first page of the 'New Project'."); newProjectDialogWizard.next(); @@ -296,15 +218,14 @@ void previousButtonTest() { try { newProjectFirstPage.comboBox(byXpath(XPathDefinitions.JDK_COMBOBOX), Duration.ofSeconds(10)); } catch (WaitForConditionTimeoutException e) { - fail("The 'Project SDK' should be available " + BUT_IS + " not."); + fail("The 'Project SDK' should be available but is not."); } } @Test - @EnabledIfSystemProperty(named = "uitestlib.idea.version", matches = "2020.|2021.") void nextButtonTest() { - newProjectFirstPage.selectNewProjectType(CreateCloseUtils.NewProjectType.PLAIN_JAVA.toString()); - newProjectFirstPage.setProjectSdkIfAvailable("11"); + newProjectFirstPage.selectNewProjectType(NewProjectType.PLAIN_JAVA); + newProjectFirstPage.setProjectSdkIfAvailable("17"); newProjectDialogWizard.next(); boolean isCommandLineAppTextPresent = listOfRemoteTextToString(newProjectFirstPage.findAllText()).contains("Command Line App"); assertTrue(isCommandLineAppTextPresent, "The 'Command Line App' text should be present on the second page of the 'New Project' wizard for java project."); @@ -315,15 +236,6 @@ void nextButtonTest() { @Test void finishButtonTest() { - if (ideaVersionInt < 20221) { - newProjectFirstPage.selectNewProjectType(CreateCloseUtils.NewProjectType.PLAIN_JAVA.toString()); - 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(); - newProjectDialogWizard.next(); - } - assertThrows(UITestException.class, () -> newProjectDialogWizard.next(), "The 'UITestException' should be thrown because the 'Next' button is not available on the last page of the 'New Project' wizard."); newProjectDialogWizard.find(JavaNewProjectFinalPage.class, Duration.ofSeconds(10)).setProjectName(PLAIN_JAVA_PROJECT_NAME); @@ -348,55 +260,39 @@ void setProjectSdkIfAvailableTest() { fail("Download JDK button was not pressed and Download JDK dialog was not found"); } } else { - setProjectSDKVersion("11"); - setProjectSDKVersion("17"); + setProjectSDKVersion(); } } - private void setProjectSDKVersion(String version) { - newProjectFirstPage.setProjectSdkIfAvailable(version); + private void setProjectSDKVersion() { + newProjectFirstPage.setProjectSdkIfAvailable("17"); ComboBoxFixture projectJdkComboBox = newProjectFirstPage.getProjectJdkComboBox(); String currentlySelectedProjectSdk = listOfRemoteTextToString(projectJdkComboBox.findAllText()); Optional optional = Arrays.stream(currentlySelectedProjectSdk.split(" ")).filter(s -> - s.startsWith(version)).findFirst(); - assertTrue(optional.isPresent(), "Selected project SDK should be Java " + version + " but is '" + currentlySelectedProjectSdk + "'"); + s.startsWith("17")).findFirst(); + assertTrue(optional.isPresent(), "Selected project SDK should be Java 17 but is '" + currentlySelectedProjectSdk + "'"); } @Test void selectNewProjectTypeTest() { - newProjectFirstPage.selectNewProjectType("Empty Project"); + newProjectFirstPage.selectNewProjectType(NewProjectType.EMPTY_PROJECT); boolean isEmptyProjectPageDisplayed; - if (ideaVersionInt >= 20231) { // For IntelliJ IDEA version 2023.1 and newer + if (ideaVersionInt >= 20231) { // For IntelliJ IDEA version 2023.1 and newer isEmptyProjectPageDisplayed = newProjectFirstPage.hasText("A basic project with free structure."); - } else if (ideaVersionInt >= 20221) { // For IntelliJ IDEA version 2022.1 and newer + } else { // For IntelliJ IDEA version 2022.3 and newer isEmptyProjectPageDisplayed = newProjectFirstPage.hasText("A basic project that allows working with separate files and compiling Java and Kotlin classes."); - } else if (ideaVersionInt == 20213) { // For IntelliJ IDEA version 2021.3 - isEmptyProjectPageDisplayed = newProjectFirstPage.hasText("Simple project with one module"); - } else { // For IntelliJ IDEA version 2021.2 and older - isEmptyProjectPageDisplayed = !newProjectFirstPage.findAll( - JListFixture.class, byXpath(XPathDefinitions.EMPTY_PROJECT) - ).isEmpty(); } assertTrue(isEmptyProjectPageDisplayed, "The 'Empty Project' page should be displayed but is not."); selectJavaNewProjectType(); - boolean isProjectSDKLabelVisible; - if (ideaVersionInt >= 20221) { - isProjectSDKLabelVisible = !newProjectFirstPage.findAll(JLabelFixture.class, byXpath("//div[@text.key='label.project.wizard.new.project.jdk']")).isEmpty(); - } else { - isProjectSDKLabelVisible = !newProjectFirstPage.findAll(JLabelFixture.class, byXpath("//div[@text='Project SDK:']")).isEmpty(); - } + boolean isProjectSDKLabelVisible = !newProjectFirstPage.findAll(JLabelFixture.class, byXpath("//div[@text.key='label.project.wizard.new.project.jdk']")).isEmpty(); assertTrue(isProjectSDKLabelVisible, "The 'Project SDK:' label should be visible but is not."); } private void selectJavaNewProjectType() { newProjectFirstPage = remoteRobot.find(NewProjectFirstPage.class, Duration.ofSeconds(10)); - if (ideaVersionInt >= 20221) { - newProjectFirstPage.selectNewProjectType("New Project"); - } else { - newProjectFirstPage.selectNewProjectType("Java"); - } + newProjectFirstPage.selectNewProjectType(NewProjectType.NEW_PROJECT); } @Test @@ -418,19 +314,15 @@ void createEmptyProjectTest() { remoteRobot.find(NewProjectDialogWizard.class).cancel(); } - private void navigateToSetProjectNamePage(CreateCloseUtils.NewProjectType newProjectType) { - if (ideaVersionInt >= 20221) { - newProjectFirstPage.setBuildSystem(newProjectType.toString().equals("Java") ? "IntelliJ" : newProjectType.toString()); - return; - } - newProjectFirstPage.selectNewProjectType(newProjectType.toString()); - newProjectDialogWizard.next(); - if (newProjectType == CreateCloseUtils.NewProjectType.PLAIN_JAVA) { - newProjectDialogWizard.next(); + private void navigateToSetProjectNamePage(NewProjectType newProjectType) { + if (NewProjectType.PLAIN_JAVA.equals(newProjectType)) { + newProjectFirstPage.setBuildSystem("IntelliJ"); + } else { + newProjectFirstPage.setBuildSystem(newProjectType.toString()); } } - private void testProjectNameAndLocationInputField(CreateCloseUtils.NewProjectType newProjectType) { + private void testProjectNameAndLocationInputField(NewProjectType newProjectType) { navigateToSetProjectNamePage(newProjectType); AbstractNewProjectFinalPage finalPage = CreateCloseUtils.getFinalPage(newProjectDialogWizard, newProjectType); @@ -438,41 +330,20 @@ private void testProjectNameAndLocationInputField(CreateCloseUtils.NewProjectTyp String newProjectName = currentProjectName + "1"; finalPage.setProjectName(newProjectName); currentProjectName = finalPage.getProjectName(); - assertEquals(currentProjectName, newProjectName, "Currently set project name should be '" + newProjectName + BUT_IS + currentProjectName + "'."); + assertEquals(currentProjectName, newProjectName, "Currently set project name doesn't match."); String currentProjectLocation = finalPage.getProjectLocation(); String newProjectLocation = currentProjectLocation + "2"; finalPage.setProjectLocation(newProjectLocation); currentProjectLocation = finalPage.getProjectLocation(); - assertEquals(currentProjectLocation, newProjectLocation, "Currently set project location should be '" + newProjectLocation + BUT_IS + currentProjectLocation + "'."); - } - - private void testOpenArtifactCoordinatesMavenGradle(CreateCloseUtils.NewProjectType newProjectType) { - if (ideaVersionInt >= 20221) { - return; - } - navigateToSetProjectNamePage(newProjectType); - MavenGradleNewProjectFinalPage mavenGradleFinalPage = newProjectDialogWizard.find(MavenGradleNewProjectFinalPage.class, Duration.ofSeconds(10)); - mavenGradleFinalPage.closeArtifactCoordinates(); - mavenGradleFinalPage.openArtifactCoordinates(); - assertTrue(isArtifactCoordinatesOpened(mavenGradleFinalPage), "The 'Artifact Coordinates' settings should be visible."); - mavenGradleFinalPage.openArtifactCoordinates(); - assertTrue(isArtifactCoordinatesOpened(mavenGradleFinalPage), "The 'Artifact Coordinates' settings should be visible."); + assertEquals(currentProjectLocation, newProjectLocation, "Currently set project location doesn't match."); } - private void testArtifactCoordinatesAttributes(CreateCloseUtils.NewProjectType newProjectType, ArtifactCoordinatesAttributes attribute) { - if (ideaVersionInt >= 20221 && attribute == ArtifactCoordinatesAttributes.VERSION) { - return; - } - + private void testArtifactCoordinatesAttributes(NewProjectType newProjectType, ArtifactCoordinatesAttributes attribute) { navigateToSetProjectNamePage(newProjectType); MavenGradleNewProjectFinalPage mavenGradleFinalPage = newProjectDialogWizard.find(MavenGradleNewProjectFinalPage.class, Duration.ofSeconds(10)); - if (ideaVersionInt >= 20221) { - mavenGradleFinalPage.openAdvanceSettings(); - } else { - mavenGradleFinalPage.openArtifactCoordinates(); - } + mavenGradleFinalPage.openAdvanceSettings(); String currentValue = ""; String newValue = ""; @@ -496,16 +367,7 @@ private void testArtifactCoordinatesAttributes(CreateCloseUtils.NewProjectType n currentValue = mavenGradleFinalPage.getVersion(); break; } - assertEquals(currentValue, newValue, "Currently set '" + attribute + "' should be '" + newValue + BUT_IS + currentValue + "'."); - } - - private boolean isMoreSettingsOpened(JavaNewProjectFinalPage javaFinalPage) { - return javaFinalPage.findAll(ContainerFixture.class, byXpath(XPathDefinitions.MORE_SETTINGS_TITLED_SEPARATOR)).size() == 2; - } - - private boolean isArtifactCoordinatesOpened(MavenGradleNewProjectFinalPage mavenGradleFinalPage) { - List cf = mavenGradleFinalPage.findAll(ContainerFixture.class, byXpath(XPathDefinitions.ARTIFACTS_COORDINATES_DIALOG_PANEL)); - return cf.size() > 5; + assertEquals(currentValue, newValue, "Currently set '" + attribute + "' doesn't match."); } private boolean isAdvancedSettingsOpened() { diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/idestatusbar/IdeStatusBarTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/idestatusbar/IdeStatusBarTest.java index fb68f986..14490766 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/idestatusbar/IdeStatusBarTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/idestatusbar/IdeStatusBarTest.java @@ -12,14 +12,13 @@ import com.intellij.remoterobot.fixtures.dataExtractor.RemoteText; import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; -import com.redhat.devtools.intellij.commonuitest.UITestRunner; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.NewProjectDialogWizard; -import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.pages.MavenGradleNewProjectFinalPage; 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.ProjectLocation; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; +import com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import com.redhat.devtools.intellij.commonuitest.utils.texttranformation.TextUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -50,19 +49,12 @@ void prepareProject() { NewProjectDialogWizard newProjectDialogWizard = CreateCloseUtils.openNewProjectDialogFromWelcomeDialog(remoteRobot); NewProjectFirstPage newProjectFirstPage = newProjectDialogWizard.find(NewProjectFirstPage.class, Duration.ofSeconds(10)); - if (UITestRunner.getIdeaVersionInt() >= 20221) { - newProjectFirstPage.selectNewProjectType("New Project"); - newProjectFirstPage.getProjectNameTextField().click(); // Click to gain focus on newProjectFirstPage - newProjectFirstPage.setProjectName(PROJECT_NAME); - newProjectFirstPage.setProjectLocation(ProjectLocation.PROJECT_LOCATION); - newProjectFirstPage.selectNewProjectType("New Project"); - newProjectFirstPage.setBuildSystem("Maven"); - } else { - newProjectFirstPage.selectNewProjectType(CreateCloseUtils.NewProjectType.MAVEN.toString()); - newProjectDialogWizard.next(); - MavenGradleNewProjectFinalPage mavenGradleFinalPage = newProjectDialogWizard.find(MavenGradleNewProjectFinalPage.class, Duration.ofSeconds(10)); - mavenGradleFinalPage.setProjectName(PROJECT_NAME); - } + newProjectFirstPage.selectNewProjectType(NewProjectType.NEW_PROJECT); + newProjectFirstPage.getProjectNameTextField().click(); // Click to gain focus on newProjectFirstPage + newProjectFirstPage.setProjectName(PROJECT_NAME); + newProjectFirstPage.setProjectLocation(ProjectLocation.PROJECT_LOCATION); + newProjectFirstPage.selectNewProjectType(NewProjectType.EMPTY_PROJECT); + newProjectFirstPage.setBuildSystem("Maven"); newProjectDialogWizard.finish(); } diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/menubar/MenuBarTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/menubar/MenuBarTest.java index a15d6324..0c423364 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/menubar/MenuBarTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/menubar/MenuBarTest.java @@ -19,9 +19,9 @@ import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.AbstractToolWinPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ProjectExplorer; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; -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 com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -39,7 +39,7 @@ class MenuBarTest extends AbstractLibraryBaseTest { @BeforeAll static void prepareProject() { - CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, CreateCloseUtils.NewProjectType.PLAIN_JAVA); + CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, NewProjectType.PLAIN_JAVA); } @AfterAll @@ -65,11 +65,7 @@ void closeAndReopenProjectTest() { CreateCloseUtils.openProjectFromWelcomeDialog(remoteRobot, PROJECT_NAME); AbstractToolWinPane toolWinPane; - if (UITestRunner.getIdeaVersionInt() >= 20221) { - toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); - } else { - toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); - } + toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); toolWinPane.openProjectExplorer(); ProjectExplorer projectExplorer = toolWinPane.find(ProjectExplorer.class, Duration.ofSeconds(10)); assertTrue(projectExplorer.isItemPresent(PROJECT_NAME), "The project should be back open, but it is not"); diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/BuildViewTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/BuildViewTest.java index 17a2899a..8603fb81 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/BuildViewTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/BuildViewTest.java @@ -14,9 +14,9 @@ import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.AbstractToolWinPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.BuildView; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.buildtoolpane.MavenBuildToolPane; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; +import com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -36,12 +36,8 @@ class BuildViewTest extends AbstractLibraryBaseTest { @BeforeAll static void prepareProject() { - CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, CreateCloseUtils.NewProjectType.MAVEN); - if (ideaVersionInt >= 20221) { - toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); - } else { - toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); - } + CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, NewProjectType.MAVEN); + toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); } @AfterAll 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 1160d0fb..a4420f60 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 @@ -15,17 +15,15 @@ import com.intellij.remoterobot.fixtures.JPopupMenuFixture; import com.intellij.remoterobot.utils.Keyboard; import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; -import com.redhat.devtools.intellij.commonuitest.UITestRunner; import com.redhat.devtools.intellij.commonuitest.exceptions.UITestException; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.AbstractToolWinPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ProjectExplorer; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane; 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.project.NewProjectType; import com.redhat.devtools.intellij.commonuitest.utils.steps.SharedSteps; import com.redhat.devtools.intellij.commonuitest.utils.texttranformation.TextUtils; -import org.intellij.lang.annotations.Language; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; @@ -50,13 +48,8 @@ class ProjectExplorerTest extends AbstractLibraryBaseTest { @BeforeAll static void prepareProject() { - CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, CreateCloseUtils.NewProjectType.PLAIN_JAVA); - AbstractToolWinPane toolWinPane; - if (UITestRunner.getIdeaVersionInt() >= 20221) { - toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); - } else { - toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); - } + CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, NewProjectType.PLAIN_JAVA); + AbstractToolWinPane toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); toolWinPane.openProjectExplorer(); projectExplorer = toolWinPane.find(ProjectExplorer.class, Duration.ofSeconds(10)); } @@ -81,9 +74,9 @@ void isItemPresentTest() { void openFileTest() { projectExplorer.openFile(PROJECT_NAME, ".gitignore"); if (ideaVersionInt >= 20231) { // Code for IJ 2023.1+ - @Language("XPath") String projectLabelXpath = "//div[@accessiblename='.gitignore' and @class='EditorTabLabel']//div[@class='ActionPanel']"; - try { // Verify file is opened by finding its tab in the editor - remoteRobot.find(ComponentFixture.class, byXpath(projectLabelXpath)); + try { + // Verify file is opened by finding its tab in the editor + remoteRobot.find(ComponentFixture.class, byXpath(XPathDefinitions.PROJECT_LABEL)); } catch (Exception e) { fail("The '.gitignore' file should be opened but is not."); } diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneGradleTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneGradleTest.java index 1a52700a..7d416d6b 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneGradleTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneGradleTest.java @@ -11,12 +11,11 @@ package com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.toolwindowspane; import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; -import com.redhat.devtools.intellij.commonuitest.UITestRunner; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.AbstractToolWinPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.buildtoolpane.GradleBuildToolPane; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; +import com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -35,7 +34,7 @@ class ToolWindowsPaneGradleTest extends AbstractLibraryBaseTest { @BeforeAll static void prepareProject() { - CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, CreateCloseUtils.NewProjectType.GRADLE); + CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, NewProjectType.GRADLE); } @AfterAll @@ -45,11 +44,7 @@ static void closeCurrentProject() { @BeforeEach void createToolWindowsPaneFixture() { - if (UITestRunner.getIdeaVersionInt() >= 20221) { - toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); - } else { - toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); - } + toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); } @Test diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneMavenTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneMavenTest.java index 55766ff7..43825e8d 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneMavenTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneMavenTest.java @@ -11,12 +11,11 @@ package com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.toolwindowspane; import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; -import com.redhat.devtools.intellij.commonuitest.UITestRunner; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.AbstractToolWinPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.buildtoolpane.MavenBuildToolPane; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; +import com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -35,7 +34,7 @@ class ToolWindowsPaneMavenTest extends AbstractLibraryBaseTest { @BeforeAll static void prepareProject() { - CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, CreateCloseUtils.NewProjectType.MAVEN); + CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, NewProjectType.MAVEN); } @AfterAll @@ -45,11 +44,7 @@ static void closeCurrentProject() { @BeforeEach void createToolWindowsPaneFixture() { - if (UITestRunner.getIdeaVersionInt() >= 20221) { - toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); - } else { - toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); - } + toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); } @Test diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/buildtoolpane/GradleBuildToolPaneTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/buildtoolpane/GradleBuildToolPaneTest.java index 45d37fa3..de857e67 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/buildtoolpane/GradleBuildToolPaneTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/buildtoolpane/GradleBuildToolPaneTest.java @@ -11,13 +11,12 @@ package com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.toolwindowspane.buildtoolpane; import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; -import com.redhat.devtools.intellij.commonuitest.UITestRunner; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.AbstractToolWinPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.BuildView; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.buildtoolpane.GradleBuildToolPane; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; +import com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -38,12 +37,8 @@ class GradleBuildToolPaneTest extends AbstractLibraryBaseTest { @BeforeAll static void prepareProject() { - CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, CreateCloseUtils.NewProjectType.GRADLE); - if (UITestRunner.getIdeaVersionInt() >= 20221) { - toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); - } else { - toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); - } + CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, NewProjectType.GRADLE); + toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); toolWinPane.openGradleBuildToolPane(); gradleBuildToolPane = toolWinPane.find(GradleBuildToolPane.class, Duration.ofSeconds(10)); } diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/buildtoolpane/MavenBuildToolPaneTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/buildtoolpane/MavenBuildToolPaneTest.java index fe3d3112..a136731b 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/buildtoolpane/MavenBuildToolPaneTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/buildtoolpane/MavenBuildToolPaneTest.java @@ -12,13 +12,12 @@ import com.intellij.remoterobot.fixtures.JTreeFixture; import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; -import com.redhat.devtools.intellij.commonuitest.UITestRunner; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.AbstractToolWinPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.BuildView; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.buildtoolpane.MavenBuildToolPane; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; +import com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -40,12 +39,8 @@ class MavenBuildToolPaneTest extends AbstractLibraryBaseTest { @BeforeAll static void prepareProject() { - CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, CreateCloseUtils.NewProjectType.MAVEN); - if (UITestRunner.getIdeaVersionInt() >= 20221) { - toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); - } else { - toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); - } + CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, NewProjectType.MAVEN); + toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); toolWinPane.openMavenBuildToolPane(); mavenBuildToolPane = toolWinPane.find(MavenBuildToolPane.class, Duration.ofSeconds(10)); } 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 ec675d8f..4d3b9af6 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 @@ -17,7 +17,6 @@ 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; @@ -42,11 +41,7 @@ public static void closeCurrentProject() { } protected static boolean isPaneOpened(Class fixtureClass) { - if (UITestRunner.getIdeaVersionInt() >= 20221) { - toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); - } else { - toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); - } + toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); try { toolWinPane.find(fixtureClass, Duration.ofSeconds(5)); diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/GradlePaneTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/GradlePaneTest.java index 77e26dbf..89bf8f7a 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/GradlePaneTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/GradlePaneTest.java @@ -10,12 +10,11 @@ ******************************************************************************/ package com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.toolwindowspane.openclose; -import com.redhat.devtools.intellij.commonuitest.UITestRunner; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.buildtoolpane.GradleBuildToolPane; import com.redhat.devtools.intellij.commonuitest.utils.constants.ButtonLabels; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; +import com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -33,12 +32,8 @@ class GradlePaneTest extends AbstractToolWinPane { @BeforeAll static void prepareProject() { - CreateCloseUtils.createNewProject(remoteRobot, GRADLE_PROJECT_NAME, CreateCloseUtils.NewProjectType.GRADLE); - if (UITestRunner.getIdeaVersionInt() >= 20221) { - toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); - } else { - toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); - } + CreateCloseUtils.createNewProject(remoteRobot, GRADLE_PROJECT_NAME, NewProjectType.GRADLE); + toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); } @BeforeEach diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/MavenPaneTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/MavenPaneTest.java index 08b9c0b7..7efb53c0 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/MavenPaneTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/MavenPaneTest.java @@ -10,12 +10,11 @@ ******************************************************************************/ package com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.toolwindowspane.openclose; -import com.redhat.devtools.intellij.commonuitest.UITestRunner; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; -import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.buildtoolpane.MavenBuildToolPane; import com.redhat.devtools.intellij.commonuitest.utils.constants.ButtonLabels; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; +import com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -33,12 +32,8 @@ class MavenPaneTest extends AbstractToolWinPane { @BeforeAll static void prepareProject() { - CreateCloseUtils.createNewProject(remoteRobot, MAVEN_PROJECT_NAME, CreateCloseUtils.NewProjectType.MAVEN); - if (UITestRunner.getIdeaVersionInt() >= 20221) { - toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); - } else { - toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); - } + CreateCloseUtils.createNewProject(remoteRobot, MAVEN_PROJECT_NAME, NewProjectType.MAVEN); + toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); } @BeforeEach 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 05047550..4805916e 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 @@ -11,12 +11,11 @@ package com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.toolwindowspane.openclose; import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; -import com.redhat.devtools.intellij.commonuitest.UITestRunner; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ProjectExplorer; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; -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 com.redhat.devtools.intellij.commonuitest.utils.project.NewProjectType; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -36,12 +35,8 @@ class PEPaneAndStripeButtonTest extends AbstractToolWinPane { @BeforeAll static void prepareProject() { - CreateCloseUtils.createNewProject(remoteRobot, MAVEN_PROJECT_NAME, CreateCloseUtils.NewProjectType.MAVEN); - if (UITestRunner.getIdeaVersionInt() >= 20221) { - toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); - } else { - toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10)); - } + CreateCloseUtils.createNewProject(remoteRobot, MAVEN_PROJECT_NAME, NewProjectType.MAVEN); + toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10)); } @BeforeEach diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/utils/test/screenshot/ScreenshotUtilsTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/utils/test/screenshot/ScreenshotUtilsTest.java index c3f930ec..b3d854e0 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/utils/test/screenshot/ScreenshotUtilsTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/utils/test/screenshot/ScreenshotUtilsTest.java @@ -13,17 +13,14 @@ import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.FlatWelcomeFrame; import com.redhat.devtools.intellij.commonuitest.utils.screenshot.ScreenshotUtils; -import org.apache.commons.io.filefilter.FileFilterUtils; import org.junit.jupiter.api.Test; import java.io.File; -import java.io.FileFilter; -import java.io.IOException; -import java.nio.file.Files; import java.time.Duration; +import java.util.Arrays; +import java.util.Objects; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; /** * ScreenshotUtils test @@ -31,24 +28,22 @@ * @author zcervink@redhat.com */ class ScreenshotUtilsTest extends AbstractLibraryBaseTest { + + private final String pathToIdeaProjectsFolder = System.getProperty("user.dir") + File.separator + "build" + File.separator + "screenshots"; + @Test void takeScreenshotTest() { remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10)); int numberOfScreenshotBefore = getNumberOfSavedScreenshot(); - File screenshotFile = ScreenshotUtils.takeScreenshot(remoteRobot); + ScreenshotUtils.takeScreenshot(remoteRobot); int numberOfScreenshotAfter = getNumberOfSavedScreenshot(); assertEquals(numberOfScreenshotAfter, numberOfScreenshotBefore + 1, "Screenshot should be already saved but is not."); - try { - Files.delete(screenshotFile.toPath()); - } catch (IOException e) { - fail(e.getMessage()); - } + Arrays.stream(Objects.requireNonNull(new File(pathToIdeaProjectsFolder).listFiles())).forEach(File::delete); } private int getNumberOfSavedScreenshot() { - String pathToIdeaProjectsFolder = System.getProperty("user.dir") + File.separator + "build" + File.separator + "screenshots"; - File[] files = new File(pathToIdeaProjectsFolder).listFiles((FileFilter) FileFilterUtils.fileFileFilter()); + File[] files = new File(pathToIdeaProjectsFolder).listFiles(); return files != null ? files.length : 0; } From 5ff766ffb6adb91ce8c25b82d5ad977763b34b02 Mon Sep 17 00:00:00 2001 From: Stephane Bouchet Date: Thu, 12 Jun 2025 09:57:07 +0200 Subject: [PATCH 4/5] chore: bump minimal version to 2022.3, due to IJ gradle plugin 2.x used. see https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#requirements fixes #287 Signed-off-by: Stephane Bouchet --- build.gradle.kts | 1 - gradle/libs.versions.toml | 2 -- .../devtools/intellij/commonuitest/UITestRunner.java | 12 ++++++------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index aeb02c3f..1548a896 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,6 @@ repositories { dependencies { implementation(libs.kotlin.reflect) - implementation(libs.openapi) api(libs.junit.jupiter.api) api(libs.remote.robot) api(libs.remote.fixtures) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fdabfc4f..49686957 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,6 @@ remote-robot = "0.11.23" kotlin = "2.1.0" junit-jupiter = "5.12.2" -openapi = "7.0.3" # plugins sonarqube = "5.1.0.4882" @@ -13,7 +12,6 @@ kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", vers junit-jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit-jupiter" } remote-robot = { group = "com.intellij.remoterobot", name = "remote-robot", version.ref = "remote-robot" } remote-fixtures = { group = "com.intellij.remoterobot", name = "remote-fixtures", version.ref = "remote-robot" } -openapi = { group = "com.intellij", name = "openapi", version.ref = "openapi" } [plugins] sonarqube = { id = "org.sonarqube", version.ref = "sonarqube" } \ No newline at end of file diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java index 99ef63b5..78a53bce 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java @@ -10,7 +10,6 @@ ******************************************************************************/ package com.redhat.devtools.intellij.commonuitest; -import com.intellij.openapi.util.SystemInfo; import com.intellij.remoterobot.RemoteRobot; import com.intellij.remoterobot.stepsProcessing.StepLogger; import com.intellij.remoterobot.stepsProcessing.StepWorker; @@ -48,6 +47,7 @@ public class UITestRunner { private static final String ACCEPTED_SOURCE_LOCATION = "accepted"; private static final String COPY_ACCEPTED_FILE_STEP_DESCRIPTION = "Copy the 'accepted' file to the appropriate location"; private static final Logger LOGGER = Logger.getLogger(UITestRunner.class.getName()); + private static final String OS_NAME = System.getProperty("os.name").toLowerCase(); private static final String USER_HOME = System.getProperty("user.home"); private static final String NEW_ITEM_PROPERTY = "New-ItemProperty"; private static final String NAME_PARAM = "-Name"; @@ -69,7 +69,7 @@ public static RemoteRobot runIde(IntelliJVersion ideaVersionUnderTest, int port) StepWorker.registerProcessor(new StepLogger()); ideaVersion = ideaVersionUnderTest; if (ideaVersionUnderTest.equals(IntelliJVersion.UNSUPPORTED)) { - LOGGER.severe("Cannot run Idea. Version is unsupported"); + LOGGER.severe("Cannot run Idea, version is unsupported. Please check supported versions in the documentation."); return null; } @@ -77,7 +77,7 @@ public static RemoteRobot runIde(IntelliJVersion ideaVersionUnderTest, int port) acceptAllTermsAndConditions(); - String fileExtension = SystemInfo.isWindows ? ".bat" : ""; + String fileExtension = OS_NAME.contains("windows") ? ".bat" : ""; String platformVersion = generatePlatformVersion(); ProcessBuilder pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-PideaVersion=" + platformVersion, "-Drobot-server.port=" + port); @@ -162,7 +162,7 @@ private static void acceptAllTermsAndConditions() { linuxPrefsXmlSourceLocation = "prefs_xml/2022_1/prefs.xml"; } - if (SystemInfo.isLinux) { + if (OS_NAME.contains("linux")) { step("Copy the 'prefs.xml' file to the appropriate location", () -> { String prefsXmlDir = USER_HOME + "/.java/.userPrefs/jetbrains/_!(!!cg\"p!(}!}@\"j!(k!|w\"w!'8!b!\"p!':!e@=="; createDirectoryHierarchy(prefsXmlDir); @@ -174,7 +174,7 @@ private static void acceptAllTermsAndConditions() { createDirectoryHierarchy(acceptedDir); copyFileFromJarResourceDir(ACCEPTED_SOURCE_LOCATION, acceptedDir + "/accepted"); }); - } else if (SystemInfo.isMac) { + } else if (OS_NAME.contains("os x")) { step("Copy the 'com.apple.java.util.prefs.plist' file to the appropriate location", () -> { String plistDir = USER_HOME + "/Library/Preferences"; copyFileFromJarResourceDir(osxPlistSourceLocation, plistDir + "/com.apple.java.util.prefs.plist"); @@ -195,7 +195,7 @@ private static void acceptAllTermsAndConditions() { Thread.currentThread().interrupt(); } }); - } else if (SystemInfo.isWindows) { + } else if (OS_NAME.contains("windows")) { step(COPY_ACCEPTED_FILE_STEP_DESCRIPTION, () -> { String acceptedDir = USER_HOME + "\\AppData\\Roaming\\JetBrains\\consentOptions"; createDirectoryHierarchy(acceptedDir); From 67655e9274a1de7506712468a2b907e928842117 Mon Sep 17 00:00:00 2001 From: Stephane Bouchet Date: Thu, 12 Jun 2025 10:35:40 +0200 Subject: [PATCH 5/5] chore: bump minimal version to 2022.3, due to IJ gradle plugin 2.x used. see https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html#requirements fixes #287 Signed-off-by: Stephane Bouchet --- .../project/NewProjectDialogWizard.java | 14 --- .../pages/AbstractNewProjectFinalPage.java | 2 +- .../pages/AbstractProjectNamePage.java | 50 ---------- .../pages/JavaNewProjectSecondPage.java | 51 ---------- .../project/pages/NewProjectFirstPage.java | 2 +- .../fixtures/mainidewindow/MainIdeWindow.java | 3 + .../mainidewindow/menubar/MenuBar.java | 4 +- .../toolwindowspane/AbstractToolWinPane.java | 8 +- .../utils/constants/ButtonLabels.java | 2 - .../test/dialogs/FlatWelcomeFrameTest.java | 3 + .../ProjectStructureDialogTest.java | 2 +- .../dialogs/information/TipDialogTest.java | 5 +- .../NewProjectDialogTest.java | 92 ++----------------- .../idestatusbar/IdeStatusBarTest.java | 3 +- .../mainidewindow/menubar/MenuBarTest.java | 1 + .../ToolWindowsPaneGradleTest.java | 6 ++ .../ToolWindowsPaneMavenTest.java | 6 ++ .../openclose/PEPaneAndStripeButtonTest.java | 2 - .../test/screenshot/ScreenshotUtilsTest.java | 5 +- 19 files changed, 42 insertions(+), 219 deletions(-) delete mode 100644 src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractProjectNamePage.java delete mode 100644 src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectSecondPage.java diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/NewProjectDialogWizard.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/NewProjectDialogWizard.java index ab4ad664..8a94fe64 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/NewProjectDialogWizard.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/NewProjectDialogWizard.java @@ -34,20 +34,6 @@ public NewProjectDialogWizard(@NotNull RemoteRobot remoteRobot, @NotNull RemoteC super(remoteRobot, remoteComponent); } - /** - * Move to the previous page of the 'New Project' dialog by clicking on the 'Previous' button - */ - public void previous() { - clickOnButton(ButtonLabels.PREVIOUS_LABEL); - } - - /** - * Move to the next page of the 'New Project' dialog by clicking on the 'Next' button - */ - public void next() { - clickOnButton(ButtonLabels.NEXT_LABEL); - } - /** * Finish the 'New Project' dialog */ diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java index 77207121..f1c6bc32 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractNewProjectFinalPage.java @@ -93,7 +93,7 @@ public void closeAdvanceSettings() { } } - private boolean isAdvancedSettingsOpened() { + public boolean isAdvancedSettingsOpened() { List cf = findAll(ComponentFixture.class, byXpath(XPathDefinitions.COLLAPSIBLE_TITLED_SEPARATOR_NEW_SIBLINGS)); for (int i = 0; i < cf.size(); i++) { diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractProjectNamePage.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractProjectNamePage.java deleted file mode 100644 index 6affd9ec..00000000 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/AbstractProjectNamePage.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, - * and is available at https://www.eclipse.org/legal/epl-v20.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.pages; - -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.JTextFieldFixture; -import org.jetbrains.annotations.NotNull; - -/** - * ???? - * - * @author zcervink@redhat.com - */ -@DefaultXpath(by = "MyDialog type", xpath = "//div[@class='DialogRootPane']") -@FixtureName(name = "New Project Dialog") -public abstract class AbstractProjectNamePage extends CommonContainerFixture { - protected AbstractProjectNamePage(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) { - super(remoteRobot, remoteComponent); - } - - /** - * Get the project name for new project in the 'New Project' dialog - * - * @return currently set new project name - */ - public String getProjectName() { - return textFields(JTextFieldFixture.Companion.byType()).get(0).getText(); - } - - /** - * Set the project name for new project in the 'New Project' dialog - * - * @param projectName name of the new project - */ - public void setProjectName(String projectName) { - textFields(JTextFieldFixture.Companion.byType()).get(0).setText(projectName); - } -} \ No newline at end of file diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectSecondPage.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectSecondPage.java deleted file mode 100644 index 243c7fd6..00000000 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/project/pages/JavaNewProjectSecondPage.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021 Red Hat, Inc. - * Distributed under license by Red Hat, Inc. All rights reserved. - * This program is made available under the terms of the - * Eclipse Public License v2.0 which accompanies this distribution, - * and is available at https://www.eclipse.org/legal/epl-v20.html - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - ******************************************************************************/ -package com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.pages; - -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.JCheckboxFixture; -import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions; -import org.jetbrains.annotations.NotNull; - -/** - * New Project dialog java project second page fixture - * - * @author zcervink@redhat.com - */ -@DefaultXpath(by = "MyDialog type", xpath = XPathDefinitions.DIALOG_ROOT_PANE) -@FixtureName(name = "New Project Dialog") -public class JavaNewProjectSecondPage extends CommonContainerFixture { - public JavaNewProjectSecondPage(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) { - super(remoteRobot, remoteComponent); - } - - /** - * Toggle the 'Create project from template' checkbox - * - * @param toggle value to set to the checkbox - */ - public void toggleFromTemplate(boolean toggle) { - fromTemplateCheckBox().setValue(toggle); - } - - /** - * Get the 'Create project from template' checkbox fixture - * - * @return checkbox fixture - */ - public JCheckboxFixture fromTemplateCheckBox() { - return checkBox("Create project from template", true); - } -} \ No newline at end of file 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 432e8c13..b7e5afc2 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 @@ -62,7 +62,7 @@ public NewProjectFirstPage(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComp * @param projectType name of the project type to which will be changed the current settings */ public void selectNewProjectType(NewProjectType projectType) { - if (ideaVersionInt == 20223 && projectType != NewProjectType.NEW_PROJECT && projectType != NewProjectType.EMPTY_PROJECT) { + if (ideaVersionInt <= 20223 && projectType != NewProjectType.NEW_PROJECT && projectType != NewProjectType.EMPTY_PROJECT) { jLists(JListFixture.Companion.byType()).get(0).findText(NewProjectType.NEW_PROJECT.toString()).click(); setLanguage(projectType.toString()); } else { diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/MainIdeWindow.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/MainIdeWindow.java index 4e6c104c..345d1f08 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/MainIdeWindow.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/mainidewindow/MainIdeWindow.java @@ -50,6 +50,9 @@ public MainIdeWindow(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent * Maximize the main IDE window */ public void maximizeIdeWindow() { + if (UITestRunner.getIdeaVersionInt() <= 20223) { + return; + } if (remoteRobot.isWin()) { runJs(""" const width = component.getWidth(); 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 1a7ff964..79a72cbd 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 @@ -95,7 +95,7 @@ private JButtonFixture mainMenuItem(String label) { } public CommonContainerFixture getMainMenu() { - CommonContainerFixture cf = null; + CommonContainerFixture cf; if (remoteRobot.isLinux() && ideaVersionInt <= 20242) { cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.LINUX_MAIN_MENU), Duration.ofSeconds(5)); } else if ((remoteRobot.isWin() && ideaVersionInt >= 20241) || (remoteRobot.isLinux() && ideaVersionInt > 20242)) { @@ -103,7 +103,7 @@ public CommonContainerFixture getMainMenu() { } else if (remoteRobot.isWin()) { cf = remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.WINDOWS_MAIN_MENU_2022_2_TO_2023_2), Duration.ofSeconds(5)); } else { - LOGGER.severe("Can't get main menu. System OS is %s / IdeaVersion is %d".formatted(remoteRobot.getOs(), ideaVersionInt)); + throw new IllegalStateException("Can't get main menu. System OS is %s / IdeaVersion is %d".formatted(remoteRobot.getOs(), ideaVersionInt)); } return cf; } 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 3bc66b95..1334b57f 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 @@ -103,7 +103,7 @@ public JButtonFixture stripeButton(String label, boolean isPaneOpened) { } protected void togglePane(String label, Class fixtureClass, boolean openPane) { - if ((!isPaneOpened(fixtureClass) && openPane)) { + if (!isPaneOpened(fixtureClass) && openPane) { clickOnStripeButton(label, false); } else if (isPaneOpened(fixtureClass) && !openPane) { clickOnStripeButton(label, true); @@ -112,11 +112,7 @@ protected void togglePane(String label, Class fixtureClass, b private boolean isPaneOpened(Class fixtureClass) { try { - if (ideaVersionInt <= 20223) { - return find(fixtureClass, Duration.ofSeconds(10)).isShowing(); - } else { - return find(CommonContainerFixture.class, byXpath("//div[@class='MavenProjectsNavigatorPanel']"), Duration.ofSeconds(10)).isShowing(); - } + return find(fixtureClass, Duration.ofSeconds(10)).isShowing(); } catch (WaitForConditionTimeoutException e) { return false; } diff --git a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/ButtonLabels.java b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/ButtonLabels.java index 1bd3f036..8ba93479 100644 --- a/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/ButtonLabels.java +++ b/src/main/java/com/redhat/devtools/intellij/commonuitest/utils/constants/ButtonLabels.java @@ -23,8 +23,6 @@ public class ButtonLabels { public static final String CANCEL_LABEL = "Cancel"; public static final String OK_LABEL = "OK"; public static final String APPLY_LABEL = "Apply"; - public static final String NEXT_LABEL = "Next"; - public static final String PREVIOUS_LABEL = "Previous"; public static final String CREATE_LABEL = "Create"; public static final String PROJECT_STRIPE_BUTTON_LABEL = "Project"; public static final String MAVEN_STRIPE_BUTTON_LABEL = "Maven"; diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java index 5a6db688..321d7d55 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/FlatWelcomeFrameTest.java @@ -27,6 +27,7 @@ import static com.intellij.remoterobot.search.locators.Locators.byXpath; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * FlatWelcomeFrame test @@ -49,6 +50,7 @@ void createNewProjectLinkTest() { flatWelcomeFrame.createNewProject(); NewProjectDialogWizard newProjectDialogWizard = remoteRobot.find(NewProjectDialogWizard.class, Duration.ofSeconds(10)); newProjectDialogWizard.cancel(); + assertTrue(flatWelcomeFrame.isShowing(), "The Welcome Window should be open."); } @Test @@ -73,6 +75,7 @@ void clearExceptionsTest() { prepareWorkspace(PROJECT_NAME); flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10)); flatWelcomeFrame.clearExceptions(); + assertTrue(flatWelcomeFrame.isShowing(), "The Welcome Window should be open."); } private int getNumberOfProjectsOnDisk() { diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/ProjectStructureDialogTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/ProjectStructureDialogTest.java index 3bb76c7f..6e676bc3 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/ProjectStructureDialogTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/ProjectStructureDialogTest.java @@ -48,7 +48,7 @@ static void closeProject() { @Test void projectStructureDialogTest() { dialogTest(() -> { - ProjectStructureDialog projectStructureDialog = remoteRobot.find(ProjectStructureDialog.class, Duration.ofSeconds(10)); + ProjectStructureDialog projectStructureDialog = remoteRobot.find(ProjectStructureDialog.class, Duration.ofSeconds(15)); projectStructureDialog.cancel(); }); } diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/TipDialogTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/TipDialogTest.java index ce143d24..8bd9cc32 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/TipDialogTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/TipDialogTest.java @@ -48,11 +48,10 @@ void prepareTipDialog() { @Test void closeButtonTest() { - Duration timeout = Duration.ofSeconds(5); - remoteRobot.find(TipDialog.class, timeout); + remoteRobot.find(TipDialog.class, Duration.ofSeconds(5)); tipDialog.close(); try { - remoteRobot.find(TipDialog.class, timeout); + remoteRobot.find(TipDialog.class); fail("The 'Tif of the Day' dialog should be closed but is not."); } catch (WaitForConditionTimeoutException e) { LOGGER.log(Level.INFO, e.getMessage(), e); 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 2667e276..a3c0524a 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 @@ -12,18 +12,15 @@ import com.intellij.remoterobot.fixtures.ActionButtonFixture; 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.utils.WaitForConditionTimeoutException; import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; import com.redhat.devtools.intellij.commonuitest.UITestRunner; -import com.redhat.devtools.intellij.commonuitest.exceptions.UITestException; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.FlatWelcomeFrame; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.NewProjectDialogWizard; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.pages.AbstractNewProjectFinalPage; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.pages.JavaNewProjectFinalPage; -import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.pages.JavaNewProjectSecondPage; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.pages.MavenGradleNewProjectFinalPage; import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.project.pages.NewProjectFirstPage; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.MainIdeWindow; @@ -38,14 +35,12 @@ import java.time.Duration; import java.util.Arrays; -import java.util.List; import java.util.Optional; import static com.intellij.remoterobot.search.locators.Locators.byXpath; import static com.redhat.devtools.intellij.commonuitest.utils.texttranformation.TextUtils.listOfRemoteTextToString; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -110,21 +105,17 @@ void setProjectNameGradleProjectTest() { @Test void openAdvancedSettingsTest() { newProjectFirstPage.closeAdvanceSettings(); - assertFalse(isAdvancedSettingsOpened(), ADVANCED_SETTINGS_SHOULD_BE_CLOSED_MSG); + assertFalse(newProjectFirstPage.isAdvancedSettingsOpened(), ADVANCED_SETTINGS_SHOULD_BE_CLOSED_MSG); newProjectFirstPage.openAdvanceSettings(); - assertTrue(isAdvancedSettingsOpened(), ADVANCED_SETTINGS_SHOULD_BE_OPENED_MSG); - newProjectFirstPage.openAdvanceSettings(); - assertTrue(isAdvancedSettingsOpened(), ADVANCED_SETTINGS_SHOULD_BE_OPENED_MSG); + assertTrue(newProjectFirstPage.isAdvancedSettingsOpened(), ADVANCED_SETTINGS_SHOULD_BE_OPENED_MSG); } @Test void closeAdvancedSettingsTest() { newProjectFirstPage.openAdvanceSettings(); - assertTrue(isAdvancedSettingsOpened(), ADVANCED_SETTINGS_SHOULD_BE_OPENED_MSG); - newProjectFirstPage.closeAdvanceSettings(); - assertFalse(isAdvancedSettingsOpened(), ADVANCED_SETTINGS_SHOULD_BE_CLOSED_MSG); + assertTrue(newProjectFirstPage.isAdvancedSettingsOpened(), ADVANCED_SETTINGS_SHOULD_BE_OPENED_MSG); newProjectFirstPage.closeAdvanceSettings(); - assertFalse(isAdvancedSettingsOpened(), ADVANCED_SETTINGS_SHOULD_BE_CLOSED_MSG); + assertFalse(newProjectFirstPage.isAdvancedSettingsOpened(), ADVANCED_SETTINGS_SHOULD_BE_CLOSED_MSG); } @Test @@ -186,67 +177,19 @@ void getSetArtifactIdGradleTest() { testArtifactCoordinatesAttributes(NewProjectType.GRADLE, ArtifactCoordinatesAttributes.ARTIFACT_ID); } - @Test - void getSetVersionGradleTest() { - testArtifactCoordinatesAttributes(NewProjectType.GRADLE, ArtifactCoordinatesAttributes.VERSION); - } - - @Test - void toggleFromTemplateTest() { - newProjectFirstPage.selectNewProjectType(NewProjectType.PLAIN_JAVA); - newProjectDialogWizard.next(); - JavaNewProjectSecondPage javaNewProjectSecondPage = newProjectDialogWizard.find(JavaNewProjectSecondPage.class, Duration.ofSeconds(10)); - boolean isSelected = javaNewProjectSecondPage.fromTemplateCheckBox().isSelected(); - if (isSelected) { - javaNewProjectSecondPage.fromTemplateCheckBox().setValue(false); - } - javaNewProjectSecondPage.toggleFromTemplate(true); - assertTrue(javaNewProjectSecondPage.fromTemplateCheckBox().isSelected(), "The 'Create project from template' checkbox should be checked but is not."); - javaNewProjectSecondPage.fromTemplateCheckBox().setValue(isSelected); - } - - @Test - void previousButtonTest() { - newProjectFirstPage.selectNewProjectType(NewProjectType.PLAIN_JAVA); - newProjectFirstPage.setProjectSdkIfAvailable("17"); - assertThrows(UITestException.class, () -> - newProjectDialogWizard.previous(), "The 'UITestException' should be thrown because the 'Previous' button is not enabled on the first page of the 'New Project'."); - newProjectDialogWizard.next(); - boolean isCommandLineAppTextPresent = listOfRemoteTextToString(newProjectFirstPage.findAllText()).contains("Command Line App"); - assertTrue(isCommandLineAppTextPresent, "The 'Command Line App' text should be present on the second page of the 'New Project' wizard for java project."); - newProjectDialogWizard.previous(); - try { - newProjectFirstPage.comboBox(byXpath(XPathDefinitions.JDK_COMBOBOX), Duration.ofSeconds(10)); - } catch (WaitForConditionTimeoutException e) { - fail("The 'Project SDK' should be available but is not."); - } - } - - @Test - void nextButtonTest() { - newProjectFirstPage.selectNewProjectType(NewProjectType.PLAIN_JAVA); - newProjectFirstPage.setProjectSdkIfAvailable("17"); - newProjectDialogWizard.next(); - boolean isCommandLineAppTextPresent = listOfRemoteTextToString(newProjectFirstPage.findAllText()).contains("Command Line App"); - assertTrue(isCommandLineAppTextPresent, "The 'Command Line App' text should be present on the second page of the 'New Project' wizard for java project."); - newProjectDialogWizard.next(); - assertThrows(UITestException.class, () -> - newProjectDialogWizard.next(), "The 'UITestException' should be thrown because the 'Next' button is not available on the last page of the 'New Project' wizard."); - } - @Test void finishButtonTest() { - assertThrows(UITestException.class, () -> - newProjectDialogWizard.next(), "The 'UITestException' should be thrown because the 'Next' button is not available on the last page of the 'New Project' wizard."); newProjectDialogWizard.find(JavaNewProjectFinalPage.class, Duration.ofSeconds(10)).setProjectName(PLAIN_JAVA_PROJECT_NAME); newProjectDialogWizard.finish(); mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(10)); + assertTrue(mainIdeWindow.isShowing(), "The Main IDE Window should be open."); } @Test void cancelButtonTest() { newProjectDialogWizard.cancel(); - remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10)); + FlatWelcomeFrame welcome = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10)); + assertTrue(welcome.isShowing(), "The Welcome Window should be open."); } @Test @@ -279,7 +222,7 @@ void selectNewProjectTypeTest() { boolean isEmptyProjectPageDisplayed; if (ideaVersionInt >= 20231) { // For IntelliJ IDEA version 2023.1 and newer isEmptyProjectPageDisplayed = newProjectFirstPage.hasText("A basic project with free structure."); - } else { // For IntelliJ IDEA version 2022.3 and newer + } else { // For IntelliJ IDEA version 2022.3 and newer isEmptyProjectPageDisplayed = newProjectFirstPage.hasText("A basic project that allows working with separate files and compiling Java and Kotlin classes."); } assertTrue(isEmptyProjectPageDisplayed, "The 'Empty Project' page should be displayed but is not."); @@ -360,30 +303,13 @@ private void testArtifactCoordinatesAttributes(NewProjectType newProjectType, Ar mavenGradleFinalPage.setArtifactId(newValue); currentValue = mavenGradleFinalPage.getArtifactId(); break; - case VERSION: - currentValue = mavenGradleFinalPage.getVersion(); - newValue = currentValue + "1"; - mavenGradleFinalPage.setVersion(newValue); - currentValue = mavenGradleFinalPage.getVersion(); - break; } assertEquals(currentValue, newValue, "Currently set '" + attribute + "' doesn't match."); } - private boolean isAdvancedSettingsOpened() { - List ss = newProjectFirstPage.findAll(ComponentFixture.class, byXpath("//div[@class='CollapsibleTitledSeparator']/../*")); - for (int i = 0; i < ss.size(); i++) { - if (listOfRemoteTextToString(ss.get(i).findAllText()).contains("Advanced Settings")) { - return i != ss.size() - 1; - } - } - throw new UITestException("Wizard does not contain 'Advanced Settings' section."); - } - private enum ArtifactCoordinatesAttributes { GROUP_ID("group ID"), - ARTIFACT_ID("artifact ID"), - VERSION("version"); + ARTIFACT_ID("artifact ID"); private final String textRepresentation; diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/idestatusbar/IdeStatusBarTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/idestatusbar/IdeStatusBarTest.java index 14490766..2511d528 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/idestatusbar/IdeStatusBarTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/idestatusbar/IdeStatusBarTest.java @@ -28,6 +28,7 @@ import java.util.List; import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitFor; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * IdeStatusBar test @@ -53,7 +54,6 @@ void prepareProject() { newProjectFirstPage.getProjectNameTextField().click(); // Click to gain focus on newProjectFirstPage newProjectFirstPage.setProjectName(PROJECT_NAME); newProjectFirstPage.setProjectLocation(ProjectLocation.PROJECT_LOCATION); - newProjectFirstPage.selectNewProjectType(NewProjectType.EMPTY_PROJECT); newProjectFirstPage.setBuildSystem("Maven"); newProjectDialogWizard.finish(); @@ -71,5 +71,6 @@ void progressBarTest() { MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(5)); mainIdeWindow.maximizeIdeWindow(); ideStatusBar.waitUntilAllBgTasksFinish(); + assertTrue(mainIdeWindow.isShowing(), "The Main IDE Window should be open."); } } \ No newline at end of file diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/menubar/MenuBarTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/menubar/MenuBarTest.java index 0c423364..c118815a 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/menubar/MenuBarTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/menubar/MenuBarTest.java @@ -25,6 +25,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; + import java.time.Duration; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneGradleTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneGradleTest.java index 7d416d6b..d2421b69 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneGradleTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneGradleTest.java @@ -12,6 +12,7 @@ import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.AbstractToolWinPane; +import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.BuildView; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.buildtoolpane.GradleBuildToolPane; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; @@ -23,6 +24,8 @@ import java.time.Duration; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * ToolWindowsPane Gradle test * @@ -52,5 +55,8 @@ void gradleBuildTest() { toolWinPane.openGradleBuildToolPane(); GradleBuildToolPane gradleBuildToolPane = toolWinPane.find(GradleBuildToolPane.class, Duration.ofSeconds(10)); gradleBuildToolPane.buildProject(); + BuildView buildView = toolWinPane.find(BuildView.class, Duration.ofSeconds(10)); + buildView.waitUntilBuildHasFinished(); + assertTrue(buildView.isBuildSuccessful(), "The build should be successful but is not."); } } \ No newline at end of file diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneMavenTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneMavenTest.java index 43825e8d..7c8aa95c 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneMavenTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/ToolWindowsPaneMavenTest.java @@ -12,6 +12,7 @@ import com.redhat.devtools.intellij.commonuitest.AbstractLibraryBaseTest; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.AbstractToolWinPane; +import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.BuildView; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane; import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.buildtoolpane.MavenBuildToolPane; import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils; @@ -23,6 +24,8 @@ import java.time.Duration; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * ToolWindowsPane Maven test * @@ -52,5 +55,8 @@ void mavenBuildTest() { toolWinPane.openMavenBuildToolPane(); MavenBuildToolPane mavenBuildToolPane = toolWinPane.find(MavenBuildToolPane.class, Duration.ofSeconds(10)); mavenBuildToolPane.buildProject("verify", PROJECT_NAME); + BuildView buildView = toolWinPane.find(BuildView.class, Duration.ofSeconds(10)); + buildView.waitUntilBuildHasFinished(); + assertTrue(buildView.isBuildSuccessful(), "The build should be successful but is not."); } } \ 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/PEPaneAndStripeButtonTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/mainidewindow/toolwindowspane/openclose/PEPaneAndStripeButtonTest.java index 4805916e..04f7e677 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 @@ -19,7 +19,6 @@ 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; @@ -55,7 +54,6 @@ void projectExplorerPaneOpenCloseTest() { } @Test - @DisabledIfSystemProperty(named = "uitestlib.idea.version", matches = "20242|20243") void stripeButtonTest() { try { toolWinPane.stripeButton(ButtonLabels.MAVEN_STRIPE_BUTTON_LABEL, false); diff --git a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/utils/test/screenshot/ScreenshotUtilsTest.java b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/utils/test/screenshot/ScreenshotUtilsTest.java index b3d854e0..d7f71ecd 100644 --- a/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/utils/test/screenshot/ScreenshotUtilsTest.java +++ b/src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/utils/test/screenshot/ScreenshotUtilsTest.java @@ -33,13 +33,14 @@ class ScreenshotUtilsTest extends AbstractLibraryBaseTest { @Test void takeScreenshotTest() { + String comment = "to_be_removed"; remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10)); int numberOfScreenshotBefore = getNumberOfSavedScreenshot(); - ScreenshotUtils.takeScreenshot(remoteRobot); + ScreenshotUtils.takeScreenshot(remoteRobot, comment); int numberOfScreenshotAfter = getNumberOfSavedScreenshot(); assertEquals(numberOfScreenshotAfter, numberOfScreenshotBefore + 1, "Screenshot should be already saved but is not."); - Arrays.stream(Objects.requireNonNull(new File(pathToIdeaProjectsFolder).listFiles())).forEach(File::delete); + Arrays.stream(Objects.requireNonNull(new File(pathToIdeaProjectsFolder).listFiles())).filter(file -> file.getName().contains(comment)).forEach(File::delete); } private int getNumberOfSavedScreenshot() {