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);
}
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);
}
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++;
}
}
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);
}
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();
}
Aggregations