Changeset 39024


Ignore:
Timestamp:
2024-05-14T23:04:30+12:00 (4 weeks ago)
Author:
anupama
Message:
  1. Properties file needd in lib to specify samplefiles.path, the file location of sample-files, so it can be located in GLI's workspace view for dragging and drop it into a collection. 2. Selection in the GatherPane's workspace and collection views implemented. Next up will be to implement dragging and dropping here.
Location:
gs3-extensions/testing/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/testing/trunk/src/build.xml

    r39016 r39024  
    9494<!-- https://stackoverflow.com/questions/10704324/how-to-add-to-classpath-all-classes-from-set-of-directories-in-ant -->
    9595<path id="tutorials.path">
    96 
     96  <!-- Path to properties file -->
     97  <pathelement path="${ext.test.folder}/lib"/>
     98 
    9799  <!-- Includes ant-nodeps-1.8.1 from 2010 that replaces 2005's optional.jar of ant
    98100       for generating reports -->
     
    112114  <fileset dir="${gli.home}/lib">
    113115    <include name="*.jar"/>
    114   </fileset> 
     116  </fileset>
    115117</path>
    116118
  • gs3-extensions/testing/trunk/src/src/gstests/tutorials/RunGLITest.java

    r39022 r39024  
    6767// Java imports
    6868import javax.swing.*;
     69import java.util.Properties;
     70import java.io.InputStream;
     71//import java.io.IOException;
    6972
    7073// static imports - call static functions without class as namespace qualifier
     
    8285    private FrameFixture window;
    8386
     87    private static Properties props;
     88   
    8489    // Changing Exit SecurityManager is now unused as GLI now doesn't System.exit in testing mode
    8590    // https://stackoverflow.com/questions/50815329/close-application-after-test-without-test-failure-using-assertj
    8691    // https://stackoverflow.com/questions/23139321/testing-java-gui-application-closing-window-during-test-ends-test-suite
    8792    // https://stackoverflow.com/questions/5401281/preventing-system-exit-from-api
    88     /*
     93   
    8994    @BeforeClass
    9095    public static void initOnce() {
    9196    // to prevent system.exit from causing issues
    9297    //org.assertj.swing.security.NoExitSecurityManagerInstaller.installNoExitSecurityManager();
    93     }
    94     */
     98
     99    props = new Properties();
     100    loadProperties();
     101    }
     102   
    95103    // Selenium
    96104    @Before
     
    126134   
    127135   
    128   @Test
     136    //@Test
    129137  public void testGLIRunning() {
    130138      // waiting a few seconds for window, so we can see it
     
    156164      // For testing, want GLI to be in librarian mode by default
    157165      changeUserMode("librarian");
    158      
     166      /*     
    159167      switchToPane(GATHER_PANE);
    160168     
     
    179187     
    180188      switchToPane(GATHER_PANE);     
    181 
     189      */
    182190      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
    183191     
     
    225233    stealAnyCollectionLock(1);
    226234    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    }
    230275}
  • gs3-extensions/testing/trunk/src/src/org/greenstone/gsdl3/testing/GSGUITestingUtil.java

    r39022 r39024  
    5555    public static final String CREATE_PANE = "Create";
    5656    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";
    5764   
    5865    public static Robot robot = null;
     
    142149   
    143150    //https://joel-costigliola.github.io/assertj/swing/api/org/assertj/swing/fixture/FrameFixture.html
    144     public static void switchToPane(String pane) {
     151    public static JTabbedPaneFixture switchToPane(String pane) {
    145152    String paneLabel = Dictionary.get("GUI." + pane); // e.g. GUI.Enrich
    146153    //JPanelFixture tab = window.panel(pane); // this just gets us the JPanel of controls within
    147154    JTabbedPaneFixture tab = window.tabbedPane("GUIManager.tab_pane");
    148     tab.selectTab(paneLabel); // select tab by its title
     155    return tab.selectTab(paneLabel); // select tab by its title
    149156    }
    150157    public static void openMenuItem(String menu, String subMenu) {
     
    179186        stealCollectionLock(timeoutSeconds);
    180187    } catch(Exception e) {
    181         System.err.println("@@@@@@@@@@@@@ No lockfile dialog appeared.");
     188        System.err.println("@@@@@@@@@@@@@ No lockfile dialog appeared.\n");
    182189    }
    183190    }
     
    384391    public static void dragNDrop(String workspacePath, String collPath) {}
    385392
     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   
    386483    /********************* ENRICH PANE ******************/
    387484    // docPath can be just docName or collectionSubfolder/Subfolder2/docName
Note: See TracChangeset for help on using the changeset viewer.