Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 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 commands | 6 import commands |
| 7 import filecmp | 7 import filecmp |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import shutil | 10 import shutil |
| 11 import sys | 11 import sys |
| 12 import tempfile | 12 import tempfile |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 """ | 208 """ |
| 209 # Create a 1 GB file on the fly | 209 # Create a 1 GB file on the fly |
| 210 file_path = self._MakeFile(2**30) | 210 file_path = self._MakeFile(2**30) |
| 211 self._DeleteAfterShutdown(file_path) | 211 self._DeleteAfterShutdown(file_path) |
| 212 file_url = self.GetFileURLForPath(file_path) | 212 file_url = self.GetFileURLForPath(file_path) |
| 213 downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), | 213 downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), |
| 214 os.path.basename(file_path)) | 214 os.path.basename(file_path)) |
| 215 self._ClearLocalDownloadState(downloaded_pkg) | 215 self._ClearLocalDownloadState(downloaded_pkg) |
| 216 self.DownloadAndWaitForStart(file_url) | 216 self.DownloadAndWaitForStart(file_url) |
| 217 self._DeleteAfterShutdown(downloaded_pkg) | 217 self._DeleteAfterShutdown(downloaded_pkg) |
| 218 # Waiting for big file to download might exceed automation timeout. | 218 # Waiting for big file to download might exceed automation timeout. |
|
Paweł Hajdan Jr.
2011/03/29 18:57:54
nit: IMHO those two comment lines can now be remov
Nirnimesh
2011/03/29 20:27:28
Yes, it'd be fine to remove these comments
Huyen
2011/03/31 02:42:55
Done.
| |
| 219 # Temporarily increase the automation timeout. | 219 # Increase timeout to large_test_timeout_ms. |
| 220 test_utils.CallFunctionWithNewTimeout(self, 4 * 60 * 1000, # 4 min. | 220 self.WaitForAllDownloadsToComplete(timeout=self.large_test_timeout_ms()); |
|
Nirnimesh
2011/03/29 20:27:28
What's the value of large_test_timeout_ms?
Huyen
2011/03/31 02:42:55
3 minutes. Running ui_tests and downloads.py this
| |
| 221 self.WaitForAllDownloadsToComplete) | |
| 222 # Verify that the file was correctly downloaded | 221 # Verify that the file was correctly downloaded |
| 223 self.assertTrue(os.path.exists(downloaded_pkg), | 222 self.assertTrue(os.path.exists(downloaded_pkg), |
| 224 'Downloaded file %s missing.' % downloaded_pkg) | 223 'Downloaded file %s missing.' % downloaded_pkg) |
| 225 self.assertTrue(self._EqualFileContents(file_path, downloaded_pkg), | 224 self.assertTrue(self._EqualFileContents(file_path, downloaded_pkg), |
| 226 'Downloaded file %s does not match original' % | 225 'Downloaded file %s does not match original' % |
| 227 downloaded_pkg) | 226 downloaded_pkg) |
| 228 | 227 |
| 229 def testFileRenaming(self): | 228 def testFileRenaming(self): |
| 230 """Test file renaming when downloading a already-existing filename.""" | 229 """Test file renaming when downloading a already-existing filename.""" |
| 231 test_dir = os.path.join(os.path.abspath(self.DataDir()), 'downloads') | 230 test_dir = os.path.join(os.path.abspath(self.DataDir()), 'downloads') |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 | 353 |
| 355 self.assertTrue(pause_dict['is_paused']) | 354 self.assertTrue(pause_dict['is_paused']) |
| 356 self.assertTrue(pause_dict['state'] == 'IN_PROGRESS') | 355 self.assertTrue(pause_dict['state'] == 'IN_PROGRESS') |
| 357 | 356 |
| 358 # Resume the download and assert it is not paused. | 357 # Resume the download and assert it is not paused. |
| 359 resume_dict = self.PerformActionOnDownload(self._GetDownloadId(), | 358 resume_dict = self.PerformActionOnDownload(self._GetDownloadId(), |
| 360 'toggle_pause') | 359 'toggle_pause') |
| 361 self.assertFalse(resume_dict['is_paused']) | 360 self.assertFalse(resume_dict['is_paused']) |
| 362 | 361 |
| 363 # Waiting for big file to download might exceed automation timeout. | 362 # Waiting for big file to download might exceed automation timeout. |
| 364 # Temporarily increase the automation timeout. | 363 # Increase timeout to large_test_timeout_ms. |
| 365 test_utils.CallFunctionWithNewTimeout(self, 2 * 60 * 1000, # 2 min. | 364 self.WaitForAllDownloadsToComplete(timeout=self.large_test_timeout_ms()); |
| 366 self.WaitForAllDownloadsToComplete) | |
| 367 | 365 |
| 368 # Verify that the file was correctly downloaded after pause and resume. | 366 # Verify that the file was correctly downloaded after pause and resume. |
| 369 self.assertTrue(os.path.exists(downloaded_pkg), | 367 self.assertTrue(os.path.exists(downloaded_pkg), |
| 370 'Downloaded file %s missing.' % downloaded_pkg) | 368 'Downloaded file %s missing.' % downloaded_pkg) |
| 371 self.assertTrue(self._EqualFileContents(file_path, downloaded_pkg), | 369 self.assertTrue(self._EqualFileContents(file_path, downloaded_pkg), |
| 372 'Downloaded file %s does not match original' % | 370 'Downloaded file %s does not match original' % |
| 373 downloaded_pkg) | 371 downloaded_pkg) |
| 374 | 372 |
| 375 def testCancelDownload(self): | 373 def testCancelDownload(self): |
| 376 """Verify that we can cancel a download.""" | 374 """Verify that we can cancel a download.""" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 # Verify download in incognito window. | 576 # Verify download in incognito window. |
| 579 # bug 69738 WaitForAllDownloadsToComplete is flaky for this test case. | 577 # bug 69738 WaitForAllDownloadsToComplete is flaky for this test case. |
| 580 # Using extra WaitUntil until this is resolved. | 578 # Using extra WaitUntil until this is resolved. |
| 581 self.assertTrue(self.WaitUntil( | 579 self.assertTrue(self.WaitUntil( |
| 582 lambda: os.path.exists(downloaded_pkg_incog))) | 580 lambda: os.path.exists(downloaded_pkg_incog))) |
| 583 self.assertTrue(self._EqualFileContents(file_path, downloaded_pkg_incog)) | 581 self.assertTrue(self._EqualFileContents(file_path, downloaded_pkg_incog)) |
| 584 | 582 |
| 585 | 583 |
| 586 if __name__ == '__main__': | 584 if __name__ == '__main__': |
| 587 pyauto_functional.Main() | 585 pyauto_functional.Main() |
| OLD | NEW |