void (@NotNull Object component) { if (component == SINK) { return; } // Re-register this interceptor to be able to intercept one more UI component if any UiInterceptors.register(this); if (component instanceof JBPopup popup) { // effective there is a chain of 3 nonBlockingRead actions for (int i = 0; i < 3; i++) { JBLoadingPanel loadingPanel = popup.isDisposed() ? null : UIUtil.findComponentOfType(popup.getContent(), JBLoadingPanel.class); if (loadingPanel == null) break; UIUtil.dispatchAllInvocationEvents(); NonBlockingReadActionImpl.waitForAsyncTaskCompletion(); } JBList<?> content = popup.isDisposed() ? null : UIUtil.findComponentOfType(popup.getContent(), JBList.class); if (content == null) { fail("JBList not found under " + popup.getContent()); } int count = content.getItemsCount(); int index = myEnvironment.generateValue(Generator.integers(0, count - 1), null); Object selectedObject = content.getModel().getElementAt(index); myEnvironment.logMessage("Selected item '"+selectedObject+"' from popup"); content.setSelectedIndex(index); assertTrue(popup.canClose()); // calls cancelHandler popup.closeOk(null); } else { throw new UnsupportedOperationException( String.format("Cannot intercept UI component %s (class: %s)", component, component.getClass())); } }