Search in sources :

Example 11 with Subscribe

use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.

the class TodosActivityStoreTest method updateRawTodoListConnectedTest.

// Test:
// todoActionPerformed
@Test(timeout = 100)
public void updateRawTodoListConnectedTest() {
    final AtomicBoolean testDone = new AtomicBoolean(false);
    RawTodoList rawTodoList = new RawTodoList();
    dataBus.register(new Object() {

        @Subscribe
        public void onListUpdated(FilteredTodoList filteredTodoList) {
            assertThat(filteredTodoList.list.size()).isEqualTo(0);
            testDone.set(true);
        }
    });
    dataBus.post(rawTodoList);
    // Wait for test to finish or timeout
    while (!testDone.get()) ;
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FilteredTodoList(com.armueller.fluxytodo.data.FilteredTodoList) Subscribe(com.squareup.otto.Subscribe) RawTodoList(com.armueller.fluxytodo.data.RawTodoList) Test(org.junit.Test)

Example 12 with Subscribe

use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.

the class TodosActivityStoreTest method setEditModeActiveForTodoIdTest.

@Test(timeout = 100)
public void setEditModeActiveForTodoIdTest() {
    final AtomicBoolean testDone = new AtomicBoolean(false);
    DataBundle<ViewAction.DataKeys> bundle = new DataBundle<>();
    bundle.put(ViewAction.DataKeys.ID, 2);
    dataBus.post(new ViewAction(ViewAction.ActionTypes.MARK_EDITABLE, bundle));
    dataBus.register(new Object() {

        @Subscribe
        public void onListUpdated(Long todoId) {
            assertThat(todoId).isEqualTo(2);
            testDone.set(true);
        }
    });
    // Wait for test to finish or timeout
    while (!testDone.get()) ;
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DataBundle(com.armueller.fluxytodo.actions.DataBundle) ViewAction(com.armueller.fluxytodo.actions.ViewAction) Subscribe(com.squareup.otto.Subscribe) Test(org.junit.Test)

Example 13 with Subscribe

use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.

the class TodosActivityStoreTest method shouldNotShowUndoButtonTest.

@Test(timeout = 100)
public void shouldNotShowUndoButtonTest() {
    final AtomicBoolean testDone = new AtomicBoolean(false);
    dataBus.post(new TodoAction(TodoAction.ActionTypes.UNDO_DELETE_ALL));
    dataBus.register(new Object() {

        @Subscribe
        public void onListUpdated(Boolean shouldShowUndoButton) {
            assertThat(shouldShowUndoButton).isFalse();
            testDone.set(true);
        }
    });
    // Wait for test to finish or timeout
    while (!testDone.get()) ;
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Subscribe(com.squareup.otto.Subscribe) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TodoAction(com.armueller.fluxytodo.actions.TodoAction) Test(org.junit.Test)

Example 14 with Subscribe

use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.

the class TodosActivityStoreTest method changeActiveFilterToAllTest.

@Test(timeout = 100)
public void changeActiveFilterToAllTest() {
    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(3);
            assertThat(filteredTodoList.filter).isEqualTo(FilteredTodoList.Filter.ALL);
            testDone.set(true);
        }
    });
    dataBus.post(new ViewAction(ViewAction.ActionTypes.VIEW_ALL));
    // 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 15 with Subscribe

use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.

the class ActionCreatorTest method createDeleteTodoActionTest.

@Test
public void createDeleteTodoActionTest() {
    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.createDeleteTodoAction(10);
    while (!testDone.get()) ;
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Subscribe(com.squareup.otto.Subscribe) Test(org.junit.Test)

Aggregations

Subscribe (com.squareup.otto.Subscribe)85 Test (org.junit.Test)28 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)27 RawTodoList (com.armueller.fluxytodo.data.RawTodoList)13 ArrayList (java.util.ArrayList)12 TodoAction (com.armueller.fluxytodo.actions.TodoAction)9 VideoData (com.zype.android.webapi.model.video.VideoData)8 DataBundle (com.armueller.fluxytodo.actions.DataBundle)7 File (com.zype.android.webapi.model.player.File)7 Intent (android.content.Intent)6 FilteredTodoList (com.armueller.fluxytodo.data.FilteredTodoList)6 ConsumerFavoriteVideoData (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData)6 Bundle (android.os.Bundle)5 Video (com.zype.android.Db.Entity.Video)5 Consumer (com.zype.android.webapi.model.consumers.Consumer)5 IOException (java.io.IOException)5 Context (android.content.Context)4 ConnectivityManager (android.net.ConnectivityManager)4 NetworkInfo (android.net.NetworkInfo)4 Dialog (android.app.Dialog)3