/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package unit.tests; import com.test.SimpleTest1; import java.awt.event.KeyEvent; import java.util.concurrent.TimeUnit; import org.fest.swing.annotation.GUITest; import org.fest.swing.core.Robot; import org.fest.swing.edt.FailOnThreadViolationRepaintManager; import org.fest.swing.finder.WindowFinder; import org.fest.swing.fixture.DialogFixture; import org.fest.swing.fixture.FrameFixture; import org.fest.swing.timing.Pause; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import static org.fest.swing.launcher.ApplicationLauncher.*; import static org.fest.swing.core.BasicRobot.robotWithCurrentAwtHierarchy; /** * * @author olivier */ public class Test1 { private static Robot robot; private static FrameFixture frameFixture; @BeforeClass public static void setUpOnce() { FailOnThreadViolationRepaintManager.install(); application(SimpleTest1.class).start(); robot = robotWithCurrentAwtHierarchy(); frameFixture = WindowFinder.findFrame("MY_FRAME_SIMPLETEST1").withTimeout(20, TimeUnit.SECONDS).using(robot); } @Before public void setUp() { } @Test @GUITest public void testAllButtons(){ NSMApis.doScreenShot("start.png"); // frameFixture.textBox("MY_FIELD").enterText("My Field 0"); // NSMApis.doScreenShot("field0.png"); // frameFixture.textBox("MY_FIELD").selectAll().enterText("My Field 1"); // NSMApis.doScreenShot("field1.png"); // frameFixture.textBox("MY_FIELD").click().pressAndReleaseKeys(KeyEvent.VK_A); // frameFixture.textBox("MY_FIELD").enterText("Oli1"); // frameFixture.textBox("MY_FIELD").pressAndReleaseKeys(KeyEvent.VK_BACK_SPACE); NSMApis.doScreenShot("beforeClick.png"); frameFixture.button("MY_BUTTON").click(); // NSMApis.doScreenShot("afterClick.png"); // Pause.pause(3000); // NSMApis.doScreenShot("afterPause.png"); DialogFixture diaFixture = WindowFinder.findDialog("PREFERENCES_DIALOG").using(robot); diaFixture.button("PREFERENCES_DIALOG_CLOSE").click(); NSMApis.doScreenShot("afterClose.png"); String oldAddress = frameFixture.textBox("MY_FIELD").text(); NSMApis.doScreenShot("afterText.png"); frameFixture.textBox("MY_FIELD").selectAll(); NSMApis.doScreenShot("afterSelect.png"); frameFixture.textBox("MY_FIELD").deleteText(); NSMApis.doScreenShot("afterDelete.png"); frameFixture.textBox("MY_FIELD").enterText("new Text"); NSMApis.doScreenShot("afterEnter.png"); frameFixture.textBox("MY_FIELD").enterText("new Text 2"); } @After public void tearDown() { robot.cleanUp(); } @AfterClass public static void tearDownClass() { } }