diff options
Diffstat (limited to 'src/tests')
-rwxr-xr-x | src/tests/stress_test.py | 87 |
1 files changed, 87 insertions, 0 deletions
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 @@ | |||
1 | #!/usr/bin/env python | ||
2 | |||
3 | # This is a simple stress test: | ||
4 | # * resize | ||
5 | # * move | ||
6 | # * title change | ||
7 | # * create/delete window test | ||
8 | |||
9 | import gtk | ||
10 | import gobject | ||
11 | import random | ||
12 | import time | ||
13 | |||
14 | |||
15 | def rotate_left(values): | ||
16 | """Rotate values left""" | ||
17 | |||
18 | new_values = values[1:len(values)] | ||
19 | new_values.append(values[0]) | ||
20 | return new_values | ||
21 | |||
22 | class App: | ||
23 | def __init__(self): | ||
24 | self.titles = [ "fluxbox", | ||
25 | ">>", | ||
26 | ">>"*4, | ||
27 | ">>"*8, | ||
28 | ">>"*16, | ||
29 | ">>"*24, | ||
30 | ">>"*32, | ||
31 | ">>"*64, | ||
32 | "more to come" ] | ||
33 | |||
34 | seed = int(time.time()) | ||
35 | print "Seed:",seed | ||
36 | random.seed(seed) | ||
37 | |||
38 | self.window = None | ||
39 | |||
40 | self.create_window() | ||
41 | |||
42 | # Setup timers | ||
43 | gobject.timeout_add(100, self.change_title) | ||
44 | gobject.timeout_add(200, self.change_size) | ||
45 | gobject.timeout_add(300, self.change_position) | ||
46 | gobject.timeout_add(1000, self.create_window) | ||
47 | |||
48 | def create_window(self): | ||
49 | """Destroys the old window and creates a new window""" | ||
50 | |||
51 | if self.window is not None: | ||
52 | self.window.destroy() | ||
53 | self.window = gtk.Window() | ||
54 | self.window.connect("delete-event", gtk.main_quit) | ||
55 | self.window.resize(300, 100) | ||
56 | self.window.set_title("fluxbox") | ||
57 | self.window.show() | ||
58 | |||
59 | return True | ||
60 | |||
61 | def change_title(self): | ||
62 | """Changes the title of the window""" | ||
63 | |||
64 | self.window.set_title(self.titles[0]) | ||
65 | self.titles = rotate_left(self.titles) | ||
66 | |||
67 | return True | ||
68 | |||
69 | def change_size(self): | ||
70 | """Changes the size of the window""" | ||
71 | |||
72 | self.window.resize(random.randrange(1, 1000), | ||
73 | random.randrange(1, 1000)) | ||
74 | |||
75 | return True | ||
76 | |||
77 | def change_position(self): | ||
78 | """Changes the position of the window""" | ||
79 | |||
80 | self.window.move(random.randrange(-100, 1000), | ||
81 | random.randrange(-100, 1000)) | ||
82 | |||
83 | return True | ||
84 | |||
85 | if __name__ == "__main__": | ||
86 | app = App() | ||
87 | gtk.main() | ||