use of com.zhuinden.simplestack.helpers.TestKey in project simple-stack by Zhuinden.
the class FlowTest method replaceHistoryResultsInLengthOneHistory.
@Test
public void replaceHistoryResultsInLengthOneHistory() {
History<?> history = History.from(Arrays.asList(able, baker, charlie));
Backstack flow = new Backstack();
flow.setup(history);
flow.setStateChanger(new FlowDispatcher());
assertThat(history.size()).isEqualTo(3);
flow.setHistory(History.single(delta), StateChange.REPLACE);
assertThat(lastStack.top()).isEqualTo(new TestKey("Delta"));
assertThat(lastStack.top() == delta).isTrue();
assertThat(lastStack.top()).isSameAs(delta);
assertThat(lastStack.size()).isEqualTo(1);
assertThat(lastDirection).isEqualTo(StateChange.REPLACE);
}
use of com.zhuinden.simplestack.helpers.TestKey in project simple-stack by Zhuinden.
the class FlowTest method setObjectKeepsOriginal.
@Test
public void setObjectKeepsOriginal() {
History<?> history = History.from(Arrays.asList(able, baker));
Backstack flow = new Backstack();
flow.setup(history);
flow.setStateChanger(new FlowDispatcher());
assertThat(history.size()).isEqualTo(2);
flow.goTo(new TestKey("Able"));
assertThat(lastStack.top()).isEqualTo(new TestKey("Able"));
assertThat(lastStack.top() == able).isTrue();
assertThat(lastStack.top()).isSameAs(able);
assertThat(lastStack.size()).isEqualTo(1);
assertThat(lastDirection).isEqualTo(StateChange.BACKWARD);
}
use of com.zhuinden.simplestack.helpers.TestKey in project simple-stack by Zhuinden.
the class FlowTest method setHistoryKeepsOriginals.
@SuppressWarnings({ "CheckResult" })
@Test
public void setHistoryKeepsOriginals() {
TestKey able = new TestKey("Able");
TestKey baker = new TestKey("Baker");
TestKey charlie = new TestKey("Charlie");
TestKey delta = new TestKey("Delta");
History<?> history = History.from(Arrays.asList(able, baker, charlie, delta));
Backstack flow = new Backstack();
flow.setup(history);
flow.setStateChanger(new FlowDispatcher());
assertThat(history.size()).isEqualTo(4);
TestKey echo = new TestKey("Echo");
TestKey foxtrot = new TestKey("Foxtrot");
History<?> newHistory = History.from(Arrays.asList(able, baker, echo, foxtrot));
flow.setHistory(newHistory, StateChange.REPLACE);
assertThat(lastStack.size()).isEqualTo(4);
assertThat(lastStack.top()).isEqualTo(foxtrot);
flow.goBack();
assertThat(lastStack.size()).isEqualTo(3);
assertThat(lastStack.top()).isEqualTo(echo);
flow.goBack();
assertThat(lastStack.size()).isEqualTo(2);
assertThat(lastStack.top()).isSameAs(baker);
flow.goBack();
assertThat(lastStack.size()).isEqualTo(1);
assertThat(lastStack.top()).isSameAs(able);
}
use of com.zhuinden.simplestack.helpers.TestKey in project simple-stack by Zhuinden.
the class HistoryTest method equals.
@Test
public void equals() throws Exception {
TestKey testKey1 = new TestKey("Hello");
TestKey testKey2 = new TestKey("World");
TestKey testKey3 = new TestKey("Kappa");
History history1 = History.of(testKey1, testKey2, testKey3);
History history2 = History.of(testKey1, testKey2, testKey3);
assertThat(history1.equals(history2)).isTrue();
History history3 = History.of(testKey1, testKey2);
assertThat(history1.equals(history3)).isFalse();
}
use of com.zhuinden.simplestack.helpers.TestKey in project simple-stack by Zhuinden.
the class HistoryTest method iterator.
@Test
public void iterator() throws Exception {
TestKey testKey1 = new TestKey("Hello");
TestKey testKey2 = new TestKey("World");
TestKey testKey3 = new TestKey("Kappa");
History history = History.of(testKey1, testKey2, testKey3);
for (Object key : history) {
assertThat(key).isIn(testKey1, testKey2, testKey3);
}
}
Aggregations