OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import copy | 7 import copy |
8 import email | 8 import email |
| 9 import logging |
9 import os | 10 import os |
10 import smtplib | 11 import smtplib |
11 import types | 12 import types |
12 | 13 |
13 import pyauto_functional | 14 import pyauto_functional |
| 15 import pyauto |
14 import pyauto_utils | 16 import pyauto_utils |
15 | 17 |
16 | 18 |
17 """Commonly used functions for PyAuto tests.""" | 19 """Commonly used functions for PyAuto tests.""" |
18 | 20 |
19 def DownloadFileFromDownloadsDataDir(test, file_name): | 21 def DownloadFileFromDownloadsDataDir(test, file_name): |
20 """Download a file from downloads data directory, in first tab first window. | 22 """Download a file from downloads data directory, in first tab first window. |
21 | 23 |
22 Args: | 24 Args: |
23 test: derived from pyauto.PyUITest - base class for UI test cases | 25 test: derived from pyauto.PyUITest - base class for UI test cases |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 210 |
209 Args: | 211 Args: |
210 content_string: string to search for within content | 212 content_string: string to search for within content |
211 have_list: list of strings found within content | 213 have_list: list of strings found within content |
212 nothave_list: list of strings not found within content | 214 nothave_list: list of strings not found within content |
213 """ | 215 """ |
214 for s in have_list: | 216 for s in have_list: |
215 test.assertTrue(s in content_string, s) | 217 test.assertTrue(s in content_string, s) |
216 for s in nothave_list: | 218 for s in nothave_list: |
217 test.assertTrue(s not in content_string) | 219 test.assertTrue(s not in content_string) |
| 220 |
| 221 |
| 222 def CallFunctionWithNewTimeout(self, new_timeout, function): |
| 223 """Sets the timeout to |new_timeout| and calls |function|. |
| 224 |
| 225 This method resets the timeout before returning. |
| 226 """ |
| 227 timeout_changer = pyauto.PyUITest.CmdExecutionTimeoutChanger( |
| 228 self, new_timeout) |
| 229 logging.info('Automation execution timeout has been changed to %d. ' |
| 230 'If the timeout is large the test might appear to hang.' |
| 231 % new_timeout) |
| 232 function() |
| 233 del timeout_changer |
OLD | NEW |