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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
with:
name: dependency-reports
path: build/reports/dependency-verification/*
if: always()
if: failure()

run_on_linux:
runs-on: ubuntu-latest
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Validate
name: Validate against IJ versions

on:
workflow_run:
workflows: [Java CI with Gradle]
types:
- completed
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
validate_versions:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import static com.intellij.remoterobot.search.locators.Locators.byXpath;
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 All @@ -49,41 +49,39 @@ public class UITestRunner {
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 RemoteRobot remoteRobot = null;
private static Process ideProcess;
private static IntelliJVersion ideaVersion;
private static final String NEW_ITEM_PROPERTY = "New-ItemProperty";
private static final String NAME_PARAM = "-Name";
private static final String VALUE_PARAM = "-Value";
private static RemoteRobot remoteRobot = null;
private static Process ideProcess;
private static IntelliJVersion ideaVersion;

private UITestRunner() {}

/**
* Start the given version of IntelliJ Idea listening on the given port
*
* @param ideaVersion version of the IntelliJ Idea to start
* @param port port number on which will the IntelliJ Idea be listening
* @param ideaVersionUnderTest version of the IntelliJ Idea to start
* @param port port number on which will the IntelliJ Idea be listening
* @return instance of the RemoteRobot
*/
public static RemoteRobot runIde(IntelliJVersion ideaVersion, int port) {
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");
return null;
}

return step("Start IntelliJ Idea ('" + ideaVersion.toString() + "') listening on port " + port, () -> {
return step("Start IntelliJ Idea ('" + ideaVersion + "') listening on port " + port, () -> {
System.setProperty("uitestlib.idea.version", Integer.toString(ideaVersion.toInt()));
UITestRunner.ideaVersion = ideaVersion;

acceptAllTermsAndConditions();

String fileExtension = OS_NAME.contains("windows") ? ".bat" : "";
String[] platformTypeVersion = generatePlatformTypeVersion();

ProcessBuilder pb;
String platformVersion = generatePlatformVersion();

if (ideaVersion.toInt() < 20242) {
pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-PideaVersion=" + platformTypeVersion[1], "-Drobot-server.port=" + port);
} else {
pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-Drobot-server.port=" + port, "-PplatformType=" + platformTypeVersion[0], "-PplatformVersion=" + platformTypeVersion[1]);
}
ProcessBuilder pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-PideaVersion=" + platformVersion, "-Drobot-server.port=" + port);
boolean isDebugOn = Boolean.parseBoolean(System.getProperty("intellij_debug", "false")); // For more info on intellij_debug please check README
if (isDebugOn) {
redirectProcessOutputs(pb);
Expand Down Expand Up @@ -154,7 +152,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);
SharedSteps.waitForComponentByXpath(remoteRobot,30, 200, byXpath(XPathDefinitions.FLAT_WELCOME_FRAME));
SharedSteps.waitForComponentByXpath(remoteRobot, 30, 200, byXpath(XPathDefinitions.FLAT_WELCOME_FRAME));
return remoteRobot;
});
}
Expand Down Expand Up @@ -311,15 +309,15 @@ private static void redirectProcessOutputs(ProcessBuilder pb) {
}

/**
* Generate platformType and platformVersion based on ideaVersion
* Generate platformVersion based on complete ideaVersion
*
* @return platformTypeVersion string array
* @return platformVersion
*/
private static String[] generatePlatformTypeVersion() {
private static String generatePlatformVersion() {
String[] platformTypeVersion = ideaVersion.toString().split("-", 2);
if (2 > platformTypeVersion.length) {
throw new UITestException("ideaVersion is not recognized.");
}
return platformTypeVersion;
return platformTypeVersion[1];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.intellij.remoterobot.fixtures.DefaultXpath;
import com.intellij.remoterobot.fixtures.FixtureName;
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
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;
Expand All @@ -24,6 +25,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import static com.intellij.remoterobot.search.locators.Locators.byXpath;

/**
* Code With Me dialog fixture
*
Expand All @@ -45,8 +48,13 @@ public CodeWithMeDialog(@NotNull RemoteRobot remoteRobot, @NotNull RemoteCompone
*/
public static void closeCodeWithMePopupIfItAppears(RemoteRobot remoteRobot) {
CodeWithMeDialog codeWithMeDialog;
int ideaVersionInt = UITestRunner.getIdeaVersionInt();
try {
codeWithMeDialog = remoteRobot.find(CodeWithMeDialog.class, Duration.ofSeconds(10));
if (ideaVersionInt <= 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));
}
} catch (WaitForConditionTimeoutException e) {
LOGGER.log(Level.INFO, "Code With Me popup not found, nothing to close.");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ public void invokeCmd(String cmdToEnter) {
invokeSearch(cmdToEnter, true);
}

public void searchText(String searchString){
public void searchText(String searchString) {
invokeSearch(searchString, false);
}

private void invokeSearch(String searchText, boolean invoke){
private void invokeSearch(String searchText, boolean invoke) {
JTextFieldFixture searchField = textField(JTextFieldFixture.Companion.byType(), Duration.ofSeconds(2));
searchField.click();
searchField.setText(searchText);
waitFor(Duration.ofSeconds(30), Duration.ofSeconds(1), "the search dialog in the Search Everywhere popup to load in 30 seconds.", () -> didSearchFinish(searchText));
if(invoke){
if (invoke) {
new Keyboard(remoteRobot).hotKey(KeyEvent.VK_ENTER);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public String getProjectLocation() {
*/
public void setProjectLocation(String projectLocation) {
if (ideaVersionInt >= 20221) {
find(JTextFieldFixture.class, byXpath(XPathDefinitions.EXTENDABLE_TEXT_FIELD )).setText(projectLocation);
find(JTextFieldFixture.class, byXpath(XPathDefinitions.EXTENDABLE_TEXT_FIELD)).setText(projectLocation);
} else {
textFields(JTextFieldFixture.Companion.byType()).get(1).setText(projectLocation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ 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) {
} else if (ideaVersionInt >= 20221) {
return find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME)).getText();
} else {
return textField("Module name:", true).getText();
Expand All @@ -91,8 +90,7 @@ else if (ideaVersionInt >= 20221) {
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) {
} else if (ideaVersionInt >= 20221) {
find(JTextFieldFixture.class, byXpath(XPathDefinitions.GET_SET_MODULE_NAME)).setText(moduleName);
} else {
textField("Module name:", true).setText(moduleName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
@FixtureName(name = "New Project Dialog")
public class NewProjectFirstPage extends AbstractNewProjectFinalPage {
protected final RemoteRobot remoteRobot;
private boolean isProjectSdkItemsLoaded = false;
private final int ideaVersionInt = UITestRunner.getIdeaVersionInt();
private boolean isProjectSdkItemsLoaded = false;

public NewProjectFirstPage(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent remoteComponent) {
super(remoteRobot, remoteComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
import com.intellij.remoterobot.fixtures.FixtureName;
import com.intellij.remoterobot.utils.Keyboard;
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
import com.redhat.devtools.intellij.commonuitest.UITestRunner;
import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.FlatWelcomeFrame;
import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.navigation.SearchEverywherePopup;
import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.menubar.MenuBar;
import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions;
import com.redhat.devtools.intellij.commonuitest.utils.internalerror.IdeInternalErrorUtils;
import org.jetbrains.annotations.NotNull;

import java.awt.event.KeyEvent;
import java.time.Duration;

import com.redhat.devtools.intellij.commonuitest.utils.internalerror.IdeInternalErrorUtils;

import static com.intellij.remoterobot.search.locators.Locators.byXpath;

/**
Expand All @@ -52,14 +52,14 @@ public MainIdeWindow(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent
public void maximizeIdeWindow() {
if (remoteRobot.isWin()) {
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); }""");
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("""
Expand All @@ -78,14 +78,14 @@ public void maximizeIdeWindow() {
* Close the currently opened project
*/
public void closeProject() {
if (remoteRobot.isMac()) {
if (UITestRunner.getIdeaVersionInt() == 20233 && remoteRobot.isLinux()) {
invokeCmdUsingSearchEverywherePopup("Close Project");
} else {
new MenuBar(remoteRobot).navigateTo("File", "Close Project");
}
IdeInternalErrorUtils.clearWindowsErrorsIfTheyAppear(remoteRobot);
remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10)).runJs("const horizontal_offset = component.getWidth()/2;\n" +
"robot.click(component, new Point(horizontal_offset, 10), MouseButton.LEFT_BUTTON, 1);");
"robot.click(component, new Point(horizontal_offset, 10), MouseButton.LEFT_BUTTON, 1);");
}

/**
Expand All @@ -94,13 +94,7 @@ 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();
searchEverywherePopup.invokeCmd(cmdToInvoke);
}

public void searchEverywhere(String searchString) {
SearchEverywherePopup searchEverywherePopup = openSearchEverywherePopup();
searchEverywherePopup.searchText(searchString);
openSearchEverywherePopup().invokeCmd(cmdToInvoke);
}

private SearchEverywherePopup openSearchEverywherePopup() {
Expand All @@ -121,4 +115,5 @@ private SearchEverywherePopup openSearchEverywherePopup() {
return searchEverywherePopup;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,16 @@
import com.intellij.remoterobot.RemoteRobot;
import com.intellij.remoterobot.fixtures.ActionButtonFixture;
import com.intellij.remoterobot.fixtures.CommonContainerFixture;
import com.intellij.remoterobot.fixtures.ComponentFixture;
import com.intellij.remoterobot.fixtures.JButtonFixture;
import com.intellij.remoterobot.fixtures.JPopupMenuFixture;
import com.intellij.remoterobot.fixtures.dataExtractor.RemoteText;
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
import com.redhat.devtools.intellij.commonuitest.UITestRunner;
import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.MainIdeWindow;
import com.redhat.devtools.intellij.commonuitest.utils.constants.XPathDefinitions;
import com.redhat.devtools.intellij.commonuitest.utils.screenshot.ScreenshotUtils;
import org.jetbrains.annotations.NotNull;

import java.time.Duration;
import java.util.List;
import java.util.Optional;
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,12 +33,12 @@
* @author [email protected]
*/
public class MenuBar {
private static final Logger LOGGER = Logger.getLogger(MenuBar.class.getName());
private final RemoteRobot remoteRobot;
private final int ideaVersionInt = UITestRunner.getIdeaVersionInt();

public MenuBar(RemoteRobot remoteRobot) {
this.remoteRobot = remoteRobot;
checkVisibility();
}

/**
Expand All @@ -58,6 +54,11 @@ public void navigateTo(String... path) {
remoteRobot.find(ActionButtonFixture.class, byXpath(XPathDefinitions.MAIN_MENU)).click();
}

if (!isVisible()) {
LOGGER.severe("Main Menu is not visible.");
return;
}

JButtonFixture mainMenuFirstItem = mainMenuItem(path[0]);
if (mainMenuFirstItem != null) {
if (ideaVersionInt >= 20242) {
Expand Down Expand Up @@ -111,22 +112,13 @@ public CommonContainerFixture getMainMenu() {
return cf;
}

private void checkVisibility() {
public boolean isVisible() {
// check menu already visible
try {
getMainMenu();
return true;
} catch (WaitForConditionTimeoutException e) {
// not visible
MainIdeWindow mainIdeWindow = remoteRobot.find(MainIdeWindow.class, Duration.ofSeconds(5));
mainIdeWindow.searchEverywhere("Appearance");
ComponentFixture appearanceDialog = remoteRobot.find(ComponentFixture.class, byXpath("//div[@class='SearchEverywhereUI']"));
List<RemoteText> items = appearanceDialog.findAllText();
Optional<RemoteText> item = items.stream().filter(remoteText -> remoteText.getText().equals("View | Appearance: Main Menu")).findFirst();
if (item.isPresent()) {
item.get().click();
} else {
ScreenshotUtils.takeScreenshot(remoteRobot, "Can't find 'Appearance' Main menu item");
}
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ private boolean isPaneOpened(Class<? extends Fixture> fixtureClass) {

private void clickOnStripeButton(String label, boolean isPaneOpened) {
waitFor(Duration.ofSeconds(30), Duration.ofSeconds(2),
"The '" + label + "' stripe button is not available.",
() -> isStripeButtonAvailable(label, isPaneOpened));
"The '" + label + "' stripe button is not available.",
() -> isStripeButtonAvailable(label, isPaneOpened));

if (ideaVersionInt >= 20242) {
// For IntelliJ IDEA 2024.2 and newer
Expand Down Expand Up @@ -175,6 +175,6 @@ private boolean isStripeButtonAvailable(String label, boolean isPaneOpened) {

private boolean isRightToolbarButton(String label) {
return label.equals(ButtonLabels.MAVEN_STRIPE_BUTTON_LABEL) ||
label.equals(ButtonLabels.GRADLE_STRIPE_BUTTON_LABEL);
label.equals(ButtonLabels.GRADLE_STRIPE_BUTTON_LABEL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public void buildProject(String goal, String projectName) {
JTreeFixture tree = mavenTargetTree();
// below workaround due to https://github.com/JetBrains/intellij-ui-test-robot/issues/459
tree.doubleClickRowWithText(projectName, true); // expand root
tree.doubleClickRowWithText("Lifecycle" ,true); // expand Lifecycle
tree.doubleClickRowWithText(goal,true);
tree.doubleClickRowWithText("Lifecycle", true); // expand Lifecycle
tree.doubleClickRowWithText(goal, true);
if (ideaVersionInt >= 20221) {
remoteRobot.find(ToolWindowPane.class).find(BuildView.class).waitUntilBuildHasFinished();
} else {
Expand Down
Loading
Loading