Chromium Code Reviews| 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. |
|
vabr (Chromium)
2015/04/13 15:26:20
What do you think about requiring that the method
melandory
2015/04/14 07:22:36
I was thinking of implementing a decorator which w
vabr (Chromium)
2015/04/14 07:30:22
Acknowledged.
| |
| 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 getattr(websitetest, test_case_name)() |
| 286 except Exception as e: | 286 except Exception as e: |
| 287 successful = False | 287 successful = False |
| 288 error = e.message | 288 error = e.message |
| 289 self.tests_results.append( | 289 self.tests_results.append( |
| 290 (websitetest.name, test_type, successful, error)) | 290 (websitetest.name, test_case_name, successful, error)) |
| 291 | 291 |
| 292 def Quit(self): | 292 def Quit(self): |
| 293 """Shuts down the driver.""" | 293 """Shuts down the driver.""" |
| 294 | 294 |
| 295 self.driver.quit() | 295 self.driver.quit() |
| OLD | NEW |