Skip to content

Commit e15fa00

Browse files
committed
Experimental fix
1 parent 547b7ad commit e15fa00

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

maven/core-unittests/src/test/java/com/codename1/ui/AutoCompleteTextComponentTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.util.ArrayList;
1414
import java.util.Hashtable;
1515
import java.util.List;
16+
import java.util.concurrent.CountDownLatch;
1617

1718
import static org.junit.jupiter.api.Assertions.*;
1819

@@ -227,20 +228,17 @@ public boolean filter(String text) {
227228
Object firstValue = popupList.getModel().getItemAt(0);
228229
@SuppressWarnings({"rawtypes", "unchecked"})
229230
ListCellRenderer renderer = (ListCellRenderer) popupList.getRenderer();
231+
CountDownLatch latch = new CountDownLatch(1);
232+
popupList.addActionListener(e -> latch.countDown());
230233
Dimension cellSize = renderer.getListCellRendererComponent(popupList, firstValue, 0, true).getPreferredSize();
231234
int selectX = popupList.getAbsoluteX() + Math.max(1, Math.min(cellSize.getWidth(), popupList.getWidth()) / 2);
232235
int selectY = popupList.getAbsoluteY() + Math.max(1, Math.min(cellSize.getHeight(), popupList.getHeight()) / 2);
233236
implementation.dispatchPointerPressAndRelease(selectX, selectY);
234-
flushSerialCalls();
235237

236-
if (!"Red".equals(field.getText())) {
237-
popupList.setSelectedIndex(0);
238-
popupList.fireActionEvent();
239-
flushSerialCalls();
240-
}
238+
waitFor(latch, 400);
241239

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());
244242
assertTrue(filteredInputs.contains("re"));
245243
}
246244

0 commit comments

Comments
 (0)