This repository has been archived by the owner on Mar 2, 2019. It is now read-only.
forked from nus-cs2103-AY1617S1/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created view handler for CommandErrorView
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/test/java/guitests/guihandles/CommandErrorViewHandle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters