theodox / mGui

Python module for cleaner maya GUI layout syntax
MIT License
123 stars 23 forks source link

Wanted: GUI test harness #54

Closed theodox closed 7 years ago

theodox commented 7 years ago

It would be great to have a way of verifying between builds that mGui is visually consistent. Perhaps doing a pixel diff on screenshot dumps or something like that? Howe would this work?

theodox commented 7 years ago

So, if we install a command line screenshot tool like boxcutter, something like this lets us grab an mGui window to a png:

BOXCUTTER = 'c:/users/steve/desktop/bc/boxcutter.exe'
import os
import subprocess

def grab_window(window):
    t, l = map(int, w.topLeftCorner)
    b, r = t + w.height + 36, l + w.width + 16
    print subprocess.call((BOXCUTTER,  '-c',  '{0},{1},{2},{3}'.format(l, b, r, t),  "c:\\users\\steve\\desktop\\bc\\{0}".format(window.title + ".png")))
    print (BOXCUTTER + ' -c {0},{1},{2},{3} "c:\\users\\steve\\desktop\\bc\\{4}"'.format( l, b, r, t, window.title + ".png"))

with Window(width = 512, height = 512) as w:
    with ColumnLayout() as c:
        b1= Button("Fred")
        b2=  Button("Barney")

w.show()

grab_window(w)    
theodox commented 7 years ago

CRC checking the completed PNG would let us spot changes. I don't know how deterministic the color values would be...

bob-white commented 7 years ago

Qt also lets us take screenshots of widgets as well. Which would be one less dependency.

As for determinism in the color values, I just did a quick test by messing with the color calibration settings in windows. Sadly the various screenshots were influenced by these values, at least when using the QPixmap technique, no clue if boxcutter is similarly impacted.

So it looks like we could provide a set of scripts to generate the baseline images, and then run tests against those, but we wouldn't be able to safely supply a set.

theodox commented 7 years ago

I suppose we could set that up so that the first run on a given machine always passed and generated a baseline image, and then used those, with a manual reset option. Too bad though.

On Thu, Nov 24, 2016 at 10:02 AM, bob-white notifications@github.com wrote:

Qt also lets us take screenshots of widgets http://stackoverflow.com/questions/10705712/screenshot-of-a-window-using-python as well. Which would be one less dependency.

As for determinism in the color values, I just did a quick test by messing with the color calibration settings in windows. Sadly the various screenshots were influenced by these values, at least when using the QPixmap technique, no clue if boxcutter is similarly impacted.

So it looks like we could provide a set of scripts to generate the baseline images, and then run tests against those, but we wouldn't be able to safely supply a set.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/theodox/mGui/issues/54#issuecomment-262826431, or mute the thread https://github.com/notifications/unsubscribe-auth/AD3mGNHmoS6pNDRTqsxgwUkpkAHsPDVIks5rBdE3gaJpZM4KxtLC .

theodox commented 7 years ago

I guess this is not really a worthwhile project, since we don't really control the graphic output.

I think there is probably room for an in-maya test suite that just opens a bunch of premade UI and ensures that it all actually displays, as a way of catching metaclass breakdowns or whatnot. But I'm going to axe this one.