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"); }
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 }