Search in sources :

Example 31 with TestKey

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

the class HistoryTest method retainAll.

@Test
public void retainAll() 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, testKey3);
    try {
        history.retainAll(list);
        fail();
    } catch (UnsupportedOperationException e) {
    // OK!
    }
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 32 with TestKey

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

the class HistoryTest method addWithIndex.

@Test
public void addWithIndex() throws Exception {
    TestKey testKey1 = new TestKey("Hello");
    TestKey testKey2 = new TestKey("World");
    History history = History.of(testKey1);
    try {
        history.add(0, testKey2);
        fail();
    } catch (UnsupportedOperationException e) {
    // OK!
    }
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) Test(org.junit.Test)

Example 33 with TestKey

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

the class HistoryTest method isEmpty.

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

Example 34 with TestKey

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

the class HistoryTest method listIterator.

@Test
public void listIterator() throws Exception {
    TestKey testKey1 = new TestKey("Hello");
    TestKey testKey2 = new TestKey("World");
    TestKey testKey3 = new TestKey("Kappa");
    History history = History.of(testKey1, testKey2, testKey3);
    Iterator<Object> keys = history.listIterator();
    while (keys.hasNext()) {
        Object key = keys.next();
        assertThat(key).isIn(testKey1, testKey2, testKey3);
    }
}
Also used : TestKey(com.zhuinden.simplestack.helpers.TestKey) Test(org.junit.Test)

Example 35 with TestKey

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

the class HistoryTest method lastIndexOf.

@Test
public void lastIndexOf() throws Exception {
    TestKey testKey1 = new TestKey("Hello");
    TestKey testKey2 = new TestKey("World");
    History history = History.of(testKey1, testKey2);
    assertThat(history.lastIndexOf(testKey2)).isEqualTo(1);
    assertThat(history.lastIndexOf(testKey1)).isEqualTo(0);
}
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