- Timestamp:
- 2018-12-18T21:22:40+13:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/testing/trunk/src/src/gstests/tutorials/RunGLITest.java
r32713 r32714 2 2 3 3 /* 4 Ctrl+Shift+A TO ABORT A RUNNING GUI-TEST CYCLE (won't abort Selenium/browser tests) 5 4 6 Using AssertJ Swing to do Java GUI testing (of swing classes) 5 7 - Obtain from: https://search.maven.org/search?q=assertj-swing-junit … … 35 37 // Junit imports 36 38 import org.junit.AfterClass; 39 import org.junit.After; 37 40 import org.junit.Assert; 38 41 import org.junit.Before; 42 import org.junit.BeforeClass; 39 43 import org.junit.Test; 40 44 … … 47 51 import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase; 48 52 import org.assertj.swing.fixture.*; 49 import org.assertj.swing.edt.GuiActionRunner; 50 import org.assertj.swing.core.*; 53 import org.assertj.swing.core.*; // Robot 51 54 import org.assertj.swing.data.Index; 52 55 … … 64 67 import javax.swing.*; 65 68 66 67 68 69 // static imports 69 import static org.assertj.swing.launcher.ApplicationLauncher.*;70 import static org.assertj.swing.finder.WindowFinder.findFrame;71 72 70 import static org.greenstone.gsdl3.testing.GSGUITestingUtil.*; 73 71 72 /** 73 * Class that will eventually go through all the Greenstone3 tutorials by running GLI and GEMS. 74 */ 74 75 public class RunGLITest extends AssertJSwingJUnitTestCase { 75 76 // For aborting running test suite, with Ctrl+Shift+A by default 77 // https://joel-costigliola.github.io/assertj/assertj-swing-running.html 78 private static EmergencyAbortListener abortListener = EmergencyAbortListener.registerInToolkit(); 76 79 private static WebDriver _driver = new FirefoxDriver(); // selenium 77 80 … … 89 92 } 90 93 94 95 // assertj-swing 96 // As init() above, onSetUp() gets called before every test method too, 97 // but is overridden from assertj-swing base class 91 98 @Override 92 99 protected void onSetUp() { 93 GathererProg frame = GuiActionRunner.execute(() -> new GathererProg()); 94 // IMPORTANT: note the call to 'robot()' 95 // we must use the Robot from AssertJSwingJUnitTestCase 100 // Launch GLI and then get a ref to the launched app window: 101 runGLI(); 96 102 97 //window = new FrameFixture(robot(), frame);98 //window.show(); // shows the frame to test99 103 100 // Launch GathererProg.java's main() method 101 // See https://joel-costigliola.github.io/assertj/assertj-swing-launch.html 102 103 String GSDLOS = System.getenv("GSDLOS"); 104 String GSDLHOME = System.getenv("GSDLHOME"); 105 String GSDL3HOME = System.getenv("GSDL3HOME"); 106 String GSDL3SRCHOME = System.getenv("GSDL3SRCHOME"); 107 application("org.greenstone.gatherer.GathererProg").withArgs( 108 "-gsdl", GSDLHOME, 109 "-gsdlos", GSDLOS, 110 "-gsdl3", GSDL3HOME, 111 "-gsdl3src", GSDL3SRCHOME, 112 "-testing_mode").start(); 104 // IMPORTANT, note the call to 'robot()': must use the Robot from AssertJSwingJUnitTestCase 105 //window = findFrame("GUIManager").using(robot()); 106 window = GSGUITestingUtil.getGLIApplicationWindow(robot()); 113 107 } 114 108 … … 117 111 public void testGLIRunning() { 118 112 119 113 120 114 // waiting a few seconds for window, so we can see it 121 PAUSE(2); 122 115 PAUSE(2); 123 116 124 117 System.err.println("@@@ First test: GLI Running"); … … 127 120 String expectedWindowTitle = Gatherer.PROGRAM_NAME; 128 121 129 window = findFrame("GUIManager").using(robot()); 130 131 GSGUITestingUtil.setWindow(window); // set this first before calling any of Util's other methods 132 122 133 123 String gatherPaneLabel = Dictionary.get("GUI.Gather"); 134 124 System.err.println("@@@ Expecting label: " + gatherPaneLabel); … … 168 158 changeUserMode("expert"); 169 159 170 PAUSE(5); 171 //exitGLI(); 160 PAUSE(2); 172 161 173 162 switchToPane(GATHER_PANE); 163 164 //exitGLI(); //System.exit() on GLI won't allow quit to be called on Selenium's web _driver, why? 165 PAUSE(3); 174 166 } 175 167 … … 179 171 public static void destroy() 180 172 { 173 abortListener.unregister(); // aborting assertJ-swing GUI tests 181 174 _driver.quit(); 182 183 175 } 184 176 }
Note:
See TracChangeset
for help on using the changeset viewer.