Skip to content

Commit 4349fb9

Browse files
committed
Fixes.
Signed-off-by: Zbynek Cervinka <[email protected]>
1 parent 1b8b9f8 commit 4349fb9

File tree

7 files changed

+46
-23
lines changed

7 files changed

+46
-23
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public void disableNotifications() {
195195
SettingsDialog settingsDialog = remoteRobot.find(SettingsDialog.class, Duration.ofSeconds(5));
196196
settingsDialog.navigateTo("Appearance & Behavior", "Notifications");
197197
NotificationsPage notificationsPage = remoteRobot.find(NotificationsPage.class, Duration.ofSeconds(5));
198-
notificationsPage.disableNotifications();
198+
notificationsPage.toggleNotifications(false);
199199
settingsDialog.ok();
200200

201201
if (ideaVersion >= 20213) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.intellij.remoterobot.fixtures.FixtureName;
1818
import com.intellij.remoterobot.fixtures.JButtonFixture;
1919
import com.intellij.remoterobot.fixtures.JTreeFixture;
20+
import com.redhat.devtools.intellij.commonuitest.exceptions.UITestException;
2021
import com.redhat.devtools.intellij.commonuitest.utils.labels.ButtonLabels;
2122
import org.jetbrains.annotations.NotNull;
2223

@@ -39,7 +40,7 @@ public SettingsDialog(@NotNull RemoteRobot remoteRobot, @NotNull RemoteComponent
3940
*/
4041
public void navigateTo(String... path) {
4142
if (path.length == 0) {
42-
return;
43+
throw new UITestException("Path is empty.");
4344
}
4445
settingsTree().expand(path);
4546
settingsTree().clickPath(path, true);

src/main/java/com/redhat/devtools/intellij/commonuitest/fixtures/dialogs/settings/pages/NotificationsPage.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,30 @@ public NotificationsPage(@NotNull RemoteRobot remoteRobot, @NotNull RemoteCompon
3232

3333
/**
3434
* Disable both balloon and system notifications
35+
*
36+
* @param value boolean value to toggle the checkboxes to
3537
*/
36-
public void disableNotifications() {
37-
disableBalloonNotifications();
38-
disableSystemNotifications();
38+
public void toggleNotifications(boolean value) {
39+
toggleBalloonNotifications(value);
40+
toggleSystemNotifications(value);
3941
}
4042

4143
/**
42-
* Disable balloon notifications
44+
* Toggle balloon notifications
45+
*
46+
* @param value boolean value to toggle the checkbox to
4347
*/
44-
public void disableBalloonNotifications() {
45-
displayBalloonNotificationsCheckBox().setValue(false);
48+
public void toggleBalloonNotifications(boolean value) {
49+
displayBalloonNotificationsCheckBox().setValue(value);
4650
}
4751

4852
/**
49-
* Disable system notifications
53+
* Toggle system notifications
54+
*
55+
* @param value boolean value to toggle the checkbox to
5056
*/
51-
public void disableSystemNotifications() {
52-
displaySystemNotificationsCheckBox().setValue(false);
57+
public void toggleSystemNotifications(boolean value) {
58+
displaySystemNotificationsCheckBox().setValue(value);
5359
}
5460

5561
/**

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/LibraryTestBase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@
3131
public class LibraryTestBase {
3232
protected static RemoteRobot remoteRobot;
3333
private static boolean intelliJHasStarted = false;
34-
protected static int ideaVersion;
34+
private static UITestRunner.IdeaVersion ideaVersion = UITestRunner.IdeaVersion.COMMUNITY_V_2021_1;
35+
protected static int ideaVersionInt = ideaVersion.toInt();
3536
protected static final Logger LOGGER = Logger.getLogger(LibraryTestBase.class.getName());
3637

3738
@BeforeAll
3839
protected static void startIntelliJ() {
3940
if (!intelliJHasStarted) {
40-
remoteRobot = UITestRunner.runIde(UITestRunner.IdeaVersion.COMMUNITY_V_2021_1, 8580);
41+
remoteRobot = UITestRunner.runIde(ideaVersion, 8580);
4142
intelliJHasStarted = true;
4243
Runtime.getRuntime().addShutdownHook(new CloseIntelliJBeforeQuit());
4344

44-
ideaVersion = UITestRunner.getIdeaVersion().toInt();
4545
FlatWelcomeFrame flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10));
4646
flatWelcomeFrame.disableNotifications();
4747
flatWelcomeFrame.preventTipDialogFromOpening();

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/information/TipDialogTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public class TipDialogTest extends LibraryTestBase {
3939

4040
@AfterAll
4141
public static void cleanUp() {
42-
if (ideaVersion >= 20213) {
42+
if (ideaVersionInt >= 20213) {
4343
JTreeFixture jTreeFixture = remoteRobot.find(JTreeFixture.class, byXpath(TREE_XPATH));
4444
jTreeFixture.findText("Projects").click();
45-
} else if (ideaVersion >= 20203) {
45+
} else if (ideaVersionInt >= 20203) {
4646
JListFixture jListFixture = remoteRobot.find(JListFixture.class, byXpath(JBLIST_XPATH));
4747
jListFixture.clickItem("Projects", false);
4848
}

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/project_manipulation/NewProjectDialogTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ public void setProjectSdkIfAvailableTest() {
297297
public void selectNewProjectTypeTest() {
298298
newProjectFirstPage.selectNewProjectType("Empty Project");
299299
boolean isEmptyProjectPageDisplayed;
300-
if (ideaVersion < 20213) {
300+
if (ideaVersionInt < 20213) {
301301
isEmptyProjectPageDisplayed = !newProjectFirstPage.findAll(JListFixture.class, byXpath("//div[@visible_text='Empty Project']")).isEmpty();
302302
} else {
303303
isEmptyProjectPageDisplayed = newProjectFirstPage.hasText("Simple project with one module");

src/test-project/src/test/java/com/redhat/devtools/intellij/commonuitest/fixtures/test/dialogs/settings/pages/NotificationsPageTest.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.settings.SettingsDialog;
1616
import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.settings.pages.NotificationsPage;
1717
import org.junit.jupiter.api.AfterAll;
18+
import org.junit.jupiter.api.AfterEach;
1819
import org.junit.jupiter.api.BeforeAll;
20+
import org.junit.jupiter.api.BeforeEach;
1921
import org.junit.jupiter.api.Test;
2022

2123
import java.time.Duration;
@@ -30,6 +32,8 @@
3032
class NotificationsPageTest extends LibraryTestBase {
3133
private static SettingsDialog settingsDialog;
3234
private static NotificationsPage notificationsPage;
35+
private boolean balloonNotificationsCheckBox;
36+
private boolean systemNotificationsCheckBox;
3337

3438
@BeforeAll
3539
public static void openSettingsDialog() {
@@ -45,32 +49,44 @@ public static void closeSettingsDialog() {
4549
settingsDialog.cancel();
4650
}
4751

52+
@BeforeEach
53+
public void backupSettings() {
54+
balloonNotificationsCheckBox = notificationsPage.displayBalloonNotificationsCheckBox().isSelected();
55+
systemNotificationsCheckBox = notificationsPage.displaySystemNotificationsCheckBox().isSelected();
56+
}
57+
58+
@AfterEach
59+
public void restoreSettings() {
60+
notificationsPage.displayBalloonNotificationsCheckBox().setValue(balloonNotificationsCheckBox);
61+
notificationsPage.displaySystemNotificationsCheckBox().setValue(systemNotificationsCheckBox);
62+
}
63+
4864
@Test
49-
public void disableNotificationsTest() {
65+
public void toggleNotificationsTest() {
5066
notificationsPage.displayBalloonNotificationsCheckBox().setValue(true);
5167
notificationsPage.displaySystemNotificationsCheckBox().setValue(true);
5268
boolean balloonNotificationsEnabled = notificationsPage.displayBalloonNotificationsCheckBox().isSelected();
5369
boolean systemNotificationsEnabled = notificationsPage.displaySystemNotificationsCheckBox().isSelected();
5470
assertTrue(balloonNotificationsEnabled && systemNotificationsEnabled, "The 'Balloon Notifications' and the 'System Notifications' checkboxes should be both checked.");
5571

56-
notificationsPage.disableNotifications();
72+
notificationsPage.toggleNotifications(false);
5773
balloonNotificationsEnabled = notificationsPage.displayBalloonNotificationsCheckBox().isSelected();
5874
systemNotificationsEnabled = notificationsPage.displaySystemNotificationsCheckBox().isSelected();
5975
assertTrue(!balloonNotificationsEnabled && !systemNotificationsEnabled, "The 'Balloon Notifications' and the 'System Notifications' checkboxes should be both unchecked.");
6076
}
6177

6278
@Test
63-
public void displayBalloonNotificationsTest() {
79+
public void toggleBalloonNotificationsTest() {
6480
notificationsPage.displayBalloonNotificationsCheckBox().setValue(true);
65-
notificationsPage.disableBalloonNotifications();
81+
notificationsPage.toggleBalloonNotifications(false);
6682
boolean balloonNotificationsEnabled = notificationsPage.displayBalloonNotificationsCheckBox().isSelected();
6783
assertTrue(!balloonNotificationsEnabled, "The 'Balloon Notifications' checkbox should be unchecked.");
6884
}
6985

7086
@Test
71-
public void displaySystemNotificationsTest() {
87+
public void toggleSystemNotificationsTest() {
7288
notificationsPage.displaySystemNotificationsCheckBox().setValue(true);
73-
notificationsPage.disableSystemNotifications();
89+
notificationsPage.toggleSystemNotifications(false);
7490
boolean systemNotificationsEnabled = notificationsPage.displaySystemNotificationsCheckBox().isSelected();
7591
assertTrue(!systemNotificationsEnabled, "The 'System Notifications' checkbox should be unchecked.");
7692
}

0 commit comments

Comments
 (0)