コード例 #1
0
        public virtual String ExtractAndCompareImages(String outputPdf, String cmpPdf, String outputPath, String fuzzValue
                                                      )
        {
            String outImgPath = outputPath + "out/";
            String cmpImgPath = outputPath + "cmp/";

            ITextTest.CreateOrClearDestinationFolder(outImgPath);
            ITextTest.CreateOrClearDestinationFolder(cmpImgPath);
            IDictionary <int, CleanUpImagesCompareTool.PageImageObjectsPaths> cmpObjectDatas = ExtractImagesFromPdf(cmpPdf
                                                                                                                    , cmpImgPath);
            IDictionary <int, CleanUpImagesCompareTool.PageImageObjectsPaths> outObjectDatas = ExtractImagesFromPdf(outputPdf
                                                                                                                    , outImgPath);

            if (cmpObjectDatas.Count != outObjectDatas.Count)
            {
                return("Number of pages differs in out and cmp pdf documents:\nout = " + outObjectDatas.Count + "\ncmp = "
                       + cmpObjectDatas.Count);
            }
            try {
                foreach (int page in cmpObjectDatas.Keys)
                {
                    InitializeIgnoredObjectPath(cmpObjectDatas.Get(page), outObjectDatas.Get(page));
                }
            }
            catch (Exception e) {
                return(e.Message);
            }
            String[] cmpImages = FileUtil.ListFilesInDirectory(cmpImgPath, true);
            String[] outImages = FileUtil.ListFilesInDirectory(outImgPath, true);
            JavaUtil.Sort(cmpImages);
            JavaUtil.Sort(outImages);
            if (cmpImages.Length != outImages.Length)
            {
                return("Number of images should be the same!");
            }
            StringBuilder resultErrorMessage = new StringBuilder();

            try {
                for (int i = 0; i < cmpImages.Length; i++)
                {
                    String diffImage = outputPath + "diff_" + new FileInfo(cmpImages[i]).Name;
                    String errorText = CompareImages(outImages[i], cmpImages[i], diffImage, fuzzValue);
                    if (errorText != null)
                    {
                        resultErrorMessage.Append(errorText);
                    }
                }
            }
            catch (Exception e) {
                return(e.Message);
            }
            return(resultErrorMessage.ToString());
        }
コード例 #2
0
 public static void BeforeClass()
 {
     ITextTest.CreateOrClearDestinationFolder(destinationFolder);
 }
コード例 #3
0
 public static void Before()
 {
     ITextTest.CreateOrClearDestinationFolder(outputPath);
 }