| Index: chrome/test/functional/find_in_page.py
|
| ===================================================================
|
| --- chrome/test/functional/find_in_page.py (revision 64201)
|
| +++ chrome/test/functional/find_in_page.py (working copy)
|
| @@ -8,6 +8,7 @@
|
|
|
| import pyauto_functional
|
| import pyauto
|
| +import test_utils
|
|
|
|
|
| class FindMatchTests(pyauto.PyUITest):
|
| @@ -74,40 +75,29 @@
|
| """Verify search for text within special URLs such as chrome:history.
|
| chrome://history, chrome://downloads, pyAuto Data directory
|
| """
|
| + zip_file = 'a_zip_file.zip'
|
| self.NavigateToURL(self.GetFileURLForPath(self.DataDir()))
|
| # search in Data directory
|
| self.assertEqual(1,
|
| self.FindInPage('downloads', tab_index=0)['match_count'])
|
| # search in History page
|
| self.AppendTab(pyauto.GURL('chrome://history'))
|
| + # the contents in the history page load asynchronously after tab loads
|
| + self.WaitUntil(
|
| + lambda: self.FindInPage('data', tab_index=1)['match_count'],
|
| + expect_retval=1)
|
| self.assertEqual(1, self.FindInPage('data', tab_index=1)['match_count'])
|
| # search in Downloads page
|
| - self._DownloadZipFile()
|
| + test_utils.DownloadTestFile(self, zip_file)
|
| self.AppendTab(pyauto.GURL('chrome://downloads'))
|
| + # the contents in the downloads page load asynchronously after tab loads
|
| + self.WaitUntil(
|
| + lambda: self.FindInPage(zip_file, tab_index=2)['match_count'],
|
| + expect_retval=2)
|
| self.assertEqual(2,
|
| - self.FindInPage('a_zip_file.zip', tab_index=2)['match_count'])
|
| - self._RemoveZipFile()
|
| + self.FindInPage(zip_file, tab_index=2)['match_count'])
|
| + test_utils.RemoveTestFile(self, zip_file)
|
|
|
| - def _DownloadZipFile(self):
|
| - """Download a zip file."""
|
| - zip_file = 'a_zip_file.zip'
|
| - download_dir = os.path.join(os.path.abspath(self.DataDir()), 'downloads')
|
| - file_path = os.path.join(download_dir, zip_file)
|
| - file_url = self.GetFileURLForPath(file_path)
|
| - downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), zip_file)
|
| - # Check if zip file already exists. If so then delete it.
|
| - if os.path.exists(downloaded_pkg):
|
| - self._RemoveZipFile()
|
| - self.DownloadAndWaitForStart(file_url)
|
| - # Wait for the download to finish
|
| - self.WaitForAllDownloadsToComplete()
|
|
|
| - def _RemoveZipFile(self):
|
| - """Delete a_zip_file.zip from the download directory."""
|
| - downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
|
| - 'a_zip_file.zip')
|
| - os.remove(downloaded_pkg)
|
| -
|
| -
|
| if __name__ == '__main__':
|
| pyauto_functional.Main()
|
|
|