public class FestTestApplet extends TestCase{ private AppletViewer viewer; private FrameFixture applet; @Override public void setUp() { final Applet app = new GraphicsTest(); viewer = AppletLauncher.applet(app).start(); applet = new FrameFixture(viewer); applet.show(); } public void testNextButtonClick() { applet.button("nextButton").click();//finds the button by the name applet.robot.waitForIdle();//give the GUI time to update //start your asserts } @Override public void tearDown() { viewer.unloadApplet(); applet.cleanUp(); } }
public class SimpleCopyApplicationTest { private FrameFixture window; @BeforeClass public static void setUpOnce() { FailOnThreadViolationRepaintManager.install(); } @Before public void setUp() { SimpleCopyApplication frame = GuiActionRunner.execute(() -> new SimpleCopyApplication()); window = new FrameFixture(frame); window.show(); // shows the frame to test } @Test public void shouldCopyTextInLabelWhenClickingButton() { window.textBox("textToCopy").enterText("Some random text"); window.button("copyButton").click(); window.label("copiedText").requireText("Some random text"); } @After public void tearDown() { window.cleanUp(); } }
@Test public void checkBug32ProblemWithJTextPane() throws Exception { // First problem: bad initial baseline checkExample(Bug32ProblemWithJTextPane.class); // Second problem: very bad baseline after appending a lot of text frame().button("append").click(); frame().resizeWidthTo(frame().component().getWidth() + 1); checkSnapshot("after-append"); }
private void tstChromoNav(String chromoText) throws Exception { JTextComponentFixture searchFixture = frame.textBox("searchTextField"); searchFixture.deleteText(); this.enterText = chromoText; //Make sure search box has focus searchFixture.focus(); searchFixture.requireFocused(); searchFixture.requireEmpty(); searchFixture.enterText(chromoText); frame.button("goButton").click(); }
@Ignore //Never seems to work on our testrunner for reasons unrelated to the code @Test public void testHome() throws Exception { IGV igv = IGV.getInstance(); ReferenceFrame frame = FrameManager.getDefaultFrame(); String chr = "chr1"; int start = 5; int end = 5000; int limit = 2; frame.jumpTo(chr, start, end); Assert.assertEquals(chr, frame.getChrName()); assertTrue(Math.abs(frame.getCurrentRange().getStart() - start) < limit); assertTrue(Math.abs(frame.getCurrentRange().getEnd() - end) < limit); FrameFixture frameFixture = new FrameFixture(IGV.getMainFrame()); //Make sure frame has focus, or else homeButton won't work JButtonFixture homeButton = frameFixture.button("homeButton"); homeButton.focus(); homeButton.click(); homeButton.focus(); homeButton.click(); igv.waitForNotify(500); Assert.assertEquals(Globals.CHR_ALL, frame.getChrName()); //In all genome view these should be the same assertEquals(frame.getChromosomeLength(), frame.getCurrentRange().getEnd()); Assert.assertEquals(0.0, frame.getOrigin()); }