Skip to content

Commit

Permalink
test: Added closeAndReopenProjectTest
Browse files Browse the repository at this point in the history
rh-pre-commit.version: 2.1.0
rh-pre-commit.check-secrets: ENABLED
  • Loading branch information
richardkocian committed Feb 5, 2024
1 parent dc7768d commit 563f899
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@
package com.redhat.devtools.intellij.commonuitest.fixtures.test.mainidewindow.menubar;

import com.intellij.remoterobot.RemoteRobot;
import com.intellij.remoterobot.fixtures.ComponentFixture;
import com.intellij.remoterobot.utils.WaitForConditionTimeoutException;
import com.redhat.devtools.intellij.commonuitest.LibraryTestBase;
import com.redhat.devtools.intellij.commonuitest.UITestRunner;
import com.redhat.devtools.intellij.commonuitest.fixtures.dialogs.information.TipDialog;
import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.menubar.MenuBar;
import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.AbstractToolWinPane;
import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ProjectExplorer;
import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowPane;
import com.redhat.devtools.intellij.commonuitest.fixtures.mainidewindow.toolwindowspane.ToolWindowsPane;
import com.redhat.devtools.intellij.commonuitest.utils.constants.ButtonLabels;
import com.redhat.devtools.intellij.commonuitest.utils.project.CreateCloseUtils;
import org.junit.jupiter.api.AfterAll;
Expand All @@ -23,6 +29,7 @@

import java.time.Duration;

import static com.intellij.remoterobot.search.locators.Locators.byXpath;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
Expand All @@ -33,6 +40,8 @@
class MenuBarTest extends LibraryTestBase {
private static final String PROJECT_NAME = "project_view_tree_java_project";

private static ProjectExplorer projectExplorer;

@BeforeAll
public static void prepareProject() {
CreateCloseUtils.createNewProject(remoteRobot, PROJECT_NAME, CreateCloseUtils.NewProjectType.PLAIN_JAVA);
Expand All @@ -52,6 +61,22 @@ public void openTipDialogUsingMenuBarTest() {
}
}

@Test
public void closeAndReopenProjectTest() {
CreateCloseUtils.closeProject(remoteRobot);
CreateCloseUtils.openProjectFromWelcomeDialog(remoteRobot, PROJECT_NAME);

AbstractToolWinPane toolWinPane;
if (UITestRunner.getIdeaVersionInt() >= 20221) {
toolWinPane = remoteRobot.find(ToolWindowPane.class, Duration.ofSeconds(10));
} else {
toolWinPane = remoteRobot.find(ToolWindowsPane.class, Duration.ofSeconds(10));
}
toolWinPane.openProjectExplorer();
projectExplorer = toolWinPane.find(ProjectExplorer.class, Duration.ofSeconds(10));
assertTrue(projectExplorer.isItemPresent(PROJECT_NAME), "The project should be back open, but it is not");
}

private boolean isTipDialogVisible(RemoteRobot remoteRobot) {
try {
remoteRobot.find(TipDialog.class, Duration.ofSeconds(10));
Expand All @@ -60,4 +85,14 @@ private boolean isTipDialogVisible(RemoteRobot remoteRobot) {
}
return true;
}

private boolean isProjectOpen(RemoteRobot remoteRobot) {
try {
projectExplorer.isItemPresent(PROJECT_NAME);
remoteRobot.find(ComponentFixture.class, byXpath("div[@visible_text='project_view_tree_java_project']"), Duration.ofSeconds(10));
} catch (WaitForConditionTimeoutException e) {
return false;
}
return true;
}
}

0 comments on commit 563f899

Please sign in to comment.