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(); } }
/** * Basic test showing usage of FEST and checking combo box * * @throws Exception */ //@Test public void scratchTestFEST() throws Exception { FrameFixture frame = new FrameFixture(IGV.getMainFrame()); JPanelFixture contentFixture = frame.panel("contentPane"); JPanelFixture commandBar = frame.panel("igvCommandBar"); JComboBoxFixture chromoBox = frame.comboBox("chromosomeComboBox"); String[] chromos = commandBar.comboBox("chromosomeComboBox").contents(); Assert.assertEquals(26, chromos.length); }
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(); } }
@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()); }
final protected void takeSnapshot(String suffix) { // To make sure the mouse is not over a component in the frame, which //would change its appearance, hence modify the snapshot. hideMouse(); // Take snapshot if (suffix.length() > 0) { suffix = "-" + suffix; } String snapshot = TestConfiguration.SCREENSHOT_PATH + "/" + _example.getClass().getSimpleName() + suffix + ".png"; _screenshot.saveComponentAsPng(_frame.panel("TOP").component(), snapshot); }
@Test public void checkBug53BadLayoutSample1() throws Exception { checkExample(Bug53BadLayoutSample1.class); frame().resizeWidthTo(frame().component().getWidth() + 100); checkSnapshot("after-resize"); }
@Test public void checkBug35PanelWithVariableHeightChild() throws Exception { // Show in default size checkExample(Bug35PanelWithVariableHeightChild.class); // Problem: resize vertically frame().resizeHeightTo(frame().component().getHeight() + 50); checkSnapshot("after-resize"); }
/** * Because loading IGV takes so long, we only load it once per class. * We reset the session in between tests * * @throws Exception */ @BeforeClass public static void setUpClass() throws Exception { AbstractHeadedTest.setUpClass(); frame = new FrameFixture(IGV.getMainFrame()); }
@Test public void checkShowHideRows() throws Exception { checkExample(ShowHideRowsRealWorldExample1.class); // Hide Address frame().checkBox("Address").uncheck(); checkSnapshot("after-1-hide-address"); // Hide Preferences frame().checkBox("Preferences").uncheck(); checkSnapshot("after-2-hide-preferences"); // Show Address frame().checkBox("Address").check(); checkSnapshot("after-3-show-address"); // Show Preferences frame().checkBox("Preferences").check(); checkSnapshot("after-4-show-preferences"); }
/** * Basic test showing usage of FEST and checking combo box */ @Test public void testChromoBoxContents() throws Exception { String[] chromos = frame.comboBox("chromosomeComboBox").contents(); assertEquals(26, chromos.length); }
final private void hideMouse() { Frame frame = _frame.component(); _robot.moveMouse(frame, frame.getWidth() + 2, 0); _robot.waitForIdle(); _robot.moveMouse(frame, frame.getWidth() + 2, frame.getHeight() + 2); _robot.waitForIdle(); }
final protected void checkSnapshot(String suffix) { if (_checkSnapshots) { // To make sure the mouse is not over a component in the frame, which //would change its appearance, hence modify the snapshot. hideMouse(); // Take snapshot of current layout if (suffix.length() > 0) { suffix = "-" + suffix; } String name = _example.getClass().getSimpleName() + suffix; String snapshot = TestConfiguration.SCREENSHOT_PATH + "/" + name + "-org.png"; _screenshot.saveComponentAsPng(_frame.panel("TOP").component(), snapshot); // Compare with previously recorded snapshots String expected = REFERENCE_SCREENSHOT_PATH + name + ".png"; assertThat(new File(snapshot)).hasSameContentAs(new File(expected)); } else { takeSnapshot(suffix); } }
@Test public void checkBug53BadLayoutWithLeftAndRightInBarRow() throws Exception { checkExample(Bug53BadLayoutWithLeftAndRightInBarRow.class); frame().resizeWidthTo(frame().component().getWidth() + 100); checkSnapshot("after-resize"); }
@Test public void checkShowHideRowGroups() throws Exception { checkExample(ShowHideRowsRealWorldExample2.class); // Hide Address frame().checkBox("Address").uncheck(); checkSnapshot("after-1-hide-address"); // Hide Preferences frame().checkBox("Preferences").uncheck(); checkSnapshot("after-2-hide-preferences"); // Show Address frame().checkBox("Address").check(); checkSnapshot("after-3-show-address"); // Show Preferences frame().checkBox("Preferences").check(); checkSnapshot("after-4-show-preferences"); }
@Test(enabled = false) public void checkBug53BadLayoutSample2() throws Exception { checkExample(Bug53BadLayoutSample2.class); frame().resizeWidthTo(frame().component().getWidth() + 100); checkSnapshot("after-resize"); }