briglia / dissertacao

Dissertacao de mestrado

This URL has Read+Write access

Anderson Briglia (author)
Tue Apr 28 17:36:53 -0700 2009
dissertacao / utilities / test-browser.py
11762e2e » Anderson Briglia 2009-04-28 Adding GPL header 1 #!/usr/bin.python
2 #
3 # Copyright (c) 2009 - Anderson Farias Briglia
4 # <anderson.briglia@gmail.com>
5 #
6 # This file is part of carman-python.
7 #
8 # carman-python is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # carman-python is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #
12b92ae6 » Anderson Briglia 2009-03-04 Reestruturacao da dissertac... 21
22 import time
23 from os import system
24
bce0bdcd » Anderson Briglia 2009-03-05 Programa python para abrir ... 25 class TestBrowser:
12b92ae6 » Anderson Briglia 2009-03-04 Reestruturacao da dissertac... 26
27 def __init__(self):
bce0bdcd » Anderson Briglia 2009-03-05 Programa python para abrir ... 28
29 self.send_url_cmd = 'run-standalone.sh dbus-send --type=method_call --dest=com.nokia.osso_browser /com/nokia/osso_browser com.nokia.osso_browser.load_url string:'
9d987f23 » Anderson Briglia 2009-03-21 Adicionando mais urls para ... 30 self.urls = ['www.uol.com.br', 'www.acritica.com.br', 'www.kibeloco.com.br',
31 'www.wikipedia.org', 'www.humortadela.com.br', 'www.google.com',
32 'www.ufam.edu.br', 'www.gmail.com',
33 'sanguedelpredador.briglia.net', 'techblog.briglia.net']
bce0bdcd » Anderson Briglia 2009-03-05 Programa python para abrir ... 34 self.wcount = 0
12b92ae6 » Anderson Briglia 2009-03-04 Reestruturacao da dissertac... 35 self.__steps = []
36
37 def close_window(self):
bce0bdcd » Anderson Briglia 2009-03-05 Programa python para abrir ... 38 cmd = ("xte -x :0.0 'mousemove 776 25' 'mouseclick 1'", 2)
12b92ae6 » Anderson Briglia 2009-03-04 Reestruturacao da dissertac... 39 self.add_step(cmd)
40
bce0bdcd » Anderson Briglia 2009-03-05 Programa python para abrir ... 41 def open_new_browser(self):
42 '''
43 This is necessary to open first browser window.
44 '''
45 if self.wcount == 0:
46 self.add_step((self.send_url_cmd, 5))
47 else:
48 cmd = ("xte -x :0.0 'mousemove 150 30' 'mouseclick 1'", 1)
49 self.add_step(cmd)
50 cmd = ("xte -x :0.0 'mousemove 150 85' 'mouseclick 1'", 1)
51 self.add_step(cmd)
52 cmd = ("xte -x :0.0 'key Page_Down' 'key Page_Down' 'key Down' 'key Return'", 10)
53 self.add_step(cmd)
54 self.wcount = self.wcount + 1
55
56 def open_url(self, url):
57 self.open_new_browser()
58 cmd = self.send_url_cmd + url
59 self.add_step((cmd, 20))
60
12b92ae6 » Anderson Briglia 2009-03-04 Reestruturacao da dissertac... 61 def add_step(self, cmd):
62 self.__steps.append(cmd)
63
bce0bdcd » Anderson Briglia 2009-03-05 Programa python para abrir ... 64 def close_all(self):
65 for i in xrange(0, self.wcount):
66 self.close_window()
67
12b92ae6 » Anderson Briglia 2009-03-04 Reestruturacao da dissertac... 68 def play_steps(self):
69 '''
70 Run each command stored in self.__steps.
71 Uses time.sleep() to make an interval between each command.
72 '''
73 for cmd in self.__steps:
d76ae086 » Anderson Briglia 2009-04-24 Improving test-browser test 74 #print 'CMD: ', cmd[0]
bce0bdcd » Anderson Briglia 2009-03-05 Programa python para abrir ... 75 system(cmd[0])
76 time.sleep(cmd[1])
77
78 def begin_test(self):
79 for url in self.urls:
80 self.open_url(url)
81 self.close_all()
82 self.play_steps()
12b92ae6 » Anderson Briglia 2009-03-04 Reestruturacao da dissertac... 83
84 if __name__ == '__main__':
d76ae086 » Anderson Briglia 2009-04-24 Improving test-browser test 85 print 'Initiating tests...'
bce0bdcd » Anderson Briglia 2009-03-05 Programa python para abrir ... 86 test = TestBrowser()
87 test.begin_test()
88 print 'Test Finished...'