Changeset 39034
- Timestamp:
- 2024-05-19T20:03:07+12:00 (3 weeks ago)
- Location:
- gs3-extensions/testing/trunk/src
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/testing/trunk/src/src/gstests/tutorials/RunGLITest.java
r39033 r39034 64 64 import org.greenstone.gsdl3.testing.GSTestingUtil; 65 65 import org.greenstone.gsdl3.testing.GSGUITestingUtil; 66 import org.greenstone.gsdl3.testing.GSBasicTestingUtil; 66 67 67 68 // Java imports 68 69 import javax.swing.*; 69 70 import java.util.Properties; 70 import java.io.InputStream; 71 import java.io.*; 72 import java.awt.event.InputEvent; 73 //import java.io.InputStream; 71 74 //import java.io.IOException; 72 75 … … 99 102 // to prevent system.exit from causing issues 100 103 //org.assertj.swing.security.NoExitSecurityManagerInstaller.installNoExitSecurityManager(); 104 105 if(System.getenv("GSDL3SRCHOME") == null) { 106 System.err.println("@@@ GS3 environment not set. Terminating tests."); 107 System.exit(-1); 108 } 101 109 102 110 props = new Properties(); … … 214 222 215 223 // First tutorial 216 simpleHTML(); 224 //simpleHTML(); 225 226 backdrop(); 217 227 218 228 } … … 237 247 switchToPane(GATHER_PANE); 238 248 changeUserMode("expert"); 239 //openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles. path").toString());249 //openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.treepath").toString()); 240 250 241 251 /* … … 245 255 openCollectionPath("b17mie/b17mie.htm", CLICK); 246 256 PAUSE(3); 247 openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles. path").toString());257 openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.treepath").toString()); 248 258 */ 249 259 … … 259 269 260 270 261 String dragNodePath = openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles. path").toString()+"simple_html/html_files", SELECT);271 String dragNodePath = openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.treepath").toString()+"simple_html/html_files", SELECT); 262 272 263 273 String collPath = dragNDrop(dragNodePath, ""); … … 265 275 266 276 openCollectionPath("html_files", DOUBLE_CLICK); 267 PAUSE(2); 268 269 277 PAUSE(2); 270 278 271 279 //changeUserMode("librarian"); … … 288 296 289 297 290 String path = openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles. path").toString(), RIGHT_CLICK);298 String path = openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.treepath").toString(), RIGHT_CLICK); 291 299 //workspaceRightClickOption(dragNodePath, ); 292 300 PAUSE(2); … … 300 308 301 309 310 public void backdrop() { 311 System.err.println("@@@ Tutorial 1: simple HTML"); 312 stealAnyCollectionLock(1); 313 switchToPane(GATHER_PANE); 314 /* 315 changeUserMode("librarian"); 316 317 String image_e_coll = props.get("samplefiles.path")+File.separator+"images"+File.separator+"image-e"; 318 File newFolder = GSBasicTestingUtil.copyIntoCollect(image_e_coll); 319 System.err.println("Trying to create the folder " + newFolder); 320 Assert.assertTrue(newFolder.exists()); 321 PAUSE(2); 322 System.err.println("Successfully created folder " + newFolder); 323 324 // Start a new collection within the Librarian Interface: 325 createCollection("backdrop", 326 "A simple image collection", 327 "Simple image collection"); 328 329 loadCollection("backdrop"); 330 PAUSE(3); 331 */ 332 //String startDragNodePath = openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.treepath").toString()+"images/Bear.jpg", SELECT); 333 //https://joel-costigliola.github.io/assertj/swing/api/index.html?org/assertj/swing/core/Robot.html 334 final String wksFolder = openWorkspacePath(WKS_TOP_FOLDER_LOCAL, props.get("samplefiles.treepath").toString()+"images", EXPAND); 335 robot().pressModifiersWhileRunning(InputEvent.SHIFT_MASK, new Runnable() { 336 //https://joel-costigliola.github.io/assertj/swing/api/index.html?org/assertj/swing/core/Robot.html 337 public void run() { 338 String startFile = openInExpandedWorkspace(wksFolder + "/Bear.jpg", CLICK); 339 String endFile = openInExpandedWorkspace(wksFolder + "/Tiger.jpg", CLICK); 340 } 341 }); 342 robot().pressModifiersWhileRunning(InputEvent.CTRL_MASK, new Runnable() { 343 //https://joel-costigliola.github.io/assertj/swing/api/index.html?org/assertj/swing/core/Robot.html 344 public void run() { 345 String skipFile = openInExpandedWorkspace(wksFolder + "/README.txt", CLICK); 346 } 347 }); 348 349 PAUSE(2); 350 //String collPath = dragNDrop(dragNodePath, ""); 351 //dragNDrop(wksFolder + "/Cat.jpg", ""); 352 //dropSelectionIntoCollection(""); 353 robot().pressModifiersWhileRunning( 354 InputEvent.SHIFT_MASK|InputEvent.CTRL_MASK, new Runnable() { 355 public void run() { 356 dragNDrop(wksFolder + "/Cat.jpg", ""); 357 } 358 }); 359 PAUSE(2); 360 } 361 302 362 public static void loadProperties() { 303 363 //System.err.println("@@@ Classpath: " + System.getProperty("java.class.path")); … … 319 379 System.exit(-1); 320 380 } 381 382 String sampleFilesTreePath = (String)props.get("samplefiles.path"); 383 // JTreeFixtures denote paths with / 384 sampleFilesTreePath = sampleFilesTreePath.replace('\\', '/'); 385 props.put("samplefiles.treepath", sampleFilesTreePath); 321 386 } 322 387 } -
gs3-extensions/testing/trunk/src/src/org/greenstone/gsdl3/testing/GSGUITestingUtil.java
r39033 r39034 90 90 public static final boolean OPTIONAL = true; 91 91 public static final boolean COMPULSORY = true; 92 93 public static final int WORKSPACE_VIEW = 1; 94 public static final int COLLECTION_VIEW = 2; 92 95 93 96 public static Robot robot = null; … … 588 591 // in current open collection 589 592 public static void createCollectionSubfolder() {} 590 593 594 public static void dropSelectionIntoCollection(String collPath) { 595 JTreeFixture collTree = window.tree("EnrichPane.collection_tree"); 596 if(collPath == null || collPath.equals("")) { 597 collTree.drop(); // empty tree, call ancestor method AbstractComponentFixture.drop() 598 } else { 599 collTree.drop(collPath); // call a JTreeFixture.drop() method 600 } 601 } 591 602 public static String dragNDrop(String workspacePath, String collPath) { 592 603 JTreeFixture workspaceTree = window.tree("GatherPane.workspace_tree"); … … 626 637 } 627 638 /*if(workspacePath.endsWith("/")) { 628 629 639 workspacePath = workspacePath.substring(0, workspacePath.length()-1); 640 }*/ 630 641 631 642 //JTabbedPaneFixture gatherPane = switchToPane(GATHER_PANE); … … 644 655 String treePath = topGLIFolder + "/" + workspacePath; 645 656 //workspaceTree.clickPath(treePath); 646 657 658 JTreeFixture wks_ptr = workspaceTree.expandPath(topGLIFolder); 659 647 660 //PAUSE(2); 648 661 649 650 662 // I think GLI works out what the child nodes are as the workspace tree is expanded, 651 663 // so childnodes don't exist when a toplevel node is closed/collapsed: so we can't 652 664 // pass the entire path in here, but have to mimic expanding one node at a time like 653 665 // a user: expand parent, then childnode, where each node is denoted by its Fullpath 654 // from root ancestor 655 JTreeFixture wks_ptr = workspaceTree.expandPath(topGLIFolder); 666 // from root ancestor 656 667 String[] nodes = workspacePath.split("/"); 657 668 for(int i = 0; i < nodes.length; i++) { … … 688 699 } 689 700 } 701 return treePath; 702 } 703 public static String openWorkspacePath(String workspacePath, int mouseAction) { 704 // I think GLI works out what the child nodes are as the workspace tree is expanded, 705 // so childnodes don't exist when a toplevel node is closed/collapsed: so we can't 706 // pass the entire path in here, but have to mimic expanding one node at a time like 707 // a user: expand parent, then childnode, where each node is denoted by its Fullpath 708 // from root ancestor 709 JTreeFixture workspaceTree = window.tree("GatherPane.workspace_tree"); 710 711 String[] nodes = workspacePath.split("/"); 712 JTreeFixture wks_ptr = workspaceTree.expandPath(nodes[0]); 713 for(int i = 1; i < nodes.length; i++) { 714 String prevNode = nodes[i-1]; 715 nodes[i] = prevNode + "/" + nodes[i]; 716 System.err.println("\t" + nodes[i]); 717 if(i < (nodes.length-1)) { 718 wks_ptr = workspaceTree.expandPath(nodes[i]); 719 System.err.println("\tExpanded node: " + nodes[i]); 720 } else { // final node 721 System.err.println("\tFinal node: " + nodes[i]); 722 wks_ptr = handleLeafNode(workspaceTree, nodes[i], mouseAction); 723 } 724 } 690 725 691 726 //PAUSE(5); … … 693 728 // If wks_ptr stores the expanded workspace treeview, it's useful for dragging and dropping, 694 729 //return wks_ptr; 695 return treePath; 696 697 } 698 730 return workspacePath; 731 } 732 public static String openInExpandedWorkspace(String nodePath, int mouseAction) { 733 JTreeFixture workspaceTree = window.tree("GatherPane.workspace_tree"); 734 JTreeFixture wks_ptr = handleLeafNode(workspaceTree, nodePath, mouseAction); 735 return nodePath; 736 } 737 public static JTreeFixture selectPaths(int view, String folderPath, String[] nodes) 738 { 739 //https://joel-costigliola.github.io/assertj/swing/api/index.html?org/assertj/swing/core/Robot.html 740 741 742 final String startFolder = (view == WORKSPACE_VIEW) ? openInExpandedWorkspace(folderPath, EXPAND) : openCollectionPath(folderPath, EXPAND); 743 744 745 JTreeFixture tree = (view == WORKSPACE_VIEW) ? window.tree("GatherPane.workspace_tree") : window.tree("EnrichPane.collection_tree"); 746 747 for(i = 0; i < nodes.length; i++) { 748 nodes[i] = startFolder + "/" + nodes[i]; 749 } 750 // String... param: varargs 751 // https://stackoverflow.com/questions/2367398/what-is-the-ellipsis-for-in-this-method-signature 752 //"Note that the arguments may also be passed as an array of param type (this makes varargs backward compatible)." 753 // "Also note that passing 0 varargs (nothing) is legal." 754 tree = tree.selectPaths(nodes); 755 756 return tree; 757 } 758 699 759 public static JTreeFixture handleLeafNode(JTreeFixture tree, String node, int mouseAction){ 700 760 JTreeFixture tree_ptr = tree;
Note:
See TracChangeset
for help on using the changeset viewer.