Search in sources :

Example 86 with TestKey

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

the class HistoryBuilderTest method getLastReturnsLastIfNotEmpty.

@Test
public void getLastReturnsLastIfNotEmpty() {
    TestKey hi = new TestKey("hi");
    TestKey hello = new TestKey("hello");
    TestKey bye = new TestKey("bye");
    History.Builder historyBuilder = History.newBuilder().add(hi).add(hello).add(bye);
    assertThat(historyBuilder.getLast()).isEqualTo(bye);
    assertThat(historyBuilder.build().get(historyBuilder.build().size() - 1)).isEqualTo(bye);
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) Test(org.junit.Test)

Example 87 with TestKey

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

the class HistoryBuilderTest method removeLastRemovesLast.

@Test
public void removeLastRemovesLast() {
    TestKey hi = new TestKey("hi");
    TestKey hello = new TestKey("hello");
    TestKey bye = new TestKey("bye");
    History.Builder builder = History.newBuilder().add(hi).add(hello).add(bye);
    List<Object> history = builder.removeLast().build();
    assertThat(history).containsExactly(hi, hello);
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) Test(org.junit.Test)

Example 88 with TestKey

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

the class HistoryBuilderTest method historyBuilderWorksAsIterable.

@Test
public void historyBuilderWorksAsIterable() {
    History.Builder historyBuilder = History.newBuilder().add(new TestKey("hello")).add(new TestKey("bye"));
    int i = 0;
    for (Object _key : historyBuilder) {
        TestKey key = (TestKey) _key;
        if (i == 0) {
            assertThat(key.name).isEqualTo("hello");
        } else if (i == 1) {
            assertThat(key.name).isEqualTo("bye");
        }
        i++;
    }
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) Test(org.junit.Test)

Example 89 with TestKey

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

the class BackstackDelegateTest method onBackPressedGoesBack.

@Test
public void onBackPressedGoesBack() {
    BackstackDelegate backstackDelegate = new BackstackDelegate();
    TestKey a = new TestKey("hello");
    TestKey b = new TestKey("hello");
    backstackDelegate.onCreate(null, null, History.of(a, b));
    backstackDelegate.setStateChanger(stateChanger);
    assertThat(backstackDelegate.getBackstack().getHistory()).containsExactly(a, b);
    backstackDelegate.onBackPressed();
    assertThat(backstackDelegate.getBackstack().getHistory()).containsExactly(a);
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) Test(org.junit.Test)

Example 90 with TestKey

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

the class BackstackDelegateTest method onPostResumeReattachesStateChanger.

@Test
public void onPostResumeReattachesStateChanger() {
    BackstackDelegate backstackDelegate = new BackstackDelegate();
    TestKey key = new TestKey("hello");
    backstackDelegate.onCreate(null, null, History.single(key));
    backstackDelegate.setStateChanger(stateChanger);
    backstackDelegate.onPause();
    assertThat(backstackDelegate.getBackstack().hasStateChanger()).isFalse();
    backstackDelegate.onPostResume();
    assertThat(backstackDelegate.getBackstack().hasStateChanger()).isTrue();
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) 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