File: TestTaskbar.py

package info (click to toggle)
cairo-dock 3.5.1-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,936 kB
  • sloc: ansic: 55,359; sh: 2,037; python: 522; xml: 34; makefile: 10
file content (124 lines) | stat: -rw-r--r-- 4,432 bytes parent folder | download | duplicates (6)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from time import sleep
import os  # system
from Test import Test, key, set_param
from CairoDock import CairoDock
import config

# test taskbar with grouped windows
class TestTaskbar(Test):
	def __init__(self, dock):
		self.exe = config.exe
		self.wmclass = config.wmclass
		self.desktop_file = config.desktop_file
		Test.__init__(self, "Test taskbar", dock)
	
	def run(self):
		# start from 0 instance and check that the launcher is the only icon of this class
		os.system('killall -q '+self.exe)
		sleep(1)
		props = self.d.GetProperties('class='+self.wmclass)
		
		if len(props) < 1:
			self.d.Add({'type':'Launcher', 'config-file':'application://'+self.desktop_file})
		elif len(props) > 1:
			self.print_error ("Too many icons in the class "+self.wmclass)
		
		# launch 1 instance and check that the launcher has taken the window
		os.system(self.exe+'&')
		sleep(1)
		props = self.d.GetProperties('class='+self.wmclass)
		if len(props) != 1 or props[0]['Xid'] == 0:
			self.print_error ("The launcher didn't take control of the window")
		
		# launch a 2nd instance and check that both windows are grouped above the launcher
		os.system(self.exe+'&')
		sleep(1)
		
		props = self.d.GetProperties('type=Application & container='+self.wmclass+' & class='+self.wmclass)
		if len(props) != 2:
			self.print_error ("Windows have not been grouped together")
		
		props = self.d.GetProperties('type=Launcher & class='+self.wmclass)
		if len(props) == 0 or props[0]['Xid'] != 0:
			self.print_error ("The launcher should have no indicator")
		
		# close 1 window and check that we come back to the previous situation
		os.system('pgrep -f '+self.exe+' | head -1 | xargs kill')
		sleep(1)
		
		props = self.d.GetProperties('class='+self.wmclass)
		if len(props) != 1 or props[0]['Xid'] == 0:
			self.print_error ("The launcher didn't take back control of the window")
		
		# close the 2nd window and check that we come back to the first situation
		os.system('killall -q '+self.exe)
		sleep(1)
		props = self.d.GetProperties('class='+self.wmclass)
		
		if len(props) != 1 or props[0]['Xid'] != 0:
			self.print_error ("All windows didn't disappear from the dock")
		
		self.end()

# test taskbar with ungrouped windows
class TestTaskbar2(Test):
	def __init__(self, dock):
		self.exe = config.exe
		self.wmclass = config.wmclass
		self.desktop_file = config.desktop_file
		Test.__init__(self, "Test taskbar2", dock)
	
	def run(self):
		set_param (self.get_conf_file(), "TaskBar", "group by class", "false")
		self.d.Reload('type=Manager & name=Taskbar')
		
		# start from 0 instance and check that the launcher is the only icon of this class
		os.system('killall -q '+self.exe)
		sleep(1)
		props = self.d.GetProperties('class='+self.wmclass)
		
		if len(props) < 1:
			self.d.Add({'type':'Launcher', 'config-file':'application://'+self.desktop_file})
		elif len(props) > 1:
			self.print_error ("Too many icons in the class "+self.wmclass)
		
		# launch 1 instance and check that the launcher has taken the window
		os.system(self.exe+'&')
		sleep(1)
		props = self.d.GetProperties('class='+self.wmclass)
		if len(props) != 1 or props[0]['Xid'] == 0:
			self.print_error ("The launcher didn't take control of the window")
		
		launcher_position = props[0]['position']
		
		# launch a 2nd instance and check that the 2nd icon is next to the launcher
		os.system(self.exe+'&')
		sleep(1)
		
		props = self.d.GetProperties('type=Application & class='+self.wmclass)
		if len(props) != 1:
			self.print_error ("There should be an icon for the 2nd window")
		
		if props[0]['position'] != launcher_position + 1:
			self.print_error ("The appli icon should be next to its launcher")
		
		# close 1 window and check that we come back to the previous situation
		os.system('pgrep -f '+self.exe+' | head -1 | xargs kill')
		sleep(1)
		
		props = self.d.GetProperties('class='+self.wmclass)
		if len(props) != 1 or props[0]['Xid'] == 0:
			self.print_error ("The launcher didn't take back control of the window")
		
		# close the 2nd window and check that we come back to the first situation
		os.system('killall -q '+self.exe)
		sleep(1)
		props = self.d.GetProperties('class='+self.wmclass)
		
		if len(props) != 1 or props[0]['Xid'] != 0:
			self.print_error ("All windows didn't disappear from the dock")
		
		set_param (self.get_conf_file(), "TaskBar", "group by class", "true")
		self.d.Reload('type=Manager & name=Taskbar')
		
		self.end()