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

Commit

Permalink
Add test to check for ongoing events
Browse files Browse the repository at this point in the history
  • Loading branch information
xiendong committed Nov 6, 2016
1 parent bfeb863 commit 3023cde
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/test/java/guitests/guihandles/TaskCardViewHandle.java
Expand Up @@ -124,6 +124,10 @@ public boolean isOverdueStyleApplied() {
return UiTestUtil.containsStyleClass(rootNode, "overdue");
}

public boolean isOngoingStyleApplied() {
return UiTestUtil.containsStyleClass(rootNode, "ongoing");
}

public boolean isTaskCardCollapsed() {
return UiTestUtil.containsStyleClass(rootNode, "collapsed");
}
Expand Down Expand Up @@ -159,6 +163,7 @@ public boolean isDisplayedCorrectly(int displayedIndex, ImmutableTask task) {
assertTrue(isTypeDisplayCorrect(task));
assertTrue(isPinDisplayCorrect(task));
assertTrue(isOverdueDisplayCorrect(task));
assertTrue(isOngoingDisplayCorrect(task));
return true;
}

Expand Down Expand Up @@ -250,6 +255,20 @@ private boolean isOverdueDisplayCorrect(ImmutableTask task) {
return expected == actual;
}

private boolean isOngoingDisplayCorrect(ImmutableTask task) {
java.util.Optional<LocalDateTime> startTime = task.getStartTime();
java.util.Optional<LocalDateTime> endTime = task.getEndTime();
boolean actual = isOngoingStyleApplied();
boolean expected;

if (startTime.isPresent() && endTime.isPresent()) {
expected = seedu.todo.testutil.TimeUtil.isOngoing(startTime.get(), endTime.get());
} else {
expected = false;
}
return expected == actual;
}

private boolean isTypeDisplayCorrect(ImmutableTask task) {
String actual = getDisplayedTypeLabel();
String expected;
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/seedu/todo/testutil/TimeUtil.java
Expand Up @@ -29,6 +29,16 @@ public static boolean isOverdue(LocalDateTime dueTime) {
return dueTime.isBefore(LocalDateTime.now());
}

/**
* Checks against system time if the provided time period is ongoing.
* @param startTime start time of the event
* @param endTime end time of the event
* @return Returns true if the provided time period surrounds the current time.
*/
public static boolean isOngoing(LocalDateTime startTime, LocalDateTime endTime) {
return startTime.isBefore(LocalDateTime.now()) && endTime.isAfter(LocalDateTime.now());
}

/**
* Gets the complete date time text in the following format:
* 12 August 2015, 12:34 PM
Expand Down

0 comments on commit 3023cde

Please sign in to comment.