Example #1
0
def MissalignmentTest(windows):
    """Run the test on the windows passed in"""
    refAlignments = {}

    #find the controls alligned along each axis
    for win in windows:
        if not win.ref:
            continue

        for side in ("top", "left", "right", "bottom"):
            sideValue = getattr(win.ref.rectangle(), side)

            # make sure that the side dictionary has been created
            sideAlignments = refAlignments.setdefault(side, {})

            # make sure that the array of controls for this
            # alignment line has been created and add the current window
            sideAlignments.setdefault(sideValue, []).append(win)

    bugs = []
    for side in refAlignments:
        for alignment in refAlignments[side]:
            controls = refAlignments[side][alignment]
            sides = [getattr(ctrl.rectangle(), side) for ctrl in controls]
            sides = set(sides)

            if len(sides) > 1:

                overAllRect = win32structures.RECT()
                overAllRect.left = min(
                    [ctrl.rectangle().left for ctrl in controls])
                overAllRect.top = min(
                    [ctrl.rectangle().top for ctrl in controls])
                overAllRect.right = max(
                    [ctrl.rectangle().right for ctrl in controls])
                overAllRect.bottom = max(
                    [ctrl.rectangle().bottom for ctrl in controls])

                bugs.append((controls, {
                    "AlignmentType": side.upper(),
                    "AlignmentRect": overAllRect
                }, testname, 0))

    return bugs
Example #2
0
 def __init__(self, l, t, r, b):
     self.rect = win32structures.RECT(l, t, r, b)