use of com.zhuinden.simplestack.helpers.TestKey in project simple-stack by Zhuinden.
the class BackstackDelegateTest method onCreateRestoresFromNonConfigInstance.
@Test
public void onCreateRestoresFromNonConfigInstance() {
BackstackDelegate.NonConfigurationInstance nonConfigurationInstance = new BackstackDelegate.NonConfigurationInstance(backstack);
BackstackDelegate backstackDelegate = new BackstackDelegate();
TestKey testKey = new TestKey("hello");
backstackDelegate.onCreate(null, nonConfigurationInstance, History.single(testKey));
assertThat(backstackDelegate.getBackstack()).isSameAs(backstack);
}
use of com.zhuinden.simplestack.helpers.TestKey in project simple-stack by Zhuinden.
the class BackstackDelegateTest method onCreateChoosesInitialKeysIfRestoredHistoryIsEmpty.
@Test
public void onCreateChoosesInitialKeysIfRestoredHistoryIsEmpty() {
BackstackDelegate backstackDelegate = new BackstackDelegate();
TestKey testKey = new TestKey("hello");
backstackDelegate.onCreate(savedInstanceState, null, History.single(testKey));
assertThat(backstackDelegate.getBackstack()).isNotNull();
backstackDelegate.setStateChanger(stateChanger);
assertThat(backstackDelegate.getBackstack().getHistory()).containsExactly(testKey);
}
use of com.zhuinden.simplestack.helpers.TestKey in project simple-stack by Zhuinden.
the class BackstackDelegateTest method testRestoreViewFromState.
@Test
public void testRestoreViewFromState() {
BackstackDelegate backstackDelegate = new BackstackDelegate();
TestKey key = new TestKey("hello");
backstackDelegate.onCreate(null, null, History.single(key));
backstackDelegate.setStateChanger(stateChanger);
Mockito.when(view.getContext()).thenReturn(context);
StateBundle stateBundle = new StateBundle();
Mockito.when(((Bundleable) view).toBundle()).thenReturn(stateBundle);
// noinspection ResourceType
Mockito.when(context.getSystemService(KeyContextWrapper.TAG)).thenReturn(key);
backstackDelegate.persistViewToState(view);
backstackDelegate.restoreViewFromState(view);
((Bundleable) Mockito.verify(view, Mockito.times(1))).fromBundle(stateBundle);
}
use of com.zhuinden.simplestack.helpers.TestKey in project simple-stack by Zhuinden.
the class HistoryTest method addAllAt.
@Test
public void addAllAt() throws Exception {
TestKey testKey1 = new TestKey("Hello");
TestKey testKey2 = new TestKey("World");
TestKey testKey3 = new TestKey("Kappa");
History history = History.of(testKey1, testKey2);
List<Object> objects = new ArrayList<>(1);
objects.add(testKey3);
try {
history.addAll(1, objects);
fail();
} catch (UnsupportedOperationException e) {
// OK!
}
}
use of com.zhuinden.simplestack.helpers.TestKey in project simple-stack by Zhuinden.
the class HistoryTest method top.
@Test
public void top() throws Exception {
TestKey testKey1 = new TestKey("Hello");
TestKey testKey2 = new TestKey("World");
History history = History.of(testKey1, testKey2);
assertThat(history.top()).isSameAs(testKey2);
}
Aggregations