Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.awt.event.InputEvent;
  2. import java.lang.reflect.InvocationTargetException;
  3. import java.util.logging.Level;
  4. import java.util.logging.Logger;
  5. import javax.swing.JFrame;
  6. import org.junit.Test;
  7. import org.netbeans.jemmy.ClassReference;
  8. import org.netbeans.jemmy.operators.JFrameOperator;
  9. import org.netbeans.jemmy.operators.JMenuBarOperator;
  10.  
  11. public class JemmyTestClass extends BaseClassSwing {
  12.  
  13.     public JemmyTestClass() {
  14.  
  15.         inputFolder = "C:\\PDFdata\\test_data\\baseline_specific\\highlights\\";
  16.         outputFolder = "C:\\PDFdata\\WIN\\specific\\output\\highlights\\";
  17.         baselineFolder = "C:\\PDFdata\\WIN\\specific\\baseline\\highlights\\";
  18.  
  19.     }
  20.  
  21.     /**
  22.      * Method to place actual test in, this test runs on all files in specified
  23.      * folder
  24.      * @param testFile File to be tested, this is just file name and not absolute file name
  25.      */
  26.     @Override
  27.     public void test(String testFile) {
  28.  
  29.         try {
  30.             //start application
  31.             ClassReference c = new ClassReference("org.jpedal.examples.viewer.Viewer");
  32.             c.startApplication(new String[]{inputFolder + testFile});
  33.  
  34.             //main frame to access all GUI components
  35.             final JFrameOperator mainFrame = new JFrameOperator();
  36.             ((JFrame) mainFrame.getSource()).setExtendedState(JFrame.MAXIMIZED_BOTH);
  37.  
  38.             mainFrame.typeKey('a', InputEvent.CTRL_DOWN_MASK);
  39.             Thread.sleep(1000);
  40.             getScreenshot(mainFrame.getSource(),
  41.             outputFolder + testFile.substring(testFile.indexOf(System.getProperty("file.separator")) + 1, testFile.length() - 4) + ".png");
  42.             Thread.sleep(1000);
  43.  
  44.             JMenuBarOperator exit = new JMenuBarOperator(mainFrame);
  45.             exit.pushMenu("File/Exit", "/");
  46.  
  47.         } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | InterruptedException ex) {
  48.             Logger.getLogger(JemmyTestClass.class.getName()).log(Level.SEVERE, null, ex);
  49.         }
  50.  
  51.     }
  52.  
  53.     @Test
  54.     @Override
  55.     public void testFiles() {
  56.         super.testFiles();
  57.     }
  58. }