import java.awt.event.InputEvent;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import org.junit.Test;
import org.netbeans.jemmy.ClassReference;
import org.netbeans.jemmy.operators.JFrameOperator;
import org.netbeans.jemmy.operators.JMenuBarOperator;
public class JemmyTestClass extends BaseClassSwing {
public JemmyTestClass() {
inputFolder = "C:\\PDFdata\\test_data\\baseline_specific\\highlights\\";
outputFolder = "C:\\PDFdata\\WIN\\specific\\output\\highlights\\";
baselineFolder = "C:\\PDFdata\\WIN\\specific\\baseline\\highlights\\";
}
/**
* Method to place actual test in, this test runs on all files in specified
* folder
* @param testFile File to be tested, this is just file name and not absolute file name
*/
@Override
public void test(String testFile) {
try {
//start application
ClassReference c = new ClassReference("org.jpedal.examples.viewer.Viewer");
c.startApplication(new String[]{inputFolder + testFile});
//main frame to access all GUI components
final JFrameOperator mainFrame = new JFrameOperator();
((JFrame) mainFrame.getSource()).setExtendedState(JFrame.MAXIMIZED_BOTH);
mainFrame.typeKey('a', InputEvent.CTRL_DOWN_MASK);
Thread.sleep(1000);
getScreenshot(mainFrame.getSource(),
outputFolder + testFile.substring(testFile.indexOf(System.getProperty("file.separator")) + 1, testFile.length() - 4) + ".png");
Thread.sleep(1000);
JMenuBarOperator exit = new JMenuBarOperator(mainFrame);
exit.pushMenu("File/Exit", "/");
} catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | InterruptedException ex) {
Logger.getLogger(JemmyTestClass.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Test
@Override
public void testFiles() {
super.testFiles();
}
}