|
13 | 13 | import com.intellij.remoterobot.RemoteRobot; |
14 | 14 | import com.intellij.remoterobot.data.RemoteComponent; |
15 | 15 | import com.intellij.remoterobot.fixtures.*; |
| 16 | +import com.intellij.remoterobot.utils.Keyboard; |
16 | 17 | import com.intellij.remoterobot.utils.UtilsKt; |
17 | 18 | import com.intellij.remoterobot.utils.WaitForConditionTimeoutException; |
18 | 19 | import com.redhat.devtools.intellij.commonuitest.UITestRunner; |
|
29 | 30 | import org.apache.commons.io.FileUtils; |
30 | 31 | import org.jetbrains.annotations.NotNull; |
31 | 32 |
|
| 33 | +import java.awt.event.KeyEvent; |
32 | 34 | import java.io.File; |
33 | 35 | import java.io.IOException; |
34 | 36 | import java.nio.file.Files; |
|
40 | 42 | import java.util.logging.Logger; |
41 | 43 |
|
42 | 44 | import static com.intellij.remoterobot.search.locators.Locators.byXpath; |
| 45 | +import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitFor; |
43 | 46 |
|
44 | 47 | /** |
45 | 48 | * Welcome to IntelliJ IDEA dialog fixture |
@@ -149,9 +152,54 @@ public void openSettingsDialog() { |
149 | 152 | jListFixture.clickItem("Customize", false); |
150 | 153 | remoteRobot.find(ContainerFixture.class, byXpath(XPathDefinitions.DIALOG_PANEL)).findText("All settings" + '\u2026').click(); |
151 | 154 | } 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; |
155 | 203 | } |
156 | 204 | } |
157 | 205 |
|
@@ -187,7 +235,7 @@ public TipDialog openTipDialog() { |
187 | 235 | * Open the 'Preferences' dialog |
188 | 236 | */ |
189 | 237 | public void disableNotifications() { |
190 | | - try{ |
| 238 | + try { |
191 | 239 | openSettingsDialog(); |
192 | 240 | SettingsDialog settingsDialog = remoteRobot.find(SettingsDialog.class, Duration.ofSeconds(5)); |
193 | 241 | settingsDialog.navigateTo("Appearance & Behavior", "Notifications"); |
|
0 commit comments