예제 #1
0
  public static void main(String[] args) throws Exception {
    List<String> msgfilecontents = new ArrayList<String>();
    if (args.length > 0) msgfilecontents = readLines(new FileReader(args[0]));
    POMsgSource msgsrc = new POMsgSource(msgfilecontents);
    final List<String> msgstrings = msgsrc.getMsgStrings();
    String screenshotSavePath = "";
    List<String> existingScreenshotPaths = new ArrayList<String>();
    if (args.length > 1) {
      screenshotSavePath = args[1] + "/";
      File screenshotDir = new File(screenshotSavePath);
      if (!screenshotDir.exists()) {
        screenshotDir.mkdirs();
      } else {
        for (String filename : screenshotDir.list()) {
          filename = screenshotSavePath + filename;
          existingScreenshotPaths.add(filename);
        }
      }
    }
    ScreenshotTaker st = new ScreenshotTaker(msgsrc, screenshotSavePath);
    st.guisetup();
    st.addNewAnnotations(new HashMap<String, MsgAnnotation>());
    for (String filename : existingScreenshotPaths) {
      // add those messages that are covered by existing screenshots to matchedMsgStrs
      System.out.println(filename);
      List<ImgMatch> matches = Main.getImgMatches(filename);
      HashMap<String, MsgAnnotation> annotations =
          Main.msgToAnnotationsTwoPass(msgstrings, GCollectionUtils.singleElemList(matches));
      st.addNewAnnotations(annotations);
      st.processedImages.add(st.hashable(matches));
    }
    st.show();
    st.runme();

    // long prev_screenshot_time = 0;

  }