@Test public void should_Find_Visible_JFileChooser_By_Name() { robot.showWindow(window); launchFileChooserNow(); JFileChooserFixture fileChooser = fixture.fileChooser("fileChooser"); assertThat(fileChooser.target()).isSameAs(window.fileChooser()); }
@Test public void should_fail_if_visible_JSpinner_not_found_by_type() { thrown.expect(ComponentLookupException.class); thrown.expectMessageToContain( "Unable to find component using matcher", "type=javax.swing.JSpinner, requireShowing=true"); fixture.spinner(); }
@Test public void should_Find_Visible_JFileChooser_By_Type_With_Timeout() { robot.showWindow(window); launchFileChooser(200); JFileChooserFixture fileChooser = fixture.fileChooser(timeout(300)); assertThat(fileChooser.target()).isSameAs(window.fileChooser()); }
@Test public void should_Fail_If_Visible_JFileChooser_Not_Found_By_Type() { thrown.expect(WaitTimedOutError.class); thrown.expectMessageToContain( "Unable to find component using matcher", "type=javax.swing.JFileChooser, requireShowing=true"); fixture.fileChooser(); }
@Test public void should_Fail_If_Visible_JFileChooser_Not_Found_By_Name() { thrown.expect(ComponentLookupException.class); thrown.expectMessageToContain( "Unable to find component using matcher", "name='myFileChooser', type=javax.swing.JFileChooser, requireShowing=true"); fixture.fileChooser("myFileChooser"); }
@Test public void should_Fail_If_Visible_JButton_Not_Found_By_Type() { thrown.expect(ComponentLookupException.class); thrown.expectMessageToContain( "Unable to find component using matcher", "type=javax.swing.JSplitPane, requireShowing=true"); fixture.splitPane(); }
@Test public void should_find_visible_JSpinner_by_Matcher() { robot.showWindow(window); JSpinnerFixture spinner = fixture.spinner( new GenericTypeMatcher<JSpinner>(JSpinner.class) { @Override protected boolean isMatching(@Nonnull JSpinner s) { return s.getValue().equals(8); } }); assertThat(spinner.target()).isSameAs(window.spinner); }
@Test public void should_Find_Visible_JButton_By_Matcher() { robot.showWindow(window); JSplitPaneFixture splitPane = fixture.splitPane( new GenericTypeMatcher<JSplitPane>(JSplitPane.class) { @Override protected boolean isMatching(@Nonnull JSplitPane s) { return s.getLeftComponent() instanceof JList; } }); assertThat(splitPane.target()).isSameAs(window.splitPane); }
@Test public void should_fail_if_visible_JSpinner_not_found_by_Matcher() { thrown.expect(ComponentLookupException.class); thrown.expectMessageToContain("Unable to find component using matcher"); fixture.spinner(neverMatches(JSpinner.class)); }
@Test public void should_find_visible_JSpinner_by_type() { robot.showWindow(window); JSpinnerFixture spinner = fixture.spinner(); assertThat(spinner.target()).isSameAs(window.spinner); }
@Test public void should_Fail_If_Visible_JFileChooser_Not_Found_By_Name_With_Timeout() { thrown.expect(WaitTimedOutError.class, "Timed out waiting for file chooser to be found"); fixture.fileChooser("fileChooser", timeout(300)); }
private void launchFileChooser(int delay) { window.launchDelay(delay); fixture.button("browse").click(); }
@Test public void should_Fail_If_Visible_JFileChooser_Not_Found_By_Matcher() { thrown.expect(WaitTimedOutError.class, "Timed out waiting for file chooser to be found"); fixture.fileChooser(new JFileChooserByTitleMatcher()); }
@Test public void should_Find_Visible_JButton_By_Type() { robot.showWindow(window); JSplitPaneFixture splitPane = fixture.splitPane(); assertThat(splitPane.target()).isSameAs(window.splitPane); }
@Test public void should_Fail_If_Visible_JButton_Not_Found_By_Matcher() { thrown.expect(ComponentLookupException.class); thrown.expectMessageToContain("Unable to find component using matcher"); fixture.splitPane(neverMatches(JSplitPane.class)); }