Salome HOME
fix a test
[tools/sat.git] / test / log / launch_browser2.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3 #  Copyright (C) 2010-2012  CEA/DEN
4 #
5 #  This library is free software; you can redistribute it and/or
6 #  modify it under the terms of the GNU Lesser General Public
7 #  License as published by the Free Software Foundation; either
8 #  version 2.1 of the License.
9 #
10 #  This library is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 #  Lesser General Public License for more details.
14 #
15 #  You should have received a copy of the GNU Lesser General Public
16 #  License along with this library; if not, write to the Free Software
17 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18
19 import unittest
20 import os
21 import sys
22 import threading
23 import time
24
25 # get execution path
26 testdir = os.path.dirname(os.path.realpath(__file__))
27 sys.path.append(os.path.join(testdir, '..', '..'))
28 sys.path.append(os.path.join(testdir, '..', '_testTools'))
29 sys.path.append(os.path.join(testdir, '..', '..','commands'))
30
31 from salomeTools import Sat
32 from tools import check_proc_existence_and_kill_multi
33 import HTMLTestRunner
34
35 sleep_time = 2
36
37 class TestLog(unittest.TestCase):
38     '''Test of log command: launch of browser
39     '''
40     def test_launch_browser(self):
41         '''Test the launch of browser when invoking the log command
42         '''
43
44         OK = "KO"
45
46         sat = Sat("-oUSER.browser='konqueror'")
47         time.sleep(sleep_time)
48         cmd_log = threading.Thread(target=sat.log, args=('',))
49         cmd_log.start()
50
51         time.sleep(sleep_time)
52         
53         sat.config("")
54         browser = sat.cfg.USER.browser
55         pid = check_proc_existence_and_kill_multi(browser + ".*" + "hat\.xml", 10)
56
57         if pid:
58             OK = "OK"
59         # pyunit method to compare 2 str
60         self.assertEqual(OK, "OK")
61
62 # test launch
63 if __name__ == '__main__':
64     HTMLTestRunner.main()