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

Unified Diff: chrome/test/functional/downloads.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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/functional/downloads.py
diff --git a/chrome/test/functional/downloads.py b/chrome/test/functional/downloads.py
index 88c0be7f3003bb1653ef7758b2b7d84e6dd0e09f..d8ad45087a24fdf414315e7924d16ab99a728a52 100644
--- a/chrome/test/functional/downloads.py
+++ b/chrome/test/functional/downloads.py
@@ -100,7 +100,7 @@ class DownloadsTest(pyauto.PyUITest):
def testNoDownloadWaitingNeeded(self):
"""Make sure "wait for downloads" returns quickly if we have none."""
- self.WaitForAllDownloadsToComplete()
+ self.WaitForAllDownloadsToComplete([])
Nirnimesh 2011/08/08 17:26:17 See my notes in pyauto.py This should default to [
dennis_jeffrey 2011/08/08 22:29:51 Done.
def testZip(self):
"""Download a zip and verify that it downloaded correctly.
@@ -113,10 +113,11 @@ class DownloadsTest(pyauto.PyUITest):
'a_zip_file.zip')
self._ClearLocalDownloadState(downloaded_pkg)
+ pre_download_ids = [x['id'] for x in self.GetDownloadsInfo().Downloads()]
self.DownloadAndWaitForStart(file_url)
# Wait for the download to finish.
- self.WaitForAllDownloadsToComplete()
+ self.WaitForAllDownloadsToComplete(pre_download_ids)
# Verify that the download shelf is visible
self.assertTrue(self.IsDownloadShelfVisible())
@@ -136,11 +137,10 @@ class DownloadsTest(pyauto.PyUITest):
self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
# Trigger download and wait in new incognito window.
- self.DownloadAndWaitForStart(file_url, 1)
- self.WaitForAllDownloadsToComplete(1)
- # Remove next line when WaitForAllDownloadsToComplete can reliably wait
- # for downloads in incognito window. crbug.com/69738
- self.WaitForDownloadToComplete(downloaded_pkg)
+ pre_download_ids = [x['id']
+ for x in self.GetDownloadsInfo(windex=1).Downloads()]
+ self.DownloadAndWaitForStart(file_url, windex=1)
+ self.WaitForAllDownloadsToComplete(pre_download_ids, windex=1)
incognito_downloads = self.GetDownloadsInfo(1).Downloads()
# Verify that download info exists in the correct profile.
@@ -157,10 +157,11 @@ class DownloadsTest(pyauto.PyUITest):
downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
os.path.basename(file_path))
self._ClearLocalDownloadState(downloaded_pkg)
+ pre_download_ids = [x['id'] for x in self.GetDownloadsInfo().Downloads()]
self._TriggerUnsafeDownload(os.path.basename(file_path))
self.PerformActionOnDownload(self._GetDownloadId(),
'save_dangerous_download')
- self.WaitForDownloadToComplete(downloaded_pkg)
+ self.WaitForAllDownloadsToComplete(pre_download_ids)
# Verify that the file was downloaded.
self.assertTrue(os.path.exists(downloaded_pkg))
@@ -187,7 +188,9 @@ class DownloadsTest(pyauto.PyUITest):
'a_zip_file.zip')
self._ClearLocalDownloadState(downloaded_pkg)
+ pre_download_ids = [x['id'] for x in self.GetDownloadsInfo().Downloads()]
self.DownloadAndWaitForStart(file_url)
+ self.WaitForAllDownloadsToComplete(pre_download_ids)
self.PerformActionOnDownload(self._GetDownloadId(), 'remove')
# The download is removed from downloads, but not from the disk.
@@ -211,9 +214,11 @@ class DownloadsTest(pyauto.PyUITest):
downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
os.path.basename(file_path))
self._ClearLocalDownloadState(downloaded_pkg)
+ pre_download_ids = [x['id'] for x in self.GetDownloadsInfo().Downloads()]
self.DownloadAndWaitForStart(file_url)
self._DeleteAfterShutdown(downloaded_pkg)
- self.WaitForAllDownloadsToComplete(timeout=self.large_test_timeout_ms());
+ self.WaitForAllDownloadsToComplete(pre_download_ids,
+ timeout=self.large_test_timeout_ms());
# Verify that the file was correctly downloaded
self.assertTrue(os.path.exists(downloaded_pkg),
'Downloaded file %s missing.' % downloaded_pkg)
@@ -227,6 +232,7 @@ class DownloadsTest(pyauto.PyUITest):
file_url = 'file://%s' % os.path.join(test_dir, 'a_zip_file.zip')
download_dir = self.GetDownloadDirectory().value()
+ pre_download_ids = [x['id'] for x in self.GetDownloadsInfo().Downloads()]
num_times = 5
assert num_times > 1, 'needs to be > 1 to work'
renamed_files = []
@@ -239,7 +245,7 @@ class DownloadsTest(pyauto.PyUITest):
self._ClearLocalDownloadState(expected_filename)
self.DownloadAndWaitForStart(file_url)
- self.WaitForAllDownloadsToComplete()
+ self.WaitForAllDownloadsToComplete(pre_download_ids)
# Verify that all files exist and have the right name
for filename in renamed_files:
@@ -272,6 +278,7 @@ class DownloadsTest(pyauto.PyUITest):
# Filesystem-interfacing functions like os.listdir() need to
# be given unicode strings to "do the right thing" on win.
# Ref: http://boodebr.org/main/python/all-about-python-and-unicode
+ pre_download_ids = [x['id'] for x in self.GetDownloadsInfo().Downloads()]
for filename in crazy_filenames: # filename is unicode.
utf8_filename = filename.encode('utf-8')
file_path = os.path.join(temp_dir, utf8_filename)
@@ -280,7 +287,7 @@ class DownloadsTest(pyauto.PyUITest):
downloaded_file = os.path.join(download_dir, filename)
self._ClearLocalDownloadState(downloaded_file)
self.DownloadAndWaitForStart(file_url)
- self.WaitForAllDownloadsToComplete()
+ self.WaitForAllDownloadsToComplete(pre_download_ids)
# Verify downloads.
downloads = self.GetDownloadsInfo().Downloads()
@@ -335,6 +342,7 @@ class DownloadsTest(pyauto.PyUITest):
downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
os.path.basename(file_path))
self._ClearLocalDownloadState(downloaded_pkg)
+ pre_download_ids = [x['id'] for x in self.GetDownloadsInfo().Downloads()]
self.DownloadAndWaitForStart(file_url)
self._DeleteAfterShutdown(downloaded_pkg)
@@ -354,7 +362,8 @@ class DownloadsTest(pyauto.PyUITest):
resume_dict = self.PerformActionOnDownload(self._GetDownloadId(),
'toggle_pause')
self.assertFalse(resume_dict['is_paused'])
- self.WaitForAllDownloadsToComplete(timeout=self.large_test_timeout_ms());
+ self.WaitForAllDownloadsToComplete(pre_download_ids,
+ timeout=self.large_test_timeout_ms());
# Verify that the file was correctly downloaded after pause and resume.
self.assertTrue(os.path.exists(downloaded_pkg),
@@ -372,6 +381,7 @@ class DownloadsTest(pyauto.PyUITest):
downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
os.path.basename(file_path))
self._ClearLocalDownloadState(downloaded_pkg)
+
self.DownloadAndWaitForStart(file_url)
self.PerformActionOnDownload(self._GetDownloadId(), 'cancel')
self._DeleteAfterShutdown(file_path)
@@ -393,8 +403,9 @@ class DownloadsTest(pyauto.PyUITest):
downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
'a_zip_file.zip')
self._ClearLocalDownloadState(downloaded_pkg)
+ pre_download_ids = [x['id'] for x in self.GetDownloadsInfo().Downloads()]
self.DownloadAndWaitForStart(file_url)
- self.WaitForDownloadToComplete(downloaded_pkg)
+ self.WaitForAllDownloadsToComplete(pre_download_ids)
downloads = self.GetDownloadsInfo().Downloads()
self.assertEqual(1, len(downloads))
self.assertEqual('a_zip_file.zip', downloads[0]['file_name'])
@@ -440,8 +451,9 @@ class DownloadsTest(pyauto.PyUITest):
self._ClearLocalDownloadState(downloaded_pkg)
file_url = 'http://src.chromium.org/viewvc/chrome/trunk/src/chrome/'\
'test/data/downloads/a_zip_file.zip'
+ pre_download_ids = [x['id'] for x in self.GetDownloadsInfo().Downloads()]
self.DownloadAndWaitForStart(file_url)
- self.WaitForAllDownloadsToComplete()
+ self.WaitForAllDownloadsToComplete(pre_download_ids)
import xattr
self.assertTrue('com.apple.quarantine' in xattr.listxattr(downloaded_pkg))
@@ -453,6 +465,7 @@ class DownloadsTest(pyauto.PyUITest):
downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
os.path.basename(file_path))
os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg)
+ pre_download_ids = [x['id'] for x in self.GetDownloadsInfo().Downloads()]
self.DownloadAndWaitForStart(file_url)
downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
os.path.basename(file_path))
@@ -464,7 +477,7 @@ class DownloadsTest(pyauto.PyUITest):
self.assertTrue(self.WaitUntil(_PercentInc),
msg='Download percentage value is not increasing')
# Once download is completed, percentage is 100.
- self.WaitForAllDownloadsToComplete()
+ self.WaitForAllDownloadsToComplete(pre_download_ids)
downloads = self.GetDownloadsInfo().Downloads()
self.assertEqual(downloads[0]['PercentComplete'], 100,
'Download percentage should be 100 after download completed')
@@ -486,12 +499,16 @@ class DownloadsTest(pyauto.PyUITest):
self._ClearLocalDownloadState(downloaded_pkg_regul)
self._ClearLocalDownloadState(downloaded_pkg_incog)
+ pre_download_ids_0 = [x['id']
+ for x in self.GetDownloadsInfo(windex=0).Downloads()]
self.DownloadAndWaitForStart(file_url, 0)
- self.WaitForAllDownloadsToComplete(0)
+ self.WaitForAllDownloadsToComplete(pre_download_ids_0, windex=0)
self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
+ pre_download_ids_1 = [x['id']
+ for x in self.GetDownloadsInfo(windex=1).Downloads()]
self.DownloadAndWaitForStart(file_url, 1)
- self.WaitForAllDownloadsToComplete(1)
+ self.WaitForAllDownloadsToComplete(pre_download_ids_1, windex=1)
# Verify download in regular window.
self.assertTrue(os.path.exists(downloaded_pkg_regul))

Powered by Google App Engine
This is Rietveld 408576698