Commit 235c01f7 authored by rohitbm@google.com's avatar rohitbm@google.com

Adding 1 minute of waiting in discover search engine test. And moved...

Adding 1 minute of waiting in discover search engine test. And moved _CallFunctionWithNewTimeout to test_utils.

BUG=69619
Review URL: http://codereview.chromium.org/6354004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71535 0039d316-1c4b-4281-b951-d872f2087c98
parent 3fd04f5f
......@@ -15,6 +15,7 @@ import urllib
import pyauto_functional # Must be imported before pyauto
import pyauto
import pyauto_utils
import test_utils
class DownloadsTest(pyauto.PyUITest):
......@@ -93,19 +94,6 @@ class DownloadsTest(pyauto.PyUITest):
logging.debug('Created temporary file %s of size %d' % (file_path, size))
return file_path
def _CallFunctionWithNewTimeout(self, new_timeout, function):
"""Sets the timeout to |new_timeout| and calls |function|.
This method resets the timeout before returning.
"""
timeout_changer = pyauto.PyUITest.CmdExecutionTimeoutChanger(
self, new_timeout)
logging.info('Automation execution timeout has been changed to %d. '
'If the timeout is large the test might appear to hang.'
% new_timeout)
function()
del timeout_changer
def _GetAllDownloadIDs(self):
"""Return a list of all download ids."""
return [download['id'] for download in self.GetDownloadsInfo().Downloads()]
......@@ -221,8 +209,8 @@ class DownloadsTest(pyauto.PyUITest):
self._DeleteAfterShutdown(downloaded_pkg)
# Waiting for big file to download might exceed automation timeout.
# Temporarily increase the automation timeout.
self._CallFunctionWithNewTimeout(4 * 60 * 1000, # 4 min.
self.WaitForAllDownloadsToComplete)
test_utils.CallFunctionWithNewTimeout(self, 4 * 60 * 1000, # 4 min.
self.WaitForAllDownloadsToComplete)
# Verify that the file was correctly downloaded
self.assertTrue(os.path.exists(downloaded_pkg),
'Downloaded file %s missing.' % downloaded_pkg)
......@@ -381,8 +369,8 @@ class DownloadsTest(pyauto.PyUITest):
# Waiting for big file to download might exceed automation timeout.
# Temporarily increase the automation timeout.
self._CallFunctionWithNewTimeout(2 * 60 * 1000, # 2 min.
self.WaitForAllDownloadsToComplete)
test_utils.CallFunctionWithNewTimeout(self, 2 * 60 * 1000, # 2 min.
self.WaitForAllDownloadsToComplete)
# Verify that the file was correctly downloaded after pause and resume.
self.assertTrue(os.path.exists(downloaded_pkg),
......@@ -478,12 +466,10 @@ class DownloadsTest(pyauto.PyUITest):
self.WaitForAllDownloadsToComplete()
id = self._GetDownloadId()
self.PerformActionOnDownload(id, 'toggle_open_files_like_this')
os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg)
# Retesting the flag we set
file_url2 = self.GetFileURLForDataPath(os.path.join('zip', 'test.zip'))
unzip_path = os.path.join(self.GetDownloadDirectory().value(),
'test', 'foo')
os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg)
os.path.exists(unzip_path) and pyauto_utils.RemovePath(unzip_path)
self.DownloadAndWaitForStart(file_url2)
self.WaitForAllDownloadsToComplete()
......
......@@ -8,6 +8,7 @@ import re
import pyauto_functional # Must be imported before pyauto
import pyauto
import test_utils
class SearchEnginesTest(pyauto.PyUITest):
......@@ -50,7 +51,10 @@ class SearchEnginesTest(pyauto.PyUITest):
# Use omnibox to invoke search engine discovery.
# Navigating using NavigateToURL does not currently invoke this logic.
self.SetOmniboxText('http://www.youtube.com')
self.OmniboxAcceptInput()
# Due to slow navigation to youtube.com on Leopard test machines, waiting
# here 1 min (max).
test_utils.CallFunctionWithNewTimeout(self, 1 * 60 * 1000,
self.OmniboxAcceptInput)
def InfoUpdated(old_info):
new_info = self.GetSearchEngineInfo()
if len(new_info) > len(old_info):
......
......@@ -6,11 +6,13 @@
import copy
import email
import logging
import os
import smtplib
import types
import pyauto_functional
import pyauto
import pyauto_utils
......@@ -215,3 +217,17 @@ def StringContentCheck(test, content_string, have_list, nothave_list):
test.assertTrue(s in content_string, s)
for s in nothave_list:
test.assertTrue(s not in content_string)
def CallFunctionWithNewTimeout(self, new_timeout, function):
"""Sets the timeout to |new_timeout| and calls |function|.
This method resets the timeout before returning.
"""
timeout_changer = pyauto.PyUITest.CmdExecutionTimeoutChanger(
self, new_timeout)
logging.info('Automation execution timeout has been changed to %d. '
'If the timeout is large the test might appear to hang.'
% new_timeout)
function()
del timeout_changer
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