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.
- Loading branch information
Showing
7 changed files
with
122 additions
and
2 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
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,37 @@ | ||
package seedu.todo.guitests; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.junit.Test; | ||
|
||
import seedu.todo.controllers.CommandDefinition; | ||
import seedu.todo.controllers.HelpController; | ||
import seedu.todo.guitests.guihandles.HelpItemHandle; | ||
|
||
public class HelpCommandTest extends GuiTest { | ||
|
||
@Test | ||
public void help_show_success() { | ||
console.runCommand("help"); | ||
assertTrue(helpView.hasLoaded()); | ||
|
||
// Make sure all command items have loaded | ||
for (CommandDefinition commandDefinition : new HelpController().getAllCommandDefinitions()) { | ||
HelpItemHandle helpItem = helpView.getHelpItem(commandDefinition); | ||
assertNotNull(helpItem); | ||
} | ||
} | ||
|
||
@Test | ||
public void help_extraArguments_noDifference() { | ||
console.runCommand("help me i'm drowning"); | ||
assertTrue(helpView.hasLoaded()); | ||
|
||
// Make sure all command items have loaded | ||
for (CommandDefinition commandDefinition : new HelpController().getAllCommandDefinitions()) { | ||
HelpItemHandle helpItem = helpView.getHelpItem(commandDefinition); | ||
assertNotNull(helpItem); | ||
} | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/test/java/seedu/todo/guitests/guihandles/HelpItemHandle.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,38 @@ | ||
package seedu.todo.guitests.guihandles; | ||
|
||
import javafx.scene.Node; | ||
import javafx.stage.Stage; | ||
import seedu.todo.controllers.CommandDefinition; | ||
import seedu.todo.guitests.GuiRobot; | ||
|
||
public class HelpItemHandle extends GuiHandle { | ||
|
||
private static final String COMMAND_NAME_TEXT_ID = "#commandNameText"; | ||
private static final String COMMAND_SYNTAX_TEXT_ID = "#commandSyntaxText"; | ||
private static final String COMMAND_DESC_TEXT_ID = "#commandDescriptionText"; | ||
private Node node; | ||
|
||
public HelpItemHandle(GuiRobot guiRobot, Stage primaryStage, Node node){ | ||
super(guiRobot, primaryStage, null); | ||
this.node = node; | ||
} | ||
|
||
public String getCommandName() { | ||
return getStringFromText(COMMAND_NAME_TEXT_ID, node); | ||
} | ||
|
||
public String getCommandSyntax() { | ||
return getStringFromText(COMMAND_SYNTAX_TEXT_ID, node); | ||
} | ||
|
||
public String getCommandDescription() { | ||
return getStringFromText(COMMAND_DESC_TEXT_ID, node); | ||
} | ||
|
||
public boolean isEqualsTo(CommandDefinition commandDefinition) { | ||
return getCommandName().equals(commandDefinition.getCommandName()) | ||
&& getCommandSyntax().equals(commandDefinition.getCommandSyntax()) | ||
&& getCommandDescription().equals(commandDefinition.getCommandDescription()); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/test/java/seedu/todo/guitests/guihandles/HelpViewHandle.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,38 @@ | ||
package seedu.todo.guitests.guihandles; | ||
|
||
import java.util.Optional; | ||
|
||
import javafx.scene.Node; | ||
import javafx.stage.Stage; | ||
import seedu.todo.controllers.CommandDefinition; | ||
import seedu.todo.guitests.GuiRobot; | ||
|
||
//@@author A0139812A | ||
public class HelpViewHandle extends GuiHandle { | ||
|
||
private static final String HELPVIEW_PLACEHOLDER_ID = "#helpCommandsPlaceholder"; | ||
private static final String HELP_ITEM_ID = "#helpCommandItem"; | ||
|
||
public HelpViewHandle(GuiRobot guiRobot, Stage primaryStage, String stageTitle) { | ||
super(guiRobot, primaryStage, stageTitle); | ||
} | ||
|
||
/** | ||
* Checks for the existence of a child element to determine if the view has loaded correctly. | ||
*/ | ||
public boolean hasLoaded() { | ||
return guiRobot.lookup(HELPVIEW_PLACEHOLDER_ID).queryAll().size() > 0; | ||
} | ||
|
||
public HelpItemHandle getHelpItem(CommandDefinition commandDefinition) { | ||
Optional<Node> itemNode = guiRobot.lookup(HELP_ITEM_ID).queryAll().stream() | ||
.filter(node -> new HelpItemHandle(guiRobot, primaryStage, node).isEqualsTo(commandDefinition)) | ||
.findFirst(); | ||
|
||
if (itemNode.isPresent()) { | ||
return new HelpItemHandle(guiRobot, primaryStage, itemNode.get()); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
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