예제 #1
0
	def run(self):
		if os.path.exists(self.test_file):
			os.remove(self.test_file)
		
		# add a new custom launcher at the beginning of the dock
		conf_file = self.d.Add({'type':'Launcher', 'name':'xxx', 'command':'echo -n 321 > '+self.test_file, 'icon':'gtk-home.png', 'position':1})
		if conf_file == None or conf_file == "" or not os.path.exists(conf_file):
			self.print_error ("Failed to add the launcher")
			return
		
		# reload
		set_param (conf_file, "Desktop Entry", "Name", "Test launcher")
		set_param (conf_file, "Desktop Entry", "Exec", "echo -n 123 > \/tmp\/cairo-dock-test")
		self.d.Reload('config-file='+conf_file)
		
		# left-click on it
		key ("super+Return")
		key("2")  # 'position' starts from 0, but numbers on the icons start from 1
		
		try:
			f = open('/tmp/cairo-dock-test', 'r')
			result = f.read()
			if result != "123":
				self.print_error ("Failed to reload the launcher")
		except:
			self.print_error ("Failed to activate the launcher")
		
		# remove it
		self.d.Remove('config-file='+conf_file);
		if os.path.exists(conf_file):
			self.print_error ("Failed to remove the launcher")
		
		self.end()
예제 #2
0
	def run(self):
		# add a new stack-icon
		conf_file = self.d.Add({'type':'Stack-icon', 'name':self.name1})  # by default, the rendering is a 'box'
		if conf_file == None or conf_file == "" or not os.path.exists(conf_file):
			self.print_error ("Failed to add the stack-icon")
		
		# add launchers inside the sub-dock
		conf_file1 = self.d.Add({'type':'Launcher', 'container':self.name1, 'config-file':'application://'+config.desktop_file1})
		conf_file2 = self.d.Add({'type':'Launcher', 'container':self.name1, 'config-file':'application://'+config.desktop_file2})
		if len (self.d.GetProperties('type=Launcher&container='+self.name1)) != 2:
			self.print_error ("Failed to add launchers into the stack")
		
		# change the name of the stack-icon
		set_param (conf_file, "Desktop Entry", "Name", self.name2)
		self.d.Reload('config-file='+conf_file)
		if len (self.d.GetProperties('type=Launcher&container='+self.name1)) != 0:
			self.print_error ("Failed to rename the sub-dock")
		if len (self.d.GetProperties('type=Launcher&container='+self.name2)) != 2:
			self.print_error ("Failed to rename the sub-dock 2")
		res = subprocess.call(['grep', 'Container *= *'+self.name2, str(conf_file1)])
		if res != 0:
			self.print_error ("Failed to move the sub-icons to the new sub-dock")
		
		# change the name of the stack-icon to something that already exists
		name3 = self.name2
		shortcuts_props = self.d.GetProperties('type=Applet&module=shortcuts')  # get the name of another sub-dock (Shortcuts)
		if len(shortcuts_props) != 0:
			used_name = shortcuts_props[0]['name']
			set_param (conf_file, "Desktop Entry", "Name", used_name)
			self.d.Reload('config-file='+conf_file)
			props = self.d.GetProperties('config-file='+conf_file)
			name3 = props[0]['name']
			
			if name3 == self.name2:
				self.print_error ('Failed to rename the stack-icon')
			elif name3 == used_name:
				self.print_error ('The name %s is already used', used_name)
			
			if len (self.d.GetProperties('type=Launcher&container='+name3)) != 2:
				self.print_error ("Failed to rename the sub-dock 3")
			res = subprocess.call(['grep', 'Container *= *'+name3, str(conf_file1)])
			if res != 0:
				self.print_error ("Failed to move the sub-icons to the new sub-dock 2")
		else:
			self.print_error ('Shortcuts applet has no sub-icon')
		
		# remove the stack-icon
		self.d.Remove('config-file='+conf_file)
		if len (self.d.GetProperties('type=Launcher&container='+name3)) != 0:  # check that no objects are in the stack any more
			self.print_error ("Failed to empty the stack")
		if len (self.d.GetProperties('config-file='+conf_file1+'|config-file='+conf_file2)) != 0:  # check that objects inside have been destroyed
			self.print_error ("Sub-icons have not been destroyed")
		if os.path.exists(conf_file1) or os.path.exists(conf_file2):  # check that objects inside have been deleted from the theme
			self.print_error ("Failed to remove the sub-icons from the theme")
		
		self.end()
예제 #3
0
	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()
예제 #4
0
	def run(self):
		
		props = self.d.GetProperties('type=Dock')
		height_ini = props[0]['height']
		
		# change the icons size and check that the dock size is updated
		# Note: if the screen is too small, the size might not change at all
		set_param (self.get_conf_file(), "Icons", "launcher size", "48;48")  # from 40 to 48
		self.d.Reload('type=Manager & name='+self.mgr)
		sleep(self.dt)  # let the 'configure' event arrive
		
		props = self.d.GetProperties('type=Dock')
		height = props[0]['height']
		
		if height == height_ini:
			self.print_error ('The dock size has not been updated')
		elif height != height_ini + 17:  # (48-40)*(1.75 + .4) = 17 (.4 = reflect height, not impacted by the zoom)
			self.print_error ('The dock height is wrong (should be %d but is %d)' % (height_ini + 17, height))
		
		set_param (self.get_conf_file(), "Icons", "launcher size", "40;40")  # back to normal
		set_param (self.get_conf_file(), "Icons", "zoom max", "2")  # from 1.75 to 2
		self.d.Reload('type=Manager & name='+self.mgr)
		sleep(self.dt)  # let the 'configure' event arrive
		
		props = self.d.GetProperties('type=Dock')
		height = props[0]['height']
		
		if height != height_ini + 10:  # 40*(2-1.75) = 10 (the reflect is not impacted by the zoom)
			self.print_error ('The dock height is wrong (should be %d but is %d)' % (height_ini + 10, height))
		
		set_param (self.get_conf_file(), "Icons", "zoom max", "1.75")  # back to normal
		self.d.Reload('type=Manager & name='+self.mgr)
		
		self.end()
예제 #5
0
    def run(self):
        if os.path.exists(self.test_file):
            os.remove(self.test_file)

        # add a new custom launcher at the beginning of the dock
        conf_file = self.d.Add({
            'type': 'Launcher',
            'name': 'xxx',
            'command': 'echo -n 321 > ' + self.test_file,
            'icon': 'gtk-home.png',
            'position': 1
        })
        if conf_file == None or conf_file == "" or not os.path.exists(
                conf_file):
            self.print_error("Failed to add the launcher")
            return

        # reload
        set_param(conf_file, "Desktop Entry", "Name", "Test launcher")
        set_param(conf_file, "Desktop Entry", "Exec",
                  "echo -n 123 > \/tmp\/cairo-dock-test")
        self.d.Reload('config-file=' + conf_file)

        # left-click on it
        key("super+Return")
        key(
            "2"
        )  # 'position' starts from 0, but numbers on the icons start from 1

        try:
            f = open('/tmp/cairo-dock-test', 'r')
            result = f.read()
            if result != "123":
                self.print_error("Failed to reload the launcher")
        except:
            self.print_error("Failed to activate the launcher")

        # remove it
        self.d.Remove('config-file=' + conf_file)
        if os.path.exists(conf_file):
            self.print_error("Failed to remove the launcher")

        self.end()
예제 #6
0
    def run(self):

        props = self.d.GetProperties('type=Dock')
        height_ini = props[0]['height']
        y_ini = props[0]['y']

        # change the line width
        set_param(self.get_conf_file(), "Background", "line width",
                  "1")  # from 2 to 1
        self.d.Reload('type=Manager & name=' + self.mgr)
        sleep(self.dt)  # let the 'configure' event arrive

        props = self.d.GetProperties('type=Dock')
        height = props[0]['height']

        if height == height_ini:
            self.print_error('The dock size has not been updated')
        elif height != height_ini - 1:
            self.print_error(
                'The dock height is wrong (should be %d but is %d)' %
                (height_ini - 1, height))

        set_param(self.get_conf_file(), "Background", "line width",
                  "2")  # back to normal
        set_param(self.get_conf_file(), "Position", "screen border",
                  "1")  # from bottom to top

        self.d.Reload('type=Manager & name=' + self.mgr)
        sleep(self.dt)  # let the 'configure' event arrive
        props = self.d.GetProperties('type=Dock')
        y = props[0]['y']

        if y_ini == y:
            self.print_error('The dock position has not been updated')
        elif y != 0:
            print("incorrect position (should be 0 but is %d)", y)

        set_param(self.get_conf_file(), "Position", "screen border",
                  "0")  # back to normal
        self.d.Reload('type=Manager & name=' + self.mgr)

        self.end()
예제 #7
0
    def run(self):

        props = self.d.GetProperties('type=Dock')
        height_ini = props[0]['height']

        # change the icons size and check that the dock size is updated
        # Note: if the screen is too small, the size might not change at all
        set_param(self.get_conf_file(), "Icons", "launcher size",
                  "48;48")  # from 40 to 48
        self.d.Reload('type=Manager & name=' + self.mgr)
        sleep(self.dt)  # let the 'configure' event arrive

        props = self.d.GetProperties('type=Dock')
        height = props[0]['height']

        if height == height_ini:
            self.print_error('The dock size has not been updated')
        elif height != height_ini + 17:  # (48-40)*(1.75 + .4) = 17 (.4 = reflect height, not impacted by the zoom)
            self.print_error(
                'The dock height is wrong (should be %d but is %d)' %
                (height_ini + 17, height))

        set_param(self.get_conf_file(), "Icons", "launcher size",
                  "40;40")  # back to normal
        set_param(self.get_conf_file(), "Icons", "zoom max",
                  "2")  # from 1.75 to 2
        self.d.Reload('type=Manager & name=' + self.mgr)
        sleep(self.dt)  # let the 'configure' event arrive

        props = self.d.GetProperties('type=Dock')
        height = props[0]['height']

        if height != height_ini + 10:  # 40*(2-1.75) = 10 (the reflect is not impacted by the zoom)
            self.print_error(
                'The dock height is wrong (should be %d but is %d)' %
                (height_ini + 10, height))

        set_param(self.get_conf_file(), "Icons", "zoom max",
                  "1.75")  # back to normal
        self.d.Reload('type=Manager & name=' + self.mgr)

        self.end()
예제 #8
0
	def run(self):
		
		props = self.d.GetProperties('type=Dock')
		height_ini = props[0]['height']
		y_ini = props[0]['y']
		
		# change the line width
		set_param (self.get_conf_file(), "Background", "line width", "1")  # from 2 to 1
		self.d.Reload('type=Manager & name='+self.mgr)
		sleep(self.dt)  # let the 'configure' event arrive
		
		props = self.d.GetProperties('type=Dock')
		height = props[0]['height']
		
		if height == height_ini:
			self.print_error ('The dock size has not been updated')
		elif height != height_ini - 1:
			self.print_error ('The dock height is wrong (should be %d but is %d)' % (height_ini - 1, height))
		
		set_param (self.get_conf_file(), "Background", "line width", "2")  # back to normal
		set_param (self.get_conf_file(), "Position", "screen border", "1")  # from bottom to top
		
		self.d.Reload('type=Manager & name='+self.mgr)
		sleep(self.dt)  # let the 'configure' event arrive
		props = self.d.GetProperties('type=Dock')
		y = props[0]['y']
		
		if y_ini == y:
			self.print_error ('The dock position has not been updated')
		elif y != 0:
			print ("incorrect position (should be 0 but is %d)", y);
		
		set_param (self.get_conf_file(), "Position", "screen border", "0")  # back to normal
		self.d.Reload('type=Manager & name='+self.mgr)
		
		self.end()
예제 #9
0
    def run(self):
        # add a new stack-icon
        conf_file = self.d.Add({
            'type': 'Stack-icon',
            'name': self.name1
        })  # by default, the rendering is a 'box'
        if conf_file == None or conf_file == "" or not os.path.exists(
                conf_file):
            self.print_error("Failed to add the stack-icon")

        # add launchers inside the sub-dock
        conf_file1 = self.d.Add({
            'type':
            'Launcher',
            'container':
            self.name1,
            'config-file':
            'application://' + config.desktop_file1
        })
        conf_file2 = self.d.Add({
            'type':
            'Launcher',
            'container':
            self.name1,
            'config-file':
            'application://' + config.desktop_file2
        })
        if len(self.d.GetProperties('type=Launcher&container=' +
                                    self.name1)) != 2:
            self.print_error("Failed to add launchers into the stack")

        # change the name of the stack-icon
        set_param(conf_file, "Desktop Entry", "Name", self.name2)
        self.d.Reload('config-file=' + conf_file)
        if len(self.d.GetProperties('type=Launcher&container=' +
                                    self.name1)) != 0:
            self.print_error("Failed to rename the sub-dock")
        if len(self.d.GetProperties('type=Launcher&container=' +
                                    self.name2)) != 2:
            self.print_error("Failed to rename the sub-dock 2")
        res = subprocess.call(
            ['grep', 'Container *= *' + self.name2,
             str(conf_file1)])
        if res != 0:
            self.print_error(
                "Failed to move the sub-icons to the new sub-dock")

        # change the name of the stack-icon to something that already exists
        name3 = self.name2
        shortcuts_props = self.d.GetProperties(
            'type=Applet&module=shortcuts'
        )  # get the name of another sub-dock (Shortcuts)
        if len(shortcuts_props) != 0:
            used_name = shortcuts_props[0]['name']
            set_param(conf_file, "Desktop Entry", "Name", used_name)
            self.d.Reload('config-file=' + conf_file)
            props = self.d.GetProperties('config-file=' + conf_file)
            name3 = props[0]['name']

            if name3 == self.name2:
                self.print_error('Failed to rename the stack-icon')
            elif name3 == used_name:
                self.print_error('The name %s is already used', used_name)

            if len(self.d.GetProperties('type=Launcher&container=' +
                                        name3)) != 2:
                self.print_error("Failed to rename the sub-dock 3")
            res = subprocess.call(
                ['grep', 'Container *= *' + name3,
                 str(conf_file1)])
            if res != 0:
                self.print_error(
                    "Failed to move the sub-icons to the new sub-dock 2")
        else:
            self.print_error('Shortcuts applet has no sub-icon')

        # remove the stack-icon
        self.d.Remove('config-file=' + conf_file)
        if len(self.d.GetProperties('type=Launcher&container=' + name3)
               ) != 0:  # check that no objects are in the stack any more
            self.print_error("Failed to empty the stack")
        if len(
                self.d.GetProperties('config-file=' + conf_file1 +
                                     '|config-file=' + conf_file2)
        ) != 0:  # check that objects inside have been destroyed
            self.print_error("Sub-icons have not been destroyed")
        if os.path.exists(conf_file1) or os.path.exists(
                conf_file2
        ):  # check that objects inside have been deleted from the theme
            self.print_error("Failed to remove the sub-icons from the theme")

        self.end()
예제 #10
0
    def run(self):

        # ensure the applet is running
        props = self.d.GetProperties('module=' + self.applet)
        if len(props) == 0:
            conf_file = self.d.Add({
                'type': 'Module-Instance',
                'module': self.applet
            })
        else:
            conf_file = props[0]['config-file']

        # detach the applet
        set_param(conf_file, "Desklet", "initially detached", "true")
        self.d.Reload('type=Module-Instance & config-file=' + conf_file)
        sleep(.3)

        props = self.d.GetProperties(
            'type=Desklet & name=' +
            self.applet)  # check that the desklet has been created
        if len(props) == 0:
            self.print_error("Failed to create the desklet")

        x_ini = props[0]['x']
        w_ini = props[0]['width']

        # move the desklet from the config
        x = x_ini - 50 if x_ini > 50 else x_ini + 50
        set_param(conf_file, "Desklet", "x position", str(x))
        self.d.Reload('type=Module-Instance & config-file=' + conf_file)
        sleep(.3)

        props = self.d.GetProperties(
            'type=Desklet & name=' +
            self.applet)  # check that the desklet's position is correct
        x2 = props[0]['x']
        if x2 != x:
            self.print_error("Failed to move the desklet (%d/%d)" % (x2, x))

        # move the desklet manually
        os.system('xdotool search --name ' + self.applet +
                  ' windowmove 100 100')
        sleep(
            .8
        )  # wait until the desklet has moved and the desklet manager has written the new position in the config file

        props = self.d.GetProperties(
            'type=Desklet & name=' +
            self.applet)  # check that the desklet's position is correct
        x = props[0]['x']
        y = props[0]['y']
        if x != 100 or y != 100:
            self.print_error("Failed to move the desklet manually (%d/%d)" %
                             (x, y))
        res = subprocess.call([
            'grep', 'x position *= *100',
            str(conf_file)
        ])  # check that the new position has been written in conf
        if res != 0:
            self.print_error("Failed to move the desklet manually")

        # resize the desklet from the config
        w = w_ini + 10
        set_param(conf_file, "Desklet", "size", str(w) + ';' + str(w))
        self.d.Reload('type=Module-Instance & config-file=' + conf_file)
        sleep(
            1.0
        )  # wait until the desklet has resized and the desklet manager has updated the desklet

        props = self.d.GetProperties(
            'type=Desklet & name=' +
            self.applet)  # check that the desklet's size is correct
        w2 = props[0]['width']
        if w2 != w:
            self.print_error("Failed to resize the desklet (%d/%d)" % (w2, w))

        # resize the desklet manually
        os.system('xdotool search --name ' + self.applet +
                  ' windowsize 100 100')
        sleep(
            1.0
        )  # wait until the desklet has resized and the desklet manager has written the new size in the config file

        props = self.d.GetProperties(
            'type=Desklet & name=' +
            self.applet)  # check that the desklet's size is correct
        w = props[0]['width']
        h = props[0]['height']
        if w != 100 or h != 100:
            self.print_error("Failed to resize the desklet manually (%d/%d)" %
                             (w, h))
        res = subprocess.call([
            'grep', 'size *= *100;100',
            str(conf_file)
        ])  # check that the new size has been written in conf
        if res != 0:
            self.print_error("Failed to resize the desklet manually")

        # just for fun ^^
        for i in range(0, 361, 15):
            set_param(conf_file, 'Desklet', 'rotation', i)
            self.d.Reload('type=Module-Instance & config-file=' + conf_file)

        # re-attach the applet
        set_param(conf_file, "Desklet", "initially detached", "false")
        self.d.Reload('type=Module-Instance & config-file=' + conf_file)

        props = self.d.GetProperties(
            'type=Desklet & name=' +
            self.applet)  # check that the desklet has been destroyed
        if len(props) != 0:
            self.print_error("Failed to destroy the desklet")

        self.end()
예제 #11
0
    def run(self):
        # add a new dock
        conf_file = self.d.Add({'type': 'Dock'})
        if conf_file == None or conf_file == "" or not os.path.exists(
                conf_file):
            self.print_error("Failed to add the dock in the theme")

        props = self.d.GetProperties('config-file=' + conf_file)
        if len(props
               ) == 0 or props[0]['type'] != 'Dock' or props[0]['name'] == "":
            self.print_error("Failed to add the dock")
            self.end()
            return
        dock_name = props[0]['name']

        # add a launcher inside
        conf_file_launcher = self.d.Add({
            'type':
            'Launcher',
            'container':
            dock_name,
            'config-file':
            'application://' + config.desktop_file1
        })
        if conf_file_launcher == None or conf_file_launcher == "" or not os.path.exists(
                conf_file_launcher):
            self.print_error("Failed to add a launcher inside the new dock")

        # add a module inside (the module must have only 1 instance for the test)
        props = self.d.GetProperties('type=Module-Instance & module=Clipper')
        if len(props) == 0:  # not active yet
            conf_file_module = self.d.Add({
                'type': 'Module-Instance',
                'module': 'Clipper'
            })
            if conf_file == None or conf_file == "" or not os.path.exists(
                    conf_file):
                self.print_error("Failed to instanciate the module")
        else:
            conf_file_module = props[0]['config-file']

        set_param(conf_file_module, 'Icon', 'dock name', dock_name)
        self.d.Reload('config-file=' + conf_file_module)

        if len(self.d.GetProperties('container=' + dock_name)) != 2:
            self.print_error(
                "Failed to add one or more icons into the new dock")

        # remove the dock -> it must delete its content too
        self.d.Remove('config-file=' + conf_file)
        if len(self.d.GetProperties('container=' + dock_name)
               ) != 0:  # check that no objects are in this dock any more
            self.print_error("Failed to remove the content of the dock")

        if os.path.exists(
                conf_file_launcher
        ):  # check that the launcher have been deleted from the theme
            self.print_error("Failed to remove the launcher from the theme")

        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
            self.print_error(
                "The config file of the module shouldn't have been deleted")
        else:
            res = subprocess.call(
                ['grep', 'dock name *= *_MainDock_',
                 str(conf_file_module)])
            if res != 0:
                self.print_error(
                    "The module should go in the main dock the next time it is activated"
                )

        self.end()