SwingScheduler extends Scheduler { @Override public Subscription schedule(Action1<Inner> action) { InnerSwingScheduler inner = new InnerSwingScheduler(); inner.schedule(action); return inner; } SwingScheduler(); static SwingScheduler getInstance(); @Override Subscription schedule(Action1<Inner> action); @Override Subscription schedule(Action1<Inner> action, long delayTime, TimeUnit unit);  }
@Test public void testNestedActions() throws Exception { final SwingScheduler scheduler = new SwingScheduler(); final Action1<Inner> firstStepStart = mock(Action1.class); final Action1<Inner> firstStepEnd = mock(Action1.class); final Action1<Inner> secondStepStart = mock(Action1.class); final Action1<Inner> secondStepEnd = mock(Action1.class); final Action1<Inner> thirdStepStart = mock(Action1.class); final Action1<Inner> thirdStepEnd = mock(Action1.class); final Action1<Inner> firstAction = new Action1<Inner>() { @Override public void call(Inner inner) { assertTrue(SwingUtilities.isEventDispatchThread()); firstStepStart.call(inner); firstStepEnd.call(inner); } }; final Action1<Inner> secondAction = new Action1<Inner>() { @Override public void call(Inner inner) { assertTrue(SwingUtilities.isEventDispatchThread()); secondStepStart.call(inner); scheduler.schedule(firstAction); secondStepEnd.call(inner); } }; final Action1<Inner> thirdAction = new Action1<Inner>() { @Override public void call(Inner inner) { assertTrue(SwingUtilities.isEventDispatchThread()); thirdStepStart.call(inner); scheduler.schedule(secondAction); thirdStepEnd.call(inner); } }; InOrder inOrder = inOrder(firstStepStart, firstStepEnd, secondStepStart, secondStepEnd, thirdStepStart, thirdStepEnd); scheduler.schedule(thirdAction); waitForEmptyEventQueue(); inOrder.verify(thirdStepStart, times(1)).call(any(Inner.class)); inOrder.verify(thirdStepEnd, times(1)).call(any(Inner.class)); inOrder.verify(secondStepStart, times(1)).call(any(Inner.class)); inOrder.verify(secondStepEnd, times(1)).call(any(Inner.class)); inOrder.verify(firstStepStart, times(1)).call(any(Inner.class)); inOrder.verify(firstStepEnd, times(1)).call(any(Inner.class)); }