Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: chrome/test/pyautolib/download_info.py

Issue 7544026: Fix for flakiness in pyauto automation hook WaitForDownloadsToComplete. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-wrote the first patch set. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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']
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698