Index: chrome/test/functional/downloads.py |
diff --git a/chrome/test/functional/downloads.py b/chrome/test/functional/downloads.py |
index f998b3654e009d119472d9c94f32483b5d294a20..2d41f5d40418a45e6dbb61f88ed1197c66e6eb8f 100644 |
--- a/chrome/test/functional/downloads.py |
+++ b/chrome/test/functional/downloads.py |
@@ -14,11 +14,29 @@ import urllib |
import pyauto_functional # Must be imported before pyauto |
import pyauto |
+import pyauto_utils |
class DownloadsTest(pyauto.PyUITest): |
"""TestCase for Downloads.""" |
+ def setUp(self): |
+ pyauto.PyUITest.setUp(self) |
+ # Record all entries in the download dir |
+ download_dir = self.GetDownloadDirectory().value() |
+ self._existing_downloads = [] |
+ if os.path.isdir(download_dir): |
+ self._existing_downloads += os.listdir(download_dir) |
+ |
+ def tearDown(self): |
+ # Cleanup all files we created in the download dir |
+ download_dir = self.GetDownloadDirectory().value() |
+ if os.path.isdir(download_dir): |
+ for name in os.listdir(download_dir): |
+ if name not in self._existing_downloads: |
+ pyauto_utils.RemovePath(os.path.join(download_dir, name)) |
+ pyauto.PyUITest.tearDown(self) |
+ |
def _GetDangerousDownload(self): |
"""Returns the file url for a dangerous download for this OS.""" |
sub_path = os.path.join(self.DataDir(), 'downloads', 'dangerous') |
@@ -245,6 +263,7 @@ class DownloadsTest(pyauto.PyUITest): |
self.assertEqual(1, len(downloads)) |
self.assertEqual('a_zip_file.zip', downloads[0]['file_name']) |
self.assertEqual(file_url, downloads[0]['url']) |
+ os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg) |
if __name__ == '__main__': |