Skip to content

Commit

Permalink
debug statements for ProjectExplorerTest
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Szuc <[email protected]>
  • Loading branch information
martinszuc committed Jan 25, 2024
1 parent 42756a9 commit fbf45dd
Showing 1 changed file with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import java.time.Duration;
import java.util.List;
import java.util.logging.Logger;

import static com.intellij.remoterobot.search.locators.Locators.byXpath;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -42,6 +43,7 @@
* @author [email protected]
*/
class ProjectExplorerTest extends LibraryTestBase {
private static final Logger LOGGER = Logger.getLogger(UITestRunner.class.getName());
private static final String PROJECT_NAME = "pe_java_project";
private static ProjectExplorer projectExplorer;
private final Keyboard keyboard = new Keyboard(remoteRobot);
Expand Down Expand Up @@ -71,27 +73,37 @@ public void hideAllPopups() {

@Test
public void isItemPresentTest() {
LOGGER.fine("Starting isItemPresentTest");
boolean isItemPresent = projectExplorer.isItemPresent(PROJECT_NAME, PROJECT_NAME + ".iml");
LOGGER.fine("isItemPresent - " + isItemPresent);
assertTrue(isItemPresent, "The file '" + PROJECT_NAME + ".iml' should be present in the project on location '" + PROJECT_NAME + "/" + PROJECT_NAME + ".iml' but is not.");
LOGGER.fine("Finished isItemPresentTest");
}

@Test
public void openFileTest() {
LOGGER.info("Starting openFileTest");
projectExplorer.openFile(PROJECT_NAME, PROJECT_NAME + ".iml");
if (ideaVersionInt >= 20231) { // Code for IJ 2023.1+
if (ideaVersionInt >= 20231) { // Code for IJ 2023.1+
LOGGER.info("IDEA version is 2023.1 or later");
String projectLabelXpath = "//div[@accessiblename='" + PROJECT_NAME + ".iml' and @class='EditorTabLabel']//div[@class='ActionPanel']";
try { // Verify file is opened by finding its tab in the editor
try { // Verify file is opened by finding its tab in the editor
remoteRobot.find(ComponentFixture.class, byXpath(projectLabelXpath));
LOGGER.info(PROJECT_NAME + ".iml file tab found in the editor");
} catch (Exception e) {
LOGGER.severe("The '" + PROJECT_NAME + ".iml' file should be opened but is not: " + e.getMessage());
fail("The '" + PROJECT_NAME + ".iml' file should be opened but is not.");
}
} else {
LOGGER.info("IDEA version is earlier than 2023.1");
List<ContainerFixture> cfs = remoteRobot.findAll(ContainerFixture.class, byXpath(XPathDefinitions.SINGLE_HEIGHT_LABEL));
ContainerFixture cf = cfs.get(cfs.size() - 1);
String allText = TextUtils.listOfRemoteTextToString(cf.findAllText());
boolean isFileOpened = allText.contains(PROJECT_NAME + ".iml");
LOGGER.info("Is '" + PROJECT_NAME + ".iml' file opened: " + isFileOpened);
assertTrue(isFileOpened, "The '" + PROJECT_NAME + ".iml' file should be opened but is not.");
}
LOGGER.info("Finished openFileTest");
}

@Test
Expand All @@ -106,47 +118,67 @@ public void openContextMenuOnTest() {

@Test
public void openViewsPopupTest() {
LOGGER.info("Starting openViewsPopupTest");
try {
JPopupMenuFixture contextMenu = projectExplorer.openViewsPopup();
assertTrue(contextMenu.hasText("Packages"), "The View popup menu should be opened but is not.");
LOGGER.info("View popup menu opened successfully");
} catch (UITestException e) {
LOGGER.severe("Failed to open View popup menu: " + e.getMessage());
fail(e.getMessage());
}
LOGGER.info("Finished openViewsPopupTest");
}

@Test
public void selectOpenedFileTest() {
LOGGER.fine("Starting selectOpenedFileTest");
projectExplorer.openFile(PROJECT_NAME, PROJECT_NAME + ".iml");
projectExplorer.projectViewTree().clickRow(0);
projectExplorer.selectOpenedFile();
assertTrue(projectExplorer.projectViewTree().isPathSelected(projectExplorer.projectViewTree().getValueAtRow(0), PROJECT_NAME + ".iml"), "The file 'modules.xml' should be selected but is not.");
boolean isFileSelected = projectExplorer.projectViewTree().isPathSelected(projectExplorer.projectViewTree().getValueAtRow(0), PROJECT_NAME + ".iml");
LOGGER.fine("isFileSelected - " + isFileSelected);
assertTrue(isFileSelected, "The file 'modules.xml' should be selected but is not.");
LOGGER.fine("Finished selectOpenedFileTest");
}

@Test
public void expandAllTest() {
LOGGER.fine("Starting expandAllTest");
projectExplorer.collapseAll();
int itemsInTreeBeforeExpanding = projectExplorer.projectViewTree().collectRows().size();
LOGGER.fine("itemsInTreeBeforeExpanding - " + itemsInTreeBeforeExpanding);
projectExplorer.expandAll();
int itemsInTreeAfterExpanding = projectExplorer.projectViewTree().collectRows().size();
LOGGER.fine("itemsInTreeAfterExpanding - " + itemsInTreeAfterExpanding);
assertTrue(itemsInTreeAfterExpanding > itemsInTreeBeforeExpanding, "Expanding of the 'Project View' tree was not successful.");
LOGGER.fine("Finished expandAllTest");
}

@Test
public void collapseAllTest() {
LOGGER.fine("Starting collapseAllTest");
projectExplorer.projectViewTree().expand(PROJECT_NAME);
int itemsInTreeBeforeCollapsing = projectExplorer.projectViewTree().collectRows().size();
LOGGER.fine("itemsInTreeBeforeCollapsing - " + itemsInTreeBeforeCollapsing);
projectExplorer.collapseAll();
int itemsInTreeAfterCollapsing = projectExplorer.projectViewTree().collectRows().size();
LOGGER.fine("itemsInTreeAfterCollapsing - " + itemsInTreeAfterCollapsing);
assertTrue(itemsInTreeAfterCollapsing < itemsInTreeBeforeCollapsing, "Collapsing of the 'Project View' tree was not successful.");
LOGGER.fine("Finished collapseAllTest");
}

@Test
public void openSettingsPopupTest() {
LOGGER.info("Starting openSettingsPopupTest");
try {
JPopupMenuFixture contextMenu = projectExplorer.openSettingsPopup();
assertTrue(contextMenu.hasText("Help"), "The Settings popup menu should be opened but is not.");
LOGGER.info("Settings popup menu opened successfully");
} catch (UITestException e) {
LOGGER.severe("Failed to open Settings popup menu: " + e.getMessage());
fail(e.getMessage());
}
LOGGER.info("Finished openSettingsPopupTest");
}
}

0 comments on commit fbf45dd

Please sign in to comment.