From 43837f82e152ea03a0bcefb07b089b1b9d72dc03 Mon Sep 17 00:00:00 2001 From: Henrik Kinnunen Date: Sat, 20 Mar 2010 00:29:39 +0100 Subject: Added simple stress test in python --- src/tests/stress_test.py | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 src/tests/stress_test.py diff --git a/src/tests/stress_test.py b/src/tests/stress_test.py new file mode 100755 index 0000000..a9c39f8 --- /dev/null +++ b/src/tests/stress_test.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python + +# This is a simple stress test: +# * resize +# * move +# * title change +# * create/delete window test + +import gtk +import gobject +import random +import time + + +def rotate_left(values): + """Rotate values left""" + + new_values = values[1:len(values)] + new_values.append(values[0]) + return new_values + +class App: + def __init__(self): + self.titles = [ "fluxbox", + ">>", + ">>"*4, + ">>"*8, + ">>"*16, + ">>"*24, + ">>"*32, + ">>"*64, + "more to come" ] + + seed = int(time.time()) + print "Seed:",seed + random.seed(seed) + + self.window = None + + self.create_window() + + # Setup timers + gobject.timeout_add(100, self.change_title) + gobject.timeout_add(200, self.change_size) + gobject.timeout_add(300, self.change_position) + gobject.timeout_add(1000, self.create_window) + + def create_window(self): + """Destroys the old window and creates a new window""" + + if self.window is not None: + self.window.destroy() + self.window = gtk.Window() + self.window.connect("delete-event", gtk.main_quit) + self.window.resize(300, 100) + self.window.set_title("fluxbox") + self.window.show() + + return True + + def change_title(self): + """Changes the title of the window""" + + self.window.set_title(self.titles[0]) + self.titles = rotate_left(self.titles) + + return True + + def change_size(self): + """Changes the size of the window""" + + self.window.resize(random.randrange(1, 1000), + random.randrange(1, 1000)) + + return True + + def change_position(self): + """Changes the position of the window""" + + self.window.move(random.randrange(-100, 1000), + random.randrange(-100, 1000)) + + return True + +if __name__ == "__main__": + app = App() + gtk.main() -- cgit v0.11.2