Skip to content

Commit 2f77bc1

Browse files
committed
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 <sbouchet@redhat.com>
1 parent 8ba212e commit 2f77bc1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+284
-890
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ jobs:
5656

5757
steps:
5858
- uses: actions/checkout@v4
59-
- name: Set up JDK 11 # Java 11 is only used for test NewProjectDialogTest/setProjectSdkIfAvailableTest
60-
uses: actions/setup-java@v4
61-
with:
62-
java-version: 11
63-
distribution: 'temurin'
64-
cache: 'gradle'
6559
- name: Set up JDK 17
6660
uses: actions/setup-java@v4
6761
with:
@@ -104,12 +98,6 @@ jobs:
10498
runs-on: windows-latest
10599
steps:
106100
- uses: actions/checkout@v4
107-
- name: Set up JDK 11 # Java 11 is only used for test NewProjectDialogTest/setProjectSdkIfAvailableTest
108-
uses: actions/setup-java@v4
109-
with:
110-
java-version: 11
111-
distribution: 'temurin'
112-
cache: 'gradle'
113101
- name: Set up JDK 17
114102
uses: actions/setup-java@v4
115103
with:
@@ -144,12 +132,6 @@ jobs:
144132
runs-on: macos-latest
145133
steps:
146134
- uses: actions/checkout@v4
147-
- name: Set up JDK 11 # Java 11 is only used for test NewProjectDialogTest/setProjectSdkIfAvailableTest
148-
uses: actions/setup-java@v4
149-
with:
150-
java-version: 11
151-
distribution: 'temurin'
152-
cache: 'gradle'
153135
- name: Set up JDK 17
154136
uses: actions/setup-java@v4
155137
with:

.github/workflows/validate.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Validate against IJ versions
22

33
on:
4-
push:
5-
branches: [ main ]
64
pull_request:
75
branches: [ main ]
86

@@ -13,29 +11,16 @@ jobs:
1311
strategy:
1412
matrix:
1513
IJ:
16-
- 2020.2
17-
- 2020.3
18-
- 2021.1
19-
- 2021.2
20-
- 2021.3
21-
- 2022.1
22-
- 2022.2
2314
- 2022.3
2415
- 2023.1
2516
- 2023.2
2617
- 2023.3
2718
- 2024.1
2819
- 2024.2
29-
- 2024.3
20+
# - 2024.3 is the current one
3021

3122
steps:
3223
- uses: actions/checkout@v4
33-
- name: Set up JDK 11 # Java 11 is only used for test NewProjectDialogTest/setProjectSdkIfAvailableTest
34-
uses: actions/setup-java@v4
35-
with:
36-
java-version: 11
37-
distribution: 'temurin'
38-
cache: 'gradle'
3924
- name: Set up JDK 17
4025
uses: actions/setup-java@v4
4126
with:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ build/
3232
target/
3333
pom.xml
3434

35-
/src/test-project/.intellijPlatform/self-update.lock
35+
/src/test-project/.intellijPlatform/
36+
/.intellijPlatform/

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ repositories {
1818

1919
dependencies {
2020
implementation(libs.kotlin.reflect)
21+
implementation(libs.openapi)
2122
api(libs.junit.jupiter.api)
2223
api(libs.remote.robot)
2324
api(libs.remote.fixtures)

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
remote-robot = "0.11.23"
44
kotlin = "2.1.0"
55
junit-jupiter = "5.12.2"
6+
openapi = "7.0.3"
67

78
# plugins
89
sonarqube = "5.1.0.4882"
@@ -12,6 +13,7 @@ kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", vers
1213
junit-jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit-jupiter" }
1314
remote-robot = { group = "com.intellij.remoterobot", name = "remote-robot", version.ref = "remote-robot" }
1415
remote-fixtures = { group = "com.intellij.remoterobot", name = "remote-fixtures", version.ref = "remote-robot" }
16+
openapi = { group = "com.intellij", name = "openapi", version.ref = "openapi" }
1517

1618
[plugins]
1719
sonarqube = { id = "org.sonarqube", version.ref = "sonarqube" }

src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
******************************************************************************/
1111
package com.redhat.devtools.intellij.commonuitest;
1212

13+
import com.intellij.openapi.util.SystemInfo;
1314
import com.intellij.remoterobot.RemoteRobot;
1415
import com.intellij.remoterobot.stepsProcessing.StepLogger;
1516
import com.intellij.remoterobot.stepsProcessing.StepWorker;
@@ -47,7 +48,6 @@ public class UITestRunner {
4748
private static final String ACCEPTED_SOURCE_LOCATION = "accepted";
4849
private static final String COPY_ACCEPTED_FILE_STEP_DESCRIPTION = "Copy the 'accepted' file to the appropriate location";
4950
private static final Logger LOGGER = Logger.getLogger(UITestRunner.class.getName());
50-
private static final String OS_NAME = System.getProperty("os.name").toLowerCase();
5151
private static final String USER_HOME = System.getProperty("user.home");
5252
private static final String NEW_ITEM_PROPERTY = "New-ItemProperty";
5353
private static final String NAME_PARAM = "-Name";
@@ -74,11 +74,10 @@ public static RemoteRobot runIde(IntelliJVersion ideaVersionUnderTest, int port)
7474
}
7575

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

7978
acceptAllTermsAndConditions();
8079

81-
String fileExtension = OS_NAME.contains("windows") ? ".bat" : "";
80+
String fileExtension = SystemInfo.isWindows ? ".bat" : "";
8281
String platformVersion = generatePlatformVersion();
8382

8483
ProcessBuilder pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-PideaVersion=" + platformVersion, "-Drobot-server.port=" + port);
@@ -116,22 +115,13 @@ public static void closeIde() {
116115
ideProcess.destroy();
117116
}
118117

119-
/**
120-
* Return the IdeaVersion representation of the currently running IntelliJ Idea version
121-
*
122-
* @return version of the currently running IntelliJ Idea
123-
*/
124-
public static IntelliJVersion getIdeaVersion() {
125-
return ideaVersion;
126-
}
127-
128118
/**
129119
* Return the integer representation of the currently running IntelliJ Idea version
130120
*
131121
* @return version of the currently running IntelliJ Idea
132122
*/
133123
public static int getIdeaVersionInt() {
134-
return getIdeaVersion().toInt();
124+
return ideaVersion.toInt();
135125
}
136126

137127
/**
@@ -172,7 +162,7 @@ private static void acceptAllTermsAndConditions() {
172162
linuxPrefsXmlSourceLocation = "prefs_xml/2022_1/prefs.xml";
173163
}
174164

175-
if (OS_NAME.contains("linux")) {
165+
if (SystemInfo.isLinux) {
176166
step("Copy the 'prefs.xml' file to the appropriate location", () -> {
177167
String prefsXmlDir = USER_HOME + "/.java/.userPrefs/jetbrains/_!(!!cg\"p!(}!}@\"j!(k!|w\"w!'8!b!\"p!':!e@==";
178168
createDirectoryHierarchy(prefsXmlDir);
@@ -184,7 +174,7 @@ private static void acceptAllTermsAndConditions() {
184174
createDirectoryHierarchy(acceptedDir);
185175
copyFileFromJarResourceDir(ACCEPTED_SOURCE_LOCATION, acceptedDir + "/accepted");
186176
});
187-
} else if (OS_NAME.contains("os x")) {
177+
} else if (SystemInfo.isMac) {
188178
step("Copy the 'com.apple.java.util.prefs.plist' file to the appropriate location", () -> {
189179
String plistDir = USER_HOME + "/Library/Preferences";
190180
copyFileFromJarResourceDir(osxPlistSourceLocation, plistDir + "/com.apple.java.util.prefs.plist");
@@ -205,7 +195,7 @@ private static void acceptAllTermsAndConditions() {
205195
Thread.currentThread().interrupt();
206196
}
207197
});
208-
} else if (OS_NAME.contains("windows")) {
198+
} else if (SystemInfo.isWindows) {
209199
step(COPY_ACCEPTED_FILE_STEP_DESCRIPTION, () -> {
210200
String acceptedDir = USER_HOME + "\\AppData\\Roaming\\JetBrains\\consentOptions";
211201
createDirectoryHierarchy(acceptedDir);

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/FlatWelcomeFrame.java

Lines changed: 35 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
import com.intellij.remoterobot.fixtures.ContainerFixture;
1818
import com.intellij.remoterobot.fixtures.DefaultXpath;
1919
import com.intellij.remoterobot.fixtures.FixtureName;
20-
import com.intellij.remoterobot.fixtures.HeavyWeightWindowFixture;
2120
import com.intellij.remoterobot.fixtures.JButtonFixture;
22-
import com.intellij.remoterobot.fixtures.JListFixture;
2321
import com.intellij.remoterobot.fixtures.JPopupMenuFixture;
2422
import com.intellij.remoterobot.fixtures.JTreeFixture;
2523
import com.intellij.remoterobot.utils.UtilsKt;
@@ -91,14 +89,7 @@ public void openProject(String projectName) {
9189
* @param label label of the link to click on
9290
*/
9391
public void clickOnLink(String label) {
94-
// Code for IntelliJ IDEA 2020.3 or newer
95-
if (ideaVersionInt >= 20203) {
96-
welcomeFrameLink(label).click();
97-
}
98-
// Code for IntelliJ IDEA 2020.2 or earlier
99-
else {
100-
actionLink(label).click();
101-
}
92+
welcomeFrameLink(label).click();
10293
}
10394

10495
/**
@@ -134,11 +125,11 @@ public void clearWorkspace() {
134125
public void clearExceptions() {
135126
try {
136127
ideErrorsIcon().click();
137-
find(IdeFatalErrorsDialog.class, Duration.ofSeconds(10)).clearAll();
128+
find(IdeFatalErrorsDialog.class, Duration.ofSeconds(5)).clearAll();
138129
} catch (WaitForConditionTimeoutException e) {
139130
LOGGER.log(Level.INFO, "No fatal errors dialog found to clear.");
140131
try {
141-
find(IdeFatalErrorsDialog.class, Duration.ofSeconds(10)).clearAll();
132+
find(IdeFatalErrorsDialog.class, Duration.ofSeconds(5)).clearAll();
142133
} catch (Exception e2) {
143134
LOGGER.log(Level.INFO, "Second attempt to clear fatal errors dialog also failed.");
144135
}
@@ -149,22 +140,18 @@ public void clearExceptions() {
149140
* Open the 'Preferences' dialog
150141
*/
151142
public void openSettingsDialog() {
152-
if (ideaVersionInt <= 20202) {
153-
clickOnLink("Configure");
154-
HeavyWeightWindowFixture heavyWeightWindowFixture = find(HeavyWeightWindowFixture.class, Duration.ofSeconds(5));
155-
heavyWeightWindowFixture.findText("Preferences").click();
156-
} else if (ideaVersionInt <= 20212) {
157-
JListFixture jListFixture = remoteRobot.find(JListFixture.class, byXpath(XPathDefinitions.JBLIST));
158-
jListFixture.clickItem("Customize", false);
159-
remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click();
160-
} else {
161-
JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE));
162-
jTreeFixture.findText("Customize").click();
163-
if (remoteRobot.isMac()) {
164-
resizeWelcomeWindow();
165-
}
166-
remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click();
143+
JTreeFixture jTreeFixture;
144+
try {
145+
jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE));
146+
} catch (WaitForConditionTimeoutException e) {
147+
// workaround for 2022.3
148+
jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath("//div[@accessiblename='Welcome screen categories']"));
149+
}
150+
jTreeFixture.findText("Customize").click();
151+
if (remoteRobot.isMac()) {
152+
resizeWelcomeWindow();
167153
}
154+
remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click();
168155
}
169156

170157
/**
@@ -204,25 +191,10 @@ private void resizeWelcomeWindow() {
204191
* @return fixture for the 'Tip Of the Day' dialog
205192
*/
206193
public TipDialog openTipDialog() {
207-
if (ideaVersionInt >= 20211) {
208-
FlatWelcomeFrame flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(2));
209-
if (ideaVersionInt >= 20223) { // COMMUNITY_V_2022_3 and higher version have different labels for Learn button
210-
flatWelcomeFrame.findText(ButtonLabels.LEARN_LABEL).click();
211-
} else {
212-
flatWelcomeFrame.findText(ButtonLabels.LEARN_INTELLIJ_IDEA_LABEL).click();
213-
}
214-
SharedSteps.waitForComponentByXpath(remoteRobot, 2, 200, byXpath(XPathDefinitions.TIP_DIALOG_2));
215-
flatWelcomeFrame.findText(TIP_OF_THE_DAY).click();
216-
} else if (ideaVersionInt <= 20202) {
217-
clickOnLink("Get Help");
218-
HeavyWeightWindowFixture heavyWeightWindowFixture = find(HeavyWeightWindowFixture.class, Duration.ofSeconds(5));
219-
heavyWeightWindowFixture.findText(TIP_OF_THE_DAY).click();
220-
} else if (ideaVersionInt == 20203) { // IJ 2020.3
221-
actionLink("Help").click();
222-
HeavyWeightWindowFixture heavyWeightWindowFixture = find(HeavyWeightWindowFixture.class, Duration.ofSeconds(5));
223-
heavyWeightWindowFixture.findText(TIP_OF_THE_DAY).click();
224-
}
225-
194+
FlatWelcomeFrame flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(2));
195+
flatWelcomeFrame.findText(ButtonLabels.LEARN_LABEL).click();
196+
SharedSteps.waitForComponentByXpath(remoteRobot, 2, 200, byXpath(XPathDefinitions.TIP_DIALOG_2));
197+
flatWelcomeFrame.findText(TIP_OF_THE_DAY).click();
226198
return remoteRobot.find(TipDialog.class, Duration.ofSeconds(10));
227199
}
228200

@@ -239,45 +211,26 @@ public void disableNotifications() {
239211
switchToProjectsPage();
240212
}
241213

242-
/**
243-
* Prevent the 'Tip of the Day' dialog from opening after project import
244-
*/
245-
public void preventTipDialogFromOpening() {
246-
TipDialog tipDialog = openTipDialog();
247-
tipDialog.dontShowTipsCheckBox().setValue(true);
248-
tipDialog.close();
249-
switchToProjectsPage();
250-
}
251-
252214
/**
253215
* Switch to the 'Projects' page of flat welcome frame
254216
*/
255217
public void switchToProjectsPage() {
256-
if (ideaVersionInt >= 20213) {
257-
JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE));
258-
jTreeFixture.findText(PROJECTS_BUTTON).click();
259-
} else if (ideaVersionInt >= 20203) {
260-
JListFixture jListFixture = remoteRobot.find(JListFixture.class, byXpath(XPathDefinitions.JBLIST));
261-
jListFixture.clickItem(PROJECTS_BUTTON, false);
218+
JTreeFixture jTreeFixture;
219+
try {
220+
jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE));
221+
} catch (WaitForConditionTimeoutException e) {
222+
// workaround for 2022.3
223+
jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath("//div[@accessiblename='Welcome screen categories']"));
262224
}
225+
jTreeFixture.findText(PROJECTS_BUTTON).click();
263226
}
264227

265228
private int projectsCount() {
266-
if (ideaVersionInt >= 20222) {
267-
try {
268-
JTreeFixture projects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0);
269-
return projects.findAllText().size() / 2;
270-
} catch (IndexOutOfBoundsException e) {
271-
return 0;
272-
}
273-
} else {
274-
try {
275-
ContainerFixture projectWrapper = find(ContainerFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW));
276-
JListFixture projectList = projectWrapper.find(JListFixture.class, byXpath(XPathDefinitions.MY_LIST));
277-
return projectList.collectItems().size();
278-
} catch (WaitForConditionTimeoutException e) {
279-
return 0;
280-
}
229+
try {
230+
JTreeFixture projects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0);
231+
return projects.findAllText().size() / 2;
232+
} catch (IndexOutOfBoundsException e) {
233+
return 0;
281234
}
282235
}
283236

@@ -293,16 +246,11 @@ private JButtonFixture welcomeFrameLink(String label) {
293246
}
294247

295248
private ComponentFixture ideErrorsIcon() {
296-
return find(ComponentFixture.class, byXpath(XPathDefinitions.IDE_ERROR_ICON), Duration.ofSeconds(10));
249+
return find(ComponentFixture.class, byXpath(XPathDefinitions.IDE_ERROR_ICON), Duration.ofSeconds(5));
297250
}
298251

299252
private void removeTopProjectFromRecentProjects() {
300-
ComponentFixture recentProjects;
301-
if (ideaVersionInt >= 20222) {
302-
recentProjects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0);
303-
} else {
304-
recentProjects = jLists(byXpath(XPathDefinitions.RECENT_PROJECTS)).get(0);
305-
}
253+
ComponentFixture recentProjects = remoteRobot.findAll(JTreeFixture.class, byXpath(XPathDefinitions.RECENT_PROJECT_PANEL_NEW_2)).get(0);
306254

307255
// Clicks on X on first recent project to remove it from the recent projects list (visible only when hovered over with cursor)
308256
recentProjects.runJs("const horizontal_offset = component.getWidth()-22;\n" +
@@ -311,16 +259,12 @@ private void removeTopProjectFromRecentProjects() {
311259
if (ideaVersionInt >= 20231) {
312260
ComponentFixture removeDialog = remoteRobot.find(ComponentFixture.class, byXpath(XPathDefinitions.MY_DIALOG), Duration.ofSeconds(10));
313261
removeDialog.findText(ButtonLabels.REMOVE_FROM_LIST_LABEL).click();
314-
} else if (ideaVersionInt >= 20203) { // Code for IntelliJ Idea 2020.3 or newer
262+
} else {
315263
List<JPopupMenuFixture> jPopupMenuFixtures = jPopupMenus(JPopupMenuFixture.Companion.byType());
316264
if (!jPopupMenuFixtures.isEmpty()) {
317265
JPopupMenuFixture contextMenu = jPopupMenuFixtures.get(0);
318-
if (ideaVersionInt >= 20222) {
319-
contextMenu.select("Remove from Recent Projects" + '\u2026');
320-
button(byXpath(XPathDefinitions.REMOVE_PROJECT_BUTTON)).click();
321-
} else {
322-
contextMenu.select("Remove from Recent Projects");
323-
}
266+
contextMenu.select("Remove from Recent Projects" + '\u2026');
267+
button(byXpath(XPathDefinitions.REMOVE_PROJECT_BUTTON)).click();
324268
}
325269
}
326270
}

0 commit comments

Comments
 (0)