diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 23:37:52 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 23:37:52 +0000 |
commit | 88424e6e8ed416c21e92bc8efc4b2658f89b7329 (patch) | |
tree | a8bf4ad9414e3834288d8e99b0949a7c19ccba94 /chrome/test | |
parent | 54a7a889cc1a3889561c0d13159b890eeaf98995 (diff) | |
download | chromium_src-88424e6e8ed416c21e92bc8efc4b2658f89b7329.zip chromium_src-88424e6e8ed416c21e92bc8efc4b2658f89b7329.tar.gz chromium_src-88424e6e8ed416c21e92bc8efc4b2658f89b7329.tar.bz2 |
PyAuto tests for find in page.
pyAuto tests for find in page. HTML files associated with tests.
(Committing on behalf of dyu. Originally reviewed and LGTMed at:
http://codereview.chromium.org/4155001/show)
BUG=
TEST=
Review URL: http://codereview.chromium.org/4194002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/data/find_in_page/populatedform.html | 14 | ||||
-rw-r--r-- | chrome/test/data/find_in_page/smalltextarea.html | 12 | ||||
-rw-r--r-- | chrome/test/data/find_in_page/textintextarea.html | 12 | ||||
-rw-r--r-- | chrome/test/functional/find_in_page.py | 52 |
4 files changed, 90 insertions, 0 deletions
diff --git a/chrome/test/data/find_in_page/populatedform.html b/chrome/test/data/find_in_page/populatedform.html new file mode 100644 index 0000000..a92f92f --- /dev/null +++ b/chrome/test/data/find_in_page/populatedform.html @@ -0,0 +1,14 @@ +<html> +<head> +<title>Find Text in Pre-populated Form testcase</title> +</head> +<body> + + <form> + <input type="text" size="5" maxlength="5" value="88888" /> + <input type="text" size="15" maxlength="15" value="cat" /> + <input type="text" size="25" maxlength="25" value="Hot Pot City" /> + </form> + +</body> +</html> diff --git a/chrome/test/data/find_in_page/smalltextarea.html b/chrome/test/data/find_in_page/smalltextarea.html new file mode 100644 index 0000000..43d3b4a --- /dev/null +++ b/chrome/test/data/find_in_page/smalltextarea.html @@ -0,0 +1,12 @@ +<html> +<head> +<title>Find Text in Small Text Area testcase</title> +</head> +<body> + +<textarea rows="1" cols="1"> +The garden was playing in the cat. +</textarea> + +</body> +</html>
\ No newline at end of file diff --git a/chrome/test/data/find_in_page/textintextarea.html b/chrome/test/data/find_in_page/textintextarea.html new file mode 100644 index 0000000..4a85329 --- /dev/null +++ b/chrome/test/data/find_in_page/textintextarea.html @@ -0,0 +1,12 @@ +<html> +<head> +<title>Find Text in Text Area testcase</title> +</head> +<body> + +<textarea rows="10" cols="30"> +The cat was playing in the garden. +</textarea> + +</body> +</html>
\ No newline at end of file diff --git a/chrome/test/functional/find_in_page.py b/chrome/test/functional/find_in_page.py index d2e212b..4211034 100644 --- a/chrome/test/functional/find_in_page.py +++ b/chrome/test/functional/find_in_page.py @@ -56,6 +56,58 @@ class FindMatchTests(pyauto.PyUITest): self.assertNotEqual(capital_i_with_dot, capital_i) self.assertNotEqual(dotted, capital_i_with_dot) + def testSearchInTextAreas(self): + """Verify search for text within various forms and text areas.""" + urls = [] + urls.append(self.GetFileURLForPath( + os.path.join(self.DataDir(), 'find_in_page', 'textintextarea.html'))) + urls.append(self.GetFileURLForPath( + os.path.join(self.DataDir(), 'find_in_page', 'smalltextarea.html'))) + urls.append(self.GetFileURLForPath(os.path.join( + self.DataDir(), 'find_in_page', 'populatedform.html'))) + for url in urls: + self.NavigateToURL(url) + self.assertEqual(1, self.FindInPage('cat')['match_count']) + self.assertEqual(0, self.FindInPage('bat')['match_count']) + + def testSearchWithinSpecialURL(self): + """Verify search for text within special URLs such as chrome:history. + chrome://history, chrome://downloads, pyAuto Data directory + """ + 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')) + self.assertEqual(1, self.FindInPage('data', tab_index=1)['match_count']) + # search in Downloads page + self._DownloadZipFile() + self.AppendTab(pyauto.GURL('chrome://downloads')) + self.assertEqual(2, + self.FindInPage('a_zip_file.zip', tab_index=2)['match_count']) + self._RemoveZipFile() + + 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() |