Skip to content

Commit 1b31826

Browse files
committed
fix: openSettingsDialogFOrMacOS
Signed-off-by: Martin Szuc <[email protected]>
1 parent 19f56a6 commit 1b31826

File tree

1 file changed

+52
-4
lines changed

1 file changed

+52
-4
lines changed

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

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.intellij.remoterobot.RemoteRobot;
1414
import com.intellij.remoterobot.data.RemoteComponent;
1515
import com.intellij.remoterobot.fixtures.*;
16+
import com.intellij.remoterobot.utils.Keyboard;
1617
import com.intellij.remoterobot.utils.UtilsKt;
1718
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
1819
import com.redhat.devtools.intellij.commonuitest.UITestRunner;
@@ -29,6 +30,7 @@
2930
import org.apache.commons.io.FileUtils;
3031
import org.jetbrains.annotations.NotNull;
3132

33+
import java.awt.event.KeyEvent;
3234
import java.io.File;
3335
import java.io.IOException;
3436
import java.nio.file.Files;
@@ -40,6 +42,7 @@
4042
import java.util.logging.Logger;
4143

4244
import static com.intellij.remoterobot.search.locators.Locators.byXpath;
45+
import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitFor;
4346

4447
/**
4548
* Welcome to IntelliJ IDEA dialog fixture
@@ -149,9 +152,54 @@ public void openSettingsDialog() {
149152
jListFixture.clickItem("Customize", false);
150153
remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click();
151154
} else {
152-
JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE));
153-
jTreeFixture.findText("Customize").click();
154-
remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click();
155+
try {
156+
JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(XPathDefinitions.TREE));
157+
jTreeFixture.findText("Customize").click();
158+
159+
if(remoteRobot.isMac()){
160+
// Enlarge the Welcome window using callJs
161+
remoteRobot.callJs("""
162+
importClass(java.awt.Frame);
163+
var frames = Frame.getFrames();
164+
var resized = false;
165+
for (var i = 0; i < frames.length; i++) {
166+
var frame = frames[i];
167+
if (frame.getTitle().contains("Welcome to IntelliJ IDEA")) {
168+
frame.setSize(frame.getWidth(), 800); // Increase the height as needed
169+
frame.validate();
170+
resized = true;
171+
break;
172+
}
173+
}
174+
resized; // Return whether the frame was resized
175+
""");
176+
}
177+
178+
// Now wait for and click the "All settings" link
179+
waitFor(
180+
Duration.ofSeconds(30),
181+
Duration.ofSeconds(2),
182+
"The 'All settings' action link did not appear in 30 seconds.",
183+
this::isAllSettingsLinkVisible
184+
);
185+
186+
remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL))
187+
.findText("All settings" + '\u2026')
188+
.click();
189+
} catch (Exception e) {
190+
ScreenshotUtils.takeScreenshot(remoteRobot, "failed");
191+
throw new RuntimeException(e);
192+
}
193+
194+
}
195+
}
196+
197+
private boolean isAllSettingsLinkVisible() {
198+
try {
199+
remoteRobot.find(ActionLinkFixture.class, byXpath(XPathDefinitions.label("All settings" + '\u2026')));
200+
return true;
201+
} catch (Exception e) {
202+
return false;
155203
}
156204
}
157205

@@ -187,7 +235,7 @@ public TipDialog openTipDialog() {
187235
* Open the 'Preferences' dialog
188236
*/
189237
public void disableNotifications() {
190-
try{
238+
try {
191239
openSettingsDialog();
192240
SettingsDialog settingsDialog = remoteRobot.find(SettingsDialog.class, Duration.ofSeconds(5));
193241
settingsDialog.navigateTo("Appearance & Behavior", "Notifications");

0 commit comments

Comments
 (0)