Search in sources :

Example 76 with TestKey

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

the class HistoryTest method removeAll.

@Test
public void removeAll() throws Exception {
    TestKey testKey1 = new TestKey("Hello");
    TestKey testKey2 = new TestKey("World");
    TestKey testKey3 = new TestKey("Kappa");
    List<Object> list = new ArrayList<>();
    list.add(testKey3);
    History history = History.of(testKey1, testKey2);
    try {
        history.removeAll(list);
        fail();
    } catch (UnsupportedOperationException e) {
    // OK!
    }
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 77 with TestKey

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

the class HistoryTest method get.

@Test
public void get() throws Exception {
    TestKey testKey1 = new TestKey("Hello");
    TestKey testKey2 = new TestKey("World");
    TestKey testKey3 = new TestKey("Kappa");
    History history = History.of(testKey1, testKey2, testKey3);
    assertThat(history.get(0)).isSameAs(testKey1);
    assertThat(history.get(1)).isSameAs(testKey2);
    assertThat(history.get(2)).isSameAs(testKey3);
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) Test(org.junit.Test)

Example 78 with TestKey

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

the class HistoryTest method newBuilder.

@Test
public void newBuilder() throws Exception {
    TestKey testKey1 = new TestKey("Hello");
    TestKey testKey2 = new TestKey("World");
    assertThat(History.newBuilder().add(testKey1).add(testKey2).build()).containsExactly(testKey1, testKey2);
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) Test(org.junit.Test)

Example 79 with TestKey

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

the class HistoryTest method from.

@Test
public void from() throws Exception {
    TestKey testKey1 = new TestKey("Hello");
    TestKey testKey2 = new TestKey("World");
    assertThat(History.of(testKey1, testKey2)).containsExactly(testKey1, testKey2);
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) Test(org.junit.Test)

Example 80 with TestKey

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

the class BackstackTest method exitScopeExitsImplicitScopeCorrectly.

@Test
public void exitScopeExitsImplicitScopeCorrectly() {
    Backstack backstack = new Backstack();
    backstack.setScopedServices(new ServiceProvider());
    Object firstKey = new TestKey("firstKey");
    Object lastKey = new TestKey("lastKey");
    Object key = new TestKeyWithScope("blah") {

        @Override
        public void bindServices(ServiceBinder serviceBinder) {
        }
    };
    backstack.setup(History.of(firstKey, key, lastKey));
    backstack.setStateChanger(new StateChanger() {

        @Override
        public void handleStateChange(@Nonnull StateChange stateChange, @Nonnull Callback completionCallback) {
            completionCallback.stateChangeComplete();
        }
    });
    backstack.exitScope("blah");
    assertThat(backstack.getHistory()).containsExactly(firstKey);
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) TestKeyWithScope(com.zhuinden.simplestack.helpers.TestKeyWithScope) ServiceProvider(com.zhuinden.simplestack.helpers.ServiceProvider) Test(org.junit.Test)

Aggregations

TestKey (com.zhuinden.simplestack.helpers.TestKey)148 Test (org.junit.Test)148 Nonnull (javax.annotation.Nonnull)43 ServiceProvider (com.zhuinden.simplestack.helpers.ServiceProvider)26 ArrayList (java.util.ArrayList)22 StateBundle (com.zhuinden.statebundle.StateBundle)11 Parcel (android.os.Parcel)10 HasServices (com.zhuinden.simplestack.helpers.HasServices)7 TestKeyWithScope (com.zhuinden.simplestack.helpers.TestKeyWithScope)7 HasParentServices (com.zhuinden.simplestack.helpers.HasParentServices)6 Parcelable (android.os.Parcelable)5 TestKeyWithOnlyParentServices (com.zhuinden.simplestack.helpers.TestKeyWithOnlyParentServices)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 List (java.util.List)3 Nullable (javax.annotation.Nullable)3 Activity (android.app.Activity)2 TestKeyWithExplicitParent (com.zhuinden.simplestack.helpers.TestKeyWithExplicitParent)2 Application (android.app.Application)1 Context (android.content.Context)1 View (android.view.View)1