| 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 """DownloadInfo: python representation for downloads visible to Chrome. | 7 """DownloadInfo: python representation for downloads visible to Chrome. |
| 8 | 8 |
| 9 Obtain one of these from PyUITestSuite::GetDownloadsInfo() call. | 9 Obtain one of these from PyUITestSuite::GetDownloadsInfo() call. |
| 10 | 10 |
| 11 class MyDownloadsTest(pyauto.PyUITest): | 11 class MyDownloadsTest(pyauto.PyUITest): |
| 12 def testDownload(self): | 12 def testDownload(self): |
| 13 self.NavigateToURL('http://my.url/package.zip') | 13 self.DownloadAndWaitForStart('http://my.url/package.zip') |
| 14 self.WaitForDownloadsToComplete() | 14 self.WaitForAllDownloadsToComplete() |
| 15 info = self.GetDownloadsInfo() | 15 info = self.GetDownloadsInfo() |
| 16 print info.Downloads() | 16 print info.Downloads() |
| 17 self.assertEqual(info.Downloads()[0]['file_name'], 'packge.zip') | 17 self.assertEqual(info.Downloads()[0]['file_name'], 'packge.zip') |
| 18 | 18 |
| 19 See more tests in chrome/test/functional/downloads.py. | 19 See more tests in chrome/test/functional/downloads.py. |
| 20 """ | 20 """ |
| 21 | 21 |
| 22 import os | 22 import os |
| 23 import simplejson as json | 23 import simplejson as json |
| 24 import sys | 24 import sys |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 """ | 72 """ |
| 73 return [x for x in self.Downloads() if x['state'] == 'IN_PROGRESS'] | 73 return [x for x in self.Downloads() if x['state'] == 'IN_PROGRESS'] |
| 74 | 74 |
| 75 def DownloadsComplete(self): | 75 def DownloadsComplete(self): |
| 76 """Info about all downloads that have completed. | 76 """Info about all downloads that have completed. |
| 77 | 77 |
| 78 Returns: | 78 Returns: |
| 79 [downloaditem1, downloaditem2, ...] | 79 [downloaditem1, downloaditem2, ...] |
| 80 """ | 80 """ |
| 81 return [x for x in self.Downloads() if x['state'] == 'COMPLETE'] | 81 return [x for x in self.Downloads() if x['state'] == 'COMPLETE'] |
| OLD | NEW |