OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 file_url = self.GetFileURLForPath(file_path) | 351 file_url = self.GetFileURLForPath(file_path) |
352 downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), | 352 downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), |
353 os.path.basename(file_path)) | 353 os.path.basename(file_path)) |
354 self._ClearLocalDownloadState(downloaded_pkg) | 354 self._ClearLocalDownloadState(downloaded_pkg) |
355 self.DownloadAndWaitForStart(file_url) | 355 self.DownloadAndWaitForStart(file_url) |
356 | 356 |
357 self._DeleteAfterShutdown(downloaded_pkg) | 357 self._DeleteAfterShutdown(downloaded_pkg) |
358 self._DeleteAfterShutdown(file_path) | 358 self._DeleteAfterShutdown(file_path) |
359 | 359 |
360 # Pause the download and assert that it is paused. | 360 # Pause the download and assert that it is paused. |
361 pause_dict = self.PerformActionOnDownload(self._GetDownloadId(), | 361 pause_dict = self.PerformActionOnDownload(self._GetDownloadId(), 'pause') |
362 'toggle_pause') | |
363 if pause_dict['state'] == 'COMPLETE': | 362 if pause_dict['state'] == 'COMPLETE': |
364 logging.info('The download completed before pause. Stopping test.') | 363 logging.info('The download completed before pause. Stopping test.') |
365 return | 364 return |
366 | 365 |
367 self.assertTrue(pause_dict['is_paused']) | 366 self.assertTrue(pause_dict['is_paused']) |
368 self.assertTrue(pause_dict['state'] == 'IN_PROGRESS') | 367 self.assertTrue(pause_dict['state'] == 'IN_PROGRESS') |
369 | 368 |
370 # Resume the download and assert it is not paused. | 369 # Resume the download and assert it is not paused. |
371 resume_dict = self.PerformActionOnDownload(self._GetDownloadId(), | 370 resume_dict = self.PerformActionOnDownload(self._GetDownloadId(), 'resume') |
372 'toggle_pause') | |
373 self.assertFalse(resume_dict['is_paused']) | 371 self.assertFalse(resume_dict['is_paused']) |
374 self.WaitForAllDownloadsToComplete(timeout=10 * 60 * 1000); | 372 self.WaitForAllDownloadsToComplete(timeout=10 * 60 * 1000); |
375 | 373 |
376 # Verify that the file was correctly downloaded after pause and resume. | 374 # Verify that the file was correctly downloaded after pause and resume. |
377 self.assertTrue(os.path.exists(downloaded_pkg), | 375 self.assertTrue(os.path.exists(downloaded_pkg), |
378 'Downloaded file %s missing.' % downloaded_pkg) | 376 'Downloaded file %s missing.' % downloaded_pkg) |
379 self.assertTrue(self._EqualFileContents(file_path, downloaded_pkg), | 377 self.assertTrue(self._EqualFileContents(file_path, downloaded_pkg), |
380 'Downloaded file %s does not match original' % | 378 'Downloaded file %s does not match original' % |
381 downloaded_pkg) | 379 downloaded_pkg) |
382 | 380 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 # Verify download in incognito window. | 507 # Verify download in incognito window. |
510 # bug 69738 WaitForAllDownloadsToComplete is flaky for this test case. | 508 # bug 69738 WaitForAllDownloadsToComplete is flaky for this test case. |
511 # Using extra WaitUntil until this is resolved. | 509 # Using extra WaitUntil until this is resolved. |
512 self.assertTrue(self.WaitUntil( | 510 self.assertTrue(self.WaitUntil( |
513 lambda: os.path.exists(downloaded_pkg_incog))) | 511 lambda: os.path.exists(downloaded_pkg_incog))) |
514 self.assertTrue(self._EqualFileContents(file_path, downloaded_pkg_incog)) | 512 self.assertTrue(self._EqualFileContents(file_path, downloaded_pkg_incog)) |
515 | 513 |
516 | 514 |
517 if __name__ == '__main__': | 515 if __name__ == '__main__': |
518 pyauto_functional.Main() | 516 pyauto_functional.Main() |
OLD | NEW |