RouteChange { public ScreenSwap toScreenSwap() { return new ScreenSwap(this.previousScreen(), this.nextScreen(), this.direction); } RouteChange(List<Screen> fromPath, List<Screen> toPath, TransitionDirection direction); ScreenSwap toScreenSwap(); final List<Screen> fromPath; final List<Screen> toPath; final TransitionDirection direction; }
@Test public void screenEmptyPath() { List<Screen> fromPath = Arrays.<Screen>asList(); List<Screen> toPath = Arrays.<Screen>asList(); RouteChange routeChange = new RouteChange(fromPath, toPath, ENTER_TRANSITION); ScreenSwap screenSwap = routeChange.toScreenSwap(); assertNull(screenSwap.next); assertNull(screenSwap.previous); assertEquals(ENTER_TRANSITION, screenSwap.direction); }
@Test public void screenOneElementPath() { List<Screen> fromPath = Arrays.<Screen>asList(new ScreenA()); List<Screen> toPath = Arrays.<Screen>asList(new ScreenA()); RouteChange routeChange = new RouteChange(fromPath, toPath, ENTER_TRANSITION); ScreenSwap screenSwap = routeChange.toScreenSwap(); assertEquals(new ScreenA(), screenSwap.next); assertEquals(new ScreenA(), screenSwap.previous); assertEquals(ENTER_TRANSITION, screenSwap.direction); }
@Test public void screenMultipleElementPath() { List<Screen> fromPath = Arrays.<Screen>asList(new ScreenA(), new ScreenB()); List<Screen> toPath = Arrays.<Screen>asList(new ScreenA(), new ScreenB()); RouteChange routeChange = new RouteChange(fromPath, toPath, ENTER_TRANSITION); ScreenSwap screenSwap = routeChange.toScreenSwap(); assertEquals(new ScreenB(), screenSwap.next); assertEquals(new ScreenB(), screenSwap.previous); assertEquals(ENTER_TRANSITION, screenSwap.direction); }