Commit e7f23b89 authored by alyssad@google.com's avatar alyssad@google.com

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
parent 1d000681
......@@ -6,6 +6,7 @@
# ascii.
# Used by: chrome/test/functional/downloads.py
# chrome/test/functional/omnibox.py
# chrome/test/functional/translate.py
[
u'a_file_name.zip',
......
# List of crazy URLs.
# URLs are for pages that 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.
# Used by: chrome/test/functional/translate.py
[ { u'snippet': u'',
u'time': 1281727939.661804,
u'title': u'Google \ube14\ub85c\uadf8 \uac80\uc0c9',
u'url': u'http://blogsearch.google.com/?q=&hl=ko&tab=sb'},
{ u'snippet': u'',
u'time': 1281727937.0636239,
u'title': u'Google \ud559\uc220 \uac80\uc0c9',
u'url': u'http://scholar.google.com/schhp?q=&hl=ko&tab=ps'},
{ u'snippet': u'',
u'time': 1281727934.328491,
u'title': u'Google \ub3c4\uc11c',
u'url': u'http://books.google.com/bkshp?q&hl=ko&tab=np'},
{ u'snippet': u'',
u'time': 1281727933.137692,
u'title': u'',
u'url': u'http://translate.google.com/?q=&hl=ko&tab=pT#'},
{ u'snippet': u'',
u'time': 1281727926.639116,
u'title': u'Google \ub274\uc2a4',
u'url': u'http://news.google.com/news?hl=ko&sa=N&tab=ln&q='},
{ u'snippet': u'',
u'time': 1281727923.4877269,
u'title': u'Google \uc9c0\ub3c4',
u'url': u'http://maps.google.com/maps?hl=ko&tab=vl'},
{ u'snippet': u'',
u'time': 1281727921.0749111,
u'title': u'Google \ube44\ub514\uc624',
u'url': u'http://video.google.com/?hl=ko&tab=iv'},
{ u'snippet': u'',
u'time': 1281727918.5299749,
u'title': u'Google \uc774\ubbf8\uc9c0',
u'url': u'http://www.google.com/imghp?hl=ko&tab=wi'},
{ u'snippet': u'',
u'time': 1281727915.327976,
u'title': u'Google',
u'url': u'http://www.google.com/webhp?hl=ko'}
]
......@@ -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()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment