summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authoralyssad@chromium.org <alyssad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-10 18:11:16 +0000
committeralyssad@chromium.org <alyssad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-10 18:11:16 +0000
commit4a47d7612c2f80b6dd760fdea9ba48d9e3704057 (patch)
treeb83a011fb93df886d75559f12f2b18e1381146a5 /chrome/test
parent2c9e5769de902aacf1585f8273bf55dc3583e614 (diff)
downloadchromium_src-4a47d7612c2f80b6dd760fdea9ba48d9e3704057.zip
chromium_src-4a47d7612c2f80b6dd760fdea9ba48d9e3704057.tar.gz
chromium_src-4a47d7612c2f80b6dd760fdea9ba48d9e3704057.tar.bz2
New pyauto translate hooks: always and never translate button.
This hooks allows testers to test that always and never translate button that shows up after a user has accepted/declined translation several times. Review URL: http://codereview.chromium.org/3061054 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55590 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/functional/translate.py31
-rw-r--r--chrome/test/pyautolib/pyauto.py19
2 files changed, 45 insertions, 5 deletions
diff --git a/chrome/test/functional/translate.py b/chrome/test/functional/translate.py
index b271a5b..eb8f0f3 100644
--- a/chrome/test/functional/translate.py
+++ b/chrome/test/functional/translate.py
@@ -82,7 +82,7 @@ class TranslateTest(pyauto.PyUITest):
def testNoTranslate(self):
"""Tests that a page isn't translated if the user declines translate."""
self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())
- self.PerformActionOnInfobar('dismiss', 0)
+ self.SelectTranslateOption('decline_translation')
translate_info = self.GetTranslateInfo()
self.assertEqual(self.spanish, translate_info['original_language'])
self.assertFalse(translate_info['page_translated'])
@@ -329,6 +329,35 @@ class TranslateTest(pyauto.PyUITest):
self.NavigateToURL(self._GetDefaultSpanishURL())
self.assertFalse('translate_bar' in self.GetTranslateInfo())
+ def testAlwaysTranslateLanguageButton(self):
+ """Test the always translate language button."""
+ spanish_url = self._GetDefaultSpanishURL()
+ self._NavigateAndWaitForBar(spanish_url)
+
+ # The 'Always Translate' button doesn't show up until the user has clicked
+ # 'Translate' for a language several times.
+ max_tries = 10
+ curr_try = 0
+ while (curr_try < max_tries and
+ not self.GetTranslateInfo()['translate_bar']\
+ ['always_translate_lang_button_showing']):
+ self._ClickTranslateUntilSuccess()
+ self._NavigateAndWaitForBar(spanish_url)
+ curr_try = curr_try + 1
+ if curr_try == max_tries:
+ self.fail('Clicked translate %d times and always translate button never '\
+ 'showed up.' % max_tries)
+
+ # Click the 'Always Translate' button.
+ self.SelectTranslateOption('click_always_translate_lang_button')
+ # Navigate to another Spanish page and verify it was translated.
+ self._NavigateAndWaitForBar('http://www.google.com/webhp?hl=es')
+ self.WaitUntilTranslateComplete()
+ # Assert that a translation was attempted. We don't care if it was error
+ # or success.
+ self.assertNotEqual(self.before_translate,
+ self.GetTranslateInfo()['translate_bar']['bar_state'])
+
def testSeveralLanguages(self):
"""Verify translation for several languages.
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 7e0e766..577d117 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -691,7 +691,9 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
Returns:
A dictionary of information about translate for the page. Example:
- { u'can_translate_page': True,
+ { u'always_translate_lang_button_showing': False,
+ u'never_translate_lang_button_showing': False,
+ u'can_translate_page': True,
u'original_language': u'es',
u'page_translated': False,
# The below will only appear if the translate bar is showing.
@@ -824,15 +826,24 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
window_index: The index of the window, default is 0.
*Notes*
- never translate language: Selecting this means that no sites in this
+ never_translate_language: Selecting this means that no sites in this
language will be translated. This dismisses the infobar.
- never translate site: Selecting this means that this site will never be
+ never_translate_site: Selecting this means that this site will never be
translated, regardless of the language. This dismisses the infobar.
- toggle always translate: This does not dismiss the infobar or translate the
+ toggle_always_translate: This does not dismiss the infobar or translate the
page. See ClickTranslateBarTranslate and PerformActioOnInfobar to do
those. If a language is selected to be always translated, then whenver
the user visits a page with that language, the infobar will show the
'This page has been translated...' message.
+ decline_translation: Equivalent to selecting 'Nope' on the translate bar.
+ click_never_translate_lang_button: This button appears when the user has
+ declined translation of this language several times. Selecting it causes
+ the language to never be translated. Look at GetTranslateInfo to
+ determine if the button is showing.
+ click_always_translate_lang_button: This button appears when the user has
+ accepted translation of this language several times. Selecting it causes
+ the language to always be translated. Look at GetTranslateInfo to
+ determine if the button is showing.
Raises:
pyauto_errors.JSONInterfaceError if the automation returns an error.