Merge lp:~ara/mago/firefox_natty into lp:~mago-contributors/mago/mago-1.0
- firefox_natty
- Merge into mago-1.0
Proposed by
Ara Pulido
Status: | Merged |
---|---|
Merged at revision: | 156 |
Proposed branch: | lp:~ara/mago/firefox_natty |
Merge into: | lp:~mago-contributors/mago/mago-1.0 |
Diff against target: |
290 lines (+191/-16) 5 files modified
firefox/README (+19/-0) firefox/firefox_basics.py (+34/-2) firefox/firefox_basics.xml (+25/-7) mago/application/firefox.py (+108/-5) mago/test_suite/firefox.py (+5/-2) |
To merge this branch: | bzr merge lp:~ara/mago/firefox_natty |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jean-Baptiste Lallement | Approve | ||
Review via email: mp+43176@code.launchpad.net |
Commit message
Description of the change
Firefox tests for Natty
Including:
* Open a given URL
* Search a given text in Google
* Open a new tab and close it
* Add a new bookmark and delete it
To post a comment you must log in.
Revision history for this message
Ara Pulido (ara) wrote : | # |
Thanks for your review! I will change the setup so it closes the extra tabs when it opens.
Revision history for this message
Ara Pulido (ara) wrote : | # |
/me <3 jibel
lp:~ara/mago/firefox_natty
updated
- 154. By Ara Pulido
-
Fixed setup to leave only one tab to start with
Revision history for this message
Ara Pulido (ara) wrote : | # |
I have fixed the setup method to close all the additional tabs and start fresh with only one.
Can you please rereview?
Thanks!
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote : | # |
Rereviewed and looks good. Many thanks.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'firefox/README' | |||
2 | --- firefox/README 2010-11-23 22:02:09 +0000 | |||
3 | +++ firefox/README 2010-12-09 14:59:10 +0000 | |||
4 | @@ -0,0 +1,19 @@ | |||
5 | 1 | BANSHEE TESTS | ||
6 | 2 | ============= | ||
7 | 3 | |||
8 | 4 | Safety | ||
9 | 5 | ------ | ||
10 | 6 | The tests are safe to run | ||
11 | 7 | |||
12 | 8 | Configuration | ||
13 | 9 | ------------- | ||
14 | 10 | The tests assume that there is a network connection | ||
15 | 11 | |||
16 | 12 | Available Tests | ||
17 | 13 | --------------- | ||
18 | 14 | |||
19 | 15 | * Open a given URL | ||
20 | 16 | * Search a given text in Google | ||
21 | 17 | * Open a new tab and close it | ||
22 | 18 | * Add a new bookmark and delete it | ||
23 | 19 | |||
24 | 0 | 20 | ||
25 | === modified file 'firefox/firefox_basics.py' | |||
26 | --- firefox/firefox_basics.py 2010-11-23 22:02:09 +0000 | |||
27 | +++ firefox/firefox_basics.py 2010-12-09 14:59:10 +0000 | |||
28 | @@ -5,9 +5,41 @@ | |||
29 | 5 | from mago.test_suite.firefox import FirefoxTestSuite | 5 | from mago.test_suite.firefox import FirefoxTestSuite |
30 | 6 | 6 | ||
31 | 7 | class FirefoxBasics(FirefoxTestSuite): | 7 | class FirefoxBasics(FirefoxTestSuite): |
34 | 8 | def testAboutdialog(self, arg1=None): | 8 | |
35 | 9 | self.application.runAboutdialog() | 9 | def testOpenURL(self, url, window_name_oracle): |
36 | 10 | self.application.open_url(url) | ||
37 | 11 | window_name = self.application.get_window_name() | ||
38 | 12 | |||
39 | 13 | if window_name != window_name_oracle: | ||
40 | 14 | raise AssertionError, "The URL %s was not correctly opened. Window expected: %s, got: %s" % (url, window_name_oracle, window_name) | ||
41 | 15 | |||
42 | 16 | |||
43 | 17 | def testGoogleSearch(self, search_text, window_name_oracle): | ||
44 | 18 | self.application.search_google(search_text) | ||
45 | 19 | window_name = self.application.get_window_name() | ||
46 | 20 | window_name_oracle = search_text + window_name_oracle | ||
47 | 21 | |||
48 | 22 | if window_name != window_name_oracle: | ||
49 | 23 | raise AssertionError, "The Google Search for %s was not correctly opened. Window expected: %s, got: %s" % (search_text, window_name_oracle, window_name) | ||
50 | 24 | |||
51 | 25 | def testTabs(self): | ||
52 | 26 | number_tabs = self.application.number_of_tabs() | ||
53 | 27 | self.application.open_new_tab() | ||
54 | 28 | number_tabs_after = self.application.number_of_tabs() | ||
55 | 29 | |||
56 | 30 | if (number_tabs + 1) != number_tabs_after: | ||
57 | 31 | raise AssertionError, "The tab was not created. Number of tabs expected %s, got %s" % (str(number_tabs + 1), str(number_tabs_after)) | ||
58 | 10 | 32 | ||
59 | 33 | self.application.close_current_tab() | ||
60 | 34 | number_tabs = self.application.number_of_tabs() | ||
61 | 35 | |||
62 | 36 | if (number_tabs + 1) != number_tabs_after: | ||
63 | 37 | raise AssertionError, "The tab was not created. Number of tabs expected %s, got %s" % (str(number_tabs_after - 1), str(number_tabs)) | ||
64 | 38 | |||
65 | 39 | def testBookmarks(self): | ||
66 | 40 | self.application.add_bookmark() | ||
67 | 41 | self.application.remove_bookmark() | ||
68 | 42 | |||
69 | 11 | if __name__ == "__main__": | 43 | if __name__ == "__main__": |
70 | 12 | firefox_test = FirefoxBasics() | 44 | firefox_test = FirefoxBasics() |
71 | 13 | firefox_test.run() | 45 | firefox_test.run() |
72 | 14 | 46 | ||
73 | === modified file 'firefox/firefox_basics.xml' | |||
74 | --- firefox/firefox_basics.xml 2010-11-23 22:02:09 +0000 | |||
75 | +++ firefox/firefox_basics.xml 2010-12-09 14:59:10 +0000 | |||
76 | @@ -4,11 +4,29 @@ | |||
77 | 4 | <description> | 4 | <description> |
78 | 5 | Tests which verify Firefox basics functionality. | 5 | Tests which verify Firefox basics functionality. |
79 | 6 | </description> | 6 | </description> |
87 | 7 | <case name="about_dialog"> | 7 | <case name="open_url"> |
88 | 8 | <method>testAboutdialog</method> | 8 | <method>testOpenURL</method> |
89 | 9 | <description>Verify that the about dialog launches</description> | 9 | <description>Verify that a particular URL is opened</description> |
90 | 10 | <args> | 10 | <args> |
91 | 11 | <arg1>Arg example</arg1> | 11 | <url>http://www.ubuntu.com</url> |
92 | 12 | </args> | 12 | <window_name_oracle>Ubuntuhomepage|Ubuntu</window_name_oracle> |
93 | 13 | </case> | 13 | </args> |
94 | 14 | </case> | ||
95 | 15 | <case name="search_google"> | ||
96 | 16 | <method>testGoogleSearch</method> | ||
97 | 17 | <description>Verify that Google search works correctly</description> | ||
98 | 18 | <args> | ||
99 | 19 | <search_text>Ubuntu</search_text> | ||
100 | 20 | <window_name_oracle>-GoogleSearch</window_name_oracle> | ||
101 | 21 | </args> | ||
102 | 22 | </case> | ||
103 | 23 | <case name="play_with_tabs"> | ||
104 | 24 | <method>testTabs</method> | ||
105 | 25 | <description>Verify that creation and deletion of tabs works correctly</description> | ||
106 | 26 | </case> | ||
107 | 27 | <case name="bookmarks"> | ||
108 | 28 | <method>testBookmarks</method> | ||
109 | 29 | <description>Verify that creation and deletion of bookmarks works correctly</description> | ||
110 | 30 | </case> | ||
111 | 14 | </suite> | 31 | </suite> |
112 | 32 | |||
113 | 15 | 33 | ||
114 | === modified file 'mago/application/firefox.py' | |||
115 | --- mago/application/firefox.py 2010-11-23 22:02:09 +0000 | |||
116 | +++ mago/application/firefox.py 2010-12-09 14:59:10 +0000 | |||
117 | @@ -14,6 +14,7 @@ | |||
118 | 14 | from ..cmd import globals | 14 | from ..cmd import globals |
119 | 15 | import time | 15 | import time |
120 | 16 | import gettext | 16 | import gettext |
121 | 17 | import re | ||
122 | 17 | 18 | ||
123 | 18 | gettext.install (True) | 19 | gettext.install (True) |
124 | 19 | gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE) | 20 | gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE) |
125 | @@ -29,7 +30,8 @@ | |||
126 | 29 | 30 | ||
127 | 30 | LAUNCHER = 'firefox' | 31 | LAUNCHER = 'firefox' |
128 | 31 | LAUNCHER_ARGS = [] | 32 | LAUNCHER_ARGS = [] |
130 | 32 | WINDOW = 'frmMozillaFirefoxStartPage*MozillaFirefox4*0Beta7' | 33 | WINDOW = 'frm*MozillaFirefox*' |
131 | 34 | WINDOW_PATTERN = "frm(.*)-MozillaFirefox.*" | ||
132 | 33 | 35 | ||
133 | 34 | BTN_17 = _('btn17') | 36 | BTN_17 = _('btn17') |
134 | 35 | BTN_19 = _('btn19') | 37 | BTN_19 = _('btn19') |
135 | @@ -61,8 +63,7 @@ | |||
136 | 61 | MNU_ALLYOURUSERSTUDIES___ = _('mnuAllYourUserStudies***') | 63 | MNU_ALLYOURUSERSTUDIES___ = _('mnuAllYourUserStudies***') |
137 | 62 | MNU_BACK = _('mnuBack') | 64 | MNU_BACK = _('mnuBack') |
138 | 63 | MNU_BOOKMARKALLTABS___ = _('mnuBookmarkAllTabs***') | 65 | MNU_BOOKMARKALLTABS___ = _('mnuBookmarkAllTabs***') |
141 | 64 | MNU_BOOKMARKTHISPAGE = _('mnuBookmarkThisPage') | 66 | MNU_BOOKMARKTHISPAGE = _('mnuBookmarkThisPage*') |
140 | 65 | MNU_BOOKMARKTHISPAGE1 = _('mnuBookmarkThisPage1') | ||
142 | 66 | MNU_CLEARRECENTHISTORY___ = _('mnuClearRecentHistory***') | 67 | MNU_CLEARRECENTHISTORY___ = _('mnuClearRecentHistory***') |
143 | 67 | MNU_CLOSETAB = _('mnuCloseTab') | 68 | MNU_CLOSETAB = _('mnuCloseTab') |
144 | 68 | MNU_CLOSEWINDOW = _('mnuCloseWindow') | 69 | MNU_CLOSEWINDOW = _('mnuCloseWindow') |
145 | @@ -125,6 +126,11 @@ | |||
146 | 125 | MNU_WEBSEARCH = _('mnuWebSearch') | 126 | MNU_WEBSEARCH = _('mnuWebSearch') |
147 | 126 | MNU_ZOOMIN = _('mnuZoomIn') | 127 | MNU_ZOOMIN = _('mnuZoomIn') |
148 | 127 | MNU_ZOOMOUT = _('mnuZoomOut') | 128 | MNU_ZOOMOUT = _('mnuZoomOut') |
149 | 129 | TXT_AWESOME = _('txtGotoaWebSite') | ||
150 | 130 | TXT_SEARCH_GLG = _('txtSearchusingGoogle') | ||
151 | 131 | PNL_PAGE_BOOKMARKED = _('pnlPageBookmarked') | ||
152 | 132 | BTN_DONE = _('btnDone') | ||
153 | 133 | BTN_REMOVE_BOOKMARK = _('btnRemoveBookmark') | ||
154 | 128 | 134 | ||
155 | 129 | 135 | ||
156 | 130 | def runAboutdialog(self): | 136 | def runAboutdialog(self): |
157 | @@ -133,7 +139,7 @@ | |||
158 | 133 | and that the UI reacts | 139 | and that the UI reacts |
159 | 134 | The About dialog is the only menu that is always present in the UI | 140 | The About dialog is the only menu that is always present in the UI |
160 | 135 | """ | 141 | """ |
162 | 136 | return | 142 | return |
163 | 137 | 143 | ||
164 | 138 | # We skip that test for firefox, there no a11y components in the about dialog to play with | 144 | # We skip that test for firefox, there no a11y components in the about dialog to play with |
165 | 139 | # | 145 | # |
166 | @@ -169,7 +175,104 @@ | |||
167 | 169 | # | 175 | # |
168 | 170 | # ldtp.click(dlgAbout, btnClose) | 176 | # ldtp.click(dlgAbout, btnClose) |
169 | 171 | 177 | ||
170 | 172 | |||
171 | 173 | def __init__(self): | 178 | def __init__(self): |
172 | 174 | Application.__init__(self) | 179 | Application.__init__(self) |
173 | 175 | self.main_window = ooldtp.context(self.WINDOW) | 180 | self.main_window = ooldtp.context(self.WINDOW) |
174 | 181 | |||
175 | 182 | def open_url(self, url): | ||
176 | 183 | """ | ||
177 | 184 | Opens a given URL in Firefox | ||
178 | 185 | """ | ||
179 | 186 | firefox = ooldtp.context(self.WINDOW) | ||
180 | 187 | awesome = firefox.getchild(self.TXT_AWESOME) | ||
181 | 188 | awesome.settextvalue(url) | ||
182 | 189 | ldtp.keypress("<enter>") | ||
183 | 190 | ldtp.keyrelease("<enter>") | ||
184 | 191 | |||
185 | 192 | # Waiting for the page to load | ||
186 | 193 | ldtp.wait(5) | ||
187 | 194 | |||
188 | 195 | def search_google(self, search_text): | ||
189 | 196 | """ | ||
190 | 197 | Searchs in Google, using the search textbox | ||
191 | 198 | """ | ||
192 | 199 | firefox = ooldtp.context(self.WINDOW) | ||
193 | 200 | search = firefox.getchild(self.TXT_SEARCH_GLG) | ||
194 | 201 | search.settextvalue(search_text) | ||
195 | 202 | ldtp.keypress("<enter>") | ||
196 | 203 | ldtp.keyrelease("<enter>") | ||
197 | 204 | |||
198 | 205 | #Waiting for the page to load | ||
199 | 206 | ldtp.wait(5) | ||
200 | 207 | |||
201 | 208 | def get_window_name(self): | ||
202 | 209 | """ | ||
203 | 210 | It returns the name of the navigator at a given point | ||
204 | 211 | """ | ||
205 | 212 | pattern = re.compile(self.WINDOW_PATTERN) | ||
206 | 213 | |||
207 | 214 | windows = ldtp.getwindowlist() | ||
208 | 215 | for win in windows: | ||
209 | 216 | match = re.match(pattern, win) | ||
210 | 217 | if match: | ||
211 | 218 | return match.groups()[0] | ||
212 | 219 | |||
213 | 220 | def open_new_tab(self): | ||
214 | 221 | """ | ||
215 | 222 | It creates a new tab in Firefox | ||
216 | 223 | """ | ||
217 | 224 | firefox = ooldtp.context(self.WINDOW) | ||
218 | 225 | new_tab = firefox.getchild(self.MNU_NEWTAB) | ||
219 | 226 | new_tab.click() | ||
220 | 227 | firefox.remap() | ||
221 | 228 | |||
222 | 229 | def close_current_tab(self): | ||
223 | 230 | """ | ||
224 | 231 | It closes the current tab | ||
225 | 232 | """ | ||
226 | 233 | firefox = ooldtp.context(self.WINDOW) | ||
227 | 234 | new_tab = firefox.getchild(self.MNU_CLOSETAB) | ||
228 | 235 | new_tab.click() | ||
229 | 236 | firefox.remap() | ||
230 | 237 | |||
231 | 238 | def get_tab_names(self): | ||
232 | 239 | """ | ||
233 | 240 | It returns a list with the names of the tabs | ||
234 | 241 | """ | ||
235 | 242 | firefox = ooldtp.context(self.WINDOW) | ||
236 | 243 | tabs = firefox.getchild(role="page_tab") | ||
237 | 244 | return tabs | ||
238 | 245 | |||
239 | 246 | def number_of_tabs(self): | ||
240 | 247 | """ | ||
241 | 248 | It returns the number of opened tabs | ||
242 | 249 | """ | ||
243 | 250 | return len(self.get_tab_names()) | ||
244 | 251 | |||
245 | 252 | def add_bookmark(self): | ||
246 | 253 | """ | ||
247 | 254 | It adds the current tab to the bookmarks | ||
248 | 255 | """ | ||
249 | 256 | firefox = ooldtp.context(self.WINDOW) | ||
250 | 257 | mnu_add = firefox.getchild(self.MNU_BOOKMARKTHISPAGE) | ||
251 | 258 | mnu_add.click() | ||
252 | 259 | |||
253 | 260 | firefox.remap() | ||
254 | 261 | btn_done = firefox.getchild(self.BTN_DONE) | ||
255 | 262 | btn_done.mouseleftclick() | ||
256 | 263 | |||
257 | 264 | def remove_bookmark(self): | ||
258 | 265 | """ | ||
259 | 266 | It removes the current tab to the bookmarks | ||
260 | 267 | """ | ||
261 | 268 | firefox = ooldtp.context(self.WINDOW) | ||
262 | 269 | mnu_add = firefox.getchild(self.MNU_BOOKMARKTHISPAGE) | ||
263 | 270 | mnu_add.click() | ||
264 | 271 | |||
265 | 272 | firefox.remap() | ||
266 | 273 | btn_remove = firefox.getchild(self.BTN_REMOVE_BOOKMARK) | ||
267 | 274 | btn_remove.mouseleftclick() | ||
268 | 275 | |||
269 | 276 | |||
270 | 277 | |||
271 | 278 | |||
272 | 176 | 279 | ||
273 | === modified file 'mago/test_suite/firefox.py' | |||
274 | --- mago/test_suite/firefox.py 2010-11-23 22:02:09 +0000 | |||
275 | +++ mago/test_suite/firefox.py 2010-12-09 14:59:10 +0000 | |||
276 | @@ -12,9 +12,12 @@ | |||
277 | 12 | APPLICATION_FACTORY = Firefox | 12 | APPLICATION_FACTORY = Firefox |
278 | 13 | def setup(self): | 13 | def setup(self): |
279 | 14 | self.application.open() | 14 | self.application.open() |
281 | 15 | 15 | ||
282 | 16 | while (self.application.number_of_tabs() > 1): | ||
283 | 17 | self.application.close_current_tab() | ||
284 | 18 | |||
285 | 16 | def teardown(self): | 19 | def teardown(self): |
286 | 17 | self.application.close() | 20 | self.application.close() |
287 | 18 | 21 | ||
288 | 19 | def cleanup(self): | 22 | def cleanup(self): |
290 | 20 | self.application.close() | 23 | pass |
With a new profile the default page is displayed and the page requested by the test is opened on another tab.
When the test tries to close firefox, a dialog is displayed saying that more than 1 tab is opened and asking for confirmation before closing.
This dialog makes the test fail.