void () { assumeFalse("Test cannot be run in headless environment", GraphicsEnvironment.isHeadless()); assertTrue(ApplicationManager.getApplication().getClass().getName().contains("ApplicationImpl")); ThreadingAssertions.assertEventDispatchThread(); assertReady(null); myMonitor.addActivity(new UiActivity("non_modal_1"), ModalityState.nonModal()); assertBusy(null); Dialog dialog = new Dialog(new Dialog((Window)null), "d", true); LaterInvocator.enterModal(dialog); try { assertReady(null); myMonitor.addActivity(new UiActivity("non_modal2"), ModalityState.nonModal()); assertReady(null); ModalityState m1 = ApplicationManager.getApplication().getModalityStateForComponent(dialog); myMonitor.addActivity(new UiActivity("modal_1"), m1); assertBusy(null); Dialog popup = new Dialog(dialog, "popup", true); LaterInvocator.enterModal(popup); ModalityState m2 = ApplicationManager.getApplication().getModalityStateForComponent(popup); LaterInvocator.leaveModal(popup); assertTrue("m1: "+m1+"; m2:"+m2, m2.dominates(m1)); myMonitor.addActivity(new UiActivity("modal_2"), m2); assertBusy(null); } finally { LaterInvocator.leaveModal(dialog); } assertBusy(null); }