@RunsInEDT private static String textOf(JComboBoxFixture comboBox) { final JComboBox c = comboBox.target(); return execute( new GuiQuery<String>() { @Override protected String executeInEDT() { JTextField editor = (JTextField) c.getEditor().getEditorComponent(); return editor.getText(); } }); }
@Test public void should_enter_text_in_JComboBox_with_String_values() { JComboBoxFixture comboBox = fixture(newArrayList("1999", "2000", "2001", "2002")); comboBox.enterText("78"); assertThatEditorHasValue(comboBox, "78"); }
@Test public void should_enter_text_in_JComboBox_with__integer_values() { JComboBoxFixture comboBox = fixture(newArrayList(1999, 2000, 2001, 2002)); comboBox.enterText("20"); assertThatEditorHasValue(comboBox, "20"); }