~helene-verhaeghe27/cairo-dock-core/bugfix

« back to all changes in this revision

Viewing changes to tests/TestTaskbar.py

  • Committer: Fabrice Rey
  • Date: 2013-06-28 23:44:28 UTC
  • Revision ID: fabounet03@gmail.com-20130628234428-cwsvh6mexcfm0063
Added a test framework, and several tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from time import sleep
 
2
import os  # system
 
3
from Test import Test, key, set_param
 
4
from CairoDock import CairoDock
 
5
import config
 
6
 
 
7
# test taskbar with grouped windows
 
8
class TestTaskbar(Test):
 
9
        def __init__(self, dock):
 
10
                self.exe = config.exe
 
11
                self.wmclass = config.wmclass
 
12
                self.desktop_file = config.desktop_file
 
13
                Test.__init__(self, "Test taskbar", dock)
 
14
        
 
15
        def run(self):
 
16
                # start from 0 instance and check that the launcher is the only icon of this class
 
17
                os.system('killall -q '+self.exe)
 
18
                sleep(1)
 
19
                props = self.d.GetProperties('class='+self.wmclass)
 
20
                
 
21
                if len(props) < 1:
 
22
                        self.d.Add({'type':'Launcher', 'config-file':'application://'+self.desktop_file})
 
23
                elif len(props) > 1:
 
24
                        self.print_error ("Too many icons in the class "+self.wmclass)
 
25
                
 
26
                # launch 1 instance and check that the launcher has taken the window
 
27
                os.system(self.exe+'&')
 
28
                sleep(1)
 
29
                props = self.d.GetProperties('class='+self.wmclass)
 
30
                if len(props) != 1 or props[0]['Xid'] == 0:
 
31
                        self.print_error ("The launcher didn't take control of the window")
 
32
                
 
33
                # launch a 2nd instance and check that both windows are grouped above the launcher
 
34
                os.system(self.exe+'&')
 
35
                sleep(1)
 
36
                
 
37
                props = self.d.GetProperties('type=Application & container='+self.wmclass+' & class='+self.wmclass)
 
38
                if len(props) != 2:
 
39
                        self.print_error ("Windows have not been grouped together")
 
40
                
 
41
                props = self.d.GetProperties('type=Launcher & class='+self.wmclass)
 
42
                if len(props) == 0 or props[0]['Xid'] != 0:
 
43
                        self.print_error ("The launcher should have no indicator")
 
44
                
 
45
                # close 1 window and check that we come back to the previous situation
 
46
                os.system('pgrep -f '+self.exe+' | head -1 | xargs kill')
 
47
                sleep(1)
 
48
                
 
49
                props = self.d.GetProperties('class='+self.wmclass)
 
50
                if len(props) != 1 or props[0]['Xid'] == 0:
 
51
                        self.print_error ("The launcher didn't take back control of the window")
 
52
                
 
53
                # close the 2nd window and check that we come back to the first situation
 
54
                os.system('killall -q '+self.exe)
 
55
                sleep(1)
 
56
                props = self.d.GetProperties('class='+self.wmclass)
 
57
                
 
58
                if len(props) != 1 or props[0]['Xid'] != 0:
 
59
                        self.print_error ("All windows didn't disappear from the dock")
 
60
                
 
61
                self.end()
 
62
 
 
63
# test taskbar with ungrouped windows
 
64
class TestTaskbar2(Test):
 
65
        def __init__(self, dock):
 
66
                self.exe = config.exe
 
67
                self.wmclass = config.wmclass
 
68
                self.desktop_file = config.desktop_file
 
69
                Test.__init__(self, "Test taskbar2", dock)
 
70
        
 
71
        def run(self):
 
72
                set_param (self.get_conf_file(), "TaskBar", "group by class", "false")
 
73
                self.d.Reload('type=Manager & name=Taskbar')
 
74
                
 
75
                # start from 0 instance and check that the launcher is the only icon of this class
 
76
                os.system('killall -q '+self.exe)
 
77
                sleep(1)
 
78
                props = self.d.GetProperties('class='+self.wmclass)
 
79
                
 
80
                if len(props) < 1:
 
81
                        self.d.Add({'type':'Launcher', 'config-file':'application://'+self.desktop_file})
 
82
                elif len(props) > 1:
 
83
                        self.print_error ("Too many icons in the class "+self.wmclass)
 
84
                
 
85
                # launch 1 instance and check that the launcher has taken the window
 
86
                os.system(self.exe+'&')
 
87
                sleep(1)
 
88
                props = self.d.GetProperties('class='+self.wmclass)
 
89
                if len(props) != 1 or props[0]['Xid'] == 0:
 
90
                        self.print_error ("The launcher didn't take control of the window")
 
91
                
 
92
                launcher_position = props[0]['position']
 
93
                
 
94
                # launch a 2nd instance and check that the 2nd icon is next to the launcher
 
95
                os.system(self.exe+'&')
 
96
                sleep(1)
 
97
                
 
98
                props = self.d.GetProperties('type=Application & class='+self.wmclass)
 
99
                if len(props) != 1:
 
100
                        self.print_error ("There should be an icon for the 2nd window")
 
101
                
 
102
                if props[0]['position'] != launcher_position + 1:
 
103
                        self.print_error ("The appli icon should be next to its launcher")
 
104
                
 
105
                # close 1 window and check that we come back to the previous situation
 
106
                os.system('pgrep -f '+self.exe+' | head -1 | xargs kill')
 
107
                sleep(1)
 
108
                
 
109
                props = self.d.GetProperties('class='+self.wmclass)
 
110
                if len(props) != 1 or props[0]['Xid'] == 0:
 
111
                        self.print_error ("The launcher didn't take back control of the window")
 
112
                
 
113
                # close the 2nd window and check that we come back to the first situation
 
114
                os.system('killall -q '+self.exe)
 
115
                sleep(1)
 
116
                props = self.d.GetProperties('class='+self.wmclass)
 
117
                
 
118
                if len(props) != 1 or props[0]['Xid'] != 0:
 
119
                        self.print_error ("All windows didn't disappear from the dock")
 
120
                
 
121
                set_param (self.get_conf_file(), "TaskBar", "group by class", "true")
 
122
                self.d.Reload('type=Manager & name=Taskbar')
 
123
                
 
124
                self.end()