| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import hashlib | 6 import hashlib |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import time | 9 import time |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 checksum. Then we manually generate the md5 and check it against the | 78 checksum. Then we manually generate the md5 and check it against the |
| 79 filename. | 79 filename. |
| 80 | 80 |
| 81 Args: | 81 Args: |
| 82 download_url: URL of the file to download. | 82 download_url: URL of the file to download. |
| 83 """ | 83 """ |
| 84 start = time.time() | 84 start = time.time() |
| 85 # Make a copy of the download directory now to work around segfault | 85 # Make a copy of the download directory now to work around segfault |
| 86 downloads_dir = self.GetDownloadDirectory().value() | 86 downloads_dir = self.GetDownloadDirectory().value() |
| 87 self.DownloadAndWaitForStart(download_url) | 87 self.DownloadAndWaitForStart(download_url) |
| 88 self.WaitForAllDownloadsToComplete() | 88 self.WaitForAllDownloadsToComplete(timeout=self.large_test_timeout_ms()) |
| 89 end = time.time() | 89 end = time.time() |
| 90 logging.info('Download took %2.2f seconds to complete' % (end - start)) | 90 logging.info('Download took %2.2f seconds to complete' % (end - start)) |
| 91 downloaded_files = os.listdir(downloads_dir) | 91 downloaded_files = os.listdir(downloads_dir) |
| 92 self.assertEqual(len(downloaded_files), 1, msg='Expected only one file in ' | 92 self.assertEqual(len(downloaded_files), 1, msg='Expected only one file in ' |
| 93 'the Downloads folder, there are more.') | 93 'the Downloads folder, there are more.') |
| 94 self.assertFalse(len(downloaded_files) == 0, msg='Expected only one file in' | 94 self.assertFalse(len(downloaded_files) == 0, msg='Expected only one file in' |
| 95 ' the Downloads folder, there are none.') | 95 ' the Downloads folder, there are none.') |
| 96 filename = os.path.splitext(downloaded_files[0])[0] | 96 filename = os.path.splitext(downloaded_files[0])[0] |
| 97 file_path = os.path.join(self.GetDownloadDirectory().value(), | 97 file_path = os.path.join(self.GetDownloadDirectory().value(), |
| 98 downloaded_files[0]) | 98 downloaded_files[0]) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 117 def testDownload100MBFile(self): | 117 def testDownload100MBFile(self): |
| 118 """Test downloading a 100MB file from a wireless router.""" | 118 """Test downloading a 100MB file from a wireless router.""" |
| 119 download_url = 'http://172.22.12.98:8080/102400.lf' | 119 download_url = 'http://172.22.12.98:8080/102400.lf' |
| 120 self._ConnectToRouterAndVerify('Trendnet_639gr') | 120 self._ConnectToRouterAndVerify('Trendnet_639gr') |
| 121 self._DownloadAndVerifyFile(download_url) | 121 self._DownloadAndVerifyFile(download_url) |
| 122 self.DisconnectFromWifiNetwork() | 122 self.DisconnectFromWifiNetwork() |
| 123 | 123 |
| 124 | 124 |
| 125 if __name__ == '__main__': | 125 if __name__ == '__main__': |
| 126 pyauto_functional.Main() | 126 pyauto_functional.Main() |
| OLD | NEW |