pyWinAuto: c:\.projects\py_pywinauto\pywinauto\tests\comparetoreffont.py
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021"""Compare against reference font test
0022
0023**What is checked**
0024This test checks all the parameters of the font for the control against the
0025font for the reference control. If any value is different then this is reported
0026as a bug.
0027Here is a list of all the possible values that are tested:
0028lfFaceName The name of the font
0029lfHeight The height of the font
0030lfWidth Average width of characters
0031lfEscapement Angle of text
0032lfOrientation Another angle for the text!
0033lfWeight How bold the text is
0034lfItalic If the font is italic
0035lfUnderline If the font is underlined
0036lfStrikeOut If the font is struck out
0037lfCharSet The character set of the font
0038lfOutPrecision The output precision
0039lfClipPrecision The clipping precision
0040lfQuality The output quality
0041lfPitchAndFamily The pitch and family
0042
0043
0044**How is it checked**
0045Each property of the font for the control being tested is compared against the
0046equivalent property of the reference control font for equality.
0047
0048**When is a bug reported**
0049For each property of the font that is not identical to the reference font a bug
0050is reported. So for example if the Font Face has changed and the text is bold
0051then (at least) 2 bugs will be reported.
0052
0053**Bug Extra Information**
0054The bug contains the following extra information
0055Name Description
0056ValueType What value is incorrect (see above), String
0057Ref The reference value converted to a string, String
0058Loc The localised value converted to a string, String
0059
0060**Is Reference dialog needed**
0061This test will not run if the reference controls are not available.
0062
0063**False positive bug reports**
0064Running this test for Asian languages will result in LOTS and LOTS of false
0065positives, because the font HAS to change for the localised text to display
0066properly.
0067
0068**Test Identifier**
0069The identifier for this test/bug is "CompareToRefFont"
0070"""
0071
0072__revision__ = "$Revision: 276 $"
0073
0074testname = "CompareToRefFont"
0075
0076from pywinauto import win32structures
0077_font_attribs = [field[0] for field in win32structures.LOGFONTW._fields_]
0078
0079def CompareToRefFontTest(windows):
0080 "Compare the font to the font of the reference control"
0081
0082
0083 bugs = []
0084 for win in windows:
0085
0086 if not win.ref:
0087 continue
0088
0089
0090 for font_attrib in _font_attribs:
0091
0092 loc_value = getattr(win.Font(), font_attrib)
0093
0094 ref_value = getattr(win.ref.Font(), font_attrib)
0095
0096
0097 if loc_value != ref_value:
0098
0099
0100 bugs.append((
0101 [win, ],
0102 {
0103 "ValueType": fname,
0104 "Ref": unicode(ref_value),
0105 "Loc": unicode(loc_value),
0106 },
0107 testname,
0108 0,)
0109 )
0110 return bugs