From 6cafc0d3d1bcea5c5df9a66b4d976e13fc83c328 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 22 Jun 2016 11:26:06 +0000 Subject: [PATCH] make the test anim configurable on the command line git-svn-id: https://xpra.org/svn/Xpra/trunk@12884 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/tests/xpra/clients/test_gl_vscrollup.py | 33 +++++++++++++-------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/tests/xpra/clients/test_gl_vscrollup.py b/src/tests/xpra/clients/test_gl_vscrollup.py index 16e6f54c89..aa7fb6e1ed 100755 --- a/src/tests/xpra/clients/test_gl_vscrollup.py +++ b/src/tests/xpra/clients/test_gl_vscrollup.py @@ -30,35 +30,44 @@ def __init__(self, client, wid, W=630, H=480): self.paint_rect(0, 0, W, H, chr(255)*4*W*H) self.paint_rect(W//2-16, H//2-16, 32, 32, chr(0)*4*32*32) - def scrollup(self): - #scroll one line up: - ydelta = 1 + def scrollup(self, ydelta=1): + print("scrollup(%s)" % ydelta) scrolls = (0, ydelta, self.W, self.H-ydelta, -ydelta), - self.window.draw_region(0, 0, self.W, self.H, "scroll", scrolls, self.W*4, 0, typedict({"flush" : 1}), []) + self.window.draw_region(0, 0, self.W, self.H, "scroll", scrolls, self.W*4, 0, typedict({"flush" : 0}), []) dots = [] - for _ in range(self.W): + for _ in range(self.W*ydelta): CB = 0xFF << ((self.wid % 4) * 8) v = int(time.time()*10000) c = struct.pack("@I", v & 0xFFFFFFFF & ~CB) dots.append(c) img_data = b"".join(dots) - self.paint_rect(0, self.H-ydelta*2, self.W, ydelta, img_data) + self.paint_rect(0, self.H-ydelta, self.W, ydelta, img_data) return True + def scrolluponce(self, ydelta): + self.scrollup(ydelta) + return False + def paint_rect(self, x=200, y=200, w=32, h=32, img_data="", options={}): self.window.draw_region(x, y, w, h, "rgb32", img_data, w*4, 0, typedict(options), []) def main(): - try: - import sys - N = int(sys.argv[1]) - except: - N = 1 + import sys + def argint(n, d): + try: + return int(sys.argv[n]) + except: + return d + N = argint(1, 1) #number of windows + delay = argint(2, 20) + ydelta = argint(3, 1) client = FakeGTKClient() + print("%i windows, delay=%ims, ydelta=%i" % (N, delay, ydelta)) for wid in range(N): anim = GLWindowAnim(client, wid) - glib.timeout_add(20, anim.scrollup) + glib.idle_add(anim.scrolluponce, ydelta) + glib.timeout_add(delay, anim.scrollup, ydelta) try: gtk_main() except KeyboardInterrupt: