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

Commit

Permalink
AddressBookSystemTest: Verify that ResultDisplay style changes
Browse files Browse the repository at this point in the history
The ResultDisplay style changes if there is an error in command
execution.

This behavior is not verified by any system tests.

Let's update the system tests to verify that.
  • Loading branch information
yamgent committed Aug 9, 2018
1 parent ca028a4 commit d5dd735
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/test/java/systemtests/AddCommandSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private void assertCommandSuccess(String command, Model expectedModel, String ex
executeCommand(command);
assertApplicationDisplaysExpected("", expectedResultMessage, expectedModel);
assertSelectedCardUnchanged();
assertCommandBoxShowsDefaultStyle();
assertCommandBoxAndResultDisplayShowsDefaultStyle();
assertStatusBarUnchangedExceptSyncStatus();
}

Expand All @@ -250,7 +250,7 @@ private void assertCommandFailure(String command, String expectedResultMessage)
executeCommand(command);
assertApplicationDisplaysExpected(command, expectedResultMessage, expectedModel);
assertSelectedCardUnchanged();
assertCommandBoxShowsErrorStyle();
assertCommandBoxAndResultDisplayShowsErrorStyle();
assertStatusBarUnchanged();
}
}
19 changes: 15 additions & 4 deletions src/test/java/systemtests/AddressBookSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import seedu.address.testutil.TypicalPersons;
import seedu.address.ui.BrowserPanel;
import seedu.address.ui.CommandBox;
import seedu.address.ui.ResultDisplay;

/**
* A system test class for AddressBook, which provides access to handles of GUI components and helper methods
Expand All @@ -56,6 +57,9 @@ public abstract class AddressBookSystemTest {
private static final List<String> COMMAND_BOX_ERROR_STYLE =
Arrays.asList("text-input", "text-field", CommandBox.ERROR_STYLE_CLASS);

private List<String> defaultStyleOfResultDisplay;
private List<String> errorStyleOfResultDisplay;

private MainWindowHandle mainWindowHandle;
private TestApp testApp;
private SystemTestSetupHelper setupHelper;
Expand All @@ -71,6 +75,11 @@ public void setUp() {
testApp = setupHelper.setupApplication(this::getInitialData, getDataFileLocation());
mainWindowHandle = setupHelper.setupMainWindowHandle();

defaultStyleOfResultDisplay = mainWindowHandle.getResultDisplay().getStyleClass();

errorStyleOfResultDisplay = mainWindowHandle.getResultDisplay().getStyleClass();
errorStyleOfResultDisplay.add(ResultDisplay.ERROR_STYLE_CLASS);

waitUntilBrowserLoaded(getBrowserPanel());
assertApplicationStartingStateIsCorrect();
}
Expand Down Expand Up @@ -236,17 +245,19 @@ protected void assertSelectedCardUnchanged() {
}

/**
* Asserts that the command box's shows the default style.
* Asserts that the command box and result display shows the default style.
*/
protected void assertCommandBoxShowsDefaultStyle() {
protected void assertCommandBoxAndResultDisplayShowsDefaultStyle() {
assertEquals(COMMAND_BOX_DEFAULT_STYLE, getCommandBox().getStyleClass());
assertEquals(defaultStyleOfResultDisplay, getResultDisplay().getStyleClass());
}

/**
* Asserts that the command box's shows the error style.
* Asserts that the command box and result display shows the error style.
*/
protected void assertCommandBoxShowsErrorStyle() {
protected void assertCommandBoxAndResultDisplayShowsErrorStyle() {
assertEquals(COMMAND_BOX_ERROR_STYLE, getCommandBox().getStyleClass());
assertEquals(errorStyleOfResultDisplay, getResultDisplay().getStyleClass());
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/systemtests/ClearCommandSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void assertCommandSuccess(String command) {
private void assertCommandSuccess(String command, String expectedResultMessage, Model expectedModel) {
executeCommand(command);
assertApplicationDisplaysExpected("", expectedResultMessage, expectedModel);
assertCommandBoxShowsDefaultStyle();
assertCommandBoxAndResultDisplayShowsDefaultStyle();
assertStatusBarUnchangedExceptSyncStatus();
}

Expand All @@ -95,7 +95,7 @@ private void assertCommandFailure(String command, String expectedResultMessage)
executeCommand(command);
assertApplicationDisplaysExpected(command, expectedResultMessage, expectedModel);
assertSelectedCardUnchanged();
assertCommandBoxShowsErrorStyle();
assertCommandBoxAndResultDisplayShowsErrorStyle();
assertStatusBarUnchanged();
}
}
4 changes: 2 additions & 2 deletions src/test/java/systemtests/DeleteCommandSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private void assertCommandSuccess(String command, Model expectedModel, String ex
assertSelectedCardUnchanged();
}

assertCommandBoxShowsDefaultStyle();
assertCommandBoxAndResultDisplayShowsDefaultStyle();
assertStatusBarUnchangedExceptSyncStatus();
}

Expand All @@ -192,7 +192,7 @@ private void assertCommandFailure(String command, String expectedResultMessage)
executeCommand(command);
assertApplicationDisplaysExpected(command, expectedResultMessage, expectedModel);
assertSelectedCardUnchanged();
assertCommandBoxShowsErrorStyle();
assertCommandBoxAndResultDisplayShowsErrorStyle();
assertStatusBarUnchanged();
}
}
4 changes: 2 additions & 2 deletions src/test/java/systemtests/EditCommandSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private void assertCommandSuccess(String command, Model expectedModel, String ex
executeCommand(command);
expectedModel.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
assertApplicationDisplaysExpected("", expectedResultMessage, expectedModel);
assertCommandBoxShowsDefaultStyle();
assertCommandBoxAndResultDisplayShowsDefaultStyle();
if (expectedSelectedCardIndex != null) {
assertSelectedCardChanged(expectedSelectedCardIndex);
} else {
Expand All @@ -301,7 +301,7 @@ private void assertCommandFailure(String command, String expectedResultMessage)
executeCommand(command);
assertApplicationDisplaysExpected(command, expectedResultMessage, expectedModel);
assertSelectedCardUnchanged();
assertCommandBoxShowsErrorStyle();
assertCommandBoxAndResultDisplayShowsErrorStyle();
assertStatusBarUnchanged();
}
}
4 changes: 2 additions & 2 deletions src/test/java/systemtests/FindCommandSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private void assertCommandSuccess(String command, Model expectedModel) {

executeCommand(command);
assertApplicationDisplaysExpected("", expectedResultMessage, expectedModel);
assertCommandBoxShowsDefaultStyle();
assertCommandBoxAndResultDisplayShowsDefaultStyle();
assertStatusBarUnchanged();
}

Expand All @@ -189,7 +189,7 @@ private void assertCommandFailure(String command, String expectedResultMessage)
executeCommand(command);
assertApplicationDisplaysExpected(command, expectedResultMessage, expectedModel);
assertSelectedCardUnchanged();
assertCommandBoxShowsErrorStyle();
assertCommandBoxAndResultDisplayShowsErrorStyle();
assertStatusBarUnchanged();
}
}
4 changes: 2 additions & 2 deletions src/test/java/systemtests/SelectCommandSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private void assertCommandSuccess(String command, Index expectedSelectedCardInde
assertSelectedCardChanged(expectedSelectedCardIndex);
}

assertCommandBoxShowsDefaultStyle();
assertCommandBoxAndResultDisplayShowsDefaultStyle();
assertStatusBarUnchanged();
}

Expand All @@ -147,7 +147,7 @@ private void assertCommandFailure(String command, String expectedResultMessage)
executeCommand(command);
assertApplicationDisplaysExpected(command, expectedResultMessage, expectedModel);
assertSelectedCardUnchanged();
assertCommandBoxShowsErrorStyle();
assertCommandBoxAndResultDisplayShowsErrorStyle();
assertStatusBarUnchanged();
}
}

0 comments on commit d5dd735

Please sign in to comment.