diff options
author | alyssad@google.com <alyssad@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-30 16:35:31 +0000 |
---|---|---|
committer | alyssad@google.com <alyssad@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-30 16:35:31 +0000 |
commit | c48d8fada025ccfabd3e95e22b150d66fc98cb39 (patch) | |
tree | dd0d2ab4384c8b213147fcda476af7c724b0668c | |
parent | 359af188d36cc374076147f9808372a46a55baa7 (diff) | |
download | chromium_src-c48d8fada025ccfabd3e95e22b150d66fc98cb39.zip chromium_src-c48d8fada025ccfabd3e95e22b150d66fc98cb39.tar.gz chromium_src-c48d8fada025ccfabd3e95e22b150d66fc98cb39.tar.bz2 |
Fix pyauto wait until hooks to use client-side WaitUntil BUG=53647
Some hooks have small chances of race conditions that can cause hangs and test failures. Fix this by using the client-side WaitUntil for now.
Review URL: http://codereview.chromium.org/3222002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57865 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 96 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 18 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.cc | 35 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.h | 24 | ||||
-rw-r--r-- | chrome/test/functional/infobars.py | 13 | ||||
-rw-r--r-- | chrome/test/functional/prefs.py | 4 | ||||
-rw-r--r-- | chrome/test/functional/translate.py | 37 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyauto.py | 30 |
8 files changed, 40 insertions, 217 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index cf6b072..418738a 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -522,27 +522,6 @@ ListValue* AutomationProvider::GetInfobarsInfo(TabContents* tc) { return infobars; } -// Sample json input: { "command": "WaitForInfobarCount", -// "count": COUNT, -// "tab_index": INDEX } -// Sample output: {} -void AutomationProvider::WaitForInfobarCount(Browser* browser, - DictionaryValue* args, - IPC::Message* reply_message) { - int tab_index; - int count; - if (!args->GetInteger("count", &count) || count < 0 || - !args->GetInteger("tab_index", &tab_index) || tab_index < 0) { - AutomationJSONReply(this, reply_message).SendError( - "Missing or invalid args: 'count', 'tab_index'."); - return; - } - - TabContents* tab_contents = browser->GetTabContentsAt(tab_index); - // Observer deletes itself. - new WaitForInfobarCountObserver(this, reply_message, tab_contents, count); -} - // Sample json input: { "command": "PerformActionOnInfobar", // "action": "dismiss", // "infobar_index": 0, @@ -1004,40 +983,6 @@ void AutomationProvider::PerformActionOnDownload(Browser* browser, } } -// See WaitForAlwaysOpenDownloadTypeToOpen() in chrome/test/pyautolib/pyauto.py -// for sample json input. -// Sample json output: {} -void AutomationProvider::WaitForAlwaysOpenDownloadTypeToOpen( - Browser* browser, DictionaryValue* args, IPC::Message* reply_message) { - int id; - - if (!profile_->HasCreatedDownloadManager()) { - AutomationJSONReply(this, reply_message).SendError("No download manager."); - return; - } - if (!args->GetInteger("id", &id)) { - AutomationJSONReply(this, reply_message).SendError( - "Must include int id."); - return; - } - - DownloadItem* selected_item = GetDownloadItemFromId( - id, profile_->GetDownloadManager()); - if (!selected_item) { - AutomationJSONReply(this, reply_message).SendError( - StringPrintf("No download with an id of %d\n", id)); - return; - } - - if (selected_item->auto_opened()) { - AutomationJSONReply(this, reply_message).SendSuccess(NULL); - return; - } - // The observer will reply after the download is opened. - selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver( - this, reply_message, true)); -} - // Sample json input: { "command": "GetPrefsInfo" } // Refer chrome/test/pyautolib/prefs_info.py for sample json output. void AutomationProvider::GetPrefsInfo(Browser* browser, @@ -1776,42 +1721,6 @@ void AutomationProvider::SelectTranslateOption(Browser* browser, } } -// See WaitUntilTranslateComplete() in chrome/test/pyautolib/pyauto.py for -// sample json input and output. -void AutomationProvider::WaitUntilTranslateComplete( - Browser* browser, DictionaryValue* args, IPC::Message* reply_message) { - std::string error_message; - TabContents* tab_contents = GetTabContentsFromDict(browser, args, - &error_message); - if (!tab_contents) { - AutomationJSONReply(this, reply_message).SendError(error_message); - return; - } - - TranslateInfoBarDelegate* translate_bar = - GetTranslateInfoBarDelegate(tab_contents); - scoped_ptr<DictionaryValue> return_value(new DictionaryValue); - - if (!translate_bar) { - return_value->SetBoolean("translation_success", false); - AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); - return; - } - - // If the translation is still pending, the observer will wait - // for it to finish and then reply. - if (translate_bar->type() == TranslateInfoBarDelegate::TRANSLATING) { - new PageTranslatedObserver(this, reply_message, tab_contents); - return; - } - - // Otherwise send back the success or failure of the attempted translation. - return_value->SetBoolean( - "translation_success", - translate_bar->type() == TranslateInfoBarDelegate::AFTER_TRANSLATE); - AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); -} - // Sample json input: { "command": "GetThemeInfo" } // Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output. void AutomationProvider::GetThemeInfo(Browser* browser, @@ -2176,7 +2085,6 @@ void AutomationProvider::SendJSONRequest(int handle, handler_map["GetBrowserInfo"] = &AutomationProvider::GetBrowserInfo; - handler_map["WaitForInfobarCount"] = &AutomationProvider::WaitForInfobarCount; handler_map["PerformActionOnInfobar"] = &AutomationProvider::PerformActionOnInfobar; @@ -2199,8 +2107,6 @@ void AutomationProvider::SendJSONRequest(int handle, &AutomationProvider::WaitForDownloadsToComplete; handler_map["PerformActionOnDownload"] = &AutomationProvider::PerformActionOnDownload; - handler_map["WaitForAlwaysOpenDownloadTypeToOpen"] = - &AutomationProvider::WaitForAlwaysOpenDownloadTypeToOpen; handler_map["GetInitialLoadTimes"] = &AutomationProvider::GetInitialLoadTimes; @@ -2226,8 +2132,6 @@ void AutomationProvider::SendJSONRequest(int handle, handler_map["SelectTranslateOption"] = &AutomationProvider::SelectTranslateOption; handler_map["GetTranslateInfo"] = &AutomationProvider::GetTranslateInfo; - handler_map["WaitUntilTranslateComplete"] = - &AutomationProvider::WaitUntilTranslateComplete; handler_map["GetAutoFillProfile"] = &AutomationProvider::GetAutoFillProfile; handler_map["FillAutoFillProfile"] = &AutomationProvider::FillAutoFillProfile; diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 5cdae38..34967f3 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -231,12 +231,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // Caller owns the returned object. ListValue* GetInfobarsInfo(TabContents* tc); - // Wait for infobar count in a given tab to become a certain value. - // Uses the JSON interface for input/output. - void WaitForInfobarCount(Browser* browser, - DictionaryValue* args, - IPC::Message* reply_message); - // Perform actions on an infobar like dismiss, accept, cancel. // Uses the JSON interface for input/output. void PerformActionOnInfobar(Browser* browser, @@ -269,12 +263,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, DictionaryValue* args, IPC::Message* reply_message); - // Waits until the given download has been opened to reply. - // Uses the JSON interface for input/output. - void WaitForAlwaysOpenDownloadTypeToOpen(Browser* browser, - DictionaryValue* args, - IPC::Message* reply_message); - // Get info about history. // Uses the JSON interface for input/output. void GetHistoryInfo(Browser* browser, @@ -424,12 +412,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, DictionaryValue* args, IPC::Message* reply_message); - // Waits until an attempted page translation has completed to reply. - // Uses the JSON interface for input/output. - void WaitUntilTranslateComplete(Browser* browser, - DictionaryValue* args, - IPC::Message* reply_message); - // Get the profiles that are currently saved to the DB. // Uses the JSON interface for input/output. void GetAutoFillProfile(Browser* browser, diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index badfb4d..0107708 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -1218,38 +1218,3 @@ void SavePackageNotificationObserver::Observe( } } -WaitForInfobarCountObserver::WaitForInfobarCountObserver( - AutomationProvider* automation, - IPC::Message* reply_message, - TabContents* tab_contents, - int count) - : automation_(automation), - reply_message_(reply_message), - tab_contents_(tab_contents), - count_(count) { - if (tab_contents->infobar_delegate_count() == count) { - ConditionMet(); - return; - } - registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_ADDED, - Source<TabContents>(tab_contents_)); - registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, - Source<TabContents>(tab_contents_)); -} - -void WaitForInfobarCountObserver::Observe( - NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK(type == NotificationType::TAB_CONTENTS_INFOBAR_ADDED || - type == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED); - if (tab_contents_->infobar_delegate_count() == count_) { - ConditionMet(); - } -} - -void WaitForInfobarCountObserver::ConditionMet() { - registrar_.RemoveAll(); - AutomationJSONReply(automation_, reply_message_).SendSuccess(NULL); - delete this; -} diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index ec32e5f..e55fec8 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -782,28 +782,4 @@ class SavePackageNotificationObserver : public NotificationObserver { DISALLOW_COPY_AND_ASSIGN(SavePackageNotificationObserver); }; -// Allows the automation provider to wait for a given number of infobars. -class WaitForInfobarCountObserver : public NotificationObserver { - public: - WaitForInfobarCountObserver(AutomationProvider* automation, - IPC::Message* reply_message, - TabContents* tab_contents, - int count); - - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - - private: - void ConditionMet(); - - NotificationRegistrar registrar_; - AutomationProvider* automation_; - IPC::Message* reply_message_; - TabContents* tab_contents_; - int count_; - - DISALLOW_COPY_AND_ASSIGN(WaitForInfobarCountObserver); -}; - #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ diff --git a/chrome/test/functional/infobars.py b/chrome/test/functional/infobars.py index a2b1c1d..ebfaf18 100644 --- a/chrome/test/functional/infobars.py +++ b/chrome/test/functional/infobars.py @@ -50,7 +50,7 @@ class InfobarTest(pyauto.PyUITest): self.assertTrue(flash) logging.info('Killing flash plugin. pid %d' % flash['pid']) self.Kill(flash['pid']) - self.WaitForInfobarCount(1) + self.assertTrue(self.WaitForInfobarCount(1)) crash_infobar = self._GetTabInfo()['infobars'] self.assertTrue(crash_infobar) self.assertEqual(1, len(crash_infobar)) @@ -83,7 +83,7 @@ class InfobarTest(pyauto.PyUITest): self.DataDir(), 'geolocation', 'geolocation_on_load.html')) match_text='file:/// wants to track your physical location' self.NavigateToURL(url) - self.WaitForInfobarCount(1) + self.assertTrue(self.WaitForInfobarCount(1)) self._VerifyGeolocationInfobar(windex=0, tab_index=0, match_text=match_text) # Accept, and verify that the infobar went away self.PerformActionOnInfobar('accept', infobar_index=0) @@ -96,18 +96,19 @@ class InfobarTest(pyauto.PyUITest): match_text='file:/// wants to track your physical location' for tab_index in range(1, 2): self.AppendTab(pyauto.GURL(url)) - self.WaitForInfobarCount(1, windex=0, tab_index=tab_index) + self.assertTrue( + self.WaitForInfobarCount(1, windex=0, tab_index=tab_index)) self._VerifyGeolocationInfobar(windex=0, tab_index=tab_index, match_text=match_text) # Try in a new window self.OpenNewBrowserWindow(True) self.NavigateToURL(url, 1, 0) - self.WaitForInfobarCount(1, windex=1, tab_index=0) + self.assertTrue(self.WaitForInfobarCount(1, windex=1, tab_index=0)) self._VerifyGeolocationInfobar(windex=1, tab_index=0, match_text=match_text) # Incognito window self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) self.NavigateToURL(url, 2, 0) - self.WaitForInfobarCount(1, windex=2, tab_index=0) + self.assertTrue(self.WaitForInfobarCount(1, windex=2, tab_index=0)) self._VerifyGeolocationInfobar(windex=2, tab_index=0, match_text=match_text) def testMultipleDownloadsInfobar(self): @@ -125,7 +126,7 @@ class InfobarTest(pyauto.PyUITest): self.DownloadAndWaitForStart(file_url) # trigger page reload, which triggers the download infobar self.GetBrowserWindow(0).GetTab(0).Reload() - self.WaitForInfobarCount(1) + self.assertTrue(self.WaitForInfobarCount(1)) tab_info = self._GetTabInfo(0, 0) infobars = tab_info['infobars'] self.assertTrue(infobars, 'Expected the multiple downloads infobar') diff --git a/chrome/test/functional/prefs.py b/chrome/test/functional/prefs.py index 700ebf8..3cb54da 100644 --- a/chrome/test/functional/prefs.py +++ b/chrome/test/functional/prefs.py @@ -150,14 +150,14 @@ class PrefsTest(pyauto.PyUITest): self.assertEqual(3, # default state self.GetPrefsInfo().Prefs(pyauto.kGeolocationDefaultContentSetting)) self.NavigateToURL(url) - self.WaitForInfobarCount(1) + self.assertTrue(self.WaitForInfobarCount(1)) self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) # Disable geolocation self.SetPrefs(pyauto.kGeolocationDefaultContentSetting, 2) self.assertEqual(2, self.GetPrefsInfo().Prefs(pyauto.kGeolocationDefaultContentSetting)) self.GetBrowserWindow(0).GetTab(0).Reload() - self.WaitForInfobarCount(0) + self.assertTrue(self.WaitForInfobarCount(0)) self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) diff --git a/chrome/test/functional/translate.py b/chrome/test/functional/translate.py index 5fa0eca..abf6d90 100644 --- a/chrome/test/functional/translate.py +++ b/chrome/test/functional/translate.py @@ -43,7 +43,8 @@ class TranslateTest(pyauto.PyUITest): def _NavigateAndWaitForBar(self, url, window_index=0, tab_index=0): self.NavigateToURL(url, window_index, tab_index) - self.WaitForInfobarCount(1, windex=window_index, tab_index=tab_index) + self.assertTrue(self.WaitForInfobarCount( + 1, windex=window_index, tab_index=tab_index)) def _ClickTranslateUntilSuccess(self, window_index=0, tab_index=0): """Since the translate can fail due to server error, continue trying until @@ -172,7 +173,7 @@ class TranslateTest(pyauto.PyUITest): self.assertTrue(translate_info['can_translate_page']) # This page is an ssl error page. self.NavigateToURL('https://www.sourceforge.net') - self.WaitForInfobarCount(0) + self.assertTrue(self.WaitForInfobarCount(0)) translate_info = self.GetTranslateInfo() self.assertFalse('translate_bar' in translate_info) @@ -184,7 +185,7 @@ class TranslateTest(pyauto.PyUITest): self.assertTrue(translate_info['can_translate_page']) # With the translate bar visible in same tab open an English page. self.NavigateToURL(self._GetDefaultEnglishURL()) - self.WaitForInfobarCount(0) + self.assertTrue(self.WaitForInfobarCount(0)) translate_info = self.GetTranslateInfo() self.assertFalse('translate_bar' in translate_info) @@ -201,7 +202,7 @@ class TranslateTest(pyauto.PyUITest): self._NavigateAndWaitForBar(self._GetDefaultSpanishURL()) self.NavigateToURL(self._GetURLForDataDirFile( os.path.join('translate', 'notranslate_meta_tag.html'))) - self.WaitForInfobarCount(0) + self.assertTrue(self.WaitForInfobarCount(0)) translate_info = self.GetTranslateInfo() self.assertFalse('translate_bar' in translate_info) @@ -219,7 +220,7 @@ class TranslateTest(pyauto.PyUITest): self.assertTrue(translate_info['page_translated']) # Reload the tab and confirm the page was translated. self.GetBrowserWindow(0).GetTab(0).Reload() - self.WaitForInfobarCount(1) + self.assertTrue(self.WaitForInfobarCount(1)) success = self.WaitUntilTranslateComplete() # Sometimes the translation fails. Continue clicking until it succeeds. if not success: @@ -243,15 +244,15 @@ class TranslateTest(pyauto.PyUITest): # Due to crbug.com/51439, we must open two tabs here. self.NavigateToURL("http://www.news.google.com") self.AppendTab(pyauto.GURL("http://www.google.com/webhp?hl=es")) - self.WaitForInfobarCount(1, tab_index=1) + self.assertTrue(self.WaitForInfobarCount(1, tab_index=1)) translate_info = self.GetTranslateInfo(tab_index=1) self.assertTrue('translate_bar' in translate_info) self.SelectTranslateOption('toggle_always_translate', tab_index=1) self._ClickTranslateUntilSuccess(tab_index=1) self.SetPrefs(pyauto.kRestoreOnStartup, 1) self.RestartBrowser(clear_profile=False) - self.WaitForInfobarCount(1, tab_index=1) - self.WaitUntilTranslateComplete() + self.assertTrue(self.WaitForInfobarCount(1, tab_index=1)) + self.WaitUntilTranslateComplete(tab_index=1) translate_info = self.GetTranslateInfo(tab_index=1) self.assertTrue('translate_bar' in translate_info) # Sometimes translation fails. We don't really care whether it succeededs, @@ -269,12 +270,12 @@ class TranslateTest(pyauto.PyUITest): translate_info = self.GetTranslateInfo() self.assertTrue('translate_bar' in translate_info) self.NavigateToURL(no_trans_url) - self.WaitForInfobarCount(0) + self.assertTrue(self.WaitForInfobarCount(0)) self.assertFalse('translate_bar' in self.GetTranslateInfo()) # Go back to the page that should be translated and assert that the # translate bar re-appears. self.GetBrowserWindow(0).GetTab(0).GoBack() - self.WaitForInfobarCount(1) + self.assertTrue(self.WaitForInfobarCount(1)) self.assertTrue('translate_bar' in self.GetTranslateInfo()) # Now test going forward. @@ -283,11 +284,11 @@ class TranslateTest(pyauto.PyUITest): self.assertFalse('translate_bar' in translate_info) self._AssertTranslateWorks(trans_url, self.spanish) self.GetBrowserWindow(0).GetTab(0).GoBack() - self.WaitForInfobarCount(0) + self.assertTrue(self.WaitForInfobarCount(0)) translate_info = self.GetTranslateInfo() self.assertFalse('translate_bar' in translate_info) self.GetBrowserWindow(0).GetTab(0).GoForward() - self.WaitForInfobarCount(1) + self.assertTrue(self.WaitForInfobarCount(1)) translate_info = self.GetTranslateInfo() self.assertTrue(translate_info['can_translate_page']) self.assertTrue('translate_bar' in translate_info) @@ -299,7 +300,7 @@ class TranslateTest(pyauto.PyUITest): translate_info = self.GetTranslateInfo() self.assertTrue('translate_bar' in translate_info) self.NavigateToURL(crash_url) - self.WaitForInfobarCount(0) + self.assertTrue(self.WaitForInfobarCount(0)) self.assertFalse('translate_bar' in self.GetTranslateInfo()) def testTranslatePrefs(self): @@ -359,7 +360,7 @@ class TranslateTest(pyauto.PyUITest): # and wait for bar to go away. self._NavigateAndWaitForBar('http://www.google.com/webhp?hl=fr') self.NavigateToURL('http://www.google.com/webhp?hl=es') - self.WaitForInfobarCount(0) + self.assertTrue(self.WaitForInfobarCount(0)) self.assertFalse(self.GetTranslateInfo()['can_translate_page']) def testChangeTargetLanguageAlwaysTranslate(self): @@ -455,7 +456,7 @@ class TranslateTest(pyauto.PyUITest): # it disappears on the history page. self._NavigateAndWaitForBar(self._GetDefaultSpanishURL()) self.NavigateToURL('chrome://history/') - self.WaitForInfobarCount(0) + self.assertTrue(self.WaitForInfobarCount(0)) self.assertFalse('translate_bar' in self.GetTranslateInfo()) def testDownloadsNotTranslated(self): @@ -466,7 +467,7 @@ class TranslateTest(pyauto.PyUITest): # it disappears on the downloads page. self._NavigateAndWaitForBar(self._GetDefaultSpanishURL()) self.NavigateToURL('chrome://downloads/') - self.WaitForInfobarCount(0) + self.assertTrue(self.WaitForInfobarCount(0)) self.assertFalse('translate_bar' in self.GetTranslateInfo()) def testAlwaysTranslateInIncognito(self): @@ -494,8 +495,8 @@ class TranslateTest(pyauto.PyUITest): """Navigate to a Spanish page in the given window/tab and verify that the translate bar shows up. """ - self.NavigateToURL(url, window_index, tab_index) - self.WaitForInfobarCount(1, windex=window_index, tab_index=tab_index) + self._NavigateAndWaitForBar( + url, window_index=window_index, tab_index=tab_index) info_before_translate = self.GetTranslateInfo(window_index=window_index, tab_index=tab_index) self.assertTrue('translate_bar' in info_before_translate) diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py index 6aa64a2..0d4f667 100644 --- a/chrome/test/pyautolib/pyauto.py +++ b/chrome/test/pyautolib/pyauto.py @@ -560,21 +560,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): } return self._GetResultFromJSONRequest(cmd_dict, windex=window_index) - def WaitForAlwaysOpenDownloadTypeToOpen(self, id): - """Wait for the given download to open. - - Note: This method should not be used after PerformActionOnDownload('open'). - It is used for files that are auto-downloaded based on the file type. - - Args: - id: The id of the download. - """ - cmd_dict = { # Prepare command for the json interface - 'command': 'WaitForAlwaysOpenDownloadTypeToOpen', - 'id': id - } - self._GetResultFromJSONRequest(cmd_dict) - def DownloadAndWaitForStart(self, file_url): """Trigger download for the given url and wait for downloads to start. @@ -636,7 +621,12 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): 'count': count, 'tab_index': tab_index, } - self._GetResultFromJSONRequest(cmd_dict, windex=windex) + # TODO(phajdan.jr): We need a solid automation infrastructure to handle + # these cases. See crbug.com/53647. + return self.WaitUntil( + lambda(count): len(self.GetBrowserInfo()\ + ['windows'][windex]['tabs'][tab_index]['infobars']) == count, + args=[count]) def PerformActionOnInfobar( self, action, infobar_index, windex=0, tab_index=0): @@ -957,8 +947,12 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): 'command': 'WaitUntilTranslateComplete', 'tab_index': tab_index } - return self._GetResultFromJSONRequest( - cmd_dict, windex=window_index)['translation_success'] + # 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 FillAutoFillProfile(self, profiles=None, credit_cards=None, tab_index=0, window_index=0): |