OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 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 logging |
10 import os | 10 import os |
11 import platform | 11 import platform |
12 import smtplib | 12 import smtplib |
13 import subprocess | 13 import subprocess |
14 import types | 14 import types |
15 | 15 |
16 import pyauto_functional | 16 import pyauto_functional |
17 import pyauto | 17 import pyauto |
18 import pyauto_utils | 18 import pyauto_utils |
19 | 19 |
20 | 20 |
21 """Commonly used functions for PyAuto tests.""" | 21 """Commonly used functions for PyAuto tests.""" |
22 | 22 |
23 def DownloadFileFromDownloadsDataDir(test, file_name): | 23 def DownloadFileFromDownloadsDataDir(test, file_name): |
24 """Download a file from downloads data directory, in first tab first window. | 24 """Download a file from downloads data directory, in first tab, first window. |
25 | 25 |
26 Args: | 26 Args: |
27 test: derived from pyauto.PyUITest - base class for UI test cases | 27 test: derived from pyauto.PyUITest - base class for UI test cases. |
28 file_name: name of file to download | 28 file_name: name of file to download. |
29 """ | 29 """ |
30 file_url = test.GetFileURLForDataPath(os.path.join('downloads', file_name)) | 30 file_url = test.GetFileURLForDataPath(os.path.join('downloads', file_name)) |
31 downloaded_pkg = os.path.join(test.GetDownloadDirectory().value(), | 31 downloaded_pkg = os.path.join(test.GetDownloadDirectory().value(), |
32 file_name) | 32 file_name) |
33 # Check if file already exists. If so then delete it. | 33 # Check if file already exists. If so then delete it. |
34 if os.path.exists(downloaded_pkg): | 34 if os.path.exists(downloaded_pkg): |
35 RemoveDownloadedTestFile(test, file_name) | 35 RemoveDownloadedTestFile(test, file_name) |
| 36 pre_download_ids = [x['id'] for x in test.GetDownloadsInfo().Downloads()] |
36 test.DownloadAndWaitForStart(file_url) | 37 test.DownloadAndWaitForStart(file_url) |
37 test.WaitForAllDownloadsToComplete() | 38 test.WaitForAllDownloadsToComplete(pre_download_ids) |
38 | 39 |
39 | 40 |
40 def RemoveDownloadedTestFile(test, file_name): | 41 def RemoveDownloadedTestFile(test, file_name): |
41 """Delete a file from the downloads directory. | 42 """Delete a file from the downloads directory. |
42 | 43 |
43 Arg: | 44 Arg: |
44 test: derived from pyauto.PyUITest - base class for UI test cases | 45 test: derived from pyauto.PyUITest - base class for UI test cases |
45 file_name: name of file to remove | 46 file_name: name of file to remove |
46 """ | 47 """ |
47 downloaded_pkg = os.path.join(test.GetDownloadDirectory().value(), | 48 downloaded_pkg = os.path.join(test.GetDownloadDirectory().value(), |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 system_name = 'win' | 297 system_name = 'win' |
297 elif pyauto.PyUITest.IsLinux(): | 298 elif pyauto.PyUITest.IsLinux(): |
298 system_name = 'linux' | 299 system_name = 'linux' |
299 elif pyauto.PyUITest.IsMac(): | 300 elif pyauto.PyUITest.IsMac(): |
300 system_name = 'mac' | 301 system_name = 'mac' |
301 else: | 302 else: |
302 return None | 303 return None |
303 node = platform.uname()[1].split('.')[0] | 304 node = platform.uname()[1].split('.')[0] |
304 creds_key = 'test_google_acct_%s_%s' % (system_name, node) | 305 creds_key = 'test_google_acct_%s_%s' % (system_name, node) |
305 return creds_key | 306 return creds_key |
OLD | NEW |