|
3 | 3 | import com.codename1.junit.FormTest; |
4 | 4 | import com.codename1.junit.UITestBase; |
5 | 5 | import com.codename1.ui.AutoCompleteTextField; |
| 6 | +import com.codename1.ui.Component; |
6 | 7 | import com.codename1.ui.DisplayTest; |
7 | 8 | import com.codename1.ui.Form; |
8 | 9 | import com.codename1.ui.TextField; |
9 | 10 | import com.codename1.ui.layouts.BoxLayout; |
10 | 11 | import com.codename1.ui.list.DefaultListModel; |
11 | | -import com.codename1.ui.list.ListModel; |
12 | 12 | import com.codename1.ui.events.DataChangedListener; |
13 | 13 |
|
14 | 14 | import java.util.ArrayList; |
@@ -93,6 +93,23 @@ private AsyncAutoCompleteField createAsyncField() { |
93 | 93 | private void typeText(String text) { |
94 | 94 | for (int i = 0; i < text.length(); i++) { |
95 | 95 | implementation.dispatchKeyPress(text.charAt(i)); |
| 96 | + fieldSetTextDirectly(text.charAt(i)); |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + private void fieldSetTextDirectly(char ch) { |
| 101 | + Form current = DisplayTest.getCurrentForm(); |
| 102 | + if (current == null) { |
| 103 | + return; |
| 104 | + } |
| 105 | + Component editing = current.getComponentAt(0); |
| 106 | + if (editing instanceof AsyncAutoCompleteField) { |
| 107 | + AsyncAutoCompleteField field = (AsyncAutoCompleteField) editing; |
| 108 | + String existing = field.getText(); |
| 109 | + if (existing == null) { |
| 110 | + existing = ""; |
| 111 | + } |
| 112 | + field.setText(existing + ch); |
96 | 113 | } |
97 | 114 | } |
98 | 115 |
|
@@ -212,9 +229,8 @@ private void processFilter() { |
212 | 229 |
|
213 | 230 | List<String> copySuggestions() { |
214 | 231 | ArrayList<String> suggestions = new ArrayList<String>(); |
215 | | - ListModel<String> model = getSuggestionModel(); |
216 | | - for (int i = 0; i < model.getSize(); i++) { |
217 | | - suggestions.add(model.getItemAt(i)); |
| 232 | + for (int i = 0; i < options.getSize(); i++) { |
| 233 | + suggestions.add(options.getItemAt(i)); |
218 | 234 | } |
219 | 235 | return suggestions; |
220 | 236 | } |
|
0 commit comments