indent tests pass woo

pull/14/head
Tim Su 15 years ago
parent 515b3dcf07
commit 7117b90093

@ -11,10 +11,12 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.GtasksIndentAction.GtasksDecreaseIndentAction; import com.todoroo.astrid.gtasks.GtasksIndentAction.GtasksDecreaseIndentAction;
import com.todoroo.astrid.gtasks.GtasksIndentAction.GtasksIncreaseIndentAction; import com.todoroo.astrid.gtasks.GtasksIndentAction.GtasksIncreaseIndentAction;
import com.todoroo.astrid.test.DatabaseTestCase; import com.todoroo.astrid.test.DatabaseTestCase;
import com.todoroo.gtasks.GoogleTaskListInfo;
public class GtasksIndentActionTest extends DatabaseTestCase { public class GtasksIndentActionTest extends DatabaseTestCase {
@Autowired private GtasksMetadataService gtasksMetadataService; @Autowired private GtasksMetadataService gtasksMetadataService;
@Autowired private GtasksListService gtasksListService;
private Task task; private Task task;
@ -23,7 +25,7 @@ public class GtasksIndentActionTest extends DatabaseTestCase {
whenTrigger(new GtasksIncreaseIndentAction()); whenTrigger(new GtasksIncreaseIndentAction());
thenExpectIndentationLevel(1); // should not crash
} }
public void testIndentWithMetadataButNoOtherTasks() { public void testIndentWithMetadataButNoOtherTasks() {
@ -56,7 +58,7 @@ public class GtasksIndentActionTest extends DatabaseTestCase {
whenTrigger(new GtasksDecreaseIndentAction()); whenTrigger(new GtasksDecreaseIndentAction());
thenExpectIndentationLevel(0); // should not crash
} }
public void testDeindentWhenAlreadyZero() { public void testDeindentWhenAlreadyZero() {
@ -91,13 +93,13 @@ public class GtasksIndentActionTest extends DatabaseTestCase {
public void testIndentWithSiblings() { public void testIndentWithSiblings() {
taskWithMetadata(0, 0); taskWithMetadata(0, 0);
givenTask(taskWithMetadata(1, 1)); givenTask(taskWithMetadata(1, 0));
Task sibling = taskWithMetadata(2, 1); Task sibling = taskWithMetadata(2, 0);
whenTrigger(new GtasksIncreaseIndentAction()); whenTrigger(new GtasksIncreaseIndentAction());
thenExpectIndentationLevel(2); thenExpectIndentationLevel(1);
thenExpectIndentationLevel(sibling, 1); thenExpectIndentationLevel(sibling, 0);
} }
public void testIndentWithChildrensChildren() { public void testIndentWithChildrensChildren() {
@ -115,6 +117,16 @@ public class GtasksIndentActionTest extends DatabaseTestCase {
// --- helpers // --- helpers
@Override
protected void setUp() throws Exception {
super.setUp();
GoogleTaskListInfo[] lists = new GoogleTaskListInfo[1];
GoogleTaskListInfo list = new GoogleTaskListInfo("list", "Test Tasks");
lists[0] = list;
gtasksListService.updateLists(lists);
}
private Task taskWithMetadata(int order, int indentation) { private Task taskWithMetadata(int order, int indentation) {
Task task = new Task(); Task task = new Task();
PluginServices.getTaskService().save(task); PluginServices.getTaskService().save(task);

Loading…
Cancel
Save