|
13 | 13 | import java.util.ArrayList; |
14 | 14 | import java.util.Hashtable; |
15 | 15 | import java.util.List; |
| 16 | +import java.util.concurrent.CountDownLatch; |
16 | 17 |
|
17 | 18 | import static org.junit.jupiter.api.Assertions.*; |
18 | 19 |
|
@@ -227,20 +228,17 @@ public boolean filter(String text) { |
227 | 228 | Object firstValue = popupList.getModel().getItemAt(0); |
228 | 229 | @SuppressWarnings({"rawtypes", "unchecked"}) |
229 | 230 | ListCellRenderer renderer = (ListCellRenderer) popupList.getRenderer(); |
| 231 | + CountDownLatch latch = new CountDownLatch(1); |
| 232 | + popupList.addActionListener(e -> latch.countDown()); |
230 | 233 | Dimension cellSize = renderer.getListCellRendererComponent(popupList, firstValue, 0, true).getPreferredSize(); |
231 | 234 | int selectX = popupList.getAbsoluteX() + Math.max(1, Math.min(cellSize.getWidth(), popupList.getWidth()) / 2); |
232 | 235 | int selectY = popupList.getAbsoluteY() + Math.max(1, Math.min(cellSize.getHeight(), popupList.getHeight()) / 2); |
233 | 236 | implementation.dispatchPointerPressAndRelease(selectX, selectY); |
234 | | - flushSerialCalls(); |
235 | 237 |
|
236 | | - if (!"Red".equals(field.getText())) { |
237 | | - popupList.setSelectedIndex(0); |
238 | | - popupList.fireActionEvent(); |
239 | | - flushSerialCalls(); |
240 | | - } |
| 238 | + waitFor(latch, 400); |
241 | 239 |
|
242 | | - assertEquals("Red", field.getText(), "Field isn't red. Implementation details: " + implementation); |
243 | | - assertEquals("Red", component.getText(), "Component isn't red. Implementation details: " + implementation); |
| 240 | + assertEquals("Red", field.getText()); |
| 241 | + assertEquals("Red", component.getText()); |
244 | 242 | assertTrue(filteredInputs.contains("re")); |
245 | 243 | } |
246 | 244 |
|
|
0 commit comments