protected void VerifySUTDisplay(bool usingRemoteFX, Rectangle compareRect, int callStackIndex = 1)
{
if (!verifySUTDisplay || this.rdpbcgrAdapter.SimulatedScreen == null)
{
return;
}
imageId++;
// Get test method name and construct file name for screenshot bitmap
StackTrace st = new StackTrace();
StackFrame sf = st.GetFrame(callStackIndex);
string pathForSUTScreenShot = bitmapSavePath + @"\" + sf.GetMethod().Name + "_" + imageId + "_ScreenShot.bmp";
// Not save the bitmap to the path directly since the interface has limit on the length of path.
// Save the bitmap into a temprory file and copy it to the right file path.
int result = this.sutControlAdapter.CaptureScreenShot(tmpFilePath);
File.Copy(tmpFilePath, pathForSUTScreenShot, true);
this.TestSite.Assume.IsTrue(result >= 0, "To verify output of RDP client, the protocol-based SUT control adapter should be used and the Agent on SUT should support screenshot control command.");
// Compare the screenshot with base image in simulated screen
Bitmap image = new Bitmap(pathForSUTScreenShot);
string pathForBaseImage = bitmapSavePath + @"\" + sf.GetMethod().Name + "_" + imageId + "_BaseImage.bmp";
this.rdpbcgrAdapter.SimulatedScreen.BaseImage.Save(tmpFilePath);
File.Copy(tmpFilePath, pathForBaseImage, true);
bool compareRes = this.rdpbcgrAdapter.SimulatedScreen.Compare(image, sutDisplayShift, compareRect, usingRemoteFX);
this.TestSite.Assert.IsTrue(compareRes, "SUT display verification failed, the output on RDP client is not equal (or similar enough if using RemoteFX codec) as expected.");
}