Changeset 39024
- Timestamp:
- 2024-05-14T23:04:30+12:00 (4 weeks ago)
- Location:
- gs3-extensions/testing/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/testing/trunk/src/build.xml
r39016 r39024 94 94 <!-- https://stackoverflow.com/questions/10704324/how-to-add-to-classpath-all-classes-from-set-of-directories-in-ant --> 95 95 <path id="tutorials.path"> 96 96 <!-- Path to properties file --> 97 <pathelement path="${ext.test.folder}/lib"/> 98 97 99 <!-- Includes ant-nodeps-1.8.1 from 2010 that replaces 2005's optional.jar of ant 98 100 for generating reports --> … … 112 114 <fileset dir="${gli.home}/lib"> 113 115 <include name="*.jar"/> 114 </fileset> 116 </fileset> 115 117 </path> 116 118 -
gs3-extensions/testing/trunk/src/src/gstests/tutorials/RunGLITest.java
r39022 r39024 67 67 // Java imports 68 68 import javax.swing.*; 69 import java.util.Properties; 70 import java.io.InputStream; 71 //import java.io.IOException; 69 72 70 73 // static imports - call static functions without class as namespace qualifier … … 82 85 private FrameFixture window; 83 86 87 private static Properties props; 88 84 89 // Changing Exit SecurityManager is now unused as GLI now doesn't System.exit in testing mode 85 90 // https://stackoverflow.com/questions/50815329/close-application-after-test-without-test-failure-using-assertj 86 91 // https://stackoverflow.com/questions/23139321/testing-java-gui-application-closing-window-during-test-ends-test-suite 87 92 // https://stackoverflow.com/questions/5401281/preventing-system-exit-from-api 88 /*93 89 94 @BeforeClass 90 95 public static void initOnce() { 91 96 // to prevent system.exit from causing issues 92 97 //org.assertj.swing.security.NoExitSecurityManagerInstaller.installNoExitSecurityManager(); 93 } 94 */ 98 99 props = new Properties(); 100 loadProperties(); 101 } 102 95 103 // Selenium 96 104 @Before … … 126 134 127 135 128 @Test136 //@Test 129 137 public void testGLIRunning() { 130 138 // waiting a few seconds for window, so we can see it … … 156 164 // For testing, want GLI to be in librarian mode by default 157 165 changeUserMode("librarian"); 158 166 /* 159 167 switchToPane(GATHER_PANE); 160 168 … … 179 187 180 188 switchToPane(GATHER_PANE); 181 189 */ 182 190 exitGLI(); //System.exit() on GLI won't allow quit to be called on Selenium's web _driver, why? Because System.exit exited the JUnit tests too 183 191 … … 225 233 stealAnyCollectionLock(1); 226 234 switchToPane(GATHER_PANE); 227 changeUserMode("librarian"); 228 } 229 235 //changeUserMode("librarian"); 236 //openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.path").toString()); 237 /* 238 // Start a new collection within the Librarian Interface: 239 createCollection("Small HTML Collection", 240 "A small collection of HTML pages.", 241 null); 242 PAUSE(2); 243 openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.path").toString()); 244 */ 245 loadCollection("lucene-jdbm-demo"); 246 // wait a couple of seconds for loading to be done 247 PAUSE(2); 248 openCollectionPath("b17mie/b17mie.htm", false); 249 PAUSE(3); 250 openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.path").toString()); 251 PAUSE(2); 252 } 253 254 255 public static void loadProperties() { 256 //System.err.println("@@@ Classpath: " + System.getProperty("java.class.path")); 257 258 // try with resources >= Java 7 259 // "A try-with-resources statement can have catch and finally 260 // blocks just like an ordinary try statement. In a 261 // try-with-resources statement, any catch or finally block is 262 // run after the resources declared have been closed." 263 // https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html 264 // https://stackoverflow.com/questions/8285595/reading-properties-file-in-java 265 try (InputStream istream = Thread.currentThread().getContextClassLoader().getResourceAsStream("GLItest.properties")) { 266 //FileInputStream fstream = new FileInputStream("GLItest.properties")) { 267 props.load(istream); 268 System.err.println("sampleFilesPath: " + props.get("samplefiles.path")); 269 } catch(Exception e) { 270 e.printStackTrace(); 271 System.err.println("Could not find GLItest.properties in classpath (in testing/lib) with samplefiles.path set"); 272 System.exit(-1); 273 } 274 } 230 275 } -
gs3-extensions/testing/trunk/src/src/org/greenstone/gsdl3/testing/GSGUITestingUtil.java
r39022 r39024 55 55 public static final String CREATE_PANE = "Create"; 56 56 public static final String FORMAT_PANE = "Format"; 57 58 public static final String WKS_TOP_FOLDER_DOCS_GS = "Documents in Greenstone Collections"; 59 public static final String WKS_TOP_FOLDER_LOCAL = "Local Filespace"; 60 // TODO: generalise across users, OS etc 61 public static final String WKS_TOP_FOLDER_HOME_ME = "Home Folder (TODO)"; 62 public static final String WKS_TOP_FOLDER_DOWNLOADS = "Downloaded Files"; 63 public static final String WKS_TOP_FOLDER_SAMPLEFILES = "sample_files"; 57 64 58 65 public static Robot robot = null; … … 142 149 143 150 //https://joel-costigliola.github.io/assertj/swing/api/org/assertj/swing/fixture/FrameFixture.html 144 public static voidswitchToPane(String pane) {151 public static JTabbedPaneFixture switchToPane(String pane) { 145 152 String paneLabel = Dictionary.get("GUI." + pane); // e.g. GUI.Enrich 146 153 //JPanelFixture tab = window.panel(pane); // this just gets us the JPanel of controls within 147 154 JTabbedPaneFixture tab = window.tabbedPane("GUIManager.tab_pane"); 148 tab.selectTab(paneLabel); // select tab by its title155 return tab.selectTab(paneLabel); // select tab by its title 149 156 } 150 157 public static void openMenuItem(String menu, String subMenu) { … … 179 186 stealCollectionLock(timeoutSeconds); 180 187 } catch(Exception e) { 181 System.err.println("@@@@@@@@@@@@@ No lockfile dialog appeared. ");188 System.err.println("@@@@@@@@@@@@@ No lockfile dialog appeared.\n"); 182 189 } 183 190 } … … 384 391 public static void dragNDrop(String workspacePath, String collPath) {} 385 392 393 public static JTreeFixture openWorkspacePath(String topGLIFolder, String workspacePath) { 394 if(workspacePath.startsWith("/")) { 395 workspacePath = workspacePath.substring(1); 396 } 397 398 //JTabbedPaneFixture gatherPane = switchToPane(GATHER_PANE); 399 //BasicComponentFinder(gatherPane, "GatherPane.workspace_tree"); 400 /*JTreeFixture workspaceTree = window.tree(); 401 if(workspaceTree != null) { 402 System.err.println("Found a tree " + workspaceTree.target().getName()); 403 404 } else { 405 System.err.println("No tree"); 406 } 407 */ 408 JTreeFixture workspaceTree = window.tree("GatherPane.workspace_tree"); 409 // https://joel-costigliola.github.io/assertj/swing/api/org/assertj/swing/fixture/JTreeFixture.html 410 411 //String treePath = topGLIFolder + "/" + workspacePath; 412 //workspaceTree.clickPath(treePath); 413 414 //PAUSE(2); 415 416 417 // I think GLI works out what the child nodes are as the workspace tree is expanded, 418 // so childnodes don't exist when a toplevel node is closed/collapsed: so we can't 419 // pass the entire path in here, but have to mimic expanding one node at a time like 420 // a user: expand parent, then childnode, where each node is denoted by its Fullpath 421 // from root ancestor 422 JTreeFixture wks_ptr = workspaceTree.expandPath(topGLIFolder); 423 String[] nodes = workspacePath.split("/"); 424 for(int i = 0; i < nodes.length; i++) { 425 //String node = nodes[i]; 426 String prevNode = (i==0) ? topGLIFolder : nodes[i-1]; 427 nodes[i] = prevNode + "/" + nodes[i]; 428 System.err.println("\t" + nodes[i]); 429 wks_ptr = workspaceTree.expandPath(nodes[i]); 430 } 431 432 //PAUSE(5); 433 434 // If wks_ptr stores the expanded workspace treeview, it's useful for dragging and dropping, 435 return wks_ptr; //return treePath; 436 437 } 438 public static JTreeFixture openCollectionPath(String collPath, boolean openFile) { 439 /* 440 JTreeFixture tree = window.tree(); 441 if(tree != null) { 442 System.err.println("Found a tree " + tree.target().getName()); 443 // throws exception: that Multiple trees have been found and prints their names 444 } else { 445 System.err.println("No tree"); 446 } 447 */ 448 449 // See GLI's collection/CollectionManager.java: collection_tree shared 450 // between GatherPane and EnrichPane 451 JTreeFixture collTree = null; 452 try { 453 collTree = window.tree("GatherPane.collection_tree"); 454 } catch(Exception e) { 455 collTree = window.tree("EnrichPane.collection_tree"); 456 } 457 if(collPath != "") { 458 // same problem: GLI does lazy expansion, so childnodes not visible and are unknown 459 //collTree = collTree.expandPath(collPath); 460 461 String[] nodes = collPath.split("/"); 462 for(int i = 0; i < nodes.length; i++) { 463 if(i > 0) { // build up path to each node to be expanded next 464 nodes[i] = nodes[i-1] + "/" + nodes[i]; 465 } 466 //collTree = collTree.expandPath(nodes[i]); // if leaf, this opens file 467 468 System.err.println("\t" + nodes[i]); 469 470 if(i == (nodes.length-1) && !openFile) { 471 collTree = collTree.clickPath(nodes[i]); 472 473 } else { 474 collTree = collTree.expandPath(nodes[i]); // if leaf, expandPath opens file 475 // which can open it in browser. This may not be what we want. 476 } 477 478 } 479 } 480 return collTree; 481 } 482 386 483 /********************* ENRICH PANE ******************/ 387 484 // docPath can be just docName or collectionSubfolder/Subfolder2/docName
Note:
See TracChangeset
for help on using the changeset viewer.