コード例 #1
0
  public void testUnregisterSubscriber() {
    bus.register(subscriber);
    bus.post(new Event1("event1"));
    bus.unregister(subscriber);
    subscriber.clearEvents();

    bus.post(new Event1("event1"));
    subscriber.assertNoEvents();
  }
コード例 #2
0
  public void testSingleSubscriberOneEvent() {
    Event1 event;
    bus.register(subscriber);

    bus.post(event = new Event1("event1"));
    subscriber.assertSameEvents(event);
  }
コード例 #3
0
  public void testSingleSubscriberManyEvents() {

    Event1 event;
    bus.register(subscriber);

    ArrayList<Object> events = new ArrayList<Object>();
    for (int i = 0; i < 10; i++) {
      bus.post(event = new Event1("event1"));
      events.add(event);
    }
    subscriber.assertSameEventsList(events);
  }
コード例 #4
0
  public void testPostEventWithProducer() {

    // System.out.println("Current: " + Thread.currentThread());
    // System.out.println("Looper: " + Looper.getMainLooper().getThread());

    bus.register(producer);
    bus.register(subscriber);

    ArrayList<Object> events = new ArrayList<Object>();
    events.add(producer.lastEvent);

    Event1 event;
    bus.post(event = new Event1("second"));
    events.add(event);

    subscriber.assertSameEventsList(events);
  }
コード例 #5
0
 public void testProducerFirstWithNullEvent() {
   producer.lastEvent = null;
   bus.register(producer);
   bus.register(subscriber);
   subscriber.assertNoEvents();
 }
コード例 #6
0
 public void testUnregisterProducer() {
   bus.register(producer);
   bus.unregister(producer);
   bus.register(subscriber);
   subscriber.assertNoEvents();
 }
コード例 #7
0
 public void testProducerFirst() {
   bus.register(producer);
   bus.register(subscriber);
   subscriber.assertSameEvents(producer.lastEvent);
 }