Beispiel #1
0
        private static TestResult ComparePngs(Test test, string result_path, string master_path)
        {
            TestResult res;

            if (!File.Exists(result_path))
            {
                test.SetFailedReason(String.Format("Can not find results file {0}", result_path));
                return(TestResult.Fail);
            }

            if (!File.Exists(master_path))
            {
                test.SetToIgnore(String.Format("Can not find master file {0}", Path.GetFullPath(master_path)));
                return(TestResult.Ignore);
            }

            using (Bitmap result = (Bitmap)Image.FromFile(result_path)) {
                using (Bitmap master = (Bitmap)Image.FromFile(master_path)) {
                    res = CompareBitmaps(test, result, master);

                    if (res == TestResult.Pass)
                    {
                        res = EdgeCompare.CompareBitmaps(test, result, master);
                    }
                }
            }

            return(res);
        }
Beispiel #2
0
        private static TestResult CompareTiffs(Test test, string result_path, string master_path)
        {
            if (!File.Exists(result_path))
            {
                test.SetFailedReason(String.Format("Can not find results file {0}", result_path));
                return(TestResult.Fail);
            }

            if (!File.Exists(master_path))
            {
                test.SetToIgnore(String.Format("Can not find master file {0}", master_path));
                return(TestResult.Ignore);
            }

            using (Bitmap result = (Bitmap)Image.FromFile(result_path)) {
                using (Bitmap master = (Bitmap)Image.FromFile(master_path)) {
                    Guid [] result_frames = result.FrameDimensionsList;
                    Guid [] master_frames = master.FrameDimensionsList;

                    if (result_frames.Length != master_frames.Length)
                    {
                        test.SetFailedReason(String.Format("Result and Master do not have the same number of layers: result: {0}, master: {1}",
                                                           result_frames.Length, master_frames.Length));
                        return(TestResult.Fail);
                    }

                    for (int i = 0; i < result_frames.Length; i++)
                    {
                        FrameDimension result_dimension    = new FrameDimension(result_frames [0]);
                        FrameDimension master_dimension    = new FrameDimension(master_frames [0]);
                        int            result_frames_count = result.GetFrameCount(result_dimension);
                        int            master_frames_count = master.GetFrameCount(master_dimension);

                        if (result_frames_count != master_frames_count)
                        {
                            test.SetFailedReason(String.Format("Result and Master do not have the same number of frames for frame dimension {0} ({1} vs {2})",
                                                               i, result_frames_count, master_frames_count));
                            return(TestResult.Fail);
                        }

                        for (int f = 0; f < result_frames_count; f++)
                        {
                            result.SelectActiveFrame(result_dimension, f);
                            master.SelectActiveFrame(master_dimension, f);

                            TestResult res = CompareBitmaps(test, result, master);
                            if (res != TestResult.Pass)
                            {
                                test.SetFailedReason(String.Format("Layer {0} -- {1}", f, test.FailedReason));
                                return(res);
                            }

                            res = EdgeCompare.CompareBitmaps(test, result, master);

                            if (res != TestResult.Pass)
                            {
                                test.SetFailedReason(String.Format("Layer {0} -- {1}", f, test.FailedReason));
                                return(res);
                            }
                        }
                    }
                }
            }

            return(TestResult.Pass);
        }