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);
}
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());
}
Aggregations