Test to verify the 'multiple downloads' infobar

Verifies the multiple downloads infobar.

Implemented by Venkat, who figured out how to reliably trigger the multiple
downloads infobar.

Review URL: http://codereview.chromium.org/3066017

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54163 0039d316-1c4b-4281-b951-d872f2087c98
parent 211d0260
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Test Download Multiple files Infobar.</title>
<script>window.location.href = "a_zip_file.zip";</script>
</head>
<body>
<h2>Reloading this page should trigger the multiple downloads infobar.</h2>
</body>
</html>
...@@ -108,6 +108,36 @@ class InfobarTest(pyauto.PyUITest): ...@@ -108,6 +108,36 @@ class InfobarTest(pyauto.PyUITest):
self.WaitForInfobarCount(1, windex=2, tab_index=0) self.WaitForInfobarCount(1, windex=2, tab_index=0)
self._VerifyGeolocationInfobar(windex=2, tab_index=0, match_text=match_text) self._VerifyGeolocationInfobar(windex=2, tab_index=0, match_text=match_text)
def testMultipleDownloadsInfobar(self):
"""Verify the mutiple downloads infobar."""
assert pyauto.PyUITest.IsEnUS()
file_url = self.GetFileURLForPath(
os.path.join(self.DataDir(), 'downloads', 'download-a_zip_file.html'))
match_text = 'This site is attempting to download multiple files. ' \
'Do you want to allow this?'
self.NavigateToURL('chrome://downloads') # trigger download manager
# Clear existing files of the same name in the downloads folder
downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
'a_zip_file.zip')
os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg)
self.DownloadAndWaitForStart(file_url)
# trigger page reload, which triggers the download infobar
self.GetBrowserWindow(0).GetTab(0).Reload()
self.WaitForInfobarCount(1)
tab_info = self._GetTabInfo(0, 0)
infobars = tab_info['infobars']
self.assertTrue(infobars, 'Expected the multiple downloads infobar')
self.assertEqual(1, len(infobars))
self.assertEqual(match_text, infobars[0]['text'])
self.assertEqual(2, len(infobars[0]['buttons']))
self.assertEqual('Allow', infobars[0]['buttons'][0])
self.assertEqual('Deny', infobars[0]['buttons'][1])
# Ensure we quit only after all downloads have completed
self.WaitForAllDownloadsToComplete()
downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
'a_zip_file.zip')
os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg)
if __name__ == '__main__': if __name__ == '__main__':
pyauto_functional.Main() pyauto_functional.Main()
...@@ -216,6 +216,12 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): ...@@ -216,6 +216,12 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
"""Are we on Mac/Linux?""" """Are we on Mac/Linux?"""
return PyUITest.IsMac() or PyUITest.IsLinux() return PyUITest.IsMac() or PyUITest.IsLinux()
@staticmethod
def IsEnUS():
"""Are we en-US?"""
# TODO: figure out the machine's langugage.
return True
@staticmethod @staticmethod
def EvalDataFrom(filename): def EvalDataFrom(filename):
"""Return eval of python code from given file. """Return eval of python code from given file.
......
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