summaryrefslogtreecommitdiff
path: root/tests/functional/test9.py
blob: cefd56c83bacf4118ad493ab40f1604a78b5ea6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/python

# Check that configure requests for changing stacking order are supported.

#* Test steps
#  * show an application window
#  * show another application window
#  * configure topmost application below the other
#  * configure bottommost application above the other
#  * configure bottommost application to the top (sibling None)
#* Post-conditions
#  * stacking order is changed according to the configure requests

import os, re, sys, time

if os.system('pidof mcompositor'):
  print 'mcompositor is not running'
  sys.exit(1)

# create two application windows
fd = os.popen('windowctl n')
old_win = fd.readline().strip()
time.sleep(2)
fd = os.popen('windowctl n')
new_win = fd.readline().strip()
time.sleep(2)

# stack top application below the other
os.popen('windowctl L %s %s' % (new_win, old_win))
time.sleep(2)

ret = 0
fd = os.popen('windowstack m')
s = fd.read(5000)
for l in s.splitlines():
  if re.search("%s " % old_win, l.strip()):
    print old_win, 'found'
    break
  elif re.search("%s " % new_win, l.strip()):
    print 'FAIL: configuring below failed'
    print 'Failed stack:\n', s
    ret = 1
    break

# stack bottom application above the other
os.popen('windowctl V %s %s' % (new_win, old_win))
time.sleep(2)

fd = os.popen('windowstack m')
s = fd.read(5000)
for l in s.splitlines():
  if re.search("%s " % new_win, l.strip()):
    print new_win, 'found'
    break
  elif re.search("%s " % old_win, l.strip()):
    print 'FAIL: configuring above failed'
    print 'Failed stack:\n', s
    ret = 1
    break

# stack bottom application to top
os.popen('windowctl V %s None' % old_win)
time.sleep(2)

fd = os.popen('windowstack m')
s = fd.read(5000)
for l in s.splitlines():
  if re.search("%s " % old_win, l.strip()):
    print old_win, 'found'
    break
  elif re.search("%s " % new_win, l.strip()):
    print 'FAIL: configuring to top failed'
    print 'Failed stack:\n', s
    ret = 1
    break

# cleanup
os.popen('pkill windowctl')
time.sleep(1)

sys.exit(ret)