4708 only perform screen shot when test times out first time

This commit is contained in:
William Schaefer 2019-02-19 14:05:09 -05:00
parent bd5c6ba37e
commit 825c7ecb09

View File

@ -42,6 +42,7 @@ import org.netbeans.jellytools.NbDialogOperator;
import org.netbeans.jellytools.WizardOperator; import org.netbeans.jellytools.WizardOperator;
import org.netbeans.jemmy.JemmyProperties; import org.netbeans.jemmy.JemmyProperties;
import org.netbeans.jemmy.Timeout; import org.netbeans.jemmy.Timeout;
import org.netbeans.jemmy.TimeoutExpiredException;
import org.netbeans.jemmy.Timeouts; import org.netbeans.jemmy.Timeouts;
import org.netbeans.jemmy.operators.JButtonOperator; import org.netbeans.jemmy.operators.JButtonOperator;
import org.netbeans.jemmy.operators.JCheckBoxOperator; import org.netbeans.jemmy.operators.JCheckBoxOperator;
@ -96,14 +97,20 @@ public class AutopsyTestCases {
} }
public void testNewCaseWizardOpen(String title) { public void testNewCaseWizardOpen(String title) {
try {
logger.info("New Case"); logger.info("New Case");
resetTimeouts("WindowWaiter.WaitWindowTimeout", 240000); setTimeout("WindowWaiter.WaitWindowTimeout", 240000);
NbDialogOperator nbdo = new NbDialogOperator(title); NbDialogOperator nbdo = new NbDialogOperator(title);
JButtonOperator jbo = new JButtonOperator(nbdo, 0); // the "New Case" button JButtonOperator jbo = new JButtonOperator(nbdo, 0); // the "New Case" button
jbo.pushNoBlock(); jbo.pushNoBlock();
} catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void testNewCaseWizard() { public void testNewCaseWizard() {
try {
logger.info("New Case Wizard"); logger.info("New Case Wizard");
WizardOperator wo = new WizardOperator("New Case Information"); WizardOperator wo = new WizardOperator("New Case Information");
JTextFieldOperator jtfo0 = new JTextFieldOperator(wo, 1); JTextFieldOperator jtfo0 = new JTextFieldOperator(wo, 1);
@ -117,17 +124,23 @@ public class AutopsyTestCases {
jtfo3.typeText("Examiner 1"); // Set the case examiner jtfo3.typeText("Examiner 1"); // Set the case examiner
start = System.currentTimeMillis(); start = System.currentTimeMillis();
wo.btFinish().clickMouse(); wo.btFinish().clickMouse();
} catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void testStartAddImageFileDataSource() { public void testStartAddImageFileDataSource() {
try {
/* /*
* This time out is to give time for creating case database and opening solr index * This time out is to give time for creating case database and
* opening solr index
*/ */
new Timeout("pausing", 120000).sleep(); new Timeout("pausing", 120000).sleep();
logger.info("Starting Add Image process"); logger.info("Starting Add Image process");
resetTimeouts("WindowWaiter.WaitWindowTimeOut", 240000); setTimeout("WindowWaiter.WaitWindowTimeOut", 240000);
WizardOperator wo = new WizardOperator("Add Data Source"); WizardOperator wo = new WizardOperator("Add Data Source");
while(!wo.btNext().isEnabled()){ while (!wo.btNext().isEnabled()) {
new Timeout("pausing", 1000).sleep(); // give it a second till the Add Data Source dialog enabled new Timeout("pausing", 1000).sleep(); // give it a second till the Add Data Source dialog enabled
} }
//select the toggle button for Disk Image or VM File it will be the first button created and proceed to next panel //select the toggle button for Disk Image or VM File it will be the first button created and proceed to next panel
@ -141,17 +154,23 @@ public class AutopsyTestCases {
JComboBoxOperator comboBoxOperator = new JComboBoxOperator(wo, 0); JComboBoxOperator comboBoxOperator = new JComboBoxOperator(wo, 0);
comboBoxOperator.setSelectedItem("(GMT-5:00) America/New_York"); comboBoxOperator.setSelectedItem("(GMT-5:00) America/New_York");
wo.btNext().clickMouse(); wo.btNext().clickMouse();
} catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void testStartAddLogicalFilesDataSource() { public void testStartAddLogicalFilesDataSource() {
try {
/* /*
* This time out is to give time for creating case database and opening solr index * This time out is to give time for creating case database and
* opening solr index
*/ */
new Timeout("pausing", 120000).sleep(); new Timeout("pausing", 120000).sleep();
logger.info("Starting Add Logical Files process"); logger.info("Starting Add Logical Files process");
WizardOperator wo = new WizardOperator("Add Data Source"); WizardOperator wo = new WizardOperator("Add Data Source");
wo.setTimeouts(resetTimeouts("WindowWaiter.WaitWindowTimeOut", 240000)); wo.setTimeouts(setTimeout("WindowWaiter.WaitWindowTimeOut", 240000));
while(!wo.btNext().isEnabled()){ while (!wo.btNext().isEnabled()) {
new Timeout("pausing", 1000).sleep(); // give it a second till the Add Data Source dialog enabled new Timeout("pausing", 1000).sleep(); // give it a second till the Add Data Source dialog enabled
} }
//select the toggle button for Logical Files it will be the third button created and proceed to next panel //select the toggle button for Logical Files it will be the third button created and proceed to next panel
@ -166,27 +185,37 @@ public class AutopsyTestCases {
fileChooserOperator.goUpLevel(); fileChooserOperator.goUpLevel();
fileChooserOperator.chooseFile(new File(getEscapedPath(System.getProperty("img_path"))).getName()); fileChooserOperator.chooseFile(new File(getEscapedPath(System.getProperty("img_path"))).getName());
wo.btNext().clickMouse(); wo.btNext().clickMouse();
} catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void testAddSourceWizard1() { public void testAddSourceWizard1() {
try {
WizardOperator wo = new WizardOperator("Add Data Source"); WizardOperator wo = new WizardOperator("Add Data Source");
while (!wo.btFinish().isEnabled()) { while (!wo.btFinish().isEnabled()) {
new Timeout("pausing", 1000).sleep(); // give it a second (or five) to process new Timeout("pausing", 1000).sleep(); // give it a second (or five) to process
} }
logger.log(Level.INFO, "Add image took {0}ms", (System.currentTimeMillis() - start)); logger.log(Level.INFO, "Add image took {0}ms", (System.currentTimeMillis() - start));
wo.btFinish().clickMouse(); wo.btFinish().clickMouse();
} catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void testConfigureIngest1() { public void testConfigureIngest1() {
try {
/* /*
* This timeout is to allow the setup for the ingest job settings panel * This timeout is to allow the setup for the ingest job settings
* to complete. * panel to complete.
*/ */
new Timeout("pausing", 10000).sleep(); new Timeout("pausing", 10000).sleep();
logger.info("Looking for hash lookup module in ingest job settings panel"); logger.info("Looking for hash lookup module in ingest job settings panel");
WizardOperator wo = new WizardOperator("Add Data Source"); WizardOperator wo = new WizardOperator("Add Data Source");
while(!wo.btNext().isEnabled()){ while (!wo.btNext().isEnabled()) {
new Timeout("pausing", 1000).sleep(); // give it a second till the Add Data Source dialog enabled new Timeout("pausing", 1000).sleep(); // give it a second till the Add Data Source dialog enabled
} }
JTableOperator jto = new JTableOperator(wo, 0); JTableOperator jto = new JTableOperator(wo, 0);
@ -196,9 +225,14 @@ public class AutopsyTestCases {
JButtonOperator jbo1 = new JButtonOperator(wo, "Global Settings"); JButtonOperator jbo1 = new JButtonOperator(wo, "Global Settings");
jbo1.pushNoBlock(); jbo1.pushNoBlock();
logger.info("Pushed Global Settings button for hash lookup module in ingest job settings panel"); logger.info("Pushed Global Settings button for hash lookup module in ingest job settings panel");
} catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void testConfigureHash() { public void testConfigureHash() {
try {
logger.info("Hash Configure"); logger.info("Hash Configure");
JDialog hashMainDialog = JDialogOperator.waitJDialog("Global Hash Lookup Settings", false, false); JDialog hashMainDialog = JDialogOperator.waitJDialog("Global Hash Lookup Settings", false, false);
JDialogOperator hashMainDialogOperator = new JDialogOperator(hashMainDialog); JDialogOperator hashMainDialogOperator = new JDialogOperator(hashMainDialog);
@ -230,12 +264,17 @@ public class AutopsyTestCases {
//jbo3.pushNoBlock(); //jbo3.pushNoBlock();
JButtonOperator jbo4 = new JButtonOperator(hashMainDialogOperator, "OK", 0); JButtonOperator jbo4 = new JButtonOperator(hashMainDialogOperator, "OK", 0);
jbo4.pushNoBlock(); jbo4.pushNoBlock();
} catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void testConfigureIngest2() { public void testConfigureIngest2() {
try {
logger.info("Looking for keyword search module in ingest job settings panel"); logger.info("Looking for keyword search module in ingest job settings panel");
WizardOperator wo = new WizardOperator("Add Data Source"); WizardOperator wo = new WizardOperator("Add Data Source");
while(!wo.btNext().isEnabled()){ while (!wo.btNext().isEnabled()) {
new Timeout("pausing", 1000).sleep(); // give it a second till the Add Data Source dialog enabled new Timeout("pausing", 1000).sleep(); // give it a second till the Add Data Source dialog enabled
} }
JTableOperator jto = new JTableOperator(wo, 0); JTableOperator jto = new JTableOperator(wo, 0);
@ -245,9 +284,14 @@ public class AutopsyTestCases {
JButtonOperator jbo1 = new JButtonOperator(wo, "Global Settings"); JButtonOperator jbo1 = new JButtonOperator(wo, "Global Settings");
jbo1.pushNoBlock(); jbo1.pushNoBlock();
logger.info("Pushed Global Settings button for keyword search module in ingest job settings panel"); logger.info("Pushed Global Settings button for keyword search module in ingest job settings panel");
} catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void testConfigureSearch() { public void testConfigureSearch() {
try {
logger.info("Search Configure"); logger.info("Search Configure");
JDialog jd = JDialogOperator.waitJDialog("Global Keyword Search Settings", false, false); JDialog jd = JDialogOperator.waitJDialog("Global Keyword Search Settings", false, false);
JDialogOperator jdo = new JDialogOperator(jd); JDialogOperator jdo = new JDialogOperator(jd);
@ -273,9 +317,14 @@ public class AutopsyTestCases {
WizardOperator wo = new WizardOperator("Add Data Source"); WizardOperator wo = new WizardOperator("Add Data Source");
new Timeout("pausing", 10000).sleep(); // let things catch up new Timeout("pausing", 10000).sleep(); // let things catch up
wo.btNext().clickMouse(); wo.btNext().clickMouse();
} catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void testIngest() { public void testIngest() {
try {
logger.info("Ingest 3"); logger.info("Ingest 3");
new Timeout("pausing", 10000).sleep(); // wait for ingest to actually start new Timeout("pausing", 10000).sleep(); // wait for ingest to actually start
long startIngest = System.currentTimeMillis(); long startIngest = System.currentTimeMillis();
@ -289,31 +338,43 @@ public class AutopsyTestCases {
// consistently, making it seem like default behavior // consistently, making it seem like default behavior
Random rand = new Random(); Random rand = new Random();
new Timeout("pausing", 10000 + (rand.nextInt(15000) + 5000)).sleep(); new Timeout("pausing", 10000 + (rand.nextInt(15000) + 5000)).sleep();
screenshot("Finished Ingest"); } catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void testExpandDataSourcesTree() { public void testExpandDataSourcesTree() {
try {
logger.info("Data Sources Node"); logger.info("Data Sources Node");
MainWindowOperator mwo = MainWindowOperator.getDefault(); MainWindowOperator mwo = MainWindowOperator.getDefault();
JTreeOperator jto = new JTreeOperator(mwo, "Data Sources"); JTreeOperator jto = new JTreeOperator(mwo, "Data Sources");
String [] nodeNames = {"Data Sources"}; String[] nodeNames = {"Data Sources"};
TreePath tp = jto.findPath(nodeNames); TreePath tp = jto.findPath(nodeNames);
expandNodes(jto, tp); expandNodes(jto, tp);
screenshot("Data Sources Tree"); } catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void testGenerateReportToolbar() { public void testGenerateReportToolbar() {
try {
logger.info("Generate Report Toolbars"); logger.info("Generate Report Toolbars");
MainWindowOperator mwo = MainWindowOperator.getDefault(); MainWindowOperator mwo = MainWindowOperator.getDefault();
JButtonOperator jbo = new JButtonOperator(mwo, "Generate Report"); JButtonOperator jbo = new JButtonOperator(mwo, "Generate Report");
jbo.pushNoBlock(); jbo.pushNoBlock();
new Timeout("pausing", 5000).sleep(); } catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void testGenerateReportButton() throws IOException { public void testGenerateReportButton() throws IOException {
try {
logger.info("Generate Report Button"); logger.info("Generate Report Button");
resetTimeouts("ComponentOperator.WaitComponentTimeout", 240000); setTimeout("ComponentOperator.WaitComponentTimeout", 240000);
JDialog reportDialog = JDialogOperator.waitJDialog("Generate Report", false, false); JDialog reportDialog = JDialogOperator.waitJDialog("Generate Report", false, false);
JDialogOperator reportDialogOperator = new JDialogOperator(reportDialog); JDialogOperator reportDialogOperator = new JDialogOperator(reportDialog);
JListOperator listOperator = new JListOperator(reportDialogOperator); JListOperator listOperator = new JListOperator(reportDialogOperator);
@ -327,38 +388,42 @@ public class AutopsyTestCases {
JButtonOperator jbo1 = new JButtonOperator(reportDialogOperator, "Finish"); JButtonOperator jbo1 = new JButtonOperator(reportDialogOperator, "Finish");
jbo1.pushNoBlock(); jbo1.pushNoBlock();
JDialog previewDialog = JDialogOperator.waitJDialog("Progress", false, false); JDialog previewDialog = JDialogOperator.waitJDialog("Progress", false, false);
screenshot("Progress");
JDialogOperator previewDialogOperator = new JDialogOperator(previewDialog); JDialogOperator previewDialogOperator = new JDialogOperator(previewDialog);
JLabelOperator.waitJLabel(previewDialog, "Complete", false, false); JLabelOperator.waitJLabel(previewDialog, "Complete", false, false);
JButtonOperator jbo2 = new JButtonOperator(previewDialogOperator, "Close"); JButtonOperator jbo2 = new JButtonOperator(previewDialogOperator, "Close");
jbo2.pushNoBlock(); jbo2.pushNoBlock();
new Timeout("pausing", 10000).sleep(); new Timeout("pausing", 10000).sleep();
System.setProperty("ReportStr", datenotime); System.setProperty("ReportStr", datenotime);
screenshot("Done Testing"); } catch (TimeoutExpiredException ex) {
screenshot("TimeoutScreenshot");
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
}
} }
public void screenshot(String name) { public void screenshot(String name) {
String outPath = getEscapedPath(System.getProperty("out_path"));
File screenShotFile = new File(outPath + "\\" + name + ".png");
if (!screenShotFile.exists()) {
logger.info("Taking screenshot."); logger.info("Taking screenshot.");
try { try {
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
BufferedImage capture = new Robot().createScreenCapture(screenRect); BufferedImage capture = new Robot().createScreenCapture(screenRect);
String outPath = getEscapedPath(System.getProperty("out_path")); ImageIO.write(capture, "png", screenShotFile);
ImageIO.write(capture, "png", new File(outPath + "\\" + name + ".png"));
new Timeout("pausing", 1000).sleep(); // give it a second to save new Timeout("pausing", 1000).sleep(); // give it a second to save
} catch (IOException ex) { } catch (IOException ex) {
logger.log(Level.WARNING, "IOException taking screenshot.", ex); logger.log(Level.WARNING, "IOException taking screenshot.", ex);
} catch (AWTException ex) { } catch (AWTException ex) {
logger.log(Level.WARNING, "AWTException taking screenshot.", ex); logger.log(Level.WARNING, "AWTException taking screenshot.", ex);
}
} }
} }
/* /*
* Nightly test failed at WindowWaiter.WaitWindowTimeOut because of TimeoutExpiredException. So we * Nightly test failed at WindowWaiter.WaitWindowTimeOut because of
* use this conveninent method to override the default Jemmy Timeouts value. * TimeoutExpiredException. So we use this conveninent method to override
* the default Jemmy Timeouts value.
*/ */
private Timeouts setTimeout(String name, int value) {
private Timeouts resetTimeouts(String name, int value) {
Timeouts timeouts = JemmyProperties.getCurrentTimeouts(); Timeouts timeouts = JemmyProperties.getCurrentTimeouts();
timeouts.setTimeout(name, value); timeouts.setTimeout(name, value);
return timeouts; return timeouts;
@ -394,7 +459,7 @@ public class AutopsyTestCases {
} }
} }
private void expandNodes (JTreeOperator jto, TreePath tp) { private void expandNodes(JTreeOperator jto, TreePath tp) {
try { try {
jto.expandPath(tp); jto.expandPath(tp);
for (TreePath t : jto.getChildPaths(tp)) { for (TreePath t : jto.getChildPaths(tp)) {