- Timestamp:
- 2018-12-13T22:44:57+13:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/testing/trunk/src/src/gstests/tutorials/RunGLITest.java
r32683 r32684 19 19 import org.junit.Before; 20 20 import org.junit.Test; 21 21 import org.assertj.swing.data.Index; 22 23 import org.greenstone.gatherer.Gatherer; 22 24 import org.greenstone.gatherer.GathererProg; // main GLI class we'll be testing 25 import org.greenstone.gatherer.Dictionary; // access to display strings 23 26 24 27 import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase; 25 import org.assertj.swing.fixture. FrameFixture;28 import org.assertj.swing.fixture.*; 26 29 import org.assertj.swing.edt.GuiActionRunner; 27 30 import org.assertj.swing.core.*; 31 import javax.swing.*; 32 28 33 // static imports 29 34 import static org.assertj.swing.launcher.ApplicationLauncher.*; 30 35 import static org.assertj.swing.finder.WindowFinder.findFrame; 31 36 32 37 public class RunGLITest extends AssertJSwingJUnitTestCase { 33 private FrameFixture window; 34 35 @Override 36 protected void onSetUp() { 37 GathererProg frame = GuiActionRunner.execute(() -> new GathererProg()); 38 // IMPORTANT: note the call to 'robot()' 39 // we must use the Robot from AssertJSwingJUnitTestCase 38 private FrameFixture window; 40 39 41 //window = new FrameFixture(robot(), frame); 42 //window.show(); // shows the frame to test 43 44 // Launch GathererProg.java's main() method 45 // See https://joel-costigliola.github.io/assertj/assertj-swing-launch.html 46 47 String GSDLOS = System.getenv("GSDLOS"); 48 String GSDLHOME = System.getenv("GSDLHOME"); 49 String GSDL3HOME = System.getenv("GSDL3HOME"); 50 String GSDL3SRCHOME = System.getenv("GSDL3SRCHOME"); 51 application("org.greenstone.gatherer.GathererProg").withArgs( 40 @Override 41 protected void onSetUp() { 42 GathererProg frame = GuiActionRunner.execute(() -> new GathererProg()); 43 // IMPORTANT: note the call to 'robot()' 44 // we must use the Robot from AssertJSwingJUnitTestCase 45 46 //window = new FrameFixture(robot(), frame); 47 //window.show(); // shows the frame to test 48 49 // Launch GathererProg.java's main() method 50 // See https://joel-costigliola.github.io/assertj/assertj-swing-launch.html 51 52 String GSDLOS = System.getenv("GSDLOS"); 53 String GSDLHOME = System.getenv("GSDLHOME"); 54 String GSDL3HOME = System.getenv("GSDL3HOME"); 55 String GSDL3SRCHOME = System.getenv("GSDL3SRCHOME"); 56 application("org.greenstone.gatherer.GathererProg").withArgs( 52 57 "-gsdl", GSDLHOME, 53 58 "-gsdlos", GSDLOS, 54 59 "-gsdl3", GSDL3HOME, 55 60 "-gsdl3src", GSDL3SRCHOME).start(); 61 } 62 63 64 @Test 65 public void testGLIRunning() { 66 67 68 // waiting 2 seconds for window, so we can see it 69 try{ 70 Thread.sleep(5000); 71 } catch(Exception e) { 72 e.printStackTrace(); 73 } 74 75 76 System.err.println("@@@ First test: GLI Running"); 77 78 79 String expectedWindowTitle = Gatherer.PROGRAM_NAME; 80 81 82 // https://joel-costigliola.github.io/assertj/assertj-swing-launch.html 83 window = findFrame(new GenericTypeMatcher<JFrame>(JFrame.class) { 84 protected boolean isMatching(JFrame window) { 85 return window.getTitle().trim().startsWith(expectedWindowTitle) 86 && window.isShowing(); 87 } 88 }).using(robot()); 89 90 91 String gatherPaneLabel = Dictionary.get("GUI.Gather"); 92 System.err.println("@@@ Expecting label: " + gatherPaneLabel); 93 94 System.err.println("@@@ Second test: that Gather panel is selected and has right title"); 95 96 /*GenericTypeMatcher<JTabbedPane> textMatcher = new GenericTypeMatcher<JTabbedPane>(JTabbedPane.class) { 97 @Override protected boolean isMatching(JTabbedPane tabPane) { 98 int index = GuiActionRunner.execute(() -> tabPane.getSelectedIndex()); 99 //int index = tabPane.getSelectedIndex(); 100 String selectedTabTitle = GuiActionRunner.execute(() -> tabPane.getTitleAt(index)); 101 System.err.println("### GOT TITLE: " + selectedTabTitle); 102 return gatherPaneLabel.equals(selectedTabTitle); 103 } 104 }; 105 */ 106 JTabbedPaneFixture tab = window.tabbedPane(new GenericTypeMatcher<JTabbedPane>(JTabbedPane.class) { 107 @Override protected boolean isMatching(JTabbedPane tabPane) { 108 System.err.println("### trying for match"); 109 //int index = GuiActionRunner.execute(() -> tabPane.getSelectedIndex()); 110 int index = tabPane.getSelectedIndex(); 111 String selectedTabTitle = tabPane.getTitleAt(index); //GuiActionRunner.execute(() -> tabPane.getTitleAt(index)); 112 System.err.println("### GOT TITLE: " + selectedTabTitle); 113 return gatherPaneLabel.equals(selectedTabTitle); 114 } 115 }); 116 tab.requireSelectedTab(Index.atIndex(1)); 117 tab.requireTitle(gatherPaneLabel, Index.atIndex(1)); 56 118 } 57 58 @Test 59 public void shouldCopyTextInLabelWhenClickingButton() { 60 System.err.println("@@@ First test"); 61 //window.textBox("textToCopy").enterText("Some random text"); 62 //window.button("copyButton").click(); 63 //window.label("copiedText").requireText("Some random text"); 64 } 119 120 65 121 }
Note:
See TracChangeset
for help on using the changeset viewer.