2
import os # system, path
3
from Test import Test, key, set_param
4
from CairoDock import CairoDock
9
class TestDesklet(Test):
10
def __init__(self, dock):
12
Test.__init__(self, "Test desklet", dock)
16
# ensure the applet is running
17
props = self.d.GetProperties('module='+self.applet)
19
conf_file = self.d.Add({'type':'Module-Instance', 'module':self.applet})
21
conf_file = props[0]['config-file']
24
set_param (conf_file, "Desklet", "initially detached", "true")
25
self.d.Reload('type=Module-Instance & config-file='+conf_file)
28
props = self.d.GetProperties('type=Desklet & name='+self.applet) # check that the desklet has been created
30
self.print_error ("Failed to create the desklet")
33
w_ini = props[0]['width']
36
# move the desklet from the config
37
x = x_ini - 50 if x_ini > 50 else x_ini + 50
38
set_param (conf_file, "Desklet", "x position", str(x))
39
self.d.Reload('type=Module-Instance & config-file='+conf_file)
42
props = self.d.GetProperties('type=Desklet & name='+self.applet) # check that the desklet's position is correct
45
self.print_error ("Failed to move the desklet (%d/%d)" % (x2, x))
47
# move the desklet manually
48
os.system('xdotool search --name '+self.applet+' windowmove 100 100')
49
sleep(.8) # wait until the desklet has moved and the desklet manager has written the new position in the config file
51
props = self.d.GetProperties('type=Desklet & name='+self.applet) # check that the desklet's position is correct
54
if x != 100 or y != 100:
55
self.print_error ("Failed to move the desklet manually (%d/%d)" % (x, y))
56
res = subprocess.call(['grep', 'x position *= *100', str(conf_file)]) # check that the new position has been written in conf
58
self.print_error ("Failed to move the desklet manually")
61
# resize the desklet from the config
63
set_param (conf_file, "Desklet", "size", str(w)+';'+str(w))
64
self.d.Reload('type=Module-Instance & config-file='+conf_file)
65
sleep(1.0) # wait until the desklet has resized and the desklet manager has updated the desklet
67
props = self.d.GetProperties('type=Desklet & name='+self.applet) # check that the desklet's size is correct
68
w2 = props[0]['width']
70
self.print_error ("Failed to resize the desklet (%d/%d)" % (w2, w))
72
# resize the desklet manually
73
os.system('xdotool search --name '+self.applet+' windowsize 100 100')
74
sleep(1.0) # wait until the desklet has resized and the desklet manager has written the new size in the config file
76
props = self.d.GetProperties('type=Desklet & name='+self.applet) # check that the desklet's size is correct
78
h = props[0]['height']
79
if w != 100 or h != 100:
80
self.print_error ("Failed to resize the desklet manually (%d/%d)" % (w, h))
81
res = subprocess.call(['grep', 'size *= *100;100', str(conf_file)]) # check that the new size has been written in conf
83
self.print_error ("Failed to resize the desklet manually")
87
for i in range(0,361,15):
88
set_param(conf_file, 'Desklet', 'rotation', i)
89
self.d.Reload('type=Module-Instance & config-file='+conf_file)
91
# re-attach the applet
92
set_param (conf_file, "Desklet", "initially detached", "false")
93
self.d.Reload('type=Module-Instance & config-file='+conf_file)
95
props = self.d.GetProperties('type=Desklet & name='+self.applet) # check that the desklet has been destroyed
97
self.print_error ("Failed to destroy the desklet")