diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-03 19:02:46 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-03 19:02:46 +0000 |
commit | 4ca8b39fcc18d80948ab02db41d6ca632ad446db (patch) | |
tree | 7bc06e0cb6de732d545b52895e3523c0034f5c89 /chrome/test/functional | |
parent | aca02cf3af06c48baa7f6b7f82d319ffc848fac6 (diff) | |
download | chromium_src-4ca8b39fcc18d80948ab02db41d6ca632ad446db.zip chromium_src-4ca8b39fcc18d80948ab02db41d6ca632ad446db.tar.gz chromium_src-4ca8b39fcc18d80948ab02db41d6ca632ad446db.tar.bz2 |
1. Fix GetFileURLForPath for windows. GetFileURLForPath() should not quote() ':' in the drive letter on windows.
2. Fix testCrazyFilenames test for win. Expand crazy_filenames.txt to contain i18n filenames as ascii strings.
3. Disable bookmark_bar.testBookmarkBarVisible on win
4. Get rid of using hashlib module in dowload tests. Since we have the files, it doesn't make sense to compute checksum to verify if 2 files are the same -- direct comparison will do.
Review URL: http://codereview.chromium.org/1780013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46258 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/functional')
-rw-r--r-- | chrome/test/functional/PYAUTO_TESTS | 8 | ||||
-rw-r--r-- | chrome/test/functional/downloads.py | 46 |
2 files changed, 33 insertions, 21 deletions
diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS index a955243..585870d 100644 --- a/chrome/test/functional/PYAUTO_TESTS +++ b/chrome/test/functional/PYAUTO_TESTS @@ -18,7 +18,6 @@ { 'all': [ - 'bookmark_bar', 'bookmarks', 'history', 'test_basic.SimpleTest.testCanOpenGoogle', @@ -28,12 +27,19 @@ ], 'win': [ + # testBookmarkBarVisible fails on windows. crbug.com/42823 + # 'bookmark_bar.BookmarkBarTest.testBookmarkBarVisible', + 'bookmark_bar.BookmarkBarTest.testBookmarkBarVisibleWait', ], 'mac': [ + 'bookmark_bar.BookmarkBarTest.testBookmarkBarVisibleWait', + 'bookmark_bar.BookmarkBarTest.testBookmarkBarVisibleWait', ], 'linux': [ + 'bookmark_bar.BookmarkBarTest.testBookmarkBarVisibleWait', + 'bookmark_bar.BookmarkBarTest.testBookmarkBarVisibleWait', ], # TODO(nirnimesh): Add a ChromeOS section diff --git a/chrome/test/functional/downloads.py b/chrome/test/functional/downloads.py index 39cde57..84f3af7 100644 --- a/chrome/test/functional/downloads.py +++ b/chrome/test/functional/downloads.py @@ -3,7 +3,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import hashlib +import filecmp import logging import os import shutil @@ -19,11 +19,11 @@ import pyauto class DownloadsTest(pyauto.PyUITest): """TestCase for Downloads.""" - def _ComputeMD5sum(self, filename): - """Determine md5 checksum for the contents of |filename|.""" - md5 = hashlib.md5() - md5.update(open(filename, 'rb').read()) - return md5.hexdigest() + def _EqualFileContents(self, file1, file2): + """Determine if 2 given files have the same contents.""" + if not (os.path.exists(file1) and os.path.exists(file2)): + return False + return filecmp.cmp(file1, file2) def testNoDownloadWaitingNeeded(self): """Make sure "wait for downloads" returns quickly if we have none.""" @@ -34,9 +34,8 @@ class DownloadsTest(pyauto.PyUITest): Also verify that the download shelf showed up. """ test_dir = os.path.join(os.path.abspath(self.DataDir()), 'downloads') - checksum_file = os.path.join(test_dir, 'a_zip_file.md5sum') - file_url = 'file://%s' % os.path.join(test_dir, 'a_zip_file.zip') - golden_md5sum = urllib.urlopen(checksum_file).read() + file_path = os.path.join(test_dir, 'a_zip_file.zip') + file_url = self.GetFileURLForPath(file_path) downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), 'a_zip_file.zip') os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg) @@ -51,8 +50,7 @@ class DownloadsTest(pyauto.PyUITest): # Verify that the file was correctly downloaded self.assertTrue(os.path.exists(downloaded_pkg)) - # print 'Download size is %d' % os.path.getsize(downloaded_pkg) - self.assertEqual(golden_md5sum, self._ComputeMD5sum(downloaded_pkg)) + self.assertTrue(self._EqualFileContents(file_path, downloaded_pkg)) def testBigZip(self): # TODO: download something "pretty big". The above test will @@ -113,16 +111,24 @@ class DownloadsTest(pyauto.PyUITest): def _CreateFile(name): """Create and fill the given file with some junk.""" - fp = open(name, 'w') - print >>fp, 'This is a junk file named %s. ' % name * 100 + fp = open(name, 'w') # name could be unicode + print >>fp, 'This is a junk file named %s. ' % repr(name) * 100 fp.close() # Temp dir for hosting crazy filenames. temp_dir = tempfile.mkdtemp(prefix='download') + # Windows has a dual nature dealing with unicode filenames. + # While the files are internally saved as unicode, there's a non-unicode + # aware API that returns a locale-dependent coding on the true unicode + # filenames. This messes up things. + # 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 try: - for filename in crazy_filenames: - file_path = os.path.join(temp_dir, filename) - _CreateFile(file_path) + for filename in crazy_filenames: # filename is unicode. + utf8_filename = filename.encode('utf-8') + file_path = os.path.join(temp_dir, utf8_filename) + _CreateFile(os.path.join(temp_dir, filename)) # unicode file. file_url = self.GetFileURLForPath(file_path) downloaded_file = os.path.join(download_dir, filename) os.path.exists(downloaded_file) and os.remove(downloaded_file) @@ -136,12 +142,12 @@ class DownloadsTest(pyauto.PyUITest): for filename in crazy_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(temp_dir, filename))) + self.assertTrue( # Verify file contents. + self._EqualFileContents(downloaded_file, + os.path.join(temp_dir, filename))) os.path.exists(downloaded_file) and os.remove(downloaded_file) finally: - shutil.rmtree(temp_dir) + shutil.rmtree(unicode(temp_dir)) # unicode so that win treats nicely. if __name__ == '__main__': |