Esempio n. 1
0
        public void TransformTwoImagesAndCompare()
        {
            //Saturation button should be in unselected state

            #region TestData
            Image           image1, image2;
            bool            compareWithZeroTolerance, compareWith100Tolerance;
            ColorDifference diff          = new ColorDifference(0);
            string          originalImage = testImagesPath + "Actual.jpg";
            string          imagesPath    = FileUtilities.CheckAndCreateDirectory(testImagesPath + System.Reflection.MethodBase.GetCurrentMethod().Name + @"\");
            string          runTimeImage1 = imagesPath + "First.jpg";
            string          runTimeImage2 = imagesPath + "Second.jpg";

            #endregion

            #region OpenImageAndEdit1

            FileUtilities.OpenFile(originalImage);
            wndImagePro.ClickTabAdjust();
            wndImagePro.ClickBtnRotate();

            wndImagePro.ClickTabMeasure();
            wndImagePro.ClickBtnCreate();
            wndImagePro.ClickTabCapture();
            wndImagePro.ClickBtnSaturation();

            //wndImagePro.TabCountOrSize().ClickPoint();
            //wndImagePro.BtnCount().ClickPoint(-40);

            wndImagePro.ImageViewer.ClickPoint();
            wndImagePro.ImageViewer.CaptureImage(runTimeImage1);

            #endregion

            #region setup

            wndImagePro.CloseAllToolsAndViews(true);

            #endregion

            #region OpenImageAndEdit2

            System.Threading.Thread.Sleep(2000);
            FileUtilities.OpenFile(originalImage);
            FileUtilities.OpenFile(originalImage);

            wndImagePro.ClickTabAdjust();
            wndImagePro.ClickBtnRotate();

            wndImagePro.ClickTabMeasure();
            wndImagePro.ClickBtnCreate();
            System.Threading.Thread.Sleep(1000);

            //Observation: Saturation is selected by default
            //wndImagePro.TabCapture.ClickPoint();
            //wndImagePro.BtnSaturation.Click();

            wndImagePro.ImageViewer.ClickPoint();
            wndImagePro.ImageViewer.CaptureImage(runTimeImage2);

            #endregion


            image1 = Image.FromFile(runTimeImage1);
            image2 = Image.FromFile(runTimeImage2);

            compareWithZeroTolerance = ImageComparer.Compare(image1, image2, diff, out Image outPutFile);
            outPutFile.Save(imagesPath + "Output1.jpg");
            Assert.IsTrue(compareWithZeroTolerance, "Images should be same compareWithZeroTolerance");

            diff = new ColorDifference(100);
            compareWith100Tolerance = ImageComparer.Compare(image1, image2, diff, out outPutFile);
            outPutFile.Save(imagesPath + "Output2.jpg");
            Assert.IsTrue(compareWith100Tolerance, "Images should be same compareWith100Tolerance");
        }
Esempio n. 2
0
        public void TransformStepByStepAndCompare()
        {
            /*Open original image, transform image and save
             * open original image again, apply partial transformation again, save
             * Compare two images, the compare should result false*/

            /*Complete the transformation on second image
             * Compare two images with different threshold levels
             * Test case should pass*/

            #region TestData
            Image           image1, image2, image3;
            ColorDifference diff       = new ColorDifference(0);
            string          imagesPath = FileUtilities.CheckAndCreateDirectory(testImagesPath + System.Reflection.MethodBase.GetCurrentMethod().Name + @"\");
            bool            compare;
            string          originalImage = imagesPath + "Actual.jpg";
            string          runTimeImage1 = imagesPath + "First.jpg";
            string          runTimeImage2 = imagesPath + "Second.jpg";
            string          runTimeImage3 = imagesPath + "Third.jpg";
            #endregion


            #region OpenImageAndEdit1

            FileUtilities.OpenFile(originalImage);
            wndImagePro.ClickTabAdjust();
            wndImagePro.ClickBtnRotate();

            wndImagePro.ClickTabMeasure();
            wndImagePro.ClickBtnCreate();

            System.Threading.Thread.Sleep(1000);

            wndImagePro.ClickTabCapture();
            wndImagePro.ClickBtnSaturation();
            //Select Saturation

            wndImagePro.ImageViewer.ClickPoint();
            wndImagePro.ImageViewer.CaptureImage(runTimeImage1);

            #endregion

            wndImagePro.CloseAllToolsAndViews(true);

            #region OpenImageAndEdit Partial

            //System.Threading.Thread.Sleep(2000);
            FileUtilities.OpenFile(originalImage);
            FileUtilities.OpenFile(originalImage);

            wndImagePro.ClickTabAdjust();
            wndImagePro.ClickBtnRotate();

            wndImagePro.ClickTabMeasure();
            wndImagePro.ClickBtnCreate();

            wndImagePro.ClickTabCapture();
            wndImagePro.ClickBtnSaturation();
            //Unselect Saturation

            wndImagePro.ImageViewer.ClickPoint();
            wndImagePro.ImageViewer.CaptureImage(runTimeImage2);

            #endregion


            image1 = Image.FromFile(runTimeImage1);
            image2 = Image.FromFile(runTimeImage2);

            compare = ImageComparer.Compare(image1, image2, diff, out Image outPutFile);
            outPutFile.Save(imagesPath + "Output1.jpg");
            Assert.IsFalse(compare, "Images should not match");

            #region Continue transform

            wndImagePro.ClickTabCapture();
            wndImagePro.ClickBtnSaturation();
            //Select Saturation

            wndImagePro.ImageViewer.ClickPoint();
            wndImagePro.ImageViewer.CaptureImage(runTimeImage3);


            image3 = Image.FromFile(runTimeImage3);

            diff    = new ColorDifference(0);
            compare = ImageComparer.Compare(image1, image3, diff, out outPutFile);
            outPutFile.Save(imagesPath + "Output2.jpg");
            Assert.IsTrue(compare, "Images should match");

            #endregion
        }
Esempio n. 3
0
        public void TransformPartiallyAndCompare_ExpectedFail()
        {
            #region TestData
            bool   compare = false;
            Image  image1;
            Image  image2;
            string imagesPath = FileUtilities.CheckAndCreateDirectory(testImagesPath + System.Reflection.MethodBase.GetCurrentMethod().Name + @"\"); ColorDifference diff = new ColorDifference(0);
            string originalImage = imagesPath + "Actual.jpg";
            string runTimeImage1 = imagesPath + "First.jpg";
            string runTimeImage2 = imagesPath + "Second.jpg";

            #endregion

            #region OpenImageAndEdit1

            FileUtilities.OpenFile(originalImage);
            wndImagePro.ClickTabAdjust();
            wndImagePro.ClickBtnRotate();

            wndImagePro.ClickTabMeasure();
            wndImagePro.ClickBtnCreate();

            System.Threading.Thread.Sleep(1000);

            wndImagePro.ClickTabCapture();
            wndImagePro.ClickBtnSaturation(); //Select Saturation

            wndImagePro.ImageViewer.ClickPoint();
            wndImagePro.ImageViewer.CaptureImage(runTimeImage1);

            #endregion

            wndImagePro.CloseAllToolsAndViews(true);

            #region OpenImageAndEdit Partial

            //System.Threading.Thread.Sleep(2000);
            FileUtilities.OpenFile(originalImage);
            FileUtilities.OpenFile(originalImage);

            wndImagePro.ClickTabAdjust();
            wndImagePro.ClickBtnRotate();

            wndImagePro.ClickTabMeasure();
            wndImagePro.ClickBtnCreate();

            wndImagePro.ClickTabCapture();
            wndImagePro.ClickBtnSaturation(); //Unselect Saturation

            wndImagePro.ImageViewer.ClickPoint();
            wndImagePro.ImageViewer.CaptureImage(runTimeImage2);

            #endregion


            image1  = Image.FromFile(runTimeImage1);
            image2  = Image.FromFile(runTimeImage2);
            compare = ImageComparer.Compare(image1, image2, diff, out Image outPutFile);
            outPutFile.Save(imagesPath + "Output1.jpg");
            Assert.IsTrue(compare, "Falsy expecting: Images should not match");
        }
Esempio n. 4
0
        public void TestRecordMacroWithAction()
        {
            #region TestData
            string imagesPath    = FileUtilities.CheckAndCreateDirectory(testImagesPath + System.Reflection.MethodBase.GetCurrentMethod().Name + @"\");
            string originalImage = testImagesPath + "Actual.jpg";
            string runTimeImage1 = imagesPath + "First.jpg";
            string runTimeImage2 = imagesPath + "Second.jpg";
            string newMacroName  = "AutoTest" + rand.Next(100, 999999);
            float  diff;
            #endregion

            wndImagePro.ClickTabAutomate();
            wndImagePro.StartRecodingMacro(newMacroName);

            #region Record New Macro and Save

            FileUtilities.OpenFile(originalImage);
            wndImagePro.ClickTabAdjust();
            wndImagePro.ClickBtnRotate();
            System.Threading.Thread.Sleep(3000);

            wndImagePro.WndRecording.PauseRecording();
            System.Threading.Thread.Sleep(1000);

            wndImagePro.WndRecording.ResumeRecording();
            wndImagePro.ClickTabMeasure();
            wndImagePro.ClickBtnCreate();
            System.Threading.Thread.Sleep(3000);

            wndImagePro.WndRecording.StopRecording();

            ////WndProjectWorkbench WndProjectWorkbench = new WndProjectWorkbench();
            ////WndProjectWorkbench.ConfirmSave();
            wndImagePro.ImageViewer.CaptureImage(runTimeImage1);

            #endregion

            #region ReOpen Saved Macro
            wndImagePro.CloseAllToolsAndViews(true);

            wndImagePro.ClickTabAutomate();
            Assert.IsTrue(wndImagePro.CheckRecordedMacroExists(newMacroName), "Should be true");
            wndImagePro.ClickTabAutomate();
            wndImagePro.SelectRecordedMacro(newMacroName);
            System.Threading.Thread.Sleep(5000); //Wait for macro execution
            wndImagePro.ImageViewer.CaptureImage(runTimeImage2);

            #endregion

            #region Verify Macro Output Images
            //ColorDifference diff = new ColorDifference(0);
            //Image image1 = Image.FromFile(runTimeImage1);
            //Image image2 = Image.FromFile(runTimeImage2);

            //Image outPutFile = null;
            //bool compar2e = ImageComparer.Compare(image1, image2, diff, out outPutFile);
            //outPutFile.Save(imagesPath + "Output.jpg");
            //Assert.IsTrue(compar2e, "Images should match");

            diff = ImageUtilities.GetPercentageDifference(runTimeImage1, runTimeImage2);
            Assert.IsTrue(diff < 0.02, "Images should be Identical");
            #endregion
        }