Search in sources :

Example 11 with RawTodoList

use of com.armueller.fluxytodo.data.RawTodoList in project FluxyAndroidTodo by armueller.

the class TodoListManagerTest method completeAllTodosTest.

@Test(timeout = 100)
public void completeAllTodosTest() throws InterruptedException {
    final AtomicBoolean testDone = new AtomicBoolean(false);
    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.get(0).isComplete()) {
                actionBus.post(new TodoAction(TodoAction.ActionTypes.TOGGLE_ALL));
            } else {
                assertThat(todoItems.get(0).isComplete()).isTrue();
                assertThat(todoItems.get(1).isComplete()).isTrue();
                assertThat(todoItems.get(2).isComplete()).isTrue();
                testDone.set(true);
            }
        }
    });
    // Wait for test to finish or timeout
    while (!testDone.get()) ;
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ArrayList(java.util.ArrayList) Subscribe(com.squareup.otto.Subscribe) RawTodoList(com.armueller.fluxytodo.data.RawTodoList) TodoAction(com.armueller.fluxytodo.actions.TodoAction) Test(org.junit.Test)

Example 12 with RawTodoList

use of com.armueller.fluxytodo.data.RawTodoList in project FluxyAndroidTodo by armueller.

the class TodosActivityStoreTest method changeActiveFilterToActiveTest.

@Test(timeout = 100)
public void changeActiveFilterToActiveTest() {
    final AtomicBoolean testDone = new AtomicBoolean(false);
    ArrayList<TodoItem> list = new ArrayList<TodoItem>();
    list.add(new TodoItem(1, "Test", false));
    list.add(new TodoItem(2, "Test", true));
    list.add(new TodoItem(3, "Test", false));
    RawTodoList rawTodoList = new RawTodoList(list);
    dataBus.post(rawTodoList);
    dataBus.register(new Object() {

        @Subscribe
        public void onListUpdated(FilteredTodoList filteredTodoList) {
            assertThat(filteredTodoList.list.size()).isEqualTo(2);
            assertThat(filteredTodoList.filter).isEqualTo(FilteredTodoList.Filter.ACTIVE);
            testDone.set(true);
        }
    });
    dataBus.post(new ViewAction(ViewAction.ActionTypes.VIEW_ACTIVE));
    // Wait for test to finish or timeout
    while (!testDone.get()) ;
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TodoItem(com.armueller.fluxytodo.models.TodoItem) FilteredTodoList(com.armueller.fluxytodo.data.FilteredTodoList) ViewAction(com.armueller.fluxytodo.actions.ViewAction) ArrayList(java.util.ArrayList) Subscribe(com.squareup.otto.Subscribe) RawTodoList(com.armueller.fluxytodo.data.RawTodoList) Test(org.junit.Test)

Example 13 with RawTodoList

use of com.armueller.fluxytodo.data.RawTodoList in project FluxyAndroidTodo by armueller.

the class TodosActivityStoreTest method changeActiveFilterToCompleteTest.

@Test(timeout = 100)
public void changeActiveFilterToCompleteTest() {
    final AtomicBoolean testDone = new AtomicBoolean(false);
    ArrayList<TodoItem> list = new ArrayList<TodoItem>();
    list.add(new TodoItem(1, "Test", false));
    list.add(new TodoItem(2, "Test", true));
    list.add(new TodoItem(3, "Test", false));
    RawTodoList rawTodoList = new RawTodoList(list);
    dataBus.post(rawTodoList);
    dataBus.register(new Object() {

        @Subscribe
        public void onListUpdated(FilteredTodoList filteredTodoList) {
            assertThat(filteredTodoList.list.size()).isEqualTo(1);
            assertThat(filteredTodoList.filter).isEqualTo(FilteredTodoList.Filter.COMPLETE);
            testDone.set(true);
        }
    });
    dataBus.post(new ViewAction(ViewAction.ActionTypes.VIEW_COMPLETE));
    // Wait for test to finish or timeout
    while (!testDone.get()) ;
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TodoItem(com.armueller.fluxytodo.models.TodoItem) FilteredTodoList(com.armueller.fluxytodo.data.FilteredTodoList) ViewAction(com.armueller.fluxytodo.actions.ViewAction) ArrayList(java.util.ArrayList) Subscribe(com.squareup.otto.Subscribe) RawTodoList(com.armueller.fluxytodo.data.RawTodoList) Test(org.junit.Test)

Aggregations

RawTodoList (com.armueller.fluxytodo.data.RawTodoList)13 Subscribe (com.squareup.otto.Subscribe)13 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)12 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)9 TodoAction (com.armueller.fluxytodo.actions.TodoAction)6 DataBundle (com.armueller.fluxytodo.actions.DataBundle)5 FilteredTodoList (com.armueller.fluxytodo.data.FilteredTodoList)4 ViewAction (com.armueller.fluxytodo.actions.ViewAction)3 TodoItem (com.armueller.fluxytodo.models.TodoItem)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)1