Supports functional testing of {@code JComboBox}es.
Note: This class is intended for internal use only. Please use the classes in the package {@link org.fest.swing.fixture} in your tests.
444546474849505152535455
fixture.replaceDriverWith(mock(JComboBoxDriver.class)); } @Test public void should_return_contents_using_driver() { JComboBoxDriver driver = fixture.driver(); JComboBox target = fixture.target(); String[] contents = { "One", "Two", "Three" }; when(driver.contentsOf(target)).thenReturn(contents); assertThat(fixture.contents()).isSameAs(contents); verify(driver).contentsOf(target); }
7980818283848586878889
verify(fixture.driver()).selectItem(fixture.target(), pattern); } @Test public void should_return_value_at_index_using_driver() { JComboBoxDriver driver = fixture.driver(); JComboBox target = fixture.target(); when(driver.value(target, 6)).thenReturn("Six"); assertThat(fixture.valueAt(6)).isEqualTo("Six"); verify(driver).value(target, 6); }
119120121122123124125126127128129
verify(fixture.driver()).requireItemCount(fixture.target(), 6); } @Test public void should_return_selection_using_driver() { JComboBoxDriver driver = fixture.driver(); JComboBox target = fixture.target(); when(driver.selectedItemOf(target)).thenReturn("Six"); assertThat(fixture.selectedItem()).isEqualTo("Six"); verify(driver).selectedItemOf(target); }
158159160161162163164165166167168
verify(fixture.driver()).enterText(fixture.target(), "Hello"); } @Test public void should_return_list_using_driver() { JComboBoxDriver driver = fixture.driver(); JList list = mock(JList.class); when(driver.dropDownList()).thenReturn(list); assertThat(fixture.list()).isSameAs(list); verify(driver).dropDownList(); }
68697071727374
super(JComboBoxFixture.class, robot, comboBoxName, JComboBox.class); } @Override protected @Nonnull JComboBoxDriver createDriver(@Nonnull Robot robot) { return new JComboBoxDriver(robot); }
73747576777879
super(robot, comboBoxName, JComboBox.class); createDriver(); } private void createDriver() { driver(new JComboBoxDriver(robot)); }