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
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ jobs:
name: linux-steplogger-logs
path: src/test-project/build/test-results/*
if: always()
- name: Archiving coverage for sonar
uses: actions/upload-artifact@v4
if: always()
with:
name: sonar-coverage
path: |
src/test-project/build/test-results/**/*.xml
src/test-project/build/jacoco/

run_on_windows:
runs-on: windows-latest
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/download-artifact@v4
with:
path: reports
pattern: -test-reports
pattern: sonar-coverage
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{github.event.workflow_run.id}}
- name: Download PrInfo
Expand All @@ -37,13 +37,16 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mkdir build
ls reports
cp -r reports/* build/
if [ '${{github.event.workflow_run.event}}' == 'pull_request' ]; then
PR_NUMBER=$(<prInfo/PR)
BASE_REF=$(<prInfo/base_ref)
HEAD_REF=$(<prInfo/head_ref)
./gradlew build sonar -Dsonar.pullrequest.base=$BASE_REF -Dsonar.pullrequest.branch=$HEAD_REF -Dsonar.pullrequest.key=$PR_NUMBER -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=${{github.repository}}
./gradlew jacocoTestReport sonar -Dsonar.pullrequest.base=$BASE_REF -Dsonar.pullrequest.branch=$HEAD_REF -Dsonar.pullrequest.key=$PR_NUMBER -Dsonar.pullrequest.provider=GitHub -Dsonar.pullrequest.github.repository=${{github.repository}}
else
./gradlew build sonar
./gradlew jacocoTestReport sonar
fi
shell: bash


4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ tasks {
property("sonar.projectKey", "redhat-developer_intellij-common-ui-test-library")
property("sonar.organization", "redhat-developer")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.sources", "src")
property("sonar.junit.reportsPath", layout.buildDirectory.dir("test-results").get().asFile.absolutePath)
property("sonar.gradle.skipCompile", "true")
}
}

}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@

import com.intellij.remoterobot.RemoteRobot;
import com.intellij.remoterobot.data.RemoteComponent;
import com.intellij.remoterobot.fixtures.*;
import com.intellij.remoterobot.fixtures.CommonContainerFixture;
import com.intellij.remoterobot.fixtures.ComponentFixture;
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;
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
import com.redhat.devtools.intellij.commonuitest.UITestRunner;
Expand All @@ -21,8 +30,8 @@
import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.settings.SettingsDialog;
import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.settings.pages.NotificationsPage;
import com.redhat.devtools.intellij.commonuitest.utils.constants.ButtonLabels;
import com.redhat.devtools.intellij.commonuitest.utils.constants.ProjectLocation;
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.steps.SharedSteps;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -99,7 +108,7 @@ public void clickOnLink(String label) {
public void clearWorkspace() {
// Remove projects on disk
try {
String pathToDirToMakeEmpty = CreateCloseUtils.PROJECT_LOCATION;
String pathToDirToMakeEmpty = ProjectLocation.PROJECT_LOCATION;
Path path = Paths.get(pathToDirToMakeEmpty);
boolean doesProjectDirExists = Files.exists(path);
if (doesProjectDirExists) {
Expand Down Expand Up @@ -129,7 +138,6 @@ public void clearExceptions() {
find(IdeFatalErrorsDialog.class, Duration.ofSeconds(10)).clearAll();
} catch (WaitForConditionTimeoutException e) {
LOGGER.log(Level.INFO, "No fatal errors dialog found to clear.");

try {
find(IdeFatalErrorsDialog.class, Duration.ofSeconds(10)).clearAll();
} catch (Exception e2) {
Expand All @@ -153,46 +161,43 @@ public void openSettingsDialog() {
} else {
JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE));
jTreeFixture.findText("Customize").click();

if (remoteRobot.isMac()) {
resizeWelcomeWindow(remoteRobot, 900);
resizeWelcomeWindow(900);
}

remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL))
.findText("All settings" + '\u2026')
.click();
remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click();
}
}

/**
* Resize the Welcome to IntelliJ IDEA window
*
* @param remoteRobot Valid instance of remote robot
* @param newHeight Integer of new height to use
* @param newHeight Integer of new height to use
*/
private void resizeWelcomeWindow(RemoteRobot remoteRobot, int newHeight) {
private void resizeWelcomeWindow(int newHeight) {
try {
remoteRobot.callJs(String.format("""
importClass(java.awt.Frame);
importClass(javax.swing.SwingUtilities);
var frames = Frame.getFrames();
var resized = false;
for (var i = 0; i < frames.length; i++) {
var frame = frames[i];
if (frame.isShowing() && frame.getClass().getName().contains("FlatWelcomeFrame")) {
SwingUtilities.invokeLater(function() {
frame.setSize(frame.getWidth(), %d);
frame.validate();
});
resized = true;
break;
}
importClass(java.awt.Frame);
importClass(javax.swing.SwingUtilities);
var frames = Frame.getFrames();
var resized = false;
for (var i = 0; i < frames.length; i++) {
var frame = frames[i];
if (frame.isShowing() && frame.getClass().getName().contains("FlatWelcomeFrame")) {
SwingUtilities.invokeLater(function() {
frame.setSize(frame.getWidth(), %d);
frame.validate();
});
resized = true;
break;
}
resized;
""", newHeight));
}
resized;
""", newHeight));
Thread.sleep(5000);
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Failed to resize the Welcome window: " + e.getMessage());
LOGGER.log(Level.WARNING, "Failed to resize the Welcome window: {0}", e.getMessage());
/* Clean up whatever needs to be handled before interrupting */
Thread.currentThread().interrupt();
}
}

Expand Down Expand Up @@ -304,12 +309,11 @@ private void removeTopProjectFromRecentProjects() {

// 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" +
"robot.click(component, new Point(horizontal_offset, 22), MouseButton.LEFT_BUTTON, 1);");
"robot.click(component, new Point(horizontal_offset, 22), MouseButton.LEFT_BUTTON, 1);");

if (ideaVersion >= 20231) {
ComponentFixture removeDialog = remoteRobot.find(ComponentFixture.class, byXpath(XPathDefinitions.MY_DIALOG), Duration.ofSeconds(10));
removeDialog.findText(ButtonLabels.REMOVE_FROM_LIST_LABEL)
.click();
removeDialog.findText(ButtonLabels.REMOVE_FROM_LIST_LABEL).click();
} else if (ideaVersion >= 20203) { // Code for IntelliJ Idea 2020.3 or newer
List<JPopupMenuFixture> jPopupMenuFixtures = jPopupMenus(JPopupMenuFixture.Companion.byType());
if (!jPopupMenuFixtures.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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 All @@ -25,12 +26,15 @@
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.screenshot.ScreenshotUtils;
import com.redhat.devtools.intellij.commonuitest.utils.texttranformation.TextUtils;
import org.jetbrains.annotations.NotNull;

import java.time.Duration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.Map;

import static com.intellij.remoterobot.search.locators.Locators.byXpath;
import static com.intellij.remoterobot.stepsProcessing.StepWorkerKt.step;
Expand Down Expand Up @@ -134,7 +138,7 @@ public void setProjectSdkIfAvailable(String targetSdkName) {

ComboBoxFixture projectJdkComboBox = getProjectJdkComboBox();
String currentlySelectedProjectSdk = TextUtils.listOfRemoteTextToString(projectJdkComboBox.findAllText());
if (currentlySelectedProjectSdk.contains(targetSdkName)) {
if (currentlySelectedProjectSdk.startsWith(targetSdkName)) {
return;
}

Expand All @@ -154,8 +158,24 @@ public void setProjectSdkIfAvailable(String targetSdkName) {
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);
JPopupMenuFixture projectSdkList = parentFixture.jPopupMenus(byXpath(XPathDefinitions.HEAVY_WEIGHT_WINDOW)).get(0); // issue https://github.com/JetBrains/intellij-ui-test-robot/issues/104
List<String> sdkItems = projectSdkList.jList().collectItems();
Optional<String> item = sdkItems.stream().filter(s -> s.startsWith(targetSdkName)).findFirst();
item.ifPresent(s -> projectSdkList.jList().clickItem(s, true));
Map<String, String> foundItems = new HashMap<>();
sdkItems.forEach(item ->
Arrays.stream(item.split(" ")).filter(s ->
s.startsWith(targetSdkName)).findFirst().ifPresent(s -> foundItems.put(s, item))
);
if (!foundItems.isEmpty()) {
String label = foundItems.values().stream().findFirst().get();
projectSdkList.jList().clickItem(label, true);
// wait for 'resolving JDK' progressmonitor to end
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
} else {
ScreenshotUtils.takeScreenshot(remoteRobot, "No SDK found starting with " + targetSdkName);
}

});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,26 @@ public MainIdeWindow(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent
*/
public void maximizeIdeWindow() {
if (remoteRobot.isWin()) {
runJs("const width = component.getWidth();\n" +
"const height = component.getHeight();\n" +
"const horizontal_offset = width-72;\n" +
"robot.click(component, new Point(horizontal_offset, 14), MouseButton.LEFT_BUTTON, 1);\n" +
"const width_after = component.getWidth();\n" +
"const height_after = component.getHeight();\n" +
"const horizontal_offset_after = width_after-72;\n" +
"if (width > width_after || height > height_after) { robot.click(component, new Point(horizontal_offset_after, 14), MouseButton.LEFT_BUTTON, 1); }");
runJs("""
const width = component.getWidth();
const height = component.getHeight();
const horizontal_offset = width-72;
robot.click(component, new Point(horizontal_offset, 14), MouseButton.LEFT_BUTTON, 1);
const width_after = component.getWidth();
const height_after = component.getHeight();
const horizontal_offset_after = width_after-72;
if (width > width_after || height > height_after) { robot.click(component, new Point(horizontal_offset_after, 14), MouseButton.LEFT_BUTTON, 1); }""");

} else {
runJs("const width = component.getWidth();\n" +
"const height = component.getHeight();\n" +
"const horizontal_offset = width/2;\n" +
"robot.click(component, new Point(horizontal_offset, 10), MouseButton.LEFT_BUTTON, 2);\n" +
"const width_after = component.getWidth();\n" +
"const height_after = component.getHeight();\n" +
"const horizontal_offset_after = width_after/2;\n" +
"if (width > width_after || height > height_after) { robot.click(component, new Point(horizontal_offset_after, 10), MouseButton.LEFT_BUTTON, 2); }");
runJs("""
const width = component.getWidth();
const height = component.getHeight();
const horizontal_offset = width/2;
robot.click(component, new Point(horizontal_offset, 10), MouseButton.LEFT_BUTTON, 2);
const width_after = component.getWidth();
const height_after = component.getHeight();
const horizontal_offset_after = width_after/2;
if (width > width_after || height > height_after) { robot.click(component, new Point(horizontal_offset_after, 10), MouseButton.LEFT_BUTTON, 2); }""");
}
}

Expand All @@ -88,14 +91,14 @@ public void closeProject() {
* @param cmdToInvoke String representation of command which will be executed using the Search Everywhere popup
*/
public void invokeCmdUsingSearchEverywherePopup(String cmdToInvoke) {
SearchEverywherePopup searchEverywherePopup = openSearchEverywherePopup("All");
SearchEverywherePopup searchEverywherePopup = openSearchEverywherePopup();
searchEverywherePopup.invokeCmd(cmdToInvoke);
}

private SearchEverywherePopup openSearchEverywherePopup(String tab) {
private SearchEverywherePopup openSearchEverywherePopup() {
try {
SearchEverywherePopup searchEverywherePopup = find(SearchEverywherePopup.class, Duration.ofSeconds(10));
searchEverywherePopup.activateTab(tab);
searchEverywherePopup.activateTab("All");
return searchEverywherePopup;
} catch (WaitForConditionTimeoutException e) {
Keyboard keyboard = new Keyboard(remoteRobot);
Expand All @@ -105,7 +108,7 @@ private SearchEverywherePopup openSearchEverywherePopup(String tab) {
keyboard.hotKey(KeyEvent.VK_CONTROL, KeyEvent.VK_N);
}
SearchEverywherePopup searchEverywherePopup = find(SearchEverywherePopup.class, Duration.ofSeconds(10));
searchEverywherePopup.activateTab(tab);
searchEverywherePopup.activateTab("All");
return searchEverywherePopup;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
import com.intellij.remoterobot.fixtures.DefaultXpath;
import com.intellij.remoterobot.fixtures.FixtureName;
import com.intellij.remoterobot.fixtures.JButtonFixture;
import com.redhat.devtools.intellij.commonuitest.UITestRunner;
import com.redhat.devtools.intellij.commonuitest.utils.constants.ButtonLabels;
import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions;
import org.jetbrains.annotations.NotNull;

import java.time.Duration;

import static com.intellij.remoterobot.search.locators.Locators.byXpath;
import static org.assertj.swing.core.MouseClickInfo.button;

@DefaultXpath(by = "ToolWindowRightToolbar type", xpath = "//div[@class='ToolWindowRightToolbar']")
@FixtureName(name = "Tool Window Right Toolbar")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.redhat.devtools.intellij.commonuitest.utils.constants;

import java.io.File;
import java.util.Optional;

public final class ProjectLocation {
// For more info on testProjectLocation please check README
public static final String PROJECT_LOCATION = Optional.ofNullable(System.getProperty("testProjectLocation"))
.filter(s -> !s.isEmpty())
.orElseGet(() -> System.getProperty("user.home") + File.separator + "IdeaProjects" + File.separator + "intellij-ui-test-projects");

private ProjectLocation() {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public class XPathDefinitions {
public static final String WINDOWS_MAIN_MENU_2020_3_TO_2022_1 = "//div[@class='MenuFrameHeader']";
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']";
@Language("XPath")
public static final String ENGRAVED_LABEL = "//div[@class='EngravedLabel']";
public static final String FLAT_WELCOME_FRAME = "//div[@class='FlatWelcomeFrame']";
public static final String NEW_PROJECT_DIALOG_WIZARD = "//div[@accessiblename='New Project' and @class='MyDialog']";
Expand Down Expand Up @@ -78,6 +80,7 @@ public class XPathDefinitions {
public static final String MY_ICON_EXPAND_ALL = "//div[contains(@myvisibleactions, 'View),')]//div[@myicon='expandall.svg']";
public static final String MY_ICON_EXPAND_ALL_2024_2 = "//div[@myicon='expandAll.svg']";
public static final String MY_ICON_EXPAND_ALL_IDE = "//div[contains(@myvisibleactions, 'IDE')]//div[@myicon='expandall.svg']";
@Language("XPath")
public static final String MY_ICON_LOCATE_SVG = "//div[@myicon='locate.svg']";
public static final String MY_ICON_REFRESH = "//div[@myicon='refresh.svg']";
public static final String CONTENT_COMBO_LABEL = "//div[@class='ContentComboLabel']";
Expand Down
Loading
Loading