diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-22 23:20:13 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-22 23:20:13 +0000 |
commit | 2a37b982a8a45544842db5131bfb4b558983852e (patch) | |
tree | c8f90e2dd71654d320330bca8595cc9ac7f3c26d /chrome/test | |
parent | acb10270e823c9642805757c0060ee77239a8a17 (diff) | |
download | chromium_src-2a37b982a8a45544842db5131bfb4b558983852e.zip chromium_src-2a37b982a8a45544842db5131bfb4b558983852e.tar.gz chromium_src-2a37b982a8a45544842db5131bfb4b558983852e.tar.bz2 |
Adding download tests to test various download options
Review URL: http://codereview.chromium.org/5103007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69998 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/functional/downloads.py | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/chrome/test/functional/downloads.py b/chrome/test/functional/downloads.py index 5232ea8..bdae1de 100644 --- a/chrome/test/functional/downloads.py +++ b/chrome/test/functional/downloads.py @@ -456,6 +456,37 @@ class DownloadsTest(pyauto.PyUITest): self.assertTrue(self.WaitUntil(lambda path: not os.path.exists(path), args=[downloaded_pkg])) + def testAlwaysOpenFileType(self): + """Verify "Always Open Files of this Type" download option + + If 'always open' option is set for any filetype, downloading that type of + file gets opened always after the download. + A cross-platform trick to verify it, by downloading a .zip file and + expecting it to get unzipped. Just check if it got unzipped or not. + This way you won't have to worry about which application might 'open' + it. + """ + file_path = os.path.join(self.DataDir(), 'downloads', 'a_zip_file.zip') + file_url = self.GetFileURLForPath(file_path) + downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), + os.path.basename(file_path)) + os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg) + self.DownloadAndWaitForStart(file_url) + self.WaitForAllDownloadsToComplete() + id = self._GetDownloadId() + self.PerformActionOnDownload(id, 'toggle_open_files_like_this') + os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg) + # Retesting the flag we set + self.DownloadAndWaitForStart(file_url) + self.WaitForAllDownloadsToComplete() + unzip_file_name = os.path.join(self.GetDownloadDirectory().value(), + 'a_file.txt') + # When the downloaded zip gets 'opened', a_file.txt will become available. + self.assertTrue(self.WaitUntil(lambda: os.path.exists(unzip_file_name)), + 'Did not open the filetype') + os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg) + os.path.exists(unzip_file_name) and os.remove(unzip_file_name) + def testExtendedAttributesOnMac(self): """Verify that Chrome sets the extended attributes on a file. This test is for mac only. @@ -473,6 +504,63 @@ class DownloadsTest(pyauto.PyUITest): import xattr self.assertTrue('com.apple.quarantine' in xattr.listxattr(downloaded_pkg)) + def testOpenWhenDone(self): + """Verify "Open When Done" download option. + + Test creates a zip file on the fly and downloads it. + Set this option when file is downloading. Once file is downloaded, + verify that downloaded zip file is unzipped. + """ + # Creating a temp zip file. + file_path = self._MakeFile(2**24) + file_url = self.GetFileURLForPath(file_path) + downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), + os.path.basename(file_path)) + os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg) + self.DownloadAndWaitForStart(file_url) + id = self._GetDownloadId() + self.PerformActionOnDownload(id, 'open') + self.WaitForAllDownloadsToComplete() + unzip_file_name = downloaded_pkg + '.cpgz' + # Verify that the file was correctly downloaded + self.assertTrue(self.WaitUntil(lambda: os.path.exists(unzip_file_name)), + 'Unzipped folder %s missing.' % unzip_file_name) + self.assertTrue(os.path.exists(downloaded_pkg), + 'Downloaded file %s missing.' % downloaded_pkg) + self.assertTrue(self._EqualFileContents(file_path, downloaded_pkg), + 'Downloaded file %s does not match original' % + downloaded_pkg) + os.path.exists(file_path) and os.remove(file_path) + os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg) + os.path.exists(unzip_file_name) and os.remove(unzip_file_name) + + def testDownloadPercentage(self): + """Verify that during downloading, % values increases, + and once download is over, % value is 100""" + file_path = self._MakeFile(2**24) + file_url = self.GetFileURLForPath(file_path) + downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), + os.path.basename(file_path)) + os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg) + self.DownloadAndWaitForStart(file_url) + downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), + os.path.basename(file_path)) + downloads = self.GetDownloadsInfo().Downloads() + old_percentage = downloads[0]['PercentComplete'] + # Wait for some time again re-check the download percentage + time.sleep(1) + downloads = self.GetDownloadsInfo().Downloads() + percentage = downloads[0]['PercentComplete'] + self.assertTrue(percentage > old_percentage, + 'Download percentage value is not increasing') + # Once download is completed, percentage is 100 + self.WaitForAllDownloadsToComplete() + downloads = self.GetDownloadsInfo().Downloads() + self.assertEqual(downloads[0]['PercentComplete'], 100, + 'Download percentage should be 100 after download completed') + os.path.exists(file_path) and os.remove(file_path) + os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg) + def testDownloadIncognitoAndRegular(self): """Download the same zip file in regular and incognito window and verify that it downloaded correctly with same file name appended with |