Merge lp:~mago-contributors/mago/chromium into lp:~mago-contributors/mago/mago-testsuite

Proposed by Patrick Wright
Status: Merged
Merged at revision: 19
Proposed branch: lp:~mago-contributors/mago/chromium
Merge into: lp:~mago-contributors/mago/mago-testsuite
Diff against target: 140 lines (+132/-0)
1 file modified
chromium/test_chromium.py (+132/-0)
To merge this branch: bzr merge lp:~mago-contributors/mago/chromium
Reviewer Review Type Date Requested Status
Mago Contributors Pending
Review via email: mp+54457@code.launchpad.net

Description of the change

Added happy path test for chromium

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'chromium'
2=== added directory 'chromium/data'
3=== added file 'chromium/data/config.tar.gz'
4Binary files chromium/data/config.tar.gz 1970-01-01 00:00:00 +0000 and chromium/data/config.tar.gz 2011-03-23 01:36:30 +0000 differ
5=== added file 'chromium/test_chromium.py'
6--- chromium/test_chromium.py 1970-01-01 00:00:00 +0000
7+++ chromium/test_chromium.py 2011-03-23 01:36:30 +0000
8@@ -0,0 +1,132 @@
9+# Copyright (C) 2011 Canonical Ltd
10+#
11+# This program is free software; you can redistribute it and/or modify
12+# it under the terms of the GNU General Public License as published by
13+# the Free Software Foundation; either version 2 of the License, or
14+# (at your option) any later version.
15+#
16+# This program is distributed in the hope that it will be useful,
17+# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+# GNU General Public License for more details.
20+#
21+# You should have received a copy of the GNU General Public License
22+# along with this program; if not, write to the Free Software
23+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24+
25+"""
26+Chromium Browser Test Suite
27+"""
28+
29+from mago import TestCase
30+import unittest
31+import commands
32+import ldtp
33+import ooldtp
34+import os
35+import shutil
36+import tarfile
37+
38+class TestChromium(TestCase):
39+
40+ launcher = '/usr/bin/chromium-browser'
41+ launcher_args = ['%U']
42+ window_name = 'frm*Chromium'
43+ config_dir = os.path.join(os.path.expanduser('~'), '.config', 'chromium')
44+ config_tar = os.path.join(os.path.dirname(__file__), 'data', 'config.tar.gz')
45+
46+ button = {
47+ 'windowclose' : 'btn0',
48+ 'newtab' : 'btn4',
49+ 'closetab' : 'btn%r' # first close tab starts at index 5
50+ }
51+
52+ text = {
53+ 'address' : 'txt0'
54+ }
55+
56+ @classmethod
57+ def setUpClass(self):
58+ """Move config fir and restore known state"""
59+ super(TestChromium, self).setUpClass()
60+ if os.path.exists(self.config_dir):
61+ # mv and append .bak
62+ shutil.move(self.config_dir, self.config_dir + '.bak')
63+ # uncompress tar
64+ tar = tarfile.open(self.config_tar)
65+ tar.extractall(os.path.expanduser('~'))
66+
67+ @classmethod
68+ def tearDownClass(self):
69+ """Delete current state and restore backup"""
70+ super(TestChromium, self).tearDownClass()
71+ # delete config
72+ shutil.rmtree(self.config_dir)
73+
74+ # mv .bak to config
75+ shutil.move(self.config_dir + '.bak', self.config_dir)
76+
77+ def test_happypath(self):
78+ # navigate to url
79+ ldtp.settextvalue(self.window_name, self.text['address'], 'http://www.ubuntu.com')
80+ ldtp.generatekeyevent('<enter>')
81+ self.assertTrue(ldtp.waittillguiexist('frmUbuntuhomepage|Ubuntu*'))
82+
83+ # bookmark page
84+ keys = ['<ctrl>', 'd']
85+ for key in keys:
86+ ldtp.keypress(key)
87+ for key in keys:
88+ ldtp.keyrelease(key)
89+ ldtp.generatekeyevent('<enter>')
90+
91+ # open new tab
92+ ldtp.mouseleftclick(self.window_name, self.button['newtab'])
93+ ldtp.settextvalue(self.window_name, self.text['address'], 'http://www.canonical.com')
94+ ldtp.generatekeyevent('<enter>')
95+ self.assertTrue(ldtp.waittillguiexist('frmCanonicalHomepage|Canonical*'))
96+
97+ # close first tab
98+ ldtp.mouseleftclick(self.window_name, self.button['closetab'] % 5)
99+ self.assertTrue(ldtp.guiexist('frmCanonicalHomepage|Canonical*'))
100+ self.assertFalse(ldtp.guiexist('frmUbuntuhomepage|Ubuntu*'))
101+
102+ # open bookmarked page
103+ ldtp.mouseleftclick(self.window_name, self.button['newtab'])
104+ ldtp.mouseleftclick(self.window_name, 'btnUbuntuhomepage|Ubuntu*')
105+ self.assertTrue(ldtp.waittillguiexist('frmUbuntuhomepage|Ubuntu*'))
106+
107+if __name__ == "__main__":
108+ nose.main()
109+
110+
111+#btn0 = "btn0"
112+#btn1 = "btn1"
113+#btn10 = "btn10"
114+#btn11 = "btn11"
115+#btn12 = "btn12"
116+#btn14 = "btn14"
117+#btn16 = "btn16"
118+#btn2 = "btn2"
119+#btn3 = "btn3"
120+#btn4 = "btn4"
121+#btn5 = "btn5"
122+#btn8 = "btn8"
123+#btnBack = "btnBack"
124+#btnForward = "btnForward"
125+#btnHome = "btnHome"
126+#btnImportbookmarksnow = "btnImportbookmarksnow"
127+#btnOtherBookmarks = "btnOtherBookmarks"
128+#ico0 = "ico0"
129+#ico1 = "ico1"
130+#ico10 = "ico10"
131+#ico2 = "ico2"
132+#ico3 = "ico3"
133+#ico4 = "ico4"
134+#ico5 = "ico5"
135+#ico6 = "ico6"
136+#ico7 = "ico7"
137+#ico8 = "ico8"
138+#ico9 = "ico9"
139+#txt0 = "txt0"
140+#txt1 = "txt1"

Subscribers

People subscribed via source and target branches