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 pre_download_ids = [x['id'] for x in self.GetDownloadsInfo().Downloads()] |
14 self.WaitForDownloadsToComplete() | 14 self.DownloadAndWaitForStart('http://my.url/package.zip') |
| 15 self.WaitForAllDownloadsToComplete(pre_download_ids) |
15 info = self.GetDownloadsInfo() | 16 info = self.GetDownloadsInfo() |
16 print info.Downloads() | 17 print info.Downloads() |
17 self.assertEqual(info.Downloads()[0]['file_name'], 'packge.zip') | 18 self.assertEqual(info.Downloads()[0]['file_name'], 'packge.zip') |
18 | 19 |
19 See more tests in chrome/test/functional/downloads.py. | 20 See more tests in chrome/test/functional/downloads.py. |
20 """ | 21 """ |
21 | 22 |
22 import os | 23 import os |
23 import simplejson as json | 24 import simplejson as json |
24 import sys | 25 import sys |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 """ | 73 """ |
73 return [x for x in self.Downloads() if x['state'] == 'IN_PROGRESS'] | 74 return [x for x in self.Downloads() if x['state'] == 'IN_PROGRESS'] |
74 | 75 |
75 def DownloadsComplete(self): | 76 def DownloadsComplete(self): |
76 """Info about all downloads that have completed. | 77 """Info about all downloads that have completed. |
77 | 78 |
78 Returns: | 79 Returns: |
79 [downloaditem1, downloaditem2, ...] | 80 [downloaditem1, downloaditem2, ...] |
80 """ | 81 """ |
81 return [x for x in self.Downloads() if x['state'] == 'COMPLETE'] | 82 return [x for x in self.Downloads() if x['state'] == 'COMPLETE'] |
OLD | NEW |