def CompareToRefFontTest(windows): "Compare the font to the font of the reference control" bugs = [] for win in windows: # if no reference then skip the control if not win.ref: continue # find each of the bugs for font_attrib in _font_attribs: loc_value = getattr(win.Font(), font_attrib) # get the reference value ref_value = getattr(win.ref.Font(), font_attrib) # If they are different if loc_value != ref_value: # Add the bug information bugs.append(( [ win, ], { "ValueType": font_attrib, "Ref": six.text_type(ref_value), "Loc": six.text_type(loc_value), }, testname, 0, )) return bugs
def CompareToRefFontTest(windows): "Compare the font to the font of the reference control" bugs = [] for win in windows: # if no reference then skip the control if not win.ref: continue # find each of the bugs for font_attrib in _font_attribs: loc_value = getattr(win.Font(), font_attrib) # get the reference value ref_value = getattr(win.ref.Font(), font_attrib) # If they are different if loc_value != ref_value: # Add the bug information bugs.append(( [win, ], { "ValueType": font_attrib, "Ref": six.text_type(ref_value), "Loc": six.text_type(loc_value), }, testname, 0,) ) return bugs
def TruncationTest(windows): "Actually do the test" truncations = [] # for each of the windows in the dialog for win in windows: truncIdxs, truncStrings = _FindTruncations(win) isInRef = -1 # if there were any truncations for this control if truncIdxs: # now that we know there was at least one truncation # check if the reference control has truncations if win.ref: isInRef = 0 refTruncIdxs, refTruncStrings = _FindTruncations(win.ref) if refTruncIdxs: isInRef = 1 truncIdxs = ",".join([six.text_type(index) for index in truncIdxs]) truncStrings = '"%s"' % ",".join([six.text_type(string) for string in truncStrings]) truncations.append(([win], {"StringIndices": truncIdxs, "Strings": truncStrings}, testname, isInRef)) # return all the truncations return truncations
def TranslationTest(windows): "Returns just one bug for each control" bugs = [] for win in windows: if not win.ref: continue # get if any items are untranslated untranTitles, untranIndices = _GetUntranslations(win) if untranTitles: indicesAsString = ",".join([six.text_type(idx) for idx in untranIndices]) bugs.append(( [win,], { "StringIndices": indicesAsString, "Strings": ('"%s"' % '","'.join(untranTitles)) }, testname, 0) ) return bugs
def _GetMinimumRect(text, font, usableRect, drawFlags): """Return the minimum rectangle that the text will fit into Uses font, usableRect and drawFlags information to find how how to do it accurately """ # try to create the font # create a Display DC (compatible to the screen) txtDC = win32functions.CreateDC(u"DISPLAY", None, None, None) hFontGUI = win32functions.CreateFontIndirect(ctypes.byref(font)) # # Maybe we could not get the font or we got the system font # if not hFontGUI: # # # So just get the default system font # hFontGUI = win32functions.GetStockObject(win32defines.DEFAULT_GUI_FONT) # # # if we still don't have a font! # # ----- ie, we're on an antiquated OS, like NT 3.51 # if not hFontGUI: # # # ----- On Asian platforms, ANSI font won't show. # if win32functions.GetSystemMetrics(win32defines.SM_DBCSENABLED): # # ----- was...(SYSTEM_FONT) # hFontGUI = win32functions.GetStockObject( # win32defines.SYSTEM_FONT) # else: # # ----- was...(SYSTEM_FONT) # hFontGUI = win32functions.GetStockObject( # win32defines.ANSI_VAR_FONT) # put our font into the Device Context win32functions.SelectObject(txtDC, hFontGUI) modifiedRect = RECT(usableRect) # Now write the text to our DC with our font to get the # rectangle that the text needs to fit in win32functions.DrawText( txtDC, # The DC six.text_type(text), # The Title of the control -1, # -1 because sTitle is NULL terminated ctypes.byref(modifiedRect), # The Rectangle to be calculated to # truncCtrlData.drawTextFormat | win32defines.DT_CALCRECT | drawFlags, ) # elif modifiedRect.right == usableRect.right and \ # modifiedRect.bottom == usableRect.bottom: # print "Oh so you thought you were perfect!!!" # Delete the font we created win32functions.DeleteObject(hFontGUI) # delete the Display context that we created win32functions.DeleteDC(txtDC) return modifiedRect
def _GetMinimumRect(text, font, usableRect, drawFlags): """Return the minimum rectangle that the text will fit into Uses font, usableRect and drawFlags information to find how how to do it accurately """ # try to create the font # create a Display DC (compatible to the screen) txtDC = win32functions.CreateDC(u"DISPLAY", None, None, None) hFontGUI = win32functions.CreateFontIndirect(ctypes.byref(font)) # # Maybe we could not get the font or we got the system font # if not hFontGUI: # # # So just get the default system font # hFontGUI = win32functions.GetStockObject(win32defines.DEFAULT_GUI_FONT) # # # if we still don't have a font! # # ----- ie, we're on an antiquated OS, like NT 3.51 # if not hFontGUI: # # # ----- On Asian platforms, ANSI font won't show. # if win32functions.GetSystemMetrics(win32defines.SM_DBCSENABLED): # # ----- was...(SYSTEM_FONT) # hFontGUI = win32functions.GetStockObject( # win32defines.SYSTEM_FONT) # else: # # ----- was...(SYSTEM_FONT) # hFontGUI = win32functions.GetStockObject( # win32defines.ANSI_VAR_FONT) # put our font into the Device Context win32functions.SelectObject(txtDC, hFontGUI) modifiedRect = win32structures.RECT(usableRect) # Now write the text to our DC with our font to get the # rectangle that the text needs to fit in win32functions.DrawText( txtDC, # The DC six.text_type(text), # The Title of the control -1, # -1 because sTitle is NULL terminated ctypes.byref(modifiedRect), # The rectangle to be calculated to #truncCtrlData.drawTextFormat | win32defines.DT_CALCRECT | drawFlags) #elif modifiedRect.right == usableRect.right and \ # modifiedRect.bottom == usableRect.bottom: # print "Oh so you thought you were perfect!!!" # Delete the font we created win32functions.DeleteObject(hFontGUI) # delete the Display context that we created win32functions.DeleteDC(txtDC) return modifiedRect
def MiscValuesTest(windows): "Return the bugs from checking miscelaneous values of a control" bugs = [] for win in windows: if not win.ref: continue diffs = {} if win.class_name() != win.ref.class_name(): diffs[u"class_name"] = (win.class_name(), win.ref.class_name()) if win.style() != win.ref.style(): diffs[u"style"] = (win.style(), win.ref.style()) if win.exstyle() != win.ref.exstyle(): diffs[u"exstyle"] = (win.exstyle(), win.ref.exstyle()) if win.context_help_id() != win.ref.context_help_id(): diffs[u"help_id"] = (win.context_help_id(), win.ref.context_help_id()) if win.control_id() != win.ref.control_id(): diffs[u"control_id"] = (win.control_id(), win.ref.control_id()) if win.is_visible() != win.ref.is_visible(): diffs[u"Visibility"] = (win.is_visible(), win.ref.is_visible()) if win.user_data() != win.ref.user_data(): diffs[u"user_data"] = (win.user_data(), win.ref.user_data()) for diff, vals in diffs.items(): bugs.append(( [ win, ], { "ValueType": diff, "Ref": six.text_type(vals[1]), "Loc": six.text_type(vals[0]), }, testname, 0, )) return bugs
def MiscValuesTest(windows): "Return the bugs from checking miscelaneous values of a control" bugs = [] for win in windows: if not win.ref: continue diffs = {} if win.Class() != win.ref.Class(): diffs[u"Class"] = (win.Class(), win.ref.Class()) if win.Style() != win.ref.Style(): diffs[u"Style"] = (win.Style(), win.ref.Style()) if win.ExStyle() != win.ref.ExStyle(): diffs[u"ExStyle"] = (win.ExStyle(), win.ref.ExStyle()) if win.ContextHelpID() != win.ref.ContextHelpID(): diffs[u"HelpID"] = (win.ContextHelpID(), win.ref.ContextHelpID()) if win.ControlID() != win.ref.ControlID(): diffs[u"ControlID"] = (win.ControlID(), win.ref.ControlID()) if win.IsVisible() != win.ref.IsVisible(): diffs[u"Visibility"] = (win.IsVisible(), win.ref.IsVisible()) if win.UserData() != win.ref.UserData(): diffs[u"UserData"] = (win.UserData(), win.ref.UserData()) for diff, vals in diffs.items(): bugs.append(( [ win, ], { "ValueType": diff, "Ref": six.text_type(vals[1]), "Loc": six.text_type(vals[0]), }, testname, 0, )) return bugs
def MiscValuesTest(windows): "Return the bugs from checking miscelaneous values of a control" bugs = [] for win in windows: if not win.ref: continue diffs = {} if win.Class() != win.ref.Class(): diffs[u"Class"] = (win.Class(), win.ref.Class()) if win.Style() != win.ref.Style(): diffs[u"Style"] = (win.Style(), win.ref.Style()) if win.ExStyle() != win.ref.ExStyle(): diffs[u"ExStyle"] = (win.ExStyle(), win.ref.ExStyle()) if win.ContextHelpID() != win.ref.ContextHelpID(): diffs[u"HelpID"] = (win.ContextHelpID(), win.ref.ContextHelpID()) if win.ControlID() != win.ref.ControlID(): diffs[u"ControlID"] = (win.ControlID(), win.ref.ControlID()) if win.IsVisible() != win.ref.IsVisible(): diffs[u"Visibility"] = (win.IsVisible(), win.ref.IsVisible()) if win.UserData() != win.ref.UserData(): diffs[u"UserData"] = (win.UserData(), win.ref.UserData()) for diff, vals in diffs.items(): bugs.append(( [win, ], { "ValueType": diff, "Ref": six.text_type(vals[1]), "Loc": six.text_type(vals[0]), }, testname, 0,) ) return bugs
def MiscValuesTest(windows): "Return the bugs from checking miscelaneous values of a control" bugs = [] for win in windows: if not win.ref: continue diffs = {} if win.class_name() != win.ref.class_name(): diffs[u"class_name"] = (win.class_name(), win.ref.class_name()) if win.style() != win.ref.style(): diffs[u"style"] = (win.style(), win.ref.style()) if win.exstyle() != win.ref.exstyle(): diffs[u"exstyle"] = (win.exstyle(), win.ref.exstyle()) if win.context_help_id() != win.ref.context_help_id(): diffs[u"help_id"] = (win.context_help_id(), win.ref.context_help_id()) if win.control_id() != win.ref.control_id(): diffs[u"control_id"] = (win.control_id(), win.ref.control_id()) if win.is_visible() != win.ref.is_visible(): diffs[u"Visibility"] = (win.is_visible(), win.ref.is_visible()) if win.user_data() != win.ref.user_data(): diffs[u"user_data"] = (win.user_data(), win.ref.user_data()) for diff, vals in diffs.items(): bugs.append(( [win, ], { "ValueType": diff, "Ref": six.text_type(vals[1]), "Loc": six.text_type(vals[0]), }, testname, 0,) ) return bugs
def TruncationTest(windows): "Actually do the test" truncations = [] # for each of the windows in the dialog for win in windows: truncIdxs, truncStrings = _FindTruncations(win) isInRef = -1 # if there were any truncations for this control if truncIdxs: # now that we know there was at least one truncation # check if the reference control has truncations if win.ref: isInRef = 0 refTruncIdxs, refTruncStrings = _FindTruncations(win.ref) if refTruncIdxs: isInRef = 1 truncIdxs = ",".join([six.text_type(index) for index in truncIdxs]) truncStrings = '"%s"' % ",".join( [six.text_type(string) for string in truncStrings]) truncations.append(([ win, ], { "StringIndices": truncIdxs, "Strings": truncStrings, }, testname, isInRef)) # return all the truncations return truncations