forked from nus-cs2103-AY1617S4/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from ashpa/master
complete some gui tests + down arrow key added function
- Loading branch information
Showing
8 changed files
with
273 additions
and
236 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -1,35 +1,76 @@ | ||
//package guitests; | ||
// | ||
//import static org.junit.Assert.assertTrue; | ||
// | ||
//import org.junit.Test; | ||
// | ||
//import seedu.whatsnext.logic.commands.ClearCommand; | ||
//import seedu.whatsnext.logic.commands.DeleteCommand; | ||
//import seedu.whatsnext.testutil.BasicTaskUtil; | ||
// | ||
//public class ClearCommandTest extends AddressBookGuiTest { | ||
// | ||
// @Test | ||
// public void clear() { | ||
// | ||
// //verify a non-empty list can be cleared | ||
// assertTrue(personListPanel.isListMatching(td.getTypicalPersons())); | ||
// assertClearCommandSuccess(); | ||
// | ||
// //verify other commands can work after a clear command | ||
// commandBox.runCommand(BasicTaskUtil.getAddCommand(td.hoon)); | ||
// assertTrue(personListPanel.isListMatching(td.hoon)); | ||
// commandBox.runCommand(DeleteCommand.COMMAND_WORD + " 1"); | ||
// assertListSize(0); | ||
// | ||
// //verify clear command works when the list is empty | ||
// assertClearCommandSuccess(); | ||
// } | ||
// | ||
// private void assertClearCommandSuccess() { | ||
// commandBox.runCommand(ClearCommand.COMMAND_WORD); | ||
// assertListSize(0); | ||
// assertResultMessage("Address book has been cleared!"); | ||
// } | ||
//} | ||
package guitests; | ||
|
||
import org.junit.Test; | ||
|
||
import seedu.whatsnext.logic.commands.ClearCommand; | ||
import seedu.whatsnext.logic.commands.DeleteCommand; | ||
|
||
public class ClearCommandTest extends TaskManagerGuiTest { | ||
|
||
@Test | ||
public void clearAll() { | ||
|
||
commandBox.pressEnter(); | ||
commandBox.runCommand("list all"); | ||
assertClearCommandSuccess(); | ||
|
||
//verify other commands can work after a clear command | ||
commandBox.runCommand("add Buy a country m/to rule"); | ||
assertListSize(1); | ||
commandBox.runCommand(DeleteCommand.COMMAND_WORD + " 1"); | ||
assertListSize(0); | ||
|
||
//verify clear command works when the list is empty | ||
assertClearCommandSuccess(); | ||
} | ||
|
||
@Test | ||
public void clearIncomplete() { | ||
|
||
commandBox.pressEnter(); | ||
assertClearIncompleteCommandSuccess(); | ||
|
||
//verify other commands can work after a clear command | ||
commandBox.runCommand("list completed"); | ||
assertListSize(1); | ||
commandBox.runCommand(DeleteCommand.COMMAND_WORD + " 1"); | ||
assertListSize(0); | ||
|
||
//verify clear command works when the list is empty | ||
assertClearCommandSuccess(); | ||
} | ||
|
||
@Test | ||
public void clearCompleted() { | ||
|
||
commandBox.pressEnter(); | ||
commandBox.runCommand("list completed"); | ||
assertClearCompletedCommandSuccess(); | ||
|
||
//verify other commands can work after a clear command | ||
assertListSize(0); | ||
commandBox.runCommand("list all"); | ||
assertListSize(6); | ||
|
||
//verify clear command works when the list is empty | ||
assertClearCommandSuccess(); | ||
} | ||
|
||
private void assertClearCommandSuccess() { | ||
commandBox.runCommand(ClearCommand.COMMAND_WORD + " all"); | ||
assertListSize(0); | ||
assertResultMessage("Task List has been cleared!"); | ||
} | ||
|
||
private void assertClearIncompleteCommandSuccess() { | ||
commandBox.runCommand(ClearCommand.COMMAND_WORD + " incomplete"); | ||
assertListSize(0); | ||
assertResultMessage("Task List has been cleared!"); | ||
} | ||
|
||
private void assertClearCompletedCommandSuccess() { | ||
commandBox.runCommand(ClearCommand.COMMAND_WORD + " completed"); | ||
assertListSize(0); | ||
assertResultMessage("Task List has been cleared!"); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,76 +1,78 @@ | ||
//package guitests; | ||
// | ||
//import static org.junit.Assert.assertEquals; | ||
//import static org.junit.Assert.assertFalse; | ||
//import static org.junit.Assert.assertTrue; | ||
// | ||
//import java.util.ArrayList; | ||
// | ||
//import org.junit.Before; | ||
//import org.junit.Test; | ||
// | ||
//import seedu.whatsnext.logic.commands.SelectCommand; | ||
//import seedu.whatsnext.ui.CommandBox; | ||
// | ||
//public class CommandBoxTest extends AddressBookGuiTest { | ||
// | ||
// private static final String COMMAND_THAT_SUCCEEDS = SelectCommand.COMMAND_WORD + " 3"; | ||
// private static final String COMMAND_THAT_FAILS = "invalid command"; | ||
// | ||
// private ArrayList<String> defaultStyleOfCommandBox; | ||
// private ArrayList<String> errorStyleOfCommandBox; | ||
// | ||
// @Before | ||
// public void setUp() { | ||
// defaultStyleOfCommandBox = new ArrayList<>(commandBox.getStyleClass()); | ||
// assertFalse("CommandBox default style classes should not contain error style class.", | ||
// defaultStyleOfCommandBox.contains(CommandBox.ERROR_STYLE_CLASS)); | ||
// | ||
// // build style class for error | ||
// errorStyleOfCommandBox = new ArrayList<>(defaultStyleOfCommandBox); | ||
// errorStyleOfCommandBox.add(CommandBox.ERROR_STYLE_CLASS); | ||
// } | ||
// | ||
// @Test | ||
// public void commandBox_startingWithSuccessfulCommand() { | ||
// assertBehaviorForSuccessfulCommand(); | ||
// assertBehaviorForFailedCommand(); | ||
// } | ||
// | ||
// @Test | ||
// public void commandBox_startingWithFailedCommand() { | ||
// assertBehaviorForFailedCommand(); | ||
// assertBehaviorForSuccessfulCommand(); | ||
// | ||
// // verify that style is changed correctly even after multiple consecutive successful/failed commands | ||
// assertBehaviorForSuccessfulCommand(); | ||
// assertBehaviorForFailedCommand(); | ||
// assertBehaviorForFailedCommand(); | ||
// assertBehaviorForSuccessfulCommand(); | ||
// } | ||
// | ||
// /** | ||
// * Runs a command that fails, then verifies that | ||
// * - the return value of runCommand(...) is false, | ||
// * - the text remains, | ||
// * - the command box has only one ERROR_STYLE_CLASS, with other style classes untouched. | ||
// */ | ||
// private void assertBehaviorForFailedCommand() { | ||
// assertFalse(commandBox.runCommand(COMMAND_THAT_FAILS)); | ||
// assertEquals(COMMAND_THAT_FAILS, commandBox.getCommandInput()); | ||
// assertEquals(errorStyleOfCommandBox, commandBox.getStyleClass()); | ||
// } | ||
// | ||
// /** | ||
// * Runs a command that succeeds, then verifies that | ||
// * - the return value of runCommand(...) is true, | ||
// * - the text is cleared, | ||
// * - the command box does not have any ERROR_STYLE_CLASS, with style classes the same as default. | ||
// */ | ||
// private void assertBehaviorForSuccessfulCommand() { | ||
// assertTrue(commandBox.runCommand(COMMAND_THAT_SUCCEEDS)); | ||
// assertEquals("", commandBox.getCommandInput()); | ||
// assertEquals(defaultStyleOfCommandBox, commandBox.getStyleClass()); | ||
// } | ||
// | ||
//} | ||
package guitests; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.ArrayList; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import seedu.whatsnext.logic.commands.SelectCommand; | ||
import seedu.whatsnext.ui.CommandBox; | ||
|
||
public class CommandBoxTest extends TaskManagerGuiTest { | ||
|
||
private static final String COMMAND_THAT_SUCCEEDS = SelectCommand.COMMAND_WORD + " 1"; | ||
private static final String COMMAND_THAT_FAILS = "invalid command"; | ||
|
||
private ArrayList<String> defaultStyleOfCommandBox; | ||
private ArrayList<String> errorStyleOfCommandBox; | ||
|
||
@Before | ||
public void setUp() { | ||
defaultStyleOfCommandBox = new ArrayList<>(commandBox.getStyleClass()); | ||
assertFalse("CommandBox default style classes should not contain error style class.", | ||
defaultStyleOfCommandBox.contains(CommandBox.ERROR_STYLE_CLASS)); | ||
|
||
// build style class for error | ||
errorStyleOfCommandBox = new ArrayList<>(defaultStyleOfCommandBox); | ||
errorStyleOfCommandBox.add(CommandBox.ERROR_STYLE_CLASS); | ||
} | ||
|
||
@Test | ||
public void commandBox_startingWithSuccessfulCommand() { | ||
commandBox.pressEnter(); | ||
assertBehaviorForSuccessfulCommand(); | ||
assertBehaviorForFailedCommand(); | ||
} | ||
|
||
@Test | ||
public void commandBox_startingWithFailedCommand() { | ||
commandBox.pressEnter(); | ||
assertBehaviorForFailedCommand(); | ||
assertBehaviorForSuccessfulCommand(); | ||
|
||
// verify that style is changed correctly even after multiple consecutive successful/failed commands | ||
assertBehaviorForSuccessfulCommand(); | ||
assertBehaviorForFailedCommand(); | ||
assertBehaviorForFailedCommand(); | ||
assertBehaviorForSuccessfulCommand(); | ||
} | ||
|
||
/** | ||
* Runs a command that fails, then verifies that | ||
* - the return value of runCommand(...) is false, | ||
* - the text remains, | ||
* - the command box has only one ERROR_STYLE_CLASS, with other style classes untouched. | ||
*/ | ||
private void assertBehaviorForFailedCommand() { | ||
assertFalse(commandBox.runCommand(COMMAND_THAT_FAILS)); | ||
assertEquals(COMMAND_THAT_FAILS, commandBox.getCommandInput()); | ||
assertEquals(errorStyleOfCommandBox, commandBox.getStyleClass()); | ||
} | ||
|
||
/** | ||
* Runs a command that succeeds, then verifies that | ||
* - the return value of runCommand(...) is true, | ||
* - the text is cleared, | ||
* - the command box does not have any ERROR_STYLE_CLASS, with style classes the same as default. | ||
*/ | ||
private void assertBehaviorForSuccessfulCommand() { | ||
assertTrue(commandBox.runCommand(COMMAND_THAT_SUCCEEDS)); | ||
assertEquals("", commandBox.getCommandInput()); | ||
assertEquals(defaultStyleOfCommandBox, commandBox.getStyleClass()); | ||
} | ||
|
||
} |
Oops, something went wrong.