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

« back to all changes in this revision

Viewing changes to tests/Test.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
 
 
2
from time import sleep
 
3
import os  # system
 
4
from CairoDock import CairoDock
 
5
 
 
6
# Utilities
 
7
def key(k):
 
8
        os.system ("xdotool key "+k)
 
9
        sleep(1)
 
10
 
 
11
def set_param(conf_file, group, key, value):
 
12
        os.system ("sed -i '/^\[%s\]/,/^\[.*/ s/%s *=.*/%s = %s/g' %s" % (group, key, key, value, conf_file))
 
13
 
 
14
# Test
 
15
class Test:
 
16
        def __init__(self, _name, dock):
 
17
                self.name = _name
 
18
                self.error = 0
 
19
                self.dock = dock
 
20
                self.d = self.dock.iface
 
21
                self.conf_file = None
 
22
        
 
23
        def end(self):
 
24
                if self.error == 0:
 
25
                        print('['+self.name+'] \033[32msuccess\033[m')
 
26
                else:
 
27
                        print('['+self.name+'] \033[31merror\033[m')
 
28
        
 
29
        def run(self):
 
30
                pass
 
31
 
 
32
        def print_error(self,err):
 
33
                print('['+self.name+'] '+err)
 
34
                self.error = 1
 
35
        
 
36
        def get_conf_file(self):
 
37
                if self.conf_file == None:
 
38
                        props = self.d.GetProperties('type=Manager&name=Docks')  # all managers use the same config-file, so any manager does the trick
 
39
                        self.conf_file = props[0]['config-file']
 
40
                return self.conf_file