use of org.absmodels.abs.plugin.debug.scheduling.StepOverScheduler in project abstools by abstools.
the class SchedulingTest method testStepOverScheduler.
@Test
public void testStepOverScheduler() {
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);
TaskStackFrameView tsfv = mock(TaskStackFrameView.class);
StepOverScheduler sos = new StepOverScheduler(ss, tsfv);
ss.setCurrentScheduler(sos);
ScheduleOptions scheduleOptions = mock(ScheduleOptions.class, Mockito.RETURNS_DEEP_STUBS);
ss.curScheduler.choose(scheduleOptions);
verify(ts).reset();
verify(ts).choose(any(ScheduleOptions.class));
abs.backend.java.debugging.TaskInfo ti = mock(abs.backend.java.debugging.TaskInfo.class);
TaskView tv = mock(TaskView.class);
TaskStackView tsv = mock(TaskStackView.class);
when(tsv.hasFrames()).thenReturn(true);
TaskStackFrameView testStackFrame = mock(TaskStackFrameView.class);
OngoingStubbing<TaskStackFrameView> ongoingStubbing = when(tsv.getCurrentFrame()).thenReturn(testStackFrame);
for (int i = 0; i < 9; i++) {
testStackFrame = mock(TaskStackFrameView.class);
ongoingStubbing = ongoingStubbing.thenReturn(testStackFrame);
}
ongoingStubbing.thenReturn(tsfv);
when(tv.getStack()).thenReturn(tsv);
when(ti.getTaskView()).thenReturn(tv);
ss.steppedTask = ti;
for (int i = 0; i < 10; i++) {
ss.curScheduler.choose(scheduleOptions);
}
assertEquals(sos, ss.curScheduler);
verify(ss, never()).awaitGUIAction(any(ScheduleOptions.class));
ss.curScheduler.choose(scheduleOptions);
verify(ss).awaitGUIAction(any(ScheduleOptions.class));
}
Aggregations