Search in sources :

Example 21 with TestKeyWithScope

use of com.zhuinden.simplestack.helpers.TestKeyWithScope in project simple-stack by Zhuinden.

the class ScopingBackEventDispatchTest method onBackStackGoBackDispatchesBackToActiveScope.

@Test
public void onBackStackGoBackDispatchesBackToActiveScope() {
    final HandlesBackOnce service1 = new HandlesBackOnce();
    final HandlesBackOnce service2 = new HandlesBackOnce();
    Object key1 = new TestKeyWithScope("key1") {

        @Override
        public void bindServices(ServiceBinder serviceBinder) {
            serviceBinder.addService("service1", service1);
        }
    };
    Object key2 = new TestKeyWithScope("key2") {

        @Override
        public void bindServices(ServiceBinder serviceBinder) {
            serviceBinder.addService("service2", service2);
        }
    };
    Backstack backstack = new Backstack();
    backstack.setScopedServices(new ServiceProvider());
    backstack.setup(History.of(key1, key2));
    backstack.setStateChanger(new StateChanger() {

        @Override
        public void handleStateChange(@Nonnull StateChange stateChange, @Nonnull Callback completionCallback) {
            completionCallback.stateChangeComplete();
        }
    });
    assertThat(service2.handledBackOnce).isEqualTo(false);
    boolean handledBack = backstack.goBack();
    assertThat(handledBack).isEqualTo(true);
    assertThat(service2.handledBackOnce).isEqualTo(true);
    assertThat(backstack.getHistory()).containsExactly(key1, key2);
    assertThat(backstack.getHistory()).containsExactly(key1, key2);
    assertThat(service2.handledBackOnce).isEqualTo(true);
    handledBack = backstack.goBack();
    assertThat(handledBack).isEqualTo(true);
    assertThat(service2.handledBackOnce).isEqualTo(true);
    assertThat(backstack.getHistory()).containsExactly(key1);
    assertThat(service1.handledBackOnce).isEqualTo(false);
    handledBack = backstack.goBack();
    assertThat(handledBack).isEqualTo(true);
    assertThat(service1.handledBackOnce).isEqualTo(true);
    handledBack = backstack.goBack();
    assertThat(handledBack).isEqualTo(false);
}
Also used : TestKeyWithScope(com.zhuinden.simplestack.helpers.TestKeyWithScope) ServiceProvider(com.zhuinden.simplestack.helpers.ServiceProvider) Test(org.junit.Test)

Example 22 with TestKeyWithScope

use of com.zhuinden.simplestack.helpers.TestKeyWithScope in project simple-stack by Zhuinden.

the class ScopingBackEventDispatchTest method onBackDispatchExecutesEvenIfNoStateChanger.

@Test
public void onBackDispatchExecutesEvenIfNoStateChanger() {
    final HandlesBackOnce service = new HandlesBackOnce();
    Object key = new TestKeyWithScope("key") {

        @Override
        public void bindServices(ServiceBinder serviceBinder) {
            serviceBinder.addService("service", service);
        }
    };
    Backstack backstack = new Backstack();
    backstack.setScopedServices(new ServiceProvider());
    backstack.setup(History.of(key));
    StateChanger stateChanger = new StateChanger() {

        @Override
        public void handleStateChange(@Nonnull StateChange stateChange, @Nonnull Callback completionCallback) {
            completionCallback.stateChangeComplete();
        }
    };
    backstack.setStateChanger(stateChanger);
    assertThat(backstack.getHistory()).containsExactly(key);
    backstack.detachStateChanger();
    boolean handled = backstack.goBack();
    assertThat(handled).isTrue();
    assertThat(service.handledBackOnce).isTrue();
    // returns `false` even if no state changer
    handled = backstack.goBack();
    assertThat(handled).isFalse();
}
Also used : TestKeyWithScope(com.zhuinden.simplestack.helpers.TestKeyWithScope) Nonnull(javax.annotation.Nonnull) ServiceProvider(com.zhuinden.simplestack.helpers.ServiceProvider) Test(org.junit.Test)

Example 23 with TestKeyWithScope

use of com.zhuinden.simplestack.helpers.TestKeyWithScope in project simple-stack by Zhuinden.

the class ScopingBackEventDispatchTest method onBackDispatchDoesNotDispatchDuringStateChange.

@Test
public void onBackDispatchDoesNotDispatchDuringStateChange() {
    final HandlesBackOnce service1 = new HandlesBackOnce();
    final HandlesBackOnce service2 = new HandlesBackOnce();
    Object key1 = new TestKeyWithScope("key1") {

        @Override
        public void bindServices(ServiceBinder serviceBinder) {
            serviceBinder.addService("service1", service1);
        }
    };
    Object key2 = new TestKeyWithScope("key2") {

        @Override
        public void bindServices(ServiceBinder serviceBinder) {
            serviceBinder.addService("service2", service2);
        }
    };
    Backstack backstack = new Backstack();
    backstack.setScopedServices(new ServiceProvider());
    backstack.setup(History.of(key1));
    final AtomicReference<StateChanger.Callback> callbackRef = new AtomicReference<>();
    backstack.setStateChanger(new StateChanger() {

        @Override
        public void handleStateChange(@Nonnull StateChange stateChange, @Nonnull Callback completionCallback) {
            callbackRef.set(completionCallback);
        }
    });
    callbackRef.get().stateChangeComplete();
    assertThat(backstack.getHistory()).containsExactly(key1);
    backstack.goTo(key2);
    assertThat(service1.handledBackOnce).isEqualTo(false);
    assertThat(service2.handledBackOnce).isEqualTo(false);
    // ignored!
    boolean handled = backstack.goBack();
    assertThat(handled).isEqualTo(true);
    assertThat(service1.handledBackOnce).isEqualTo(false);
    assertThat(service2.handledBackOnce).isEqualTo(false);
    // goTo(key2)
    callbackRef.get().stateChangeComplete();
    assertThat(backstack.getHistory()).containsExactly(key1, key2);
    handled = backstack.goBack();
    assertThat(handled).isEqualTo(true);
    assertThat(service1.handledBackOnce).isEqualTo(false);
    assertThat(service2.handledBackOnce).isEqualTo(true);
    handled = backstack.goBack();
    callbackRef.get().stateChangeComplete();
    assertThat(handled).isEqualTo(true);
    assertThat(service1.handledBackOnce).isEqualTo(false);
    assertThat(service2.handledBackOnce).isEqualTo(true);
    assertThat(backstack.getHistory()).containsExactly(key1);
    handled = backstack.goBack();
    assertThat(handled).isEqualTo(true);
    assertThat(service1.handledBackOnce).isEqualTo(true);
    assertThat(service2.handledBackOnce).isEqualTo(true);
    assertThat(backstack.getHistory()).containsExactly(key1);
    handled = backstack.goBack();
    assertThat(handled).isEqualTo(false);
}
Also used : AtomicReference(java.util.concurrent.atomic.AtomicReference) TestKeyWithScope(com.zhuinden.simplestack.helpers.TestKeyWithScope) ServiceProvider(com.zhuinden.simplestack.helpers.ServiceProvider) Test(org.junit.Test)

Example 24 with TestKeyWithScope

use of com.zhuinden.simplestack.helpers.TestKeyWithScope in project simple-stack by Zhuinden.

the class ScopingGlobalScopeTest method newHistoryShouldReinitializeScopes.

@Test
public void newHistoryShouldReinitializeScopes() {
    final List<Pair<Object, ServiceEvent>> events = new ArrayList<>();
    Backstack backstack = new Backstack();
    backstack.setScopedServices(new ServiceProvider());
    class MyService implements ScopedServices.Activated, ScopedServices.Registered {

        private int id = 0;

        MyService(int id) {
            this.id = id;
        }

        @Override
        public void onServiceActive() {
            events.add(Pair.of((Object) this, ServiceEvent.ACTIVE));
        }

        @Override
        public void onServiceInactive() {
            events.add(Pair.of((Object) this, ServiceEvent.INACTIVE));
        }

        @Override
        public String toString() {
            return "MyService{" + "id=" + id + '}';
        }

        @Override
        public void onServiceRegistered() {
            events.add(Pair.of((Object) this, ServiceEvent.CREATE));
        }

        @Override
        public void onServiceUnregistered() {
            events.add(Pair.of((Object) this, ServiceEvent.DESTROY));
        }
    }
    final MyService globalService = new MyService(0);
    final MyService explicitParentService = new MyService(1);
    final MyService implicitParentService = new MyService(2);
    final MyService currentScopeService = new MyService(3);
    abstract class TestKeyWithExplicitParent extends TestKeyWithScope implements HasParentServices {

        TestKeyWithExplicitParent(String name) {
            super(name);
        }

        protected TestKeyWithExplicitParent(Parcel in) {
            super(in);
        }

        @Nonnull
        @Override
        public List<String> getParentScopes() {
            return History.of("explicitParentScope");
        }

        @Override
        public final void bindServices(ServiceBinder serviceBinder) {
            if ("explicitParentScope".equals(serviceBinder.getScopeTag())) {
                serviceBinder.addService("explicitParentService", explicitParentService);
            }
            if (name.equals(serviceBinder.getScopeTag())) {
                bindOwnServices(serviceBinder);
            }
        }

        abstract void bindOwnServices(ServiceBinder serviceBinder);
    }
    TestKeyWithScope beep = new TestKeyWithExplicitParent("beep") {

        @Override
        void bindOwnServices(ServiceBinder serviceBinder) {
            assertThat(serviceBinder.getScopeTag()).isEqualTo(getScopeTag());
            serviceBinder.addService("implicitParentService", implicitParentService);
        }
    };
    TestKeyWithScope boop = new TestKeyWithExplicitParent("boop") {

        @Override
        void bindOwnServices(ServiceBinder serviceBinder) {
            assertThat(serviceBinder.getScopeTag()).isEqualTo(getScopeTag());
            serviceBinder.addService("currentScopeService", currentScopeService);
        }
    };
    backstack.setGlobalServices(GlobalServices.builder().addService("globalService", globalService).build());
    backstack.setup(History.of(beep, boop));
    backstack.setStateChanger(new StateChanger() {

        @Override
        public void handleStateChange(@Nonnull StateChange stateChange, @Nonnull Callback completionCallback) {
            completionCallback.stateChangeComplete();
        }
    });
    assertThat(backstack.canFindService("globalService")).isTrue();
    assertThat(backstack.canFindService("currentScopeService")).isTrue();
    assertThat(backstack.canFindService("implicitParentService")).isTrue();
    assertThat(backstack.canFindService("explicitParentService")).isTrue();
    backstack.finalizeScopes();
    assertThat(backstack.canFindService("currentScopeService")).isFalse();
    assertThat(backstack.canFindService("implicitParentService")).isFalse();
    assertThat(backstack.canFindService("explicitParentService")).isFalse();
    assertThat(backstack.canFindService("globalService")).isFalse();
    backstack.setHistory(History.of(beep, boop), StateChange.REPLACE);
    assertThat(backstack.canFindService("globalService")).isTrue();
    assertThat(backstack.canFindService("currentScopeService")).isTrue();
    assertThat(backstack.canFindService("implicitParentService")).isTrue();
    assertThat(backstack.canFindService("explicitParentService")).isTrue();
    assertThat(backstack.hasService("explicitParentScope", "explicitParentService")).isTrue();
    assertThat(events).containsExactly(Pair.of((Object) globalService, ServiceEvent.CREATE), Pair.of((Object) explicitParentService, ServiceEvent.CREATE), Pair.of((Object) implicitParentService, ServiceEvent.CREATE), Pair.of((Object) currentScopeService, ServiceEvent.CREATE), Pair.of((Object) globalService, ServiceEvent.ACTIVE), Pair.of((Object) explicitParentService, ServiceEvent.ACTIVE), Pair.of((Object) currentScopeService, ServiceEvent.ACTIVE), Pair.of((Object) currentScopeService, ServiceEvent.INACTIVE), Pair.of((Object) explicitParentService, ServiceEvent.INACTIVE), Pair.of((Object) globalService, ServiceEvent.INACTIVE), Pair.of((Object) currentScopeService, ServiceEvent.DESTROY), Pair.of((Object) implicitParentService, ServiceEvent.DESTROY), Pair.of((Object) explicitParentService, ServiceEvent.DESTROY), Pair.of((Object) globalService, ServiceEvent.DESTROY), Pair.of((Object) globalService, ServiceEvent.CREATE), Pair.of((Object) explicitParentService, ServiceEvent.CREATE), Pair.of((Object) implicitParentService, ServiceEvent.CREATE), Pair.of((Object) currentScopeService, ServiceEvent.CREATE), Pair.of((Object) globalService, ServiceEvent.ACTIVE), Pair.of((Object) explicitParentService, ServiceEvent.ACTIVE), Pair.of((Object) currentScopeService, ServiceEvent.ACTIVE));
    // this is just to check things, the test'simportant part is the one above
    backstack.goBack();
    assertThat(events).containsExactly(Pair.of((Object) globalService, ServiceEvent.CREATE), Pair.of((Object) explicitParentService, ServiceEvent.CREATE), Pair.of((Object) implicitParentService, ServiceEvent.CREATE), Pair.of((Object) currentScopeService, ServiceEvent.CREATE), Pair.of((Object) globalService, ServiceEvent.ACTIVE), Pair.of((Object) explicitParentService, ServiceEvent.ACTIVE), Pair.of((Object) currentScopeService, ServiceEvent.ACTIVE), Pair.of((Object) currentScopeService, ServiceEvent.INACTIVE), Pair.of((Object) explicitParentService, ServiceEvent.INACTIVE), Pair.of((Object) globalService, ServiceEvent.INACTIVE), Pair.of((Object) currentScopeService, ServiceEvent.DESTROY), Pair.of((Object) implicitParentService, ServiceEvent.DESTROY), Pair.of((Object) explicitParentService, ServiceEvent.DESTROY), Pair.of((Object) globalService, ServiceEvent.DESTROY), Pair.of((Object) globalService, ServiceEvent.CREATE), Pair.of((Object) explicitParentService, ServiceEvent.CREATE), Pair.of((Object) implicitParentService, ServiceEvent.CREATE), Pair.of((Object) currentScopeService, ServiceEvent.CREATE), Pair.of((Object) globalService, ServiceEvent.ACTIVE), Pair.of((Object) explicitParentService, ServiceEvent.ACTIVE), Pair.of((Object) currentScopeService, ServiceEvent.ACTIVE), Pair.of((Object) implicitParentService, ServiceEvent.ACTIVE), Pair.of((Object) currentScopeService, ServiceEvent.INACTIVE), Pair.of((Object) currentScopeService, ServiceEvent.DESTROY));
}
Also used : HasParentServices(com.zhuinden.simplestack.helpers.HasParentServices) Parcel(android.os.Parcel) ArrayList(java.util.ArrayList) TestKeyWithScope(com.zhuinden.simplestack.helpers.TestKeyWithScope) ServiceProvider(com.zhuinden.simplestack.helpers.ServiceProvider) Test(org.junit.Test)

Example 25 with TestKeyWithScope

use of com.zhuinden.simplestack.helpers.TestKeyWithScope in project simple-stack by Zhuinden.

the class ScopingRegisteredCallbackTest method registeredWorks.

@Test
public void registeredWorks() {
    final List<Pair<Object, ? extends ServiceEvent>> events = new ArrayList<>();
    Backstack backstack = new Backstack();
    backstack.setScopedServices(new ServiceProvider());
    class MyService implements ScopedServices.Activated, ScopedServices.Registered {

        private final String id;

        MyService(String id) {
            this.id = id;
        }

        @Override
        public void onServiceActive() {
            events.add(Pair.of((Object) this, new ActiveEvent()));
        }

        @Override
        public void onServiceInactive() {
            events.add(Pair.of((Object) this, new InactiveEvent()));
        }

        @Override
        public void onServiceRegistered() {
            events.add(Pair.of((Object) this, new RegisterEvent()));
        }

        @Override
        public void onServiceUnregistered() {
            events.add(Pair.of((Object) this, new UnregisterEvent()));
        }

        @Override
        public String toString() {
            return "MyService{" + "id=" + id + '}';
        }
    }
    final Object service0 = new MyService("service0");
    final Object serviceShared0123P1P2P3 = new MyService("serviceShared0123P1P2P3");
    backstack.setGlobalServices(GlobalServices.builder().addService("service0", service0).addService("serviceShared0123P1P2P3", serviceShared0123P1P2P3).build());
    final Object service1 = new MyService("service1");
    final Object service2 = new MyService("service2");
    final Object service3 = new MyService("service3");
    final Object serviceShared12 = new MyService("serviceShared12");
    final Object serviceShared13 = new MyService("serviceShared13");
    final Object serviceShared23 = new MyService("serviceShared23");
    final Object serviceShared123 = new MyService("serviceShared123");
    final Object serviceShared1P1 = new MyService("serviceShared1P1");
    final Object serviceShared1P2 = new MyService("serviceShared1P2");
    final Object serviceShared1P3 = new MyService("serviceShared1P3");
    final Object serviceShared2P1 = new MyService("serviceShared2P1");
    final Object serviceShared2P2 = new MyService("serviceShared2P2");
    final Object serviceShared2P3 = new MyService("serviceShared2P3");
    final Object serviceShared3P1 = new MyService("serviceShared3P1");
    final Object serviceShared3P2 = new MyService("serviceShared3P2");
    final Object serviceShared3P3 = new MyService("serviceShared3P3");
    final Object serviceP1 = new MyService("serviceP1");
    final Object serviceP2 = new MyService("serviceP2");
    final Object serviceP3 = new MyService("serviceP3");
    TestKeyWithScope beep = new TestKeyWithScope("scope1") {

        @Override
        public void bindServices(ServiceBinder serviceBinder) {
            assertThat(serviceBinder.getScopeTag()).isEqualTo(getScopeTag());
            serviceBinder.addService("service1", service1);
            serviceBinder.addService("serviceShared12", serviceShared12);
            serviceBinder.addService("serviceShared13", serviceShared13);
            serviceBinder.addService("serviceShared123", serviceShared123);
            serviceBinder.addService("serviceShared1P1", serviceShared1P1);
            serviceBinder.addService("serviceShared1P2", serviceShared1P2);
            serviceBinder.addService("serviceShared1P3", serviceShared1P3);
            serviceBinder.addService("serviceShared0123P1P2P3", serviceShared0123P1P2P3);
        }
    };
    abstract class TestKeyWithExplicitParent extends TestKeyWithScope implements HasParentServices {

        TestKeyWithExplicitParent(String name) {
            super(name);
        }

        protected TestKeyWithExplicitParent(Parcel in) {
            super(in);
        }

        @Override
        public final void bindServices(ServiceBinder serviceBinder) {
            if (name.equals(serviceBinder.getScopeTag())) {
                bindOwnServices(serviceBinder);
            } else {
                bindParentServices(serviceBinder);
            }
        }

        abstract void bindParentServices(ServiceBinder serviceBinder);

        abstract void bindOwnServices(ServiceBinder serviceBinder);
    }
    TestKeyWithExplicitParent boop = new TestKeyWithExplicitParent("scope2") {

        @Nonnull
        @Override
        public List<String> getParentScopes() {
            return History.of("parent1", "parent2");
        }

        @Override
        void bindParentServices(ServiceBinder serviceBinder) {
            if ("parent1".equals(serviceBinder.getScopeTag())) {
                serviceBinder.addService("serviceP1", serviceP1);
                serviceBinder.addService("serviceShared1P1", serviceShared1P1);
                serviceBinder.addService("serviceShared2P1", serviceShared2P1);
                serviceBinder.addService("serviceShared3P1", serviceShared3P1);
                serviceBinder.addService("serviceShared0123P1P2P3", serviceShared0123P1P2P3);
            }
            if ("parent2".equals(serviceBinder.getScopeTag())) {
                serviceBinder.addService("serviceP2", serviceP2);
                serviceBinder.addService("serviceShared1P2", serviceShared1P2);
                serviceBinder.addService("serviceShared2P2", serviceShared2P2);
                serviceBinder.addService("serviceShared3P2", serviceShared3P2);
                serviceBinder.addService("serviceShared0123P1P2P3", serviceShared0123P1P2P3);
            }
        }

        @Override
        void bindOwnServices(ServiceBinder serviceBinder) {
            serviceBinder.addService("service2", service2);
            serviceBinder.addService("serviceShared12", serviceShared12);
            serviceBinder.addService("serviceShared23", serviceShared23);
            serviceBinder.addService("serviceShared123", serviceShared123);
            serviceBinder.addService("serviceShared2P1", serviceShared2P1);
            serviceBinder.addService("serviceShared2P2", serviceShared2P2);
            serviceBinder.addService("serviceShared2P3", serviceShared2P3);
            serviceBinder.addService("serviceShared0123P1P2P3", serviceShared0123P1P2P3);
        }
    };
    TestKeyWithExplicitParent braap = new TestKeyWithExplicitParent("scope3") {

        @Nonnull
        @Override
        public List<String> getParentScopes() {
            return History.of("parent1", "parent3");
        }

        @Override
        void bindParentServices(ServiceBinder serviceBinder) {
            if ("parent1".equals(serviceBinder.getScopeTag())) {
                serviceBinder.addService("serviceP1", serviceP1);
                serviceBinder.addService("serviceShared1P1", serviceShared1P1);
                serviceBinder.addService("serviceShared2P1", serviceShared2P1);
                serviceBinder.addService("serviceShared3P1", serviceShared3P1);
                serviceBinder.addService("serviceShared0123P1P2P3", serviceShared0123P1P2P3);
            }
            if ("parent3".equals(serviceBinder.getScopeTag())) {
                serviceBinder.addService("serviceP3", serviceP3);
                serviceBinder.addService("serviceShared1P3", serviceShared1P3);
                serviceBinder.addService("serviceShared2P3", serviceShared2P3);
                serviceBinder.addService("serviceShared3P3", serviceShared3P3);
                serviceBinder.addService("serviceShared0123P1P2P3", serviceShared0123P1P2P3);
            }
        }

        @Override
        void bindOwnServices(ServiceBinder serviceBinder) {
            serviceBinder.addService("service3", service3);
            serviceBinder.addService("serviceShared13", serviceShared13);
            serviceBinder.addService("serviceShared23", serviceShared23);
            serviceBinder.addService("serviceShared123", serviceShared123);
            serviceBinder.addService("serviceShared3P1", serviceShared3P1);
            serviceBinder.addService("serviceShared3P2", serviceShared3P2);
            serviceBinder.addService("serviceShared3P3", serviceShared3P3);
            serviceBinder.addService("serviceShared0123P1P2P3", serviceShared0123P1P2P3);
        }
    };
    /*                      GLOBAL
         *                                PARENT1
         *                        PARENT2        PARENT3
         *   BEEP               BOOP                 BRAAP
         */
    backstack.setup(History.of(beep, boop, braap));
    StateChanger stateChanger = new StateChanger() {

        @Override
        public void handleStateChange(@Nonnull StateChange stateChange, @Nonnull Callback completionCallback) {
            completionCallback.stateChangeComplete();
        }
    };
    backstack.setStateChanger(stateChanger);
    backstack.goBack();
    backstack.goBack();
    backstack.finalizeScopes();
    backstack.goTo(beep);
    assertThat(events).containsExactly(Pair.of(service0, new RegisterEvent()), Pair.of(serviceShared0123P1P2P3, new RegisterEvent()), Pair.of(service1, new RegisterEvent()), Pair.of(serviceShared12, new RegisterEvent()), Pair.of(serviceShared13, new RegisterEvent()), Pair.of(serviceShared123, new RegisterEvent()), Pair.of(serviceShared1P1, new RegisterEvent()), Pair.of(serviceShared1P2, new RegisterEvent()), Pair.of(serviceShared1P3, new RegisterEvent()), Pair.of(serviceP1, new RegisterEvent()), Pair.of(serviceShared2P1, new RegisterEvent()), Pair.of(serviceShared3P1, new RegisterEvent()), Pair.of(serviceP2, new RegisterEvent()), Pair.of(serviceShared2P2, new RegisterEvent()), Pair.of(serviceShared3P2, new RegisterEvent()), Pair.of(service2, new RegisterEvent()), Pair.of(serviceShared23, new RegisterEvent()), Pair.of(serviceShared2P3, new RegisterEvent()), Pair.of(serviceP3, new RegisterEvent()), Pair.of(serviceShared3P3, new RegisterEvent()), Pair.of(service3, new RegisterEvent()), Pair.of(service0, new ActiveEvent()), Pair.of(serviceShared0123P1P2P3, new ActiveEvent()), Pair.of(serviceP1, new ActiveEvent()), Pair.of(serviceShared1P1, new ActiveEvent()), Pair.of(serviceShared2P1, new ActiveEvent()), Pair.of(serviceShared3P1, new ActiveEvent()), Pair.of(serviceP3, new ActiveEvent()), Pair.of(serviceShared1P3, new ActiveEvent()), Pair.of(serviceShared2P3, new ActiveEvent()), Pair.of(serviceShared3P3, new ActiveEvent()), Pair.of(service3, new ActiveEvent()), Pair.of(serviceShared13, new ActiveEvent()), Pair.of(serviceShared23, new ActiveEvent()), Pair.of(serviceShared123, new ActiveEvent()), Pair.of(serviceShared3P2, new ActiveEvent()), Pair.of(serviceP2, new ActiveEvent()), Pair.of(serviceShared1P2, new ActiveEvent()), Pair.of(serviceShared2P2, new ActiveEvent()), Pair.of(service2, new ActiveEvent()), Pair.of(serviceShared12, new ActiveEvent()), Pair.of(serviceShared13, new InactiveEvent()), Pair.of(service3, new InactiveEvent()), Pair.of(serviceShared3P3, new InactiveEvent()), Pair.of(serviceShared1P3, new InactiveEvent()), Pair.of(serviceP3, new InactiveEvent()), Pair.of(service3, new UnregisterEvent()), Pair.of(serviceShared3P3, new UnregisterEvent()), Pair.of(serviceP3, new UnregisterEvent()), Pair.of(service1, new ActiveEvent()), Pair.of(serviceShared13, new ActiveEvent()), Pair.of(serviceShared1P3, new ActiveEvent()), Pair.of(serviceShared2P3, new InactiveEvent()), Pair.of(serviceShared23, new InactiveEvent()), Pair.of(service2, new InactiveEvent()), Pair.of(serviceShared3P2, new InactiveEvent()), Pair.of(serviceShared2P2, new InactiveEvent()), Pair.of(serviceP2, new InactiveEvent()), Pair.of(serviceShared3P1, new InactiveEvent()), Pair.of(serviceShared2P1, new InactiveEvent()), Pair.of(serviceP1, new InactiveEvent()), Pair.of(serviceShared2P3, new UnregisterEvent()), Pair.of(serviceShared23, new UnregisterEvent()), Pair.of(service2, new UnregisterEvent()), Pair.of(serviceShared3P2, new UnregisterEvent()), Pair.of(serviceShared2P2, new UnregisterEvent()), Pair.of(serviceP2, new UnregisterEvent()), Pair.of(serviceShared3P1, new UnregisterEvent()), Pair.of(serviceShared2P1, new UnregisterEvent()), Pair.of(serviceP1, new UnregisterEvent()), Pair.of(serviceShared1P3, new InactiveEvent()), Pair.of(serviceShared1P2, new InactiveEvent()), Pair.of(serviceShared1P1, new InactiveEvent()), Pair.of(serviceShared123, new InactiveEvent()), Pair.of(serviceShared13, new InactiveEvent()), Pair.of(serviceShared12, new InactiveEvent()), Pair.of(service1, new InactiveEvent()), Pair.of(serviceShared0123P1P2P3, new InactiveEvent()), Pair.of(service0, new InactiveEvent()), Pair.of(serviceShared1P3, new UnregisterEvent()), Pair.of(serviceShared1P2, new UnregisterEvent()), Pair.of(serviceShared1P1, new UnregisterEvent()), Pair.of(serviceShared123, new UnregisterEvent()), Pair.of(serviceShared13, new UnregisterEvent()), Pair.of(serviceShared12, new UnregisterEvent()), Pair.of(service1, new UnregisterEvent()), Pair.of(serviceShared0123P1P2P3, new UnregisterEvent()), Pair.of(service0, new UnregisterEvent()), // restoration to 'beep'
    Pair.of(service0, new RegisterEvent()), Pair.of(serviceShared0123P1P2P3, new RegisterEvent()), Pair.of(service1, new RegisterEvent()), Pair.of(serviceShared12, new RegisterEvent()), Pair.of(serviceShared13, new RegisterEvent()), Pair.of(serviceShared123, new RegisterEvent()), Pair.of(serviceShared1P1, new RegisterEvent()), Pair.of(serviceShared1P2, new RegisterEvent()), Pair.of(serviceShared1P3, new RegisterEvent()), Pair.of(service0, new ActiveEvent()), Pair.of(serviceShared0123P1P2P3, new ActiveEvent()), Pair.of(service1, new ActiveEvent()), Pair.of(serviceShared12, new ActiveEvent()), Pair.of(serviceShared13, new ActiveEvent()), Pair.of(serviceShared123, new ActiveEvent()), Pair.of(serviceShared1P1, new ActiveEvent()), Pair.of(serviceShared1P2, new ActiveEvent()), Pair.of(serviceShared1P3, new ActiveEvent()));
}
Also used : HasParentServices(com.zhuinden.simplestack.helpers.HasParentServices) Nonnull(javax.annotation.Nonnull) Parcel(android.os.Parcel) ArrayList(java.util.ArrayList) TestKeyWithScope(com.zhuinden.simplestack.helpers.TestKeyWithScope) ServiceProvider(com.zhuinden.simplestack.helpers.ServiceProvider) Test(org.junit.Test)

Aggregations

ServiceProvider (com.zhuinden.simplestack.helpers.ServiceProvider)25 TestKeyWithScope (com.zhuinden.simplestack.helpers.TestKeyWithScope)25 Test (org.junit.Test)25 TestKey (com.zhuinden.simplestack.helpers.TestKey)7 Nonnull (javax.annotation.Nonnull)4 TestKeyWithExplicitParent (com.zhuinden.simplestack.helpers.TestKeyWithExplicitParent)3 ArrayList (java.util.ArrayList)3 Parcel (android.os.Parcel)2 HasParentServices (com.zhuinden.simplestack.helpers.HasParentServices)2 Action (com.zhuinden.simplestack.helpers.Action)1 StateBundle (com.zhuinden.statebundle.StateBundle)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Nullable (javax.annotation.Nullable)1