use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.
the class ActionCreatorTest method createViewCompleteTodosActionTest.
@Test
public void createViewCompleteTodosActionTest() {
final AtomicBoolean testDone = new AtomicBoolean(false);
actionBus.register(new Object() {
@Subscribe
public void addTodo(ViewAction action) {
assertThat(action.getType()).isEqualTo(ViewAction.ActionTypes.VIEW_COMPLETE);
testDone.set(true);
}
});
actionCreator.createViewCompleteTodosAction();
while (!testDone.get()) ;
}
use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.
the class ActionCreatorTest method createToggleTodoCompleteActionTest.
@Test
public void createToggleTodoCompleteActionTest() {
final AtomicBoolean testDone = new AtomicBoolean(false);
actionBus.register(new Object() {
@Subscribe
public void addTodo(TodoAction action) {
assertThat(action.getData().get(TodoAction.DataKeys.ID, -1)).isEqualTo(10);
testDone.set(true);
}
});
actionCreator.createToggleTodoCompleteAction(10);
while (!testDone.get()) ;
}
use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.
the class TodoListManagerTest method createMultipleTodosTest.
@Test(timeout = 100)
public void createMultipleTodosTest() throws InterruptedException {
final AtomicBoolean testDone = new AtomicBoolean(false);
createTodos(4);
dataBus.register(new Object() {
@Subscribe
public void onListUpdated(RawTodoList rawTodoList) {
assertThat(rawTodoList.list.size()).isEqualTo(4);
testDone.set(true);
}
});
// Wait for test to finish or timeout
while (!testDone.get()) ;
}
use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.
the class TodoListManagerTest method deleteTodoTest.
@Test(timeout = 100)
public void deleteTodoTest() throws InterruptedException {
final AtomicBoolean testDone = new AtomicBoolean(false);
final AtomicLong deletedId = new AtomicLong(-1);
final ArrayList<TodoItem> todoItems = new ArrayList<TodoItem>();
createTodos(3);
dataBus.register(new Object() {
@Subscribe
public void onListUpdated(RawTodoList rawTodoList) {
todoItems.clear();
todoItems.addAll(rawTodoList.list);
if (todoItems.size() == 3) {
deletedId.set(todoItems.get(1).getId());
DataBundle<TodoAction.DataKeys> bundle = new DataBundle<>();
bundle.put(TodoAction.DataKeys.ID, todoItems.get(1).getId());
actionBus.post(new TodoAction(TodoAction.ActionTypes.DELETE, bundle));
} else {
assertThat(todoItems.size()).isEqualTo(2);
assertThat(todoItems.get(0).getId()).isNotEqualTo(deletedId.get());
assertThat(todoItems.get(1).getId()).isNotEqualTo(deletedId.get());
testDone.set(true);
}
}
});
// Wait for test to finish or timeout
while (!testDone.get()) ;
}
use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.
the class TodoListManagerTest method undoDeleteAllCompleteTodosTest.
@Test(timeout = 100)
public void undoDeleteAllCompleteTodosTest() throws InterruptedException {
final AtomicBoolean testDone = new AtomicBoolean(false);
final AtomicBoolean checkedTodo1 = new AtomicBoolean(false);
final AtomicBoolean checkedTodo3 = new AtomicBoolean(false);
final AtomicBoolean deletedTodos = new AtomicBoolean(false);
final AtomicBoolean undidDelete = new AtomicBoolean(false);
final ArrayList<TodoItem> todoItems = new ArrayList<TodoItem>();
createTodos(4);
dataBus.register(new Object() {
@Subscribe
public void onListUpdated(RawTodoList rawTodoList) {
todoItems.clear();
todoItems.addAll(rawTodoList.list);
if (!checkedTodo1.get()) {
checkedTodo1.set(true);
DataBundle<TodoAction.DataKeys> bundle = new DataBundle<>();
bundle.put(TodoAction.DataKeys.ID, todoItems.get(1).getId());
actionBus.post(new TodoAction(TodoAction.ActionTypes.TOGGLE, bundle));
return;
}
if (!checkedTodo3.get()) {
checkedTodo3.set(true);
DataBundle<TodoAction.DataKeys> bundle = new DataBundle<>();
bundle.put(TodoAction.DataKeys.ID, todoItems.get(3).getId());
actionBus.post(new TodoAction(TodoAction.ActionTypes.TOGGLE, bundle));
return;
}
if (!deletedTodos.get() && checkedTodo1.get() && checkedTodo3.get()) {
deletedTodos.set(true);
actionBus.post(new TodoAction(TodoAction.ActionTypes.DELETE_ALL));
return;
}
if (!undidDelete.get() && deletedTodos.get()) {
undidDelete.set(true);
actionBus.post(new TodoAction(TodoAction.ActionTypes.UNDO_DELETE_ALL));
return;
}
if (undidDelete.get() && deletedTodos.get()) {
assertThat(todoItems.size()).isEqualTo(4);
testDone.set(true);
}
}
});
// Wait for test to finish or timeout
while (!testDone.get()) ;
}
Aggregations