### Question:
Crossfader extends Fader { @Override public int[] getBuffer(int[] visual1Buffer, int[] visual2Buffer) { currentStep++; try { if (super.isDone()) { return visual2Buffer; } if (presetFader) { return CrossfaderHelper.getBuffer(getCurrentStep(), oldBuffer, visual2Buffer); } return CrossfaderHelper.getBuffer(getCurrentStep(), visual1Buffer, visual2Buffer); } catch (Exception e) { LOG.log(Level.SEVERE, "getBuffer failed, ignore error", e); super.setDone(); return visual1Buffer; } } Crossfader(MatrixData matrix, int fps);  Crossfader(MatrixData matrix, int time, int fps); @Override int[] getBuffer(int[] visual1Buffer, int[] visual2Buffer);  }### Answer:
@Test public void presetFadeTest() throws Exception { final int fps = 50; MatrixData matrix = new MatrixData(8, 8); IFader switchFader = new Crossfader(matrix, fps); assertEquals(Fader.FaderName.CROSSFADE.getId(), switchFader.getId()); assertFalse(switchFader.isDone()); assertFalse(switchFader.isStarted()); switchFader.startFade(99, new int[55]); assertTrue(switchFader.isStarted()); switchFader.getBuffer(new int[55], new int[55]); switchFader.cleanUp(); }
@Test public void visualFadeTest() throws Exception { final int fps = 50; MatrixData matrix = new MatrixData(8, 8); IFader switchFader = new Crossfader(matrix, 20, fps); assertEquals(Fader.FaderName.CROSSFADE.getId(), switchFader.getId()); assertFalse(switchFader.isDone()); assertFalse(switchFader.isStarted()); switchFader.startFade(99, 1); assertTrue(switchFader.isStarted()); switchFader.getBuffer(new int[55], new int[55]); switchFader.getBuffer(new int[55], new int[55]); assertTrue(switchFader.isDone()); switchFader.cleanUp(); }