4
from Test import Test, key, set_param
5
from CairoDock import CairoDock
9
class TestRootDock(Test):
10
def __init__(self, dock):
11
Test.__init__(self, "Test root dock", dock)
15
conf_file = self.d.Add({'type':'Dock'})
16
if conf_file == None or conf_file == "" or not os.path.exists(conf_file):
17
self.print_error ("Failed to add the dock in the theme")
19
props = self.d.GetProperties('config-file='+conf_file)
20
if len(props) == 0 or props[0]['type'] != 'Dock' or props[0]['name'] == "":
21
self.print_error ("Failed to add the dock")
24
dock_name = props[0]['name']
26
# add a launcher inside
27
conf_file_launcher = self.d.Add({'type':'Launcher', 'container':dock_name, 'config-file':'application://'+config.desktop_file1})
28
if conf_file_launcher == None or conf_file_launcher == "" or not os.path.exists(conf_file_launcher):
29
self.print_error ("Failed to add a launcher inside the new dock")
31
# add a module inside (the module must have only 1 instance for the test)
32
props = self.d.GetProperties('type=Module-Instance & module=Clipper')
33
if len(props) == 0: # not active yet
34
conf_file_module = self.d.Add({'type':'Module-Instance', 'module':'Clipper'})
35
if conf_file == None or conf_file == "" or not os.path.exists(conf_file):
36
self.print_error ("Failed to instanciate the module")
38
conf_file_module = props[0]['config-file']
40
set_param (conf_file_module, 'Icon', 'dock name', dock_name)
41
self.d.Reload('config-file='+conf_file_module)
43
if len(self.d.GetProperties('container='+dock_name)) != 2:
44
self.print_error ("Failed to add one or more icons into the new dock")
46
# remove the dock -> it must delete its content too
47
self.d.Remove('config-file='+conf_file)
48
if len (self.d.GetProperties('container='+dock_name)) != 0: # check that no objects are in this dock any more
49
self.print_error ("Failed to remove the content of the dock")
51
if os.path.exists(conf_file_launcher): # check that the launcher have been deleted from the theme
52
self.print_error ("Failed to remove the launcher from the theme")
54
if not os.path.exists(conf_file_module): # check that the module-instance has been deleted, but its config-file kept and updated to go in the main-dock next time
55
self.print_error ("The config file of the module shouldn't have been deleted")
57
res = subprocess.call(['grep', 'dock name *= *_MainDock_', str(conf_file_module)])
59
self.print_error ("The module should go in the main dock the next time it is activated")
63
# test root dock with auto-destruction when emptied
64
class TestRootDock2(Test):
65
def __init__(self, dock):
66
Test.__init__(self, "Test root dock 2", dock)
70
conf_file = self.d.Add({'type':'Dock'})
71
if conf_file == None or conf_file == "" or not os.path.exists(conf_file):
72
self.print_error ("Failed to add the dock in the theme")
74
props = self.d.GetProperties('config-file='+conf_file)
75
if len(props) == 0 or props[0]['type'] != 'Dock' or props[0]['name'] == "":
76
self.print_error ("Failed to add the dock")
79
dock_name = props[0]['name']
81
# add a launcher inside
82
conf_file_launcher = self.d.Add({'type':'Launcher', 'container':dock_name, 'config-file':'application://'+config.desktop_file1})
83
if conf_file_launcher == None or conf_file_launcher == "" or not os.path.exists(conf_file_launcher):
84
self.print_error ("Failed to add a launcher inside the new dock")
86
# remove all icons from the dock -> the dock must auto-destroy
87
self.d.Remove('container='+dock_name)
88
if len (self.d.GetProperties('container='+dock_name)) != 0: # check that no objects are in this dock any more
89
self.print_error ("Failed to remove the content of the dock")
91
sleep(.1) # wait for the dock to auto-destroy
93
if len (self.d.GetProperties('type=Dock & name='+dock_name)) != 0: # check that the dock has been destroyed
94
self.print_error ("The dock has not been deleted automatically")
96
if not os.path.exists(conf_file): # check that its config file has been kept for next time
97
self.print_error ("The config file of the dock shouldn't have been deleted")