Search in sources :

Example 1 with IEntryModelUpdateListener

use of com.newsrob.IEntryModelUpdateListener in project newsrob by marianokamp.

the class MarkAllReadDbQueryTests method executeMarkAllRead.

private void executeMarkAllRead(DBQuery dbq) throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    entryManager.addListener(new IEntryModelUpdateListener() {

        @Override
        public void statusUpdated() {
        }

        @Override
        public void modelUpdated(String atomId) {
        }

        @Override
        public void modelUpdated() {
            latch.countDown();
        }

        @Override
        public void modelUpdateStarted(boolean fastSyncOnly) {
        }

        @Override
        public void modelUpdateFinished(ModelUpdateResult result) {
        }
    });
    entryManager.requestMarkAllAsRead(dbq);
    latch.await(3, TimeUnit.SECONDS);
}
Also used : IEntryModelUpdateListener(com.newsrob.IEntryModelUpdateListener) ModelUpdateResult(com.newsrob.jobs.ModelUpdateResult) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 2 with IEntryModelUpdateListener

use of com.newsrob.IEntryModelUpdateListener in project newsrob by marianokamp.

the class PinTests method executeMarkAllRead.

private void executeMarkAllRead(DBQuery dbq) throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    entryManager.addListener(new IEntryModelUpdateListener() {

        @Override
        public void statusUpdated() {
        }

        @Override
        public void modelUpdated(String atomId) {
        }

        @Override
        public void modelUpdated() {
            latch.countDown();
        }

        @Override
        public void modelUpdateStarted(boolean fastSyncOnly) {
        }

        @Override
        public void modelUpdateFinished(ModelUpdateResult result) {
        }
    });
    entryManager.requestMarkAllAsRead(dbq);
    latch.await(3, TimeUnit.SECONDS);
}
Also used : IEntryModelUpdateListener(com.newsrob.IEntryModelUpdateListener) ModelUpdateResult(com.newsrob.jobs.ModelUpdateResult) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 3 with IEntryModelUpdateListener

use of com.newsrob.IEntryModelUpdateListener in project newsrob by marianokamp.

the class MarkReadUntilHereUITests method doReadUntilHereWithConfirmationDialog.

private void doReadUntilHereWithConfirmationDialog(boolean positive) throws InterruptedException {
    setMarkAllReadConfirmationThreshold(1);
    final CountDownLatch latch = new CountDownLatch(1);
    entryManager.addListener(new IEntryModelUpdateListener() {

        @Override
        public void statusUpdated() {
        }

        @Override
        public void modelUpdated(String atomId) {
        }

        @Override
        public void modelUpdated() {
            latch.countDown();
        }

        @Override
        public void modelUpdateStarted(boolean fastSyncOnly) {
        }

        @Override
        public void modelUpdateFinished(ModelUpdateResult result) {
        }
    });
    sendKeys("DPAD_DOWN DPAD_DOWN DPAD_DOWN DPAD_DOWN");
    assertEquals(3, getActivity().getListView().getSelectedItemPosition());
    getInstrumentation().waitForIdleSync();
    getInstrumentation().invokeContextMenuAction(getActivity(), 112, 0);
    getInstrumentation().waitForIdleSync();
    if (positive)
        sendKeys("DPAD_CENTER");
    else
        sendKeys("DPAD_RIGHT DPAD_RIGHT DPAD_CENTER");
    getInstrumentation().waitForIdleSync();
    boolean reachedZero = latch.await(3000, TimeUnit.MILLISECONDS);
    if (positive)
        // Scream if timeout
        assertTrue(reachedZero);
}
Also used : IEntryModelUpdateListener(com.newsrob.IEntryModelUpdateListener) ModelUpdateResult(com.newsrob.jobs.ModelUpdateResult) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 4 with IEntryModelUpdateListener

use of com.newsrob.IEntryModelUpdateListener in project newsrob by marianokamp.

the class MarkReadUntilHereUITests method executeMarkReadUntilHereOnCurrentSelection.

private void executeMarkReadUntilHereOnCurrentSelection() throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(1);
    entryManager.addListener(new IEntryModelUpdateListener() {

        @Override
        public void statusUpdated() {
        }

        @Override
        public void modelUpdated(String atomId) {
        }

        @Override
        public void modelUpdated() {
            latch.countDown();
        }

        @Override
        public void modelUpdateStarted(boolean fastSyncOnly) {
        }

        @Override
        public void modelUpdateFinished(ModelUpdateResult result) {
        }
    });
    getInstrumentation().invokeContextMenuAction(getActivity(), 112, 0);
    getInstrumentation().waitForIdleSync();
    // Scream if timeout
    assertTrue(latch.await(3, TimeUnit.SECONDS));
}
Also used : IEntryModelUpdateListener(com.newsrob.IEntryModelUpdateListener) ModelUpdateResult(com.newsrob.jobs.ModelUpdateResult) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 5 with IEntryModelUpdateListener

use of com.newsrob.IEntryModelUpdateListener in project newsrob by marianokamp.

the class LikeStateTests method testUpdateNotification.

public void testUpdateNotification() {
    entryManager.addListener(new IEntryModelUpdateListener() {

        @Override
        public void statusUpdated() {
        }

        @Override
        public void modelUpdated(String atomId) {
            modelUpdatedStringCalled = true;
        }

        @Override
        public void modelUpdated() {
            modelUpdatedCalled = true;
        }

        @Override
        public void modelUpdateStarted(boolean fastSyncOnly) {
        }

        @Override
        public void modelUpdateFinished(ModelUpdateResult result) {
        }
    });
    Entry e = findEntryNotLikedNotLikePending();
    assertTrue(modelUpdatedCalled);
}
Also used : IEntryModelUpdateListener(com.newsrob.IEntryModelUpdateListener) Entry(com.newsrob.Entry) ModelUpdateResult(com.newsrob.jobs.ModelUpdateResult)

Aggregations

IEntryModelUpdateListener (com.newsrob.IEntryModelUpdateListener)5 ModelUpdateResult (com.newsrob.jobs.ModelUpdateResult)5 CountDownLatch (java.util.concurrent.CountDownLatch)4 Entry (com.newsrob.Entry)1