summaryrefslogtreecommitdiffstats
path: root/chrome/test/functional
diff options
context:
space:
mode:
authoralyssad@google.com <alyssad@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-23 16:23:20 +0000
committeralyssad@google.com <alyssad@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-23 16:23:20 +0000
commite7f23b89a9ea2442221f2fa748b941515337ca4e (patch)
treec11ad5d44c4a8fcb7aa91a1f95f52c64faa01dc9 /chrome/test/functional
parent1d000681ef18ea1ebd39a19bf17a7bfccd3ed352 (diff)
downloadchromium_src-e7f23b89a9ea2442221f2fa748b941515337ca4e.zip
chromium_src-e7f23b89a9ea2442221f2fa748b941515337ca4e.tar.gz
chromium_src-e7f23b89a9ea2442221f2fa748b941515337ca4e.tar.bz2
New translate test for pyauto.
New pyauto functional test for translate on history and downloads pages. Review URL: http://codereview.chromium.org/3109017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57065 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/functional')
-rw-r--r--chrome/test/functional/translate.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/chrome/test/functional/translate.py b/chrome/test/functional/translate.py
index eb8f0f3..536ae7c 100644
--- a/chrome/test/functional/translate.py
+++ b/chrome/test/functional/translate.py
@@ -6,6 +6,8 @@
import glob
import logging
import os
+import shutil
+import tempfile
import pyauto_functional # Must be imported before pyauto
import pyauto
@@ -380,6 +382,66 @@ class TranslateTest(pyauto.PyUITest):
lang_file = self.GetFileURLForPath(lang_file)
self._AssertTranslateWorks(lang_file, lang_code)
+ def _CreateCrazyDownloads(self):
+ """Doownload files with filenames containing special chars.
+ The files are created on the fly and cleaned after use.
+ """
+ download_dir = self.GetDownloadDirectory().value()
+ filename = os.path.join(self.DataDir(), 'downloads', 'crazy_filenames.txt')
+ crazy_filenames = self.EvalDataFrom(filename)
+ logging.info('Testing with %d crazy filenames' % len(crazy_filenames))
+
+ def _CreateFile(name):
+ """Create and fill the given file with some junk."""
+ 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')
+ # 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: # 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)
+ self.DownloadAndWaitForStart(file_url)
+ self.WaitForAllDownloadsToComplete()
+
+ finally:
+ shutil.rmtree(unicode(temp_dir)) # unicode so that win treats nicely.
+
+ def testHistoryNotTranslated(self):
+ """Tests navigating to History page with other languages."""
+ # Build the history with non-English content.
+ history_file = os.path.join(
+ self.DataDir(), 'translate', 'crazy_history.txt')
+ history_items = self.EvalDataFrom(history_file)
+ for history_item in history_items:
+ self.AddHistoryItem(history_item)
+ # Navigate to a page that triggers the translate bar so we can verify that
+ # it disappears on the history page.
+ self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())
+ self.NavigateToURL('chrome://history/')
+ self.WaitForInfobarCount(0)
+ self.assertFalse('translate_bar' in self.GetTranslateInfo())
+
+ def testDownloadsNotTranslated(self):
+ """Tests navigating to the Downloads page with other languages."""
+ # Build the download history with non-English content.
+ self._CreateCrazyDownloads()
+ # Navigate to a page that triggers the translate bar so we can verify that
+ # it disappears on the downloads page.
+ self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())
+ self.NavigateToURL('chrome://downloads/')
+ self.WaitForInfobarCount(0)
+ self.assertFalse('translate_bar' in self.GetTranslateInfo())
+
if __name__ == '__main__':
pyauto_functional.Main()