Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: chrome/test/pyautolib/pyauto.py

Issue 10914041: Revert 154464 - Revert 154453 - Remove the translate pyauto test to chrome tests and all the suppor… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/functional/translate.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/pyautolib/pyauto.py
===================================================================
--- chrome/test/pyautolib/pyauto.py (revision 154465)
+++ chrome/test/pyautolib/pyauto.py (working copy)
@@ -2782,170 +2782,6 @@
return history_info.HistoryInfo(
self._GetResultFromJSONRequest(cmd_dict, windex=windex))
- def GetTranslateInfo(self, tab_index=0, window_index=0):
- """Returns info about translate for the given page.
-
- If the translate bar is showing, also returns information about the bar.
-
- Args:
- tab_index: The tab index, default is 0.
- window_index: The window index, default is 0.
-
- Returns:
- A dictionary of information about translate for the page. Example:
- { 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.
- u'translate_bar': { u'bar_state': u'BEFORE_TRANSLATE',
- u'original_lang_code': u'es',
- u'target_lang_code': u'en'}}
- """
- cmd_dict = { # Prepare command for the json interface
- 'command': 'GetTranslateInfo',
- 'tab_index': tab_index
- }
- return self._GetResultFromJSONRequest(cmd_dict, windex=window_index)
-
- def ClickTranslateBarTranslate(self, tab_index=0, window_index=0):
- """If the translate bar is showing, clicks the 'Translate' button on the
- bar. This will show the 'this page has been translated...' infobar.
-
- Args:
- tab_index: The index of the tab, default is 0.
- window_index: The index of the window, default is 0.
-
- Returns:
- True if the translation was successful or false if there was an error.
- Note that an error shouldn't neccessarily mean a failed test - retry the
- call on error.
-
- Raises:
- pyauto_errors.JSONInterfaceError if the automation returns an error.
- """
- cmd_dict = { # Prepare command for the json interface
- 'command': 'SelectTranslateOption',
- 'tab_index': tab_index,
- 'option': 'translate_page'
- }
- return self._GetResultFromJSONRequest(
- cmd_dict, windex=window_index)['translation_success']
-
- def RevertPageTranslation(self, tab_index=0, window_index=0):
- """Select the 'Show original' button on the 'this page has been
- translated...' infobar. This will remove the infobar and revert the
- page translation.
-
- Args:
- tab_index: The index of the tab, default is 0.
- window_index: The index of the window, default is 0.
- """
- cmd_dict = { # Prepare command for the json interface
- 'command': 'SelectTranslateOption',
- 'tab_index': tab_index,
- 'option': 'revert_translation'
- }
- self._GetResultFromJSONRequest(cmd_dict, windex=window_index)
-
- def ChangeTranslateToLanguage(self, new_language, tab_index=0,
- window_index=0):
- """Set the target language to be a new language.
-
- This is equivalent to selecting a different language from the 'to'
- drop-down menu on the translate bar. If the page was already translated
- before calling this function, this will trigger a re-translate to the
- new language.
-
- Args:
- new_language: The new target language. The string should be equivalent
- to the text seen in the translate bar options.
- Example: 'English'.
- tab_index: The tab index - default is 0.
- window_index: The window index - default is 0.
-
- Returns:
- False, if a new translation was triggered and the translation failed.
- True on success.
- """
- cmd_dict = { # Prepare command for the json interface
- 'command': 'SelectTranslateOption',
- 'tab_index': tab_index,
- 'option': 'set_target_language',
- 'target_language': new_language
- }
- return self._GetResultFromJSONRequest(
- cmd_dict, windex=window_index)['translation_success']
-
- def SelectTranslateOption(self, option, tab_index=0, window_index=0):
- """Selects one of the options in the drop-down menu for the translate bar.
-
- Args:
- option: One of 'never_translate_language', 'never_translate_site', or
- 'toggle_always_translate'. See notes on each below.
- tab_index: The index of the tab, default is 0.
- window_index: The index of the window, default is 0.
-
- *Notes*
- 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
- translated, regardless of the language. This dismisses the infobar.
- 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.
- """
- cmd_dict = { # Prepare command for the json interface
- 'command': 'SelectTranslateOption',
- 'option': option,
- 'tab_index': tab_index
- }
- self._GetResultFromJSONRequest(cmd_dict, windex=window_index)
-
- def WaitUntilTranslateComplete(self, tab_index=0, window_index=0):
- """Waits until an attempted translation has finished.
-
- This should be called after navigating to a page that should be translated
- automatically (because the language always-translate is on). It does not
- need to be called after 'ClickTranslateBarTranslate'.
-
- Do not call this function if you are not expecting a page translation - it
- will hang. If you call it when there is no translate bar, it will return
- False.
-
- Args:
- tab_index: The tab index, default is 0.
- window_index: The window index, default is 0.
-
- Returns:
- True if the translation was successful, False if there was an error.
- """
- cmd_dict = { # Prepare command for the json interface
- 'command': 'WaitUntilTranslateComplete',
- 'tab_index': tab_index
- }
- # TODO(phajdan.jr): We need a solid automation infrastructure to handle
- # these cases. See crbug.com/53647.
- return self.WaitUntil(
- lambda tab_index, window_index: self.GetTranslateInfo(
- tab_index=tab_index, window_index=window_index)['page_translated'],
- args=[tab_index, window_index])
-
def InstallExtension(self, extension_path, with_ui=False, from_webstore=None,
windex=0):
"""Installs an extension from the given path.
@@ -3187,30 +3023,6 @@
return self.WaitUntil(lambda: _IsExtensionViewClosed())
- def AddHistoryItem(self, item):
- """Forge a history item for Chrome.
-
- Args:
- item: a python dictionary representing the history item. Example:
- {
- # URL is the only mandatory item.
- 'url': 'http://news.google.com',
- # Title is optional.
- 'title': 'Google News',
- # Time is optional; if not set, assume "now". Time is in
- # seconds since the Epoch. The python construct to get "Now"
- # in the right scale is "time.time()". Can be float or int.
- 'time': 1271781612
- }
- """
- cmd_dict = { # Prepare command for the json interface
- 'command': 'AddHistoryItem',
- 'item': item
- }
- if not 'url' in item:
- raise JSONInterfaceError('must specify url')
- self._GetResultFromJSONRequest(cmd_dict)
-
def GetPluginsInfo(self, windex=0):
"""Return info about plugins.
« no previous file with comments | « chrome/test/functional/translate.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698