Reputation: 10915
I have two main issues, both depending on the DPI settings:
Our project is written for 96 DPI. In Windows, there are three settings available for DPI:
Are Coded UI Tests suitable for such complex tasks? Or what would you suggest me?
If you need further information, I would be glad to answer them. I don't think any code is needed, because it is just a normal winforms application and I am looking for an approach to cover any winform application.
Upvotes: 1
Views: 1250
Reputation: 1
Here I have found and tweaked a little code snippet. It is written in c#.
In this code, we are converting two Image objects into Base64 String
. By Comparing the Base64 string
together , we will know that whether images are same. The Code is below.
public static bool ImageCompareString(Image firstImage, Image secondImage)
{
var ms = new MemoryStream();
firstImage.Save(ms, ImageFormat.Png);
String firstBitmap = Convert.ToBase64String(ms.ToArray());
ms.Position = 0;
secondImage.Save(ms, ImageFormat.Png);
String secondBitmap = Convert.ToBase64String(ms.ToArray());
if (firstBitmap.Equals(secondBitmap))
{
return true;
}
else
{
return false;
}
}
Upvotes: 0
Reputation: 14066
Coded UI is intended for testing the function of an application. Not for testing the appearance. So generally Coded UI will not be suitable for checking screen colours or fonts used or line breaks in text. However, Coded UI does provide a CaptureImage()
method so at any point in the test you can write code in the form:
Image img = UITestControl.Desktop.CaptureImage();
Image img = this.UIMap.UIYourApplicationsWindow.CaptureImage();
Image img = this.UIMap.UIYourApplicationsWindow.UISubWindow.UISubSub.CaptureImage();
... followed by:
img.Save( ... filename ... );
TextContext.AddResultFile(... filename ... )
I have used the CaptureImage()
method but have not experimented on whether does a screen capture or whether it uses the underlying image file.
There is also an MSDN blog that may help. See http://blogs.msdn.com/b/gautamg/archive/2010/04/08/how-to-do-image-comparison-in-coded-ui-test.aspx
Upvotes: 1
Reputation: 41
If all controls are visible ( forms, dialog boxes) in different DPI settings, then I don't think there is any issue. You need to record assertions on all forms, buttons and dialogs (any controls) to verify 'exist' while only on one DPI say 100% and then repeat the test execution on all other DPI settings. Pls give it a try and let us also know the outcome.
-Prasant
Upvotes: 0