Skip to content
This repository has been archived by the owner on Mar 2, 2019. It is now read-only.

Commit

Permalink
Created view handler for CommandErrorView
Browse files Browse the repository at this point in the history
  • Loading branch information
xiendong committed Nov 6, 2016
1 parent ae8e662 commit e0a9d7a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/test/java/guitests/guihandles/CommandErrorViewHandle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package guitests.guihandles;

import guitests.GuiRobot;
import javafx.scene.Node;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import seedu.todo.TestApp;
import seedu.todo.testutil.UiTestUtil;

//@@author A0135805H
/**
* A handler for retrieving error messages to user via {@link seedu.todo.ui.view.CommandErrorView}
*/
public class CommandErrorViewHandle extends GuiHandle {
/* Constants */
private static final String NON_FIELD_ERROR_GRID_ID = "#nonFieldErrorGrid";
private static final String FIELD_ERROR_GRID_ID = "#fieldErrorGrid";
private static final String ERROR_VIEW_PLACEHOLDER_ID = "#commandErrorViewPlaceholder";

/**
* Constructs a handle to the {@link CommandFeedbackViewHandle}
*
* @param guiRobot {@link GuiRobot} for the current GUI test.
* @param primaryStage The stage where the views for this handle is located.
*/
public CommandErrorViewHandle(GuiRobot guiRobot, Stage primaryStage) {
super(guiRobot, primaryStage, TestApp.APP_TITLE);
}

/**
* Returns true if the placeholder is visible.
*/
public boolean isVisible() {
Node placeholder = getNode(ERROR_VIEW_PLACEHOLDER_ID);
return UiTestUtil.isDisplayed(placeholder);
}

/**
* Returns true if the placeholder has messages displayed.
*/
public boolean hasErrorMessages() {
int numOfErrorMessages = 0;

GridPane errorField = (GridPane) getNode(FIELD_ERROR_GRID_ID);
GridPane nonErrorField = (GridPane) getNode(NON_FIELD_ERROR_GRID_ID);

numOfErrorMessages += errorField.getChildren().size() / 2;
numOfErrorMessages += nonErrorField.getChildren().size() / 2;

return numOfErrorMessages > 0;
}
}
4 changes: 4 additions & 0 deletions src/test/java/guitests/guihandles/MainGuiHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ public CommandFeedbackViewHandle getCommandFeedbackView() {
public CommandPreviewViewHandle getCommandPreviewView() {
return new CommandPreviewViewHandle(guiRobot, primaryStage);
}

public CommandErrorViewHandle getCommandErrorView() {
return new CommandErrorViewHandle(guiRobot, primaryStage);
}
}

0 comments on commit e0a9d7a

Please sign in to comment.