mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-11 23:46:15 +00:00
4708 only perform screen shot when test times out first time
This commit is contained in:
parent
bd5c6ba37e
commit
825c7ecb09
@ -42,6 +42,7 @@ import org.netbeans.jellytools.NbDialogOperator;
|
||||
import org.netbeans.jellytools.WizardOperator;
|
||||
import org.netbeans.jemmy.JemmyProperties;
|
||||
import org.netbeans.jemmy.Timeout;
|
||||
import org.netbeans.jemmy.TimeoutExpiredException;
|
||||
import org.netbeans.jemmy.Timeouts;
|
||||
import org.netbeans.jemmy.operators.JButtonOperator;
|
||||
import org.netbeans.jemmy.operators.JCheckBoxOperator;
|
||||
@ -96,14 +97,20 @@ public class AutopsyTestCases {
|
||||
}
|
||||
|
||||
public void testNewCaseWizardOpen(String title) {
|
||||
try {
|
||||
logger.info("New Case");
|
||||
resetTimeouts("WindowWaiter.WaitWindowTimeout", 240000);
|
||||
setTimeout("WindowWaiter.WaitWindowTimeout", 240000);
|
||||
NbDialogOperator nbdo = new NbDialogOperator(title);
|
||||
JButtonOperator jbo = new JButtonOperator(nbdo, 0); // the "New Case" button
|
||||
jbo.pushNoBlock();
|
||||
} catch (TimeoutExpiredException ex) {
|
||||
screenshot("TimeoutScreenshot");
|
||||
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void testNewCaseWizard() {
|
||||
try {
|
||||
logger.info("New Case Wizard");
|
||||
WizardOperator wo = new WizardOperator("New Case Information");
|
||||
JTextFieldOperator jtfo0 = new JTextFieldOperator(wo, 1);
|
||||
@ -117,17 +124,23 @@ public class AutopsyTestCases {
|
||||
jtfo3.typeText("Examiner 1"); // Set the case examiner
|
||||
start = System.currentTimeMillis();
|
||||
wo.btFinish().clickMouse();
|
||||
} catch (TimeoutExpiredException ex) {
|
||||
screenshot("TimeoutScreenshot");
|
||||
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
logger.info("Starting Add Image process");
|
||||
resetTimeouts("WindowWaiter.WaitWindowTimeOut", 240000);
|
||||
setTimeout("WindowWaiter.WaitWindowTimeOut", 240000);
|
||||
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
|
||||
}
|
||||
//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);
|
||||
comboBoxOperator.setSelectedItem("(GMT-5:00) America/New_York");
|
||||
wo.btNext().clickMouse();
|
||||
} catch (TimeoutExpiredException ex) {
|
||||
screenshot("TimeoutScreenshot");
|
||||
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
logger.info("Starting Add Logical Files process");
|
||||
WizardOperator wo = new WizardOperator("Add Data Source");
|
||||
wo.setTimeouts(resetTimeouts("WindowWaiter.WaitWindowTimeOut", 240000));
|
||||
while(!wo.btNext().isEnabled()){
|
||||
wo.setTimeouts(setTimeout("WindowWaiter.WaitWindowTimeOut", 240000));
|
||||
while (!wo.btNext().isEnabled()) {
|
||||
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
|
||||
@ -166,27 +185,37 @@ public class AutopsyTestCases {
|
||||
fileChooserOperator.goUpLevel();
|
||||
fileChooserOperator.chooseFile(new File(getEscapedPath(System.getProperty("img_path"))).getName());
|
||||
wo.btNext().clickMouse();
|
||||
} catch (TimeoutExpiredException ex) {
|
||||
screenshot("TimeoutScreenshot");
|
||||
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void testAddSourceWizard1() {
|
||||
try {
|
||||
WizardOperator wo = new WizardOperator("Add Data Source");
|
||||
while (!wo.btFinish().isEnabled()) {
|
||||
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));
|
||||
wo.btFinish().clickMouse();
|
||||
} catch (TimeoutExpiredException ex) {
|
||||
screenshot("TimeoutScreenshot");
|
||||
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void testConfigureIngest1() {
|
||||
try {
|
||||
/*
|
||||
* This timeout is to allow the setup for the ingest job settings panel
|
||||
* to complete.
|
||||
* This timeout is to allow the setup for the ingest job settings
|
||||
* panel to complete.
|
||||
*/
|
||||
new Timeout("pausing", 10000).sleep();
|
||||
|
||||
logger.info("Looking for hash lookup module in ingest job settings panel");
|
||||
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
|
||||
}
|
||||
JTableOperator jto = new JTableOperator(wo, 0);
|
||||
@ -196,9 +225,14 @@ public class AutopsyTestCases {
|
||||
JButtonOperator jbo1 = new JButtonOperator(wo, "Global Settings");
|
||||
jbo1.pushNoBlock();
|
||||
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() {
|
||||
try {
|
||||
logger.info("Hash Configure");
|
||||
JDialog hashMainDialog = JDialogOperator.waitJDialog("Global Hash Lookup Settings", false, false);
|
||||
JDialogOperator hashMainDialogOperator = new JDialogOperator(hashMainDialog);
|
||||
@ -230,12 +264,17 @@ public class AutopsyTestCases {
|
||||
//jbo3.pushNoBlock();
|
||||
JButtonOperator jbo4 = new JButtonOperator(hashMainDialogOperator, "OK", 0);
|
||||
jbo4.pushNoBlock();
|
||||
} catch (TimeoutExpiredException ex) {
|
||||
screenshot("TimeoutScreenshot");
|
||||
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void testConfigureIngest2() {
|
||||
try {
|
||||
logger.info("Looking for keyword search module in ingest job settings panel");
|
||||
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
|
||||
}
|
||||
JTableOperator jto = new JTableOperator(wo, 0);
|
||||
@ -245,9 +284,14 @@ public class AutopsyTestCases {
|
||||
JButtonOperator jbo1 = new JButtonOperator(wo, "Global Settings");
|
||||
jbo1.pushNoBlock();
|
||||
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() {
|
||||
try {
|
||||
logger.info("Search Configure");
|
||||
JDialog jd = JDialogOperator.waitJDialog("Global Keyword Search Settings", false, false);
|
||||
JDialogOperator jdo = new JDialogOperator(jd);
|
||||
@ -273,9 +317,14 @@ public class AutopsyTestCases {
|
||||
WizardOperator wo = new WizardOperator("Add Data Source");
|
||||
new Timeout("pausing", 10000).sleep(); // let things catch up
|
||||
wo.btNext().clickMouse();
|
||||
} catch (TimeoutExpiredException ex) {
|
||||
screenshot("TimeoutScreenshot");
|
||||
logger.log(Level.SEVERE, "AutopsyTestCases.testNewCaseWizard encountered timed out", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void testIngest() {
|
||||
try {
|
||||
logger.info("Ingest 3");
|
||||
new Timeout("pausing", 10000).sleep(); // wait for ingest to actually start
|
||||
long startIngest = System.currentTimeMillis();
|
||||
@ -289,31 +338,43 @@ public class AutopsyTestCases {
|
||||
// consistently, making it seem like default behavior
|
||||
Random rand = new Random();
|
||||
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() {
|
||||
try {
|
||||
logger.info("Data Sources Node");
|
||||
MainWindowOperator mwo = MainWindowOperator.getDefault();
|
||||
JTreeOperator jto = new JTreeOperator(mwo, "Data Sources");
|
||||
String [] nodeNames = {"Data Sources"};
|
||||
String[] nodeNames = {"Data Sources"};
|
||||
TreePath tp = jto.findPath(nodeNames);
|
||||
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() {
|
||||
try {
|
||||
logger.info("Generate Report Toolbars");
|
||||
MainWindowOperator mwo = MainWindowOperator.getDefault();
|
||||
JButtonOperator jbo = new JButtonOperator(mwo, "Generate Report");
|
||||
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 {
|
||||
try {
|
||||
logger.info("Generate Report Button");
|
||||
resetTimeouts("ComponentOperator.WaitComponentTimeout", 240000);
|
||||
setTimeout("ComponentOperator.WaitComponentTimeout", 240000);
|
||||
JDialog reportDialog = JDialogOperator.waitJDialog("Generate Report", false, false);
|
||||
JDialogOperator reportDialogOperator = new JDialogOperator(reportDialog);
|
||||
JListOperator listOperator = new JListOperator(reportDialogOperator);
|
||||
@ -327,38 +388,42 @@ public class AutopsyTestCases {
|
||||
JButtonOperator jbo1 = new JButtonOperator(reportDialogOperator, "Finish");
|
||||
jbo1.pushNoBlock();
|
||||
JDialog previewDialog = JDialogOperator.waitJDialog("Progress", false, false);
|
||||
screenshot("Progress");
|
||||
JDialogOperator previewDialogOperator = new JDialogOperator(previewDialog);
|
||||
JLabelOperator.waitJLabel(previewDialog, "Complete", false, false);
|
||||
JButtonOperator jbo2 = new JButtonOperator(previewDialogOperator, "Close");
|
||||
jbo2.pushNoBlock();
|
||||
new Timeout("pausing", 10000).sleep();
|
||||
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) {
|
||||
String outPath = getEscapedPath(System.getProperty("out_path"));
|
||||
File screenShotFile = new File(outPath + "\\" + name + ".png");
|
||||
if (!screenShotFile.exists()) {
|
||||
logger.info("Taking screenshot.");
|
||||
try {
|
||||
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
|
||||
BufferedImage capture = new Robot().createScreenCapture(screenRect);
|
||||
String outPath = getEscapedPath(System.getProperty("out_path"));
|
||||
ImageIO.write(capture, "png", new File(outPath + "\\" + name + ".png"));
|
||||
ImageIO.write(capture, "png", screenShotFile);
|
||||
new Timeout("pausing", 1000).sleep(); // give it a second to save
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.WARNING, "IOException taking screenshot.", ex);
|
||||
} catch (AWTException ex) {
|
||||
logger.log(Level.WARNING, "AWTException taking screenshot.", ex);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Nightly test failed at WindowWaiter.WaitWindowTimeOut because of TimeoutExpiredException. So we
|
||||
* use this conveninent method to override the default Jemmy Timeouts value.
|
||||
* Nightly test failed at WindowWaiter.WaitWindowTimeOut because of
|
||||
* TimeoutExpiredException. So we use this conveninent method to override
|
||||
* the default Jemmy Timeouts value.
|
||||
*/
|
||||
|
||||
private Timeouts resetTimeouts(String name, int value) {
|
||||
private Timeouts setTimeout(String name, int value) {
|
||||
Timeouts timeouts = JemmyProperties.getCurrentTimeouts();
|
||||
timeouts.setTimeout(name, value);
|
||||
return timeouts;
|
||||
@ -394,7 +459,7 @@ public class AutopsyTestCases {
|
||||
}
|
||||
}
|
||||
|
||||
private void expandNodes (JTreeOperator jto, TreePath tp) {
|
||||
private void expandNodes(JTreeOperator jto, TreePath tp) {
|
||||
try {
|
||||
jto.expandPath(tp);
|
||||
for (TreePath t : jto.getChildPaths(tp)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user