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

Commit

Permalink
Merge f46d9bf into 60e8213
Browse files Browse the repository at this point in the history
  • Loading branch information
Wang Xien Dong committed Nov 6, 2016
2 parents 60e8213 + f46d9bf commit 8ea6723
Show file tree
Hide file tree
Showing 21 changed files with 781 additions and 34 deletions.
1 change: 1 addition & 0 deletions src/main/java/seedu/todo/commons/util/CollectionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.HashSet;
import java.util.Set;

//@@author reused
/**
* Utility methods related to Collections
*/
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/seedu/todo/logic/commands/CommandSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ public CommandSummary(String scenario, String command, String arguments) {
this.command = command.toLowerCase().trim();
this.arguments = arguments.trim();
}

//@@author A0135805H
/**
* Re-represents this {@link CommandSummary} as an array of strings in the following format:
* [Scenario, Command, Arguments]
*/
public String[] toArray() {
return new String[] {scenario, command, arguments};
}
}
6 changes: 2 additions & 4 deletions src/main/java/seedu/todo/ui/view/GlobalTagView.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static GlobalTagView load(Stage primaryStage, AnchorPane placeholder) {
}

/**
* Configure the UI layout of {@link globalTagView}
* Configure the UI layout of {@link GlobalTagView}
*/
private void configureLayout() {
FxViewUtil.applyAnchorBoundaryParameters(globalTagViewPanel, 0.0, 0.0, 0.0, 0.0);
Expand All @@ -75,9 +75,7 @@ private Label constructTagLabel(Tag tag) {
public void displayGlobalTags(Collection<Tag> globalTags) {
this.showGlobalTagViewPanel();
tagFlowPane.getChildren().clear();
for (Tag tag : globalTags){
appendTag(tag);
}
globalTags.forEach(this::appendTag);
}

/* Ui Methods */
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/style/DefaultStyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
.roundLabel.white {
-fx-text-fill: #2D2D2D;
-fx-background-color: #f3f3f3;
-fx-font-size: 12pt;
}

/***View Filter Styles Start***/
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/view/FilterBarView.fxml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--@@author generated-->

<?import javafx.scene.layout.FlowPane?>

<FlowPane alignment="CENTER_LEFT" maxWidth="-Infinity" minWidth="-Infinity" styleClass="viewFilter"
xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="seedu.todo.ui.view.FilterBarView">

<FlowPane fx:id="filterBarView" alignment="CENTER_LEFT" maxWidth="-Infinity" minWidth="-Infinity" styleClass="viewFilter" xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seedu.todo.ui.view.FilterBarView">
</FlowPane>
20 changes: 13 additions & 7 deletions src/main/resources/view/GlobalTagView.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@

<!--@@author generated-->

<?import java.lang.String?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

<VBox minWidth="-Infinity" style="-fx-background-color: #2D2D2D;" styleClass="spacing grey" stylesheets="@../style/DefaultStyle.css" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seedu.todo.ui.view.GlobalTagView">
<VBox fx:id="globalTagViewPanel" minHeight="-Infinity" minWidth="-Infinity" style="-fx-background-color: #2D2D2D;" styleClass="spacing grey" stylesheets="@../style/DefaultStyle.css" xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seedu.todo.ui.view.GlobalTagView">
<HBox alignment="CENTER_LEFT" minHeight="-Infinity" minWidth="-Infinity" styleClass="spacing">
<Label alignment="TOP_LEFT" prefHeight="30.0" prefWidth="196.0" styleClass="text2" text="Tags" />
<padding>
<Insets bottom="16.0" />
</padding>
<Label alignment="TOP_LEFT" styleClass="text2" text="Tags" />
<Label styleClass="text4" text="All your tags in one place." />
<VBox.margin>
<Insets bottom="8.0" />
<Insets />
</VBox.margin>
</HBox>
<FlowPane fx:id="tagFlowPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="-Infinity" styleClass="spacing" />
<FlowPane fx:id="tagFlowPane" minWidth="-Infinity">
<VBox.margin>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
</VBox.margin>
<styleClass>
<String fx:value="spacing" />
<String fx:value="gridPanel" />
</styleClass></FlowPane>
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
Expand Down
22 changes: 10 additions & 12 deletions src/main/resources/view/HelpView.fxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--@@author generated-->

<?import javafx.geometry.Insets?>
Expand All @@ -9,28 +10,25 @@
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>

<VBox maxHeight="-Infinity" maxWidth="-Infinity" minWidth="-Infinity"
styleClass="spacing, grey" stylesheets="@../style/DefaultStyle.css" xmlns="http://javafx.com/javafx/8.0.102"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="seedu.todo.ui.view.HelpView">
<VBox fx:id="helpPanelView" maxHeight="-Infinity" maxWidth="-Infinity" minWidth="-Infinity" styleClass="spacing, grey" stylesheets="@../style/DefaultStyle.css" xmlns="http://javafx.com/javafx/8.0.102" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seedu.todo.ui.view.HelpView">
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0"/>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
</padding>
<HBox alignment="CENTER_LEFT" styleClass="spacing">
<Label styleClass="text2" text="Help"/>
<Label styleClass="text4" text="Need help? Try these commands out to get started."/>
<Label styleClass="text2" text="Help" />
<Label styleClass="text4" text="Need help? Try these commands out to get started." />
</HBox>
<GridPane fx:id="helpGrid" styleClass="gridPanel">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity"/>
<ColumnConstraints hgrow="SOMETIMES" minWidth="-Infinity"/>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="-Infinity" />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="SOMETIMES"/>
<RowConstraints vgrow="SOMETIMES" />
</rowConstraints>
<VBox.margin>
<Insets/>
<Insets />
</VBox.margin>
</GridPane>
<Label alignment="CENTER_RIGHT" contentDisplay="TEXT_ONLY" styleClass="text4"
text="Start typing in the command to dismiss."/>
<Label alignment="CENTER_RIGHT" contentDisplay="TEXT_ONLY" styleClass="text4" text="Start typing in the command to dismiss." />
</VBox>
8 changes: 4 additions & 4 deletions src/main/resources/view/SearchStatusView.fxml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--@@author generated-->

<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.Text?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.text.Text?>

<StackPane maxWidth="Infinity" prefHeight="24" styleClass="searchStatus"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="seedu.todo.ui.view.SearchStatusView">
<HBox minWidth="0" maxWidth="Infinity" spacing="2.0" StackPane.alignment="CENTER_LEFT">
<StackPane fx:id="searchStatusView" maxWidth="Infinity" prefHeight="24" styleClass="searchStatus" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.102" fx:controller="seedu.todo.ui.view.SearchStatusView">
<HBox maxWidth="Infinity" minWidth="0" spacing="2.0" StackPane.alignment="CENTER_LEFT">
<Text styleClass="searchLabel">Searching for:</Text>
<Text fx:id="searchTerm" styleClass="searchTerm" text="search terms" />
</HBox>
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/guitests/AddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ public void add_addManyRandom() {
randomTaskList.forEach(this::executeAddTestHelper);
}

@Test
public void add_invalidParameters() {
//No title
assertErrorViewDisplayed("add /d tomorrow");

//Wrong date
assertErrorViewDisplayed("add some task /d hehe");

//Invalid tag
assertErrorViewDisplayed("add invalid tag /t oops!");
}

/* Helper Methods */
/**
* Gets the index of the newly added task.
Expand All @@ -107,6 +119,9 @@ private void executeAddCommand(ImmutableTask task) {
runCommand(commandText);
}

/**
* Asserts that specific view scenarios are displayed correctly.
*/
private void assertCorrectnessHelper(ImmutableTask newTask) {
int addedIndex = getNewlyAddedTaskIndex();
TaskCardViewHandle taskCardHandle = todoListView.getTaskCardViewHandle(addedIndex);
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/guitests/DeleteCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ public void delete_allTasks() {
}
}

@Test
public void delete_invalidCommands() {
//Missing Index
assertErrorViewDisplayed("delete ");

//Invalid Index
assertErrorViewDisplayed("delete a");
}

/**
* A helper method to run the entire delete command process and testing.
*/
Expand Down
51 changes: 51 additions & 0 deletions src/test/java/guitests/HelpCommandTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package guitests;

import org.junit.Test;
import seedu.todo.logic.commands.CommandMap;
import seedu.todo.logic.commands.CommandSummary;

import java.util.List;
import java.util.stream.Collectors;

import static org.junit.Assert.assertTrue;

//@@author A0135805H
/**
* Tests the display of help command.
*/
public class HelpCommandTest extends TodoListGuiTest {

@Test
public void help_showHelpPanelWithFull() {
//Should display help with the complete "help" word.
runCommand("help");
assertHelpViewDisplayed();
}

@Test
public void help_showHelpPanelWithShort() {
//Should display help with an incomplete word of "help".
runCommand("h");
assertHelpViewDisplayed();
}

/**
* Helper method to check if the help view is shown, and the content is correctly displayed.
*/
private void assertHelpViewDisplayed() {
assertTrue(helpView.isVisible());
assertTrue(helpView.isHelpItemsDisplayedCorrectly(getAllCommandSummaryArray()));
}

/* Helper Methods */
/**
* Get a representation of the command summary by a list of array strings, where each item has the
* following format:
* [Scenario, Command, Arguments]
*/
private List<String[]> getAllCommandSummaryArray() {
return CommandMap.getAllCommandSummary().stream()
.map(CommandSummary::toArray)
.collect(Collectors.toList());
}
}
86 changes: 86 additions & 0 deletions src/test/java/guitests/TagCommandTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package guitests;

import com.google.common.collect.Sets;
import org.junit.Test;
import seedu.todo.model.TodoList;
import seedu.todo.model.tag.Tag;
import seedu.todo.model.task.ImmutableTask;
import seedu.todo.testutil.TaskBuilder;
import seedu.todo.testutil.TaskFactory;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

//@@author A0135805H
/**
* Tests the tag command, including:
* 1. Display the global list of tags.
* 2. TODO: CRUD of tags.
*/
public class TagCommandTest extends TodoListGuiTest {

@Override
protected TodoList getInitialData() {
List<ImmutableTask> tasks = new ArrayList<>();

//Initialise some dummy tasks with tags.
for (int numOfTags = 0; numOfTags <= 5; numOfTags ++) {
String[] listOfTagNames = TaskFactory.randomTags(numOfTags);

ImmutableTask task = TaskBuilder.name(TaskFactory.taskTitle())
.tagged(listOfTagNames).build();

tasks.add(task);
}

return getInitialDataHelper(tasks);
}

/* Actual Tests */
@Test
public void tags_displayGlobalTagList() {
//Check that all the tags are displayed, and they are unique.
runCommand("tag");
List<String> displayedTagNames = globalTagView.getDisplayedTags();
assertNoDuplicate(displayedTagNames);
assertEqualTagNames(getTagList(todoListView.getImmutableTaskList()),
Sets.newHashSet(displayedTagNames));
}

/* Helper Method */
/**
* Get the list of tags given a listof {@code tasks}
*/
private Set<String> getTagList(List<ImmutableTask> tasks) {
Set<String> listOfTagNames = new HashSet<>();
tasks.forEach(task -> listOfTagNames.addAll(Tag.getLowerCaseNames(task.getTags())));
return listOfTagNames;
}

/**
* Asserts that two sets are equal (with no case sensitivity)
*/
private void assertEqualTagNames(Set<String> tagNames1, Set<String> tagNames2) {
tagNames1 = tagNames1.stream()
.map(String::toLowerCase)
.collect(Collectors.toSet());
tagNames2 = tagNames2.stream()
.map(String::toLowerCase)
.collect(Collectors.toSet());
assertEquals(tagNames1, tagNames2);
}

/**
* Asserts that there are no duplicate strings
*/
private void assertNoDuplicate(List<String> strings) {
Set<String> stringSet = new HashSet<>(strings);
assertTrue(strings.size() == stringSet.size());
}
}

0 comments on commit 8ea6723

Please sign in to comment.