OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """The testing Environment class. | 5 """The testing Environment class. |
6 | 6 |
7 It holds the WebsiteTest instances, provides them with credentials, | 7 It holds the WebsiteTest instances, provides them with credentials, |
8 provides clean browser environment, runs the tests, and gathers the | 8 provides clean browser environment, runs the tests, and gathers the |
9 results. | 9 results. |
10 """ | 10 """ |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 string_should_show_up): | 254 string_should_show_up): |
255 raise Exception(error) | 255 raise Exception(error) |
256 finally: | 256 finally: |
257 self.driver.switch_to_window(self.website_window) | 257 self.driver.switch_to_window(self.website_window) |
258 | 258 |
259 def DeleteCookies(self): | 259 def DeleteCookies(self): |
260 """Deletes cookies via the settings page.""" | 260 """Deletes cookies via the settings page.""" |
261 | 261 |
262 self._ClearDataForCheckbox("#delete-cookies-checkbox") | 262 self._ClearDataForCheckbox("#delete-cookies-checkbox") |
263 | 263 |
264 def RunTestsOnSites(self, test_type): | 264 def RunTestsOnSites(self, test_case_name): |
265 """Runs the specified test on the known websites. | 265 """Runs the specified test on the known websites. |
266 | 266 |
267 Also saves the test results in the environment. Note that test types | 267 Also saves the test results in the environment. Note that test types |
268 differ in their requirements on whether the save password prompt | 268 differ in their requirements on whether the save password prompt |
269 should be displayed. Make sure that such requirements are consistent | 269 should be displayed. Make sure that such requirements are consistent |
270 with the enable_automatic_password_saving argument passed to |self| | 270 with the enable_automatic_password_saving argument passed to |self| |
271 on construction. | 271 on construction. |
272 | 272 |
273 Args: | 273 Args: |
274 test_type: A test identifier understood by WebsiteTest.run_test(). | 274 test_case_name: A test name which is a method of WebsiteTest. |
275 """ | 275 """ |
276 | 276 |
277 self.DeleteCookies() | 277 self.DeleteCookies() |
278 self._ClearDataForCheckbox("#delete-passwords-checkbox") | 278 self._ClearDataForCheckbox("#delete-passwords-checkbox") |
279 self._EnablePasswordSaving() | 279 self._EnablePasswordSaving() |
280 | 280 |
281 for websitetest in self.websitetests: | 281 for websitetest in self.websitetests: |
282 successful = True | 282 successful = True |
283 error = "" | 283 error = "" |
284 try: | 284 try: |
285 websitetest.RunTest(test_type) | 285 # TODO(melandory): Implement a decorator for WesiteTest methods |
| 286 # which allows to mark them as test cases. And then add a check if |
| 287 # test_case_name is a valid test case. |
| 288 getattr(websitetest, test_case_name)() |
286 except Exception as e: | 289 except Exception as e: |
287 successful = False | 290 successful = False |
288 error = e.message | 291 error = e.message |
289 self.tests_results.append( | 292 self.tests_results.append( |
290 (websitetest.name, test_type, successful, error)) | 293 (websitetest.name, test_case_name, successful, error)) |
291 | 294 |
292 def Quit(self): | 295 def Quit(self): |
293 """Shuts down the driver.""" | 296 """Shuts down the driver.""" |
294 | 297 |
295 self.driver.quit() | 298 self.driver.quit() |
OLD | NEW |