19 package org.sleuthkit.autopsy.testing;
21 import java.awt.AWTException;
22 import java.awt.Rectangle;
23 import java.awt.Robot;
24 import java.awt.Toolkit;
25 import java.awt.image.BufferedImage;
27 import java.io.IOException;
28 import java.text.DateFormat;
29 import java.text.SimpleDateFormat;
30 import java.util.ArrayList;
31 import java.util.Date;
32 import java.util.List;
33 import java.util.Random;
34 import java.util.logging.Level;
35 import java.util.logging.Logger;
36 import javax.imageio.ImageIO;
37 import javax.swing.JDialog;
38 import javax.swing.text.JTextComponent;
39 import org.netbeans.jellytools.MainWindowOperator;
40 import org.netbeans.jellytools.NbDialogOperator;
41 import org.netbeans.jellytools.WizardOperator;
42 import org.netbeans.jemmy.Timeout;
43 import org.netbeans.jemmy.operators.JButtonOperator;
44 import org.netbeans.jemmy.operators.JCheckBoxOperator;
45 import org.netbeans.jemmy.operators.JComboBoxOperator;
46 import org.netbeans.jemmy.operators.JDialogOperator;
47 import org.netbeans.jemmy.operators.JFileChooserOperator;
48 import org.netbeans.jemmy.operators.JLabelOperator;
49 import org.netbeans.jemmy.operators.JListOperator;
50 import org.netbeans.jemmy.operators.JTabbedPaneOperator;
51 import org.netbeans.jemmy.operators.JTableOperator;
52 import org.netbeans.jemmy.operators.JTextFieldOperator;
53 import org.netbeans.jemmy.operators.JToggleButtonOperator;
71 if (path.startsWith(
"\\\\")) {
74 if (path.startsWith(
"\\")) {
86 logger.info(
"New Case");
87 NbDialogOperator nbdo =
new NbDialogOperator(title);
88 JButtonOperator jbo =
new JButtonOperator(nbdo, 0);
93 logger.info(
"New Case Wizard");
94 WizardOperator wo =
new WizardOperator(
"New Case Information");
95 JTextFieldOperator jtfo0 =
new JTextFieldOperator(wo, 1);
96 jtfo0.typeText(
"AutopsyTestCase");
97 JTextFieldOperator jtfo1 =
new JTextFieldOperator(wo, 2);
99 wo.btNext().clickMouse();
100 JTextFieldOperator jtfo2 =
new JTextFieldOperator(wo, 0);
101 jtfo2.typeText(
"000");
102 JTextFieldOperator jtfo3 =
new JTextFieldOperator(wo, 1);
103 jtfo3.typeText(
"Examiner 1");
104 start = System.currentTimeMillis();
105 wo.btFinish().clickMouse();
109 logger.info(
"Starting Add Image process");
110 WizardOperator wo =
new WizardOperator(
"Add Data");
112 JToggleButtonOperator jtbo =
new JToggleButtonOperator(wo, 0);
114 wo.btNext().clickMouse();
115 JTextFieldOperator jtfo0 =
new JTextFieldOperator(wo, 0);
117 String imageDir = img_path;
118 ((JTextComponent) jtfo0.getSource()).setText(imageDir);
119 JComboBoxOperator comboBoxOperator =
new JComboBoxOperator(wo, 0);
120 comboBoxOperator.setSelectedItem(
"(GMT-5:00) America/New_York");
121 wo.btNext().clickMouse();
125 logger.info(
"Starting Add Logical Files process");
126 WizardOperator wo =
new WizardOperator(
"Add Data");
128 JToggleButtonOperator jtbo =
new JToggleButtonOperator(wo, 2);
130 wo.btNext().clickMouse();
131 JButtonOperator addButtonOperator =
new JButtonOperator(wo,
"Add");
132 addButtonOperator.pushNoBlock();
133 JFileChooserOperator fileChooserOperator =
new JFileChooserOperator();
134 fileChooserOperator.setCurrentDirectory(
new File(
getEscapedPath(System.getProperty(
"img_path"))));
136 fileChooserOperator.goUpLevel();
137 fileChooserOperator.chooseFile(
new File(
getEscapedPath(System.getProperty(
"img_path"))).getName());
138 wo.btNext().clickMouse();
142 WizardOperator wo =
new WizardOperator(
"Add Data");
143 while (!wo.btFinish().isEnabled()) {
144 new Timeout(
"pausing", 1000).sleep();
146 logger.log(Level.INFO,
"Add image took {0}ms", (System.currentTimeMillis() -
start));
147 wo.btFinish().clickMouse();
155 new Timeout(
"pausing", 10000).sleep();
157 logger.info(
"Looking for hash lookup module in ingest job settings panel");
158 WizardOperator wo =
new WizardOperator(
"Add Data");
159 JTableOperator jto =
new JTableOperator(wo, 0);
160 int row = jto.findCellRow(
"Hash Lookup", 2, 0);
161 jto.clickOnCell(row, 1);
162 logger.info(
"Selected hash lookup module in ingest job settings panel");
163 JButtonOperator jbo1 =
new JButtonOperator(wo,
"Global Settings");
165 logger.info(
"Pushed Global Settings button for hash lookup module in ingest job settings panel");
169 logger.info(
"Hash Configure");
170 JDialog hashMainDialog = JDialogOperator.waitJDialog(
"Global Hash Lookup Settings",
false,
false);
171 JDialogOperator hashMainDialogOperator =
new JDialogOperator(hashMainDialog);
172 List<String> databases =
new ArrayList<>();
174 databases.add(
getEscapedPath(System.getProperty(
"known_bad_path")));
175 databases.stream().map((database) -> {
176 JButtonOperator importButtonOperator =
new JButtonOperator(hashMainDialogOperator,
"Import");
177 importButtonOperator.pushNoBlock();
178 JDialog addDatabaseDialog = JDialogOperator.waitJDialog(
"Import Hash Database",
false,
false);
179 JDialogOperator addDatabaseDialogOperator =
new JDialogOperator(addDatabaseDialog);
180 JButtonOperator browseButtonOperator =
new JButtonOperator(addDatabaseDialogOperator,
"Open...", 0);
181 browseButtonOperator.pushNoBlock();
182 JFileChooserOperator fileChooserOperator =
new JFileChooserOperator();
183 fileChooserOperator.chooseFile(database);
184 JButtonOperator okButtonOperator =
new JButtonOperator(addDatabaseDialogOperator,
"OK", 0);
185 return okButtonOperator;
186 }).map((okButtonOperator) -> {
187 okButtonOperator.pushNoBlock();
188 return okButtonOperator;
189 }).forEach((_item) -> {
190 new Timeout(
"pausing", 1000).sleep();
196 new Timeout(
"pausing", 1000).sleep();
198 JButtonOperator jbo4 =
new JButtonOperator(hashMainDialogOperator,
"OK", 0);
203 logger.info(
"Looking for keyword search module in ingest job settings panel");
204 WizardOperator wo =
new WizardOperator(
"Add Data");
205 JTableOperator jto =
new JTableOperator(wo, 0);
206 int row = jto.findCellRow(
"Keyword Search", 2, 0);
207 jto.clickOnCell(row, 1);
208 logger.info(
"Selected keyword search module in ingest job settings panel");
209 JButtonOperator jbo1 =
new JButtonOperator(wo,
"Global Settings");
211 logger.info(
"Pushed Global Settings button for keyword search module in ingest job settings panel");
215 logger.info(
"Search Configure");
216 JDialog jd = JDialogOperator.waitJDialog(
"Global Keyword Search Settings",
false,
false);
217 JDialogOperator jdo =
new JDialogOperator(jd);
218 String words =
getEscapedPath(System.getProperty(
"keyword_path"));
219 JButtonOperator jbo0 =
new JButtonOperator(jdo,
"Import List", 0);
221 JFileChooserOperator jfco0 =
new JFileChooserOperator();
222 jfco0.chooseFile(words);
223 JTableOperator jto =
new JTableOperator(jdo, 0);
224 jto.clickOnCell(0, 0);
225 new Timeout(
"pausing", 1000).sleep();
226 if (Boolean.parseBoolean(System.getProperty(
"mugen_mode"))) {
227 JTabbedPaneOperator jtpo =
new JTabbedPaneOperator(jdo);
228 jtpo.selectPage(
"String Extraction");
229 JCheckBoxOperator jcbo0 =
new JCheckBoxOperator(jtpo,
"Arabic (Arabic)");
231 JCheckBoxOperator jcbo1 =
new JCheckBoxOperator(jtpo,
"Han (Chinese, Japanese, Korean)");
233 new Timeout(
"pausing", 1000).sleep();
235 JButtonOperator jbo2 =
new JButtonOperator(jdo,
"OK", 0);
237 WizardOperator wo =
new WizardOperator(
"Add Data");
238 new Timeout(
"pausing", 10000).sleep();
239 wo.btNext().clickMouse();
243 logger.info(
"Ingest 3");
244 new Timeout(
"pausing", 10000).sleep();
245 long startIngest = System.currentTimeMillis();
248 new Timeout(
"pausing", 1000).sleep();
250 logger.log(Level.INFO,
"Ingest (including enqueue) took {0}ms", (System.currentTimeMillis() - startIngest));
254 Random rand =
new Random();
255 new Timeout(
"pausing", 10000 + (rand.nextInt(15000) + 5000)).sleep();
261 logger.info(
"Generate Report Toolbars");
262 MainWindowOperator mwo = MainWindowOperator.getDefault();
263 JButtonOperator jbo =
new JButtonOperator(mwo,
"Generate Report");
265 new Timeout(
"pausing", 5000).sleep();
269 logger.info(
"Generate Report Button");
270 JDialog reportDialog = JDialogOperator.waitJDialog(
"Generate Report",
false,
false);
271 JDialogOperator reportDialogOperator =
new JDialogOperator(reportDialog);
272 JListOperator listOperator =
new JListOperator(reportDialogOperator);
273 JButtonOperator jbo0 =
new JButtonOperator(reportDialogOperator,
"Next");
274 DateFormat dateFormat =
new SimpleDateFormat(
"MM-dd-yyyy-HH-mm-ss");
275 Date date =
new Date();
276 String datenotime = dateFormat.format(date);
277 listOperator.clickOnItem(0, 1);
278 new Timeout(
"pausing", 2000).sleep();
280 new Timeout(
"pausing", 2000).sleep();
281 JButtonOperator jbo1 =
new JButtonOperator(reportDialogOperator,
"Finish");
283 new Timeout(
"pausing", 1000).sleep();
284 JDialog previewDialog = JDialogOperator.waitJDialog(
"Progress",
false,
false);
286 JDialogOperator previewDialogOperator =
new JDialogOperator(previewDialog);
287 JLabelOperator.waitJLabel(previewDialog,
"Complete",
false,
false);
288 JButtonOperator jbo2 =
new JButtonOperator(previewDialogOperator,
"Close");
290 new Timeout(
"pausing", 10000).sleep();
291 System.setProperty(
"ReportStr", datenotime);
296 logger.info(
"Taking screenshot.");
298 Rectangle screenRect =
new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
299 BufferedImage capture =
new Robot().createScreenCapture(screenRect);
301 ImageIO.write(capture,
"png",
new File(outPath +
"\\" + name +
".png"));
302 new Timeout(
"pausing", 1000).sleep();
303 }
catch (IOException ex) {
304 logger.log(Level.WARNING,
"IOException taking screenshot.", ex);
305 }
catch (AWTException ex) {
306 logger.log(Level.WARNING,
"AWTException taking screenshot.", ex);
void screenshot(String name)
void testConfigureSearch()
static synchronized IngestManager getInstance()
void testGenerateReportToolbar()
void testStartAddLogicalFilesDataSource()
void testConfigureIngest1()
void testAddSourceWizard1()
boolean isIngestRunning()
static String getEscapedPath(String path)
void testGenerateReportButton()
void testNewCaseWizardOpen(String title)
static final Logger logger
void testStartAddImageFileDataSource()
void testConfigureIngest2()