Search in sources :

Example 1 with RxEventBus

use of org.odk.collect.android.events.RxEventBus in project collect by opendatakit.

the class RxEventBusTest method testEventType.

/**
 * Ensures that the register method of the RxEvent Bus is filtering events appropriately.
 * The assertValue method of TestObserver is used instead of AssertResult because
 * AssertResult is used to check for completeness and RxRelay's main objective is
 * to get rid of onComplete and onError that could damage a stream especially in the case
 * of a bus.
 */
@Test
public void testEventType() {
    RxEventBus bus = new RxEventBus();
    CoolerDummyEvent event = new CoolerDummyEvent();
    // RxEvent that won't get propagated to the observer.
    DummyEvent dummyEvent = new DummyEvent();
    TestObserver<CoolerDummyEvent> testObserver = bus.register(CoolerDummyEvent.class).test();
    bus.post(event);
    bus.post(dummyEvent);
    testObserver.assertValue(event);
}
Also used : RxEventBus(org.odk.collect.android.events.RxEventBus) Test(org.junit.Test)

Example 2 with RxEventBus

use of org.odk.collect.android.events.RxEventBus in project collect by opendatakit.

the class RxEventBusTest method testEventBusSubscription.

/**
 * Verifies that when subscription takes place the Subject knows this has
 * happened.
 */
@Test
public void testEventBusSubscription() {
    RxEventBus bus = new RxEventBus();
    assertFalse(bus.getBusSubject().hasObservers());
    TestObserver<RxEvent> testObserver = bus.register(RxEvent.class).test();
    testObserver.assertSubscribed();
    assertTrue(bus.getBusSubject().hasObservers());
}
Also used : RxEventBus(org.odk.collect.android.events.RxEventBus) RxEvent(org.odk.collect.android.events.RxEvent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 RxEventBus (org.odk.collect.android.events.RxEventBus)2 RxEvent (org.odk.collect.android.events.RxEvent)1