use of org.absmodels.abs.plugin.debug.scheduling.RunToLineScheduler in project abstools by abstools.
the class SchedulingTest method testRunToLineScheduler.
@Test
public void testRunToLineScheduler() {
final SchedulingStrategy ss = mock(SchedulingStrategy.class);
doCallRealMethod().when(ss).setBaseScheduler(any(TotalScheduler.class));
doCallRealMethod().when(ss).setCurrentScheduler(any(TotalScheduler.class));
doCallRealMethod().when(ss).doSingleStep();
TotalScheduler ts = mock(TotalScheduler.class);
ScheduleAction scheduleAction = mock(ScheduleAction.class, Mockito.RETURNS_DEEP_STUBS);
when(ts.choose(any(ScheduleOptions.class))).thenReturn(scheduleAction);
TaskInfo taskInfo = mock(TaskInfo.class);
when(ts.schedule(any(TaskScheduler.class), any(List.class))).thenReturn(taskInfo);
ss.setBaseScheduler(ts);
final int line = new Random().nextInt(1000);
final String fileName = "filename";
abs.backend.java.debugging.TaskInfo ti = mock(abs.backend.java.debugging.TaskInfo.class);
when(ti.getCurrentFile()).thenReturn("filename");
when(ti.getCurrentLine()).thenReturn(line - 5).thenReturn(line - 4).thenReturn(line - 3).thenReturn(line - 2).thenReturn(line - 1).thenReturn(line);
ss.steppedTask = ti;
RunToLineScheduler rtls = new RunToLineScheduler(ss, fileName, line);
ss.setCurrentScheduler(rtls);
ScheduleOptions scheduleOptions = mock(ScheduleOptions.class, Mockito.RETURNS_DEEP_STUBS);
for (int i = 0; i < 6; i++) {
ss.curScheduler.choose(scheduleOptions);
}
verify(ss).awaitGUIAction(any(ScheduleOptions.class));
}
Aggregations