3
from Test import Test, key, set_param
4
from CairoDock import CairoDock
8
class TestStackIcon(Test):
9
def __init__(self, dock):
12
Test.__init__(self, "Test stack icon", dock)
15
# add a new stack-icon
16
conf_file = self.d.Add({'type':'Stack-icon', 'name':self.name1}) # by default, the rendering is a 'box'
17
if conf_file == None or conf_file == "" or not os.path.exists(conf_file):
18
self.print_error ("Failed to add the stack-icon")
20
# add launchers inside the sub-dock
21
conf_file1 = self.d.Add({'type':'Launcher', 'container':self.name1, 'config-file':'application://'+config.desktop_file1})
22
conf_file2 = self.d.Add({'type':'Launcher', 'container':self.name1, 'config-file':'application://'+config.desktop_file2})
23
if len (self.d.GetProperties('type=Launcher&container='+self.name1)) != 2:
24
self.print_error ("Failed to add launchers into the stack")
26
# change the name of the stack-icon
27
set_param (conf_file, "Desktop Entry", "Name", self.name2)
28
self.d.Reload('config-file='+conf_file)
29
if len (self.d.GetProperties('type=Launcher&container='+self.name1)) != 0:
30
self.print_error ("Failed to rename the sub-dock")
31
if len (self.d.GetProperties('type=Launcher&container='+self.name2)) != 2:
32
self.print_error ("Failed to rename the sub-dock 2")
33
res = subprocess.call(['grep', 'Container *= *'+self.name2, str(conf_file1)])
35
self.print_error ("Failed to move the sub-icons to the new sub-dock")
37
# change the name of the stack-icon to something that already exists
39
shortcuts_props = self.d.GetProperties('type=Applet&module=shortcuts') # get the name of another sub-dock (Shortcuts)
40
if len(shortcuts_props) != 0:
41
used_name = shortcuts_props[0]['name']
42
set_param (conf_file, "Desktop Entry", "Name", used_name)
43
self.d.Reload('config-file='+conf_file)
44
props = self.d.GetProperties('config-file='+conf_file)
45
name3 = props[0]['name']
47
if name3 == self.name2:
48
self.print_error ('Failed to rename the stack-icon')
49
elif name3 == used_name:
50
self.print_error ('The name %s is already used', used_name)
52
if len (self.d.GetProperties('type=Launcher&container='+name3)) != 2:
53
self.print_error ("Failed to rename the sub-dock 3")
54
res = subprocess.call(['grep', 'Container *= *'+name3, str(conf_file1)])
56
self.print_error ("Failed to move the sub-icons to the new sub-dock 2")
58
self.print_error ('Shortcuts applet has no sub-icon')
60
# remove the stack-icon
61
self.d.Remove('config-file='+conf_file)
62
if len (self.d.GetProperties('type=Launcher&container='+name3)) != 0: # check that no objects are in the stack any more
63
self.print_error ("Failed to empty the stack")
64
if len (self.d.GetProperties('config-file='+conf_file1+'|config-file='+conf_file2)) != 0: # check that objects inside have been destroyed
65
self.print_error ("Sub-icons have not been destroyed")
66
if os.path.exists(conf_file1) or os.path.exists(conf_file2): # check that objects inside have been deleted from the theme
67
self.print_error ("Failed to remove the sub-icons from the theme")