~helene-verhaeghe27/cairo-dock-core/bugfix

« back to all changes in this revision

Viewing changes to tests/TestLauncher.py

  • Committer: Fabrice Rey
  • Date: 2013-06-28 23:44:28 UTC
  • Revision ID: fabounet03@gmail.com-20130628234428-cwsvh6mexcfm0063
Added a test framework, and several tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from time import sleep
 
2
import os  # system, path
 
3
from Test import Test, key, set_param
 
4
from CairoDock import CairoDock
 
5
import config
 
6
 
 
7
# Test Launcher
 
8
class TestLauncher(Test):
 
9
        def __init__(self, dock):
 
10
                self.exe = config.exe1
 
11
                self.wmclass = config.wmclass1
 
12
                self.desktop_file = config.desktop_file1
 
13
                Test.__init__(self, "Test launcher", dock)
 
14
        
 
15
        def run(self):
 
16
                os.system('killall -q '+self.exe)
 
17
                sleep(1)
 
18
                self.d.Remove('type=Launcher & class='+self.wmclass)
 
19
                
 
20
                # add a new launcher
 
21
                conf_file = self.d.Add({'type':'Launcher', 'position':1, 'config-file':'application://'+self.desktop_file})
 
22
                if conf_file == None or conf_file == "" or not os.path.exists(conf_file):
 
23
                        self.print_error ("Failed to add the launcher")
 
24
                
 
25
                # activate the launcher and check that it launches the program
 
26
                key ("super+Return")
 
27
                key("2")  # 'position' starts from 0, but numbers on the icons start from 1
 
28
                
 
29
                os.system('pgrep -f '+self.exe)
 
30
                
 
31
                # remove the launcher
 
32
                self.d.Remove('config-file='+conf_file)
 
33
                if len (self.d.GetProperties('config-file='+conf_file)) != 0:  # check that it has been deleted
 
34
                        self.print_error ("Failed to remove the launcher")
 
35
                
 
36
                if os.path.exists(conf_file):  # check that it has been removed from the theme
 
37
                        self.print_error ("Failed to remove the launcher from the theme")
 
38
                
 
39
                self.end()