diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-20 22:05:33 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-20 22:05:33 +0000 |
commit | 2211999633e869ea1b7586d965897c07af30c926 (patch) | |
tree | d64bf119a573bc4da33b17abae347e32871a808e /chrome | |
parent | a4e1481fbcf80d110be4c846bb35d555d3e791ec (diff) | |
download | chromium_src-2211999633e869ea1b7586d965897c07af30c926.zip chromium_src-2211999633e869ea1b7586d965897c07af30c926.tar.gz chromium_src-2211999633e869ea1b7586d965897c07af30c926.tar.bz2 |
Add a download test for crazy filenames.
crazy filenames = long/short filenames, special chars, i18n chars.
Test written by rohitbm
Review URL: http://codereview.chromium.org/1717001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45090 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
10 files changed, 46 insertions, 0 deletions
diff --git a/chrome/test/data/downloads/crazy_filenames/Picture 1.doc b/chrome/test/data/downloads/crazy_filenames/Picture 1.doc Binary files differnew file mode 100644 index 0000000..a82c507 --- /dev/null +++ b/chrome/test/data/downloads/crazy_filenames/Picture 1.doc diff --git a/chrome/test/data/downloads/crazy_filenames/Wohoo-to hoo+I.rtf b/chrome/test/data/downloads/crazy_filenames/Wohoo-to hoo+I.rtf new file mode 100644 index 0000000..e965047 --- /dev/null +++ b/chrome/test/data/downloads/crazy_filenames/Wohoo-to hoo+I.rtf @@ -0,0 +1 @@ +Hello diff --git a/chrome/test/data/downloads/crazy_filenames/jiho!@#$tiho$%^&-()_+=miho copy.rtf b/chrome/test/data/downloads/crazy_filenames/jiho!@#$tiho$%^&-()_+=miho copy.rtf new file mode 100644 index 0000000..e965047 --- /dev/null +++ b/chrome/test/data/downloads/crazy_filenames/jiho!@#$tiho$%^&-()_+=miho copy.rtf @@ -0,0 +1 @@ +Hello diff --git a/chrome/test/data/downloads/crazy_filenames/jiho....tiho...miho.rtf b/chrome/test/data/downloads/crazy_filenames/jiho....tiho...miho.rtf new file mode 100644 index 0000000..e965047 --- /dev/null +++ b/chrome/test/data/downloads/crazy_filenames/jiho....tiho...miho.rtf @@ -0,0 +1 @@ +Hello diff --git a/chrome/test/data/downloads/crazy_filenames/tini(玉树强震已致760人遇难).rtf b/chrome/test/data/downloads/crazy_filenames/tini(玉树强震已致760人遇难).rtf new file mode 100644 index 0000000..e965047 --- /dev/null +++ b/chrome/test/data/downloads/crazy_filenames/tini(玉树强震已致760人遇难).rtf @@ -0,0 +1 @@ +Hello diff --git a/chrome/test/data/downloads/crazy_filenames/Цинхай достигло 760-540.rtf b/chrome/test/data/downloads/crazy_filenames/Цинхай достигло 760-540.rtf new file mode 100644 index 0000000..e965047 --- /dev/null +++ b/chrome/test/data/downloads/crazy_filenames/Цинхай достигло 760-540.rtf @@ -0,0 +1 @@ +Hello diff --git a/chrome/test/data/downloads/crazy_filenames/супруги Мишель.rtf b/chrome/test/data/downloads/crazy_filenames/супруги Мишель.rtf new file mode 100644 index 0000000..e965047 --- /dev/null +++ b/chrome/test/data/downloads/crazy_filenames/супруги Мишель.rtf @@ -0,0 +1 @@ +Hello diff --git a/chrome/test/data/downloads/crazy_filenames/截至15日下午16时30分.rtf b/chrome/test/data/downloads/crazy_filenames/截至15日下午16时30分.rtf new file mode 100644 index 0000000..e965047 --- /dev/null +++ b/chrome/test/data/downloads/crazy_filenames/截至15日下午16时30分.rtf @@ -0,0 +1 @@ +Hello diff --git a/chrome/test/functional/downloads.py b/chrome/test/functional/downloads.py index 8e36172..6a8492d 100644 --- a/chrome/test/functional/downloads.py +++ b/chrome/test/functional/downloads.py @@ -4,6 +4,7 @@ # found in the LICENSE file. import hashlib +import logging import os import sys import time @@ -99,6 +100,34 @@ class DownloadsTest(pyauto.PyUITest): # Verify that all files exist and have the right name for filename in renamed_files: self.assertTrue(os.path.exists(filename)) + os.path.exists(filename) and os.remove(filename) + + def testCrazyFilenames(self): + """Test downloading with filenames containing special chars.""" + download_dir = self.GetDownloadDirectory().value() + test_dir = os.path.join(os.path.abspath(self.DataDir()), 'downloads', + 'crazy_filenames') + data_file = os.path.join(test_dir, 'download_filenames') + filenames = os.listdir(test_dir) + logging.info('Testing with %d crazy filenames' % len(filenames)) + for filename in filenames: + downloaded_file = os.path.join(download_dir, filename) + os.path.exists(downloaded_file) and os.remove(downloaded_file) + file_url = self.GetFileURLForPath(os.path.join(test_dir, filename)) + self._DownloadAndWaitForStart(file_url) + self.WaitForAllDownloadsToComplete() + + # Verify downloads. + downloads = self.GetDownloadsInfo().Downloads() + self.assertEqual(len(downloads), len(filenames)) + + for filename in filenames: + downloaded_file = os.path.join(download_dir, filename) + self.assertTrue(os.path.exists(downloaded_file)) + self.assertEqual( # Verify checksum. + self._ComputeMD5sum(downloaded_file), + self._ComputeMD5sum(os.path.join(test_dir, filename))) + os.path.exists(downloaded_file) and os.remove(downloaded_file) if __name__ == '__main__': diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py index cf894bf..9e848c6 100644 --- a/chrome/test/pyautolib/pyauto.py +++ b/chrome/test/pyautolib/pyauto.py @@ -33,6 +33,7 @@ import sys import time import types import unittest +import urllib def _LocateBinDirs(): @@ -139,6 +140,15 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): """Returns the path to the data dir chrome/test/data.""" return os.path.join(os.path.dirname(__file__), os.pardir, "data") + @staticmethod + def GetFileURLForPath(path): + """Get file:// url for the given path. + + Also quotes the url using urllib.quote(). + """ + abs_path = urllib.quote(os.path.abspath(path).replace('\\', '/')) + return 'file://' + abs_path + def WaitUntil(self, function, timeout=-1, retry_sleep=0.25, args=[]): """Poll on a condition until timeout. |