Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 7 additions & 66 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:

run_on_linux:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 11 # Java 11 is only used for test NewProjectDialogTest/setProjectSdkIfAvailableTest
Expand All @@ -45,30 +46,10 @@ jobs:
java-version: 17
distribution: 'temurin'
cache: 'gradle'
- name: Run mainidewindow_idestatusbar_screenshot integration tests
run: |
cd src/test-project
xvfb-run --server-args="-screen 0 1920x1080x24" ./gradlew integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.utils.* --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.idestatusbar.*
- name: Run dialogs_information_settings integration tests
run: |
cd src/test-project
xvfb-run --server-args="-screen 0 1920x1080x24" ./gradlew integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.information.* --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.settings.*
- name: Run dialogs_project_manipulation integration tests
run: |
cd src/test-project
xvfb-run --server-args="-screen 0 1920x1080x24" ./gradlew integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.project_manipulation.*
- name: Run dialogs integration tests
run: |
cd src/test-project
xvfb-run --server-args="-screen 0 1920x1080x24" ./gradlew integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.FlatWelcomeFrameTest
- name: Run mainidewindow-menubar integration tests
run: |
cd src/test-project
xvfb-run --server-args="-screen 0 1920x1080x24" ./gradlew integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.menubar.*
- name: Run mainidewindow-toolwindowspane integration tests
- name: Run integration tests
run: |
cd src/test-project
xvfb-run --server-args="-screen 0 1920x1080x24" ./gradlew integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.toolwindowspane.*
xvfb-run --server-args="-screen 0 1920x1080x24" ./gradlew integrationUITest --warning-mode none
- name: Archiving tests reports
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -113,30 +94,10 @@ jobs:
java-version: 17
distribution: 'temurin'
cache: 'gradle'
- name: Run mainidewindow_idestatusbar_screenshot integration tests
run: |
cd src/test-project
./gradlew.bat integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.utils.* --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.idestatusbar.*
- name: Run dialogs_information_settings integration tests
run: |
cd src/test-project
./gradlew.bat integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.information.* --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.settings.*
- name: Run dialogs_project_manipulation integration tests
- name: Run integration tests
run: |
cd src/test-project
./gradlew.bat integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.project_manipulation.*
- name: Run dialogs integration tests
run: |
cd src/test-project
./gradlew.bat integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.FlatWelcomeFrameTest
- name: Run mainidewindow-menubar integration tests
run: |
cd src/test-project
./gradlew.bat integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.menubar.*
- name: Run mainidewindow-toolwindowspane integration tests
run: |
cd src/test-project
./gradlew.bat integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.toolwindowspane.*
./gradlew.bat integrationUITest --warning-mode none
- name: Archiving tests reports
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -173,30 +134,10 @@ jobs:
java-version: 17
distribution: 'temurin'
cache: 'gradle'
- name: Run mainidewindow_idestatusbar_screenshot integration tests
run: |
cd src/test-project
./gradlew integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.utils.* --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.idestatusbar.*
- name: Run dialogs_information_settings integration tests
run: |
cd src/test-project
./gradlew integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.information.* --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.settings.*
- name: Run dialogs_project_manipulation integration tests
run: |
cd src/test-project
./gradlew integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.project_manipulation.*
- name: Run dialogs integration tests
run: |
cd src/test-project
./gradlew integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.dialogs.FlatWelcomeFrameTest
- name: Run mainidewindow-menubar integration tests
run: |
cd src/test-project
./gradlew integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.menubar.*
- name: Run mainidewindow-toolwindowspane integration tests
- name: Run integration tests
run: |
cd src/test-project
./gradlew integrationUITest --warning-mode none --tests com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.toolwindowspane.*
./gradlew integrationUITest --warning-mode none
- name: Archiving tests reports
uses: actions/upload-artifact@v4
with:
Expand Down
9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("java-library")
id("maven-publish")
alias(libs.plugins.gradleNexusPublishPlugin)
id("jacoco") // Code coverage
alias(libs.plugins.sonarqube) // SonarQube
}

Expand Down Expand Up @@ -40,6 +41,14 @@ tasks {
useJUnitPlatform()
}

jacocoTestReport {
executionData.setFrom(fileTree(layout.buildDirectory).include("/jacoco/*.exec"))
//classDirectories.setFrom(instrumentCode)
reports {
xml.required = true
}
}

sonar {
properties {
property("sonar.projectKey", "redhat-developer_intellij-common-ui-test-library")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
package com.redhat.devtools.intellij.commonuitest;

import com.intellij.remoterobot.RemoteRobot;
import com.intellij.remoterobot.fixtures.CommonContainerFixture;
import com.intellij.remoterobot.stepsProcessing.StepLogger;
import com.intellij.remoterobot.stepsProcessing.StepWorker;
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
import com.redhat.devtools.intellij.commonuitest.exceptions.UITestException;
import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.FlatWelcomeFrame;
import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions;
import com.redhat.devtools.intellij.commonuitest.utils.runner.IntelliJVersion;

import java.io.File;
Expand All @@ -35,6 +35,7 @@

import static com.intellij.remoterobot.stepsProcessing.StepWorkerKt.step;
import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitFor;
import static com.intellij.remoterobot.search.locators.Locators.byXpath;

/**
* Basic methods for starting and quiting the IntelliJ Idea IDE for UI tests
Expand Down Expand Up @@ -96,7 +97,6 @@ public static RemoteRobot runIde(IntelliJVersion ideaVersion, int port) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}

remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10)).clearWorkspace();
return remoteRobot;
});
}
Expand Down Expand Up @@ -154,19 +154,7 @@ public static RemoteRobot getRemoteRobot() {
public static RemoteRobot getRemoteRobotConnection(int port) {
return step("Create an instance of the RemoteRobot listening on port " + port, () -> {
RemoteRobot remoteRobot = new RemoteRobot("http://127.0.0.1:" + port);
for (int i = 0; i < 60; i++) {
try {
remoteRobot.find(FlatWelcomeFrame.class);
} catch (WaitForConditionTimeoutException e) {
try {
Thread.sleep(1000);
} catch (InterruptedException e2) {
LOGGER.log(Level.SEVERE, e2.getMessage(), e2);
Thread.currentThread().interrupt();
}
}
}

waitFor(Duration.ofSeconds(30), Duration.ofMillis(500), () -> remoteRobot.find(CommonContainerFixture.class, byXpath(XPathDefinitions.FLAT_WELCOME_FRAME)).isShowing());
return remoteRobot;
});
}
Expand Down Expand Up @@ -253,15 +241,15 @@ private static void acceptAllTermsAndConditions() {
}

private static void waitUntilIntelliJStarts(int port) {
waitFor(Duration.ofSeconds(600), Duration.ofSeconds(3), "The IntelliJ Idea did not start in 10 minutes.", () -> isIntelliJUIVisible(port));
waitFor(Duration.ofSeconds(600), Duration.ofSeconds(3), "IntelliJ to start for 10 minutes.", () -> isIntelliJUIVisible(port));
}

private static boolean isIntelliJUIVisible(int port) {
return isHostOnIpAndPortAccessible("127.0.0.1", port);
return isHostOnIpAndPortAccessible(port);
}

private static boolean isHostOnIpAndPortAccessible(String ip, int port) {
SocketAddress sockaddr = new InetSocketAddress(ip, port);
private static boolean isHostOnIpAndPortAccessible(int port) {
SocketAddress sockaddr = new InetSocketAddress("127.0.0.1", port);
try (Socket socket = new Socket()) {
connectToHost(socket, sockaddr);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,16 @@ public void openSettingsDialog() {
JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE));
jTreeFixture.findText("Customize").click();
if (remoteRobot.isMac()) {
resizeWelcomeWindow(900);
resizeWelcomeWindow();
}
remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click();
}
}

/**
* Resize the Welcome to IntelliJ IDEA window
*
* @param newHeight Integer of new height to use
*/
private void resizeWelcomeWindow(int newHeight) {
private void resizeWelcomeWindow() {
try {
remoteRobot.callJs(String.format("""
importClass(java.awt.Frame);
Expand All @@ -192,7 +190,7 @@ private void resizeWelcomeWindow(int newHeight) {
}
}
resized;
""", newHeight));
""", 900));
Thread.sleep(5000);
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Failed to resize the Welcome window: {0}", e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.intellij.remoterobot.data.RemoteComponent;
import com.intellij.remoterobot.fixtures.ComboBoxFixture;
import com.intellij.remoterobot.fixtures.CommonContainerFixture;
import com.intellij.remoterobot.fixtures.ContainerFixture;
import com.intellij.remoterobot.fixtures.DefaultXpath;
import com.intellij.remoterobot.fixtures.FixtureName;
import com.intellij.remoterobot.fixtures.HeavyWeightWindowFixture;
Expand Down Expand Up @@ -167,10 +166,13 @@ public void setProjectSdkIfAvailable(String targetSdkName) {
String label = foundItems.values().stream().findFirst().get();
projectSdkList.jList().clickItem(label, true);
// wait for 'resolving JDK' progressmonitor to end
// TODO for now don't know what kind of dialog is the 'resolving' so just pausing thread
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
ScreenshotUtils.takeScreenshot(remoteRobot, "interrupted while waiting for " + targetSdkName);
/* Clean up whatever needs to be handled before interrupting */
Thread.currentThread().interrupt();
}
} else {
ScreenshotUtils.takeScreenshot(remoteRobot, "No SDK found starting with " + targetSdkName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@
import com.intellij.remoterobot.fixtures.ComponentFixture;
import com.intellij.remoterobot.fixtures.DefaultXpath;
import com.intellij.remoterobot.fixtures.FixtureName;
import com.intellij.remoterobot.fixtures.dataExtractor.RemoteText;
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions;
import org.jetbrains.annotations.NotNull;

import java.time.Duration;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import static com.intellij.remoterobot.search.locators.Locators.byXpath;
import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitFor;
Expand All @@ -37,7 +33,6 @@
@DefaultXpath(by = "IdeStatusBarImpl type", xpath = XPathDefinitions.IDE_STATUS_BAR)
@FixtureName(name = "Ide Status Bar")
public class IdeStatusBar extends CommonContainerFixture {
private static final Logger LOGGER = Logger.getLogger(IdeStatusBar.class.getName());
private final RemoteRobot remoteRobot;

public IdeStatusBar(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) {
Expand Down Expand Up @@ -85,20 +80,7 @@ private boolean didProjectImportFinish() {
}

private boolean didAllBgTasksFinish() {
for (int i = 0; i < 5; i++) {
IdeStatusBar ideStatusBar = remoteRobot.find(IdeStatusBar.class);
List<RemoteText> inlineProgressPanelContent = ideStatusBar.inlineProgressPanel().findAllText();
if (!inlineProgressPanelContent.isEmpty()) {
return false;
}

try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
Thread.currentThread().interrupt();
}
}
return true;
waitFor(Duration.ofSeconds(5), Duration.ofMillis(500), () -> remoteRobot.find(IdeStatusBar.class).isShowing());
return remoteRobot.find(IdeStatusBar.class).inlineProgressPanel().findAllText().isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ protected AbstractToolWinPane(@NotNull RemoteRobot remoteRobot, @NotNull RemoteC

/**
* Open project explorer
*
* @return the Project Explorer fixture
*/
public ProjectExplorer openProjectExplorer() {
return togglePane(ButtonLabels.PROJECT_STRIPE_BUTTON_LABEL, ProjectExplorer.class, true);
public void openProjectExplorer() {
togglePane(ButtonLabels.PROJECT_STRIPE_BUTTON_LABEL, ProjectExplorer.class, true);
}

/**
Expand All @@ -59,11 +57,9 @@ public void closeProjectExplorer() {

/**
* Open maven build tool pane
*
* @return the Maven Build Tool Pane fixture
*/
public MavenBuildToolPane openMavenBuildToolPane() {
return togglePane(ButtonLabels.MAVEN_STRIPE_BUTTON_LABEL, MavenBuildToolPane.class, true);
public void openMavenBuildToolPane() {
togglePane(ButtonLabels.MAVEN_STRIPE_BUTTON_LABEL, MavenBuildToolPane.class, true);
}

/**
Expand All @@ -75,11 +71,9 @@ public void closeMavenBuildToolPane() {

/**
* Open gradle build tool pane
*
* @return the Gradle Build Tool Pane fixture
*/
public GradleBuildToolPane openGradleBuildToolPane() {
return togglePane(ButtonLabels.GRADLE_STRIPE_BUTTON_LABEL, GradleBuildToolPane.class, true);
public void openGradleBuildToolPane() {
togglePane(ButtonLabels.GRADLE_STRIPE_BUTTON_LABEL, GradleBuildToolPane.class, true);
}

/**
Expand Down Expand Up @@ -111,14 +105,12 @@ public JButtonFixture stripeButton(String label, boolean isPaneOpened) {
return button(byXpath(XPathDefinitions.label(label)), Duration.ofSeconds(2));
}

protected <T extends Fixture> T togglePane(String label, Class<T> fixtureClass, boolean openPane) {
protected void togglePane(String label, Class<? extends Fixture> fixtureClass, boolean openPane) {
if ((!isPaneOpened(fixtureClass) && openPane)) {
clickOnStripeButton(label, false);
return find(fixtureClass, Duration.ofSeconds(10));
} else if (isPaneOpened(fixtureClass) && !openPane) {
clickOnStripeButton(label, true);
}
return null;
}

private boolean isPaneOpened(Class<? extends Fixture> fixtureClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ public JTreeFixture gradleTaskTree() {

private boolean isGradleTreeVisible() {
String treeContent = TextUtils.listOfRemoteTextToString(gradleTaskTree().findAllText());
return !treeContent.toLowerCase(Locale.ROOT).contains("nothing") && !treeContent.equals("");
return !treeContent.toLowerCase(Locale.ROOT).contains("nothing") && !treeContent.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ public JTreeFixture mavenTargetTree() {

private boolean isMavenTreeVisible() {
String treeContent = TextUtils.listOfRemoteTextToString(mavenTargetTree().findAllText());
return !treeContent.toLowerCase(Locale.ROOT).contains("nothing") && !treeContent.equals("");
return !treeContent.toLowerCase(Locale.ROOT).contains("nothing") && !treeContent.isEmpty();
}
}
Loading
Loading