summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authornirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-03 19:02:46 +0000
committernirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-03 19:02:46 +0000
commit4ca8b39fcc18d80948ab02db41d6ca632ad446db (patch)
tree7bc06e0cb6de732d545b52895e3523c0034f5c89 /chrome/test
parentaca02cf3af06c48baa7f6b7f82d319ffc848fac6 (diff)
downloadchromium_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')
-rw-r--r--chrome/test/data/downloads/a_zip_file.md5sum1
-rw-r--r--chrome/test/data/downloads/crazy_filenames.txt24
-rw-r--r--chrome/test/functional/PYAUTO_TESTS8
-rw-r--r--chrome/test/functional/downloads.py46
-rw-r--r--chrome/test/pyautolib/pyauto.py12
5 files changed, 59 insertions, 32 deletions
diff --git a/chrome/test/data/downloads/a_zip_file.md5sum b/chrome/test/data/downloads/a_zip_file.md5sum
deleted file mode 100644
index 9cc0846..0000000
--- a/chrome/test/data/downloads/a_zip_file.md5sum
+++ /dev/null
@@ -1 +0,0 @@
-4ba9fedffa42168d89da48eae1f38687 \ No newline at end of file
diff --git a/chrome/test/data/downloads/crazy_filenames.txt b/chrome/test/data/downloads/crazy_filenames.txt
index 31c1a90..2447995 100644
--- a/chrome/test/data/downloads/crazy_filenames.txt
+++ b/chrome/test/data/downloads/crazy_filenames.txt
@@ -2,15 +2,23 @@
# Filenames contain i18n chars, special chars.
# These files are created on-the-fly instead of checking-in because i18n
# chars in filenames causes svn problems on win.
+# The filenames are provided as unicode strings so that this file can remain
+# ascii.
# Used by: chrome/test/functional/downloads.py
[
- '截至15日下午16时30分.rtf',
- 'супруги Мишель.rtf',
- 'Цинхай достигло 760-540.rtf',
- 'tini(玉树强震已致760人遇难).rtf',
- 'jiho....tiho...miho.rtf',
- 'jiho!@#$tiho$%^&-()_+=miho copy.rtf',
- 'Wohoo-to hoo+I.rtf',
- 'Picture 1.doc',
+ u'a_file_name.zip',
+ u'\u89c6\u9891\u76f4\u64ad\u56fe\u7247.zip', # chinese chars
+ u'\u0412\u043e \u0424\u043b\u043e\u0440\u0438\u0434\u0435\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0440\u0435\u0436\u0438\u043c \u0427\u041f \u0438\u0437-\u0437\u0430 \u0443\u0442\u0435\u0447\u043a\u0438 \u043d\u0435\u0444\u0442\u0438.zip', # russian
+ u'Desocupa\xe7\xe3o est\xe1vel.zip',
+ u'\u0638\u2026\u0638\u02c6\u0637\xa7\u0638\u201a\u0637\xb9 \u0638\u201e\u0638\u201e\u0637\xb2\u0638\u0679\u0637\xa7\u0637\xb1\u0637\xa9.zip', # arabic
+ u'\u05d4\u05e2\u05d3\u05e4\u05d5\u05ea.zip', # hebrew
+ u'\u092d\u093e\u0930\u0924.zip', # hindi
+ u'd\xe9stabilis\xe9.zip', # french
+ u'\u97d3-\u4e2d \uc815\uc0c1, \ucc9c\uc548\ud568 \uc758\uacac.zip', # korean
+ u'jiho....tiho...miho.zip',
+ u'jiho!@#$tiho$%^&-()_+=miho copy.zip', # special chars
+ u'Wohoo-to hoo+I.zip',
+ u'Picture 1.zip',
+ u'This is a very very long english sentence with spaces and , and +.zip',
]
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__':
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index e8975126..ddf6bc9 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -166,8 +166,16 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
Also quotes the url using urllib.quote().
"""
- abs_path = urllib.quote(os.path.abspath(path).replace('\\', '/'))
- return 'file://' + abs_path
+ abs_path = os.path.abspath(path)
+ if sys.platform == 'win32':
+ # Don't quote the ':' in drive letter ( say, C: ) on win.
+ # Also, replace '\' with '/' as expected in a file:/// url.
+ drive, rest = os.path.splitdrive(abs_path)
+ quoted_path = drive.upper() + urllib.quote((rest.replace('\\', '/')))
+ return 'file:///' + quoted_path
+ else:
+ quoted_path = urllib.quote(abs_path)
+ return 'file://' + quoted_path
def WaitUntil(self, function, timeout=-1, retry_sleep=0.25, args=[]):
"""Poll on a condition until timeout.