Beispiel #1
0
        public void TakeScreenShotforBaseline(IVisualTestingDriver driver)
        {
            mDriver = driver;
            //TODO: verify we have driver
            // get updated screen shot
            baseImage = mDriver.GetScreenShot();

            //Verify we have screenshots folder
            string SAVING_PATH = System.IO.Path.Combine(SolutionFolder, @"Documents\ScreenShots\");

            if (!Directory.Exists(SAVING_PATH))
            {
                Directory.CreateDirectory(SAVING_PATH);
            }

            // Create default file name if not exist
            if (string.IsNullOrEmpty(BaseLineFileName))
            {
                BaseLineFileName = @"~\Documents\ScreenShots\" + Description + " - Baseline.png";
            }

            //string FullPath = BaseLineFileName.Replace(@"~\", SolutionFolder);
            string FullPath = amdocs.ginger.GingerCoreNET.WorkSpace.Instance.SolutionRepository.ConvertSolutionRelativePath(BaseLineFileName);

            // no need to ask user, + it might be at run time
            //TOOD: handle err
            if (File.Exists(FullPath))
            {
                File.Delete(FullPath);
            }

            baseImage.Save(FullPath);
        }
Beispiel #2
0
        public void CreateBaseline(IVisualTestingDriver driver)
        {
            mDriver = driver;

            CheckSetAppWindowSize();
            TakeScreenShotforBaseline(driver);

            // Call the actual analyzer to take/create the baseline needed
            CheckSetVisualAnalyzer();
            mVisualAnalyzer.SetAction(driver, this);
            mVisualAnalyzer.CreateBaseline();
        }
Beispiel #3
0
        void IVisualAnalyzer.Compare()
        {
            //TODO: use interface on the driver to get elements
            if (mDriver is IVisualTestingDriver)
            {
                IVisualTestingDriver d = (IVisualTestingDriver)mDriver;

                string             filename = mAct.GetFullFilePath(mAct.BaselineInfoFile);
                VisualElementsInfo VE1      = VisualElementsInfo.Load(filename);
                VE1.Bitmap = mAct.baseImage;

                VisualElementsInfo VE2 = d.GetVisualElementsInfo();
                VE1.Compare(VE2);
                IEnumerable <VisualElement> listwithnomatch = from x in VE1.Elements where x.Text != "" && x.MatchingElement == null select x;

                // Create compare bitmap for VE1
                Bitmap bmp = new Bitmap(VE1.Bitmap);
                // mark element with no match
                foreach (VisualElement VE in listwithnomatch)
                {
                    using (Graphics gr = Graphics.FromImage(bmp))
                    {
                        gr.SmoothingMode = SmoothingMode.AntiAlias;

                        //TODO: check the -3 or + 6 will not go out of bitmap
                        Rectangle rect = new Rectangle(VE.X - 3, VE.Y - 3, VE.Width + 6, VE.Height + 6);

                        gr.FillRectangle(Brushes.Transparent, rect);
                        using (Pen thick_pen = new Pen(Color.HotPink, 2))
                        {
                            gr.DrawRectangle(thick_pen, rect);
                        }
                    }
                }

                mAct.CompareResult = bmp;

                // Add output of mismatch
                mAct.AddOrUpdateReturnParamActual("Mismatch elements in target", listwithnomatch.Count() + "");

                //TODO: if output each mismatch then do output


                mAct.AddScreenShot(bmp, "Compare Result");

                //TODO: add small bitmap of mismatch elem
            }
        }
Beispiel #4
0
        public void Execute(IVisualTestingDriver driver)
        {
            mDriver = driver;
            CheckSetVisualAnalyzer();
            CheckSetAppWindowSize();

            if (mVisualAnalyzer.SupportUniqueExecution())
            {
                mVisualAnalyzer.SetAction(mDriver, this);
                mVisualAnalyzer.Execute();
            }
            else
            {
                if (CreateBaselineAction)
                {
                    CreateBaseline(mDriver);
                }
                else
                {
                    Compare();
                }
            }
        }
Beispiel #5
0
 void IVisualAnalyzer.SetAction(IVisualTestingDriver driver, ActVisualTesting act)
 {
     mDriver = driver;
     mAct    = act;
 }