summaryrefslogtreecommitdiff
path: root/tests/functional/test10.py
blob: 031f4531ba8ed97f03ee4dcfb07471535eb23a08 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/python

# Check that windows belonging to the same group are stacked together.

#* Test steps
#  * show two application windows in the same group
#  * show another application window that is not in the group
#  * raise the desktop
#  * raise the first grouped application window
#  * raise the non-grouped application window
#  * raise the second grouped application window
#* Post-conditions
#  * grouped application windows are stacked together above the desktop

import os, re, sys, time

if os.system('/sbin/mcetool --unblank-screen --set-tklock-mode=unlocked --set-inhibit-mode=stay-on'):
  print 'mcetool is missing!'

if os.system('/usr/bin/gconftool-2 --type bool --set /desktop/meego/notifications/previews_enabled false'):
  print 'cannot disable notifications'

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

fd = os.popen('windowstack m')
s = fd.read(5000)
win_re = re.compile('^0x[0-9a-f]+')
home_win = 0
for l in s.splitlines():
  if re.search(' DESKTOP viewable ', l.strip()):
    home_win = win_re.match(l.strip()).group()
    break

if home_win == 0:
  print 'FAIL: desktop not found'
  sys.exit(1)

# create two application windows in the same group
fd = os.popen('windowctl n')
old_win = fd.readline().strip()
time.sleep(1)
os.popen('windowctl G %s %s' % (old_win, old_win))
time.sleep(1)
fd = os.popen('windowctl n')
new_win = fd.readline().strip()
time.sleep(1)
os.popen('windowctl G %s %s' % (new_win, old_win))
time.sleep(1)
# create one application window not in the group
fd = os.popen('windowctl n')
outsider = fd.readline().strip()
time.sleep(1)

# raise home
os.popen('windowctl A %s' % home_win)
time.sleep(1)

# raise first grouped application
os.popen('windowctl A %s' % old_win)
time.sleep(1)
# raise outsider
os.popen('windowctl A %s' % outsider)
time.sleep(1)
# raise second grouped application
os.popen('windowctl A %s' % new_win)
time.sleep(1)

ret = new_win_found = 0
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, '(new_win) found'
    new_win_found = 1
  elif re.search("%s " % old_win, l.strip()) and new_win_found:
    print old_win, '(old_win) found'
    break
  elif re.search("%s " % old_win, l.strip()):
    print 'FAIL: wrong app window is stacked on top'
    print 'Failed stack:\n', s
    ret = 1
    break
  elif re.search("%s " % home_win, l.strip()):
    print 'FAIL: home is stacked on top'
    print 'Failed stack:\n', s
    ret = 1
    break
  elif re.search("%s " % outsider, l.strip()):
    print 'FAIL: non-grouped app is stacked before the group'
    print 'Failed stack:\n', s
    ret = 1
    break

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

if os.system('/usr/bin/gconftool-2 --type bool --set /desktop/meego/notifications/previews_enabled true'):
  print 'cannot re-enable notifications'

sys.exit(ret)