Ignore:
Timestamp:
2018-12-18T21:22:40+13:00 (5 years ago)
Author:
ak19
Message:
  1. window (the main app windows of running GLI, or later GEMS) is now instantiated and a handle kept to it inside GSGUITestingUtil after all. The test class now calls GSGUITestingUtil.runGLI() followed by getApplicationWindow() to launch GLI and get a hold of its window and then sets its own private reference to it. 2. Added an abort listener to stop the running test suite on assertj-swing's default abort key combination of Ctrl+Shift+A. 3. More cleaning up.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/testing/trunk/src/src/org/greenstone/gsdl3/testing/GSGUITestingUtil.java

    r32713 r32714  
    1616import org.greenstone.gatherer.GathererProg; // main GLI class we'll be testing
    1717import org.greenstone.gatherer.Dictionary; // access to display strings
     18
     19
     20// Java GUI testing with AssertJ Swing
     21import org.assertj.swing.junit.testcase.AssertJSwingJUnitTestCase;
     22import org.assertj.swing.fixture.*;
     23import org.assertj.swing.edt.GuiActionRunner;
     24import org.assertj.swing.core.Robot;
     25
     26
     27// static imports
     28import static org.assertj.swing.launcher.ApplicationLauncher.*;
     29import static org.assertj.swing.finder.WindowFinder.findFrame;
    1830
    1931/*
     
    4254    // can have easier access to those GUI components when testing here through their names   
    4355
    44     /************************ GENERAL *******************************/
    45 
    46     public static void setWindow(FrameFixture w) { window = w; }
    47    
     56    /****************************** APPLICATION  *******************************/
    4857    public static void PAUSE() {   
    4958    PAUSE(5);
     
    5867         e.printStackTrace();
    5968     }
    60     }
    61    
     69    }   
     70
     71    //public static void setWindow(FrameFixture w) { window = w; } // if we want to null window
     72   
     73    public static void runGLI() {
     74    //GathererProg frame = GuiActionRunner.execute(() -> new GathererProg());           
     75   
     76    // IMPORTANT, note the call to 'robot()': must use the Robot from AssertJSwingJUnitTestCase
     77    //window = new FrameFixture(robot(), frame);
     78    //window.show(); // shows the frame to test
     79
     80    // Instead, we'll be launching GLI and then getting a ref to the launched app window:
     81     
     82    // Launch GathererProg.java's main() method
     83    // See https://joel-costigliola.github.io/assertj/assertj-swing-launch.html
     84   
     85    String GSDLOS = System.getenv("GSDLOS");
     86    String GSDLHOME = System.getenv("GSDLHOME");
     87    String GSDL3HOME = System.getenv("GSDL3HOME");
     88    String GSDL3SRCHOME = System.getenv("GSDL3SRCHOME");
     89    application("org.greenstone.gatherer.GathererProg").withArgs(
     90                                 "-gsdl", GSDLHOME,
     91                                 "-gsdlos", GSDLOS,
     92                                 "-gsdl3", GSDL3HOME,
     93                                 "-gsdl3src", GSDL3SRCHOME,
     94                                 "-testing_mode").start();
     95    // The -testing_mode flag passed into GLI above is a special flag
     96    // that calls GLI's TestingPreparating.setNamesRecursively()
     97    // to help testing by calling setName() on GUI components.
     98    }
     99   
     100    public static void exitGLI() {
     101    openMenuItem("file", "exit");
     102    }
     103
     104    // Gets a ref to the main window (FrameFixture) of a running GLI
     105    public static FrameFixture getGLIApplicationWindow(Robot robot) {
     106    // locate and set the internal FrameFixture member variable 'window' and return a handle to it
     107    window = findFrame("GUIManager").using(robot); // GLI application JFrame's name is set to its classname, 'GUIManager'
     108
     109    // https://joel-costigliola.github.io/assertj/swing/api/index.html?org/assertj/swing/launcher/ApplicationLauncher.html
     110    // "To change the speed of a GUI test, you need to change the values of both delayBetweenEvents and eventPostingDelay."
     111    //robot.settings().delayBetweenEvents(50);
     112    //robot.settings().eventPostingDelay(2*SECOND); // annoying, after every click!
     113   
     114    return window;
     115    }
     116   
     117    /****************************** BASICS  *******************************/
     118
    62119   
    63120    //https://joel-costigliola.github.io/assertj/swing/api/org/assertj/swing/fixture/FrameFixture.html
     
    122179    }
    123180
    124     public static void exitGLI() {
    125     openMenuItem("file", "exit");
    126     PAUSE(5);
    127     }
    128181   
    129182    public static void closeCollection(){
     
    315368    }
    316369
     370
     371    /********************* GEMS ******************/
     372   
     373    // TODO:
     374    public static void runGEMS() {}
     375    public static void exitGEMS() {}
     376    public static FrameFixture getGEMSApplicationWindow(Robot robot) {
     377    // TODO: don't forget to set internal member variable called 'window' before returning it
     378    return window;
     379    }
     380   
    317381    // Moving these working bits of code here, in case I can use them to right
    318382    // general get methods that make use of the GenericTypeMatcher method of accessing components
Note: See TracChangeset for help on using the changeset viewer.