pyWinAuto: c:\.projects\py_pywinauto\pywinauto\tests\miscvalues.py

0001# GUI Application automation and testing library
0002# Copyright (C) 2006 Mark Mc Mahon
0003#
0004# This library is free software; you can redistribute it and/or
0005# modify it under the terms of the GNU Lesser General Public License
0006# as published by the Free Software Foundation; either version 2.1
0007# of the License, or (at your option) any later version.
0008#
0009# This library is distributed in the hope that it will be useful,
0010# but WITHOUT ANY WARRANTY; without even the implied warranty of
0011# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0012# See the GNU Lesser General Public License for more details.
0013#
0014# You should have received a copy of the GNU Lesser General Public
0015# License along with this library; if not, write to the
0016#    Free Software Foundation, Inc.,
0017#    59 Temple Place,
0018#    Suite 330,
0019#    Boston, MA 02111-1307 USA
0020
0021"""Miscellaneous Control properties Test
0022
0023**What is checked**
0024This checks various values related to a control in windows. The values tested
0025are
0026Class   The class type of the control
0027Style   The Style of the control (GetWindowLong)
0028ExStyle The Extended Style of the control (GetWindowLong)
0029HelpID  The Help ID of the control (GetWindowLong)
0030ControlID       The Control ID of the control (GetWindowLong)
0031UserData        The User Data of the control (GetWindowLong)
0032Visibility      Whether the control is visible or not
0033
0034**How is it checked**
0035After retrieving the information for the control we compare it to the same
0036information from the reference control.
0037
0038**When is a bug reported**
0039If the information does not match then a bug is reported.
0040
0041**Bug Extra Information**
0042The bug contains the following extra information
0043Name    Description
0044ValueType       What value is incorrect (see above), String
0045Ref     The reference value converted to a string, String
0046Loc     The localised value converted to a string, String
0047
0048**Is Reference dialog needed**
0049This test will not run if the reference controls are not available.
0050
0051**False positive bug reports**
0052Some values can change easily without any bug being caused, for example User
0053Data is actually meant for programmers to store information for the control
0054and this can change every time the software is run.
0055
0056**Test Identifier**
0057The identifier for this test/bug is "MiscValues"
0058"""
0059__revision__ = "$Revision: 328 $"
0060
0061testname = "MiscValues"
0062
0063def MiscValuesTest(windows):
0064    "Return the bugs from checking miscelaneous values of a control"
0065    bugs = []
0066    for win in windows:
0067        if not win.ref:
0068            continue
0069
0070        diffs = {}
0071
0072        if win.Class() != win.ref.Class():
0073            diffs["Class"] = (win.Class(), win.ref.Class())
0074
0075
0076        if win.Style() != win.ref.Style():
0077            diffs["Style"] = (win.Style(), win.ref.Style())
0078
0079        if win.ExStyle() != win.ref.ExStyle():
0080            diffs["ExStyle"] = (win.ExStyle(), win.ref.ExStyle())
0081
0082        if win.ContextHelpID() != win.ref.ContextHelpID():
0083            diffs["HelpID"] = (win.ContextHelpID(), win.ref.ContextHelpID())
0084
0085        if win.ControlID() != win.ref.ControlID():
0086            diffs["ControlID()"] = (win.ControlID(), win.ref.ControlID())
0087
0088        if win.IsVisible() != win.ref.IsVisible():
0089            diffs["Visibility"] = (win.IsVisible(), win.ref.IsVisible())
0090
0091        if win.UserData() != win.ref.UserData():
0092            diffs["UserData()"] = (win.UserData(), win.ref.UserData())
0093
0094
0095        for diff, vals in diffs.items():
0096            bugs.append((
0097                [win, ],
0098                {
0099                    "ValueType": diff,
0100                    "Ref": unicode(vals[1]),
0101                    "Loc": unicode(vals[0]),
0102                },
0103                testname,
0104                0,)
0105            )
0106    return bugs