diff options
author | dyu@chromium.org <dyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-23 21:48:17 +0000 |
---|---|---|
committer | dyu@chromium.org <dyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-23 21:48:17 +0000 |
commit | cf667c88932398fc44e4821fc6d0b7d88c63a1cd (patch) | |
tree | 2546981a1f27a4c7481ea2a09d0183bca0a3c0ee /chrome/test | |
parent | ca6667890dde9c98fc1ad8203f002757ea740110 (diff) | |
download | chromium_src-cf667c88932398fc44e4821fc6d0b7d88c63a1cd.zip chromium_src-cf667c88932398fc44e4821fc6d0b7d88c63a1cd.tar.gz chromium_src-cf667c88932398fc44e4821fc6d0b7d88c63a1cd.tar.bz2 |
Used functions within test_utils for testDownloadNoHistory within history.py.
Used fuctions within test_utils for testMultipleDownloadInfobar and testDisplayAndSavePasswordInfobar within infobars.py.
Added addtional functions into test_utils.py for commonly used Log in functions.
Used new private creds files for infobars test used in sync.py.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/4561002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67159 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/functional/history.py | 32 | ||||
-rw-r--r-- | chrome/test/functional/infobars.py | 16 | ||||
-rw-r--r-- | chrome/test/functional/passwords.py | 23 | ||||
-rw-r--r-- | chrome/test/functional/test_utils.py | 44 |
4 files changed, 94 insertions, 21 deletions
diff --git a/chrome/test/functional/history.py b/chrome/test/functional/history.py index 40ea326..0d881e8 100644 --- a/chrome/test/functional/history.py +++ b/chrome/test/functional/history.py @@ -8,6 +8,7 @@ import time import pyauto_functional # Must be imported before pyauto import pyauto +import test_utils class HistoryTest(pyauto.PyUITest): @@ -144,15 +145,10 @@ class HistoryTest(pyauto.PyUITest): def testDownloadNoHistory(self): """Downloaded URLs should not show up in history.""" + zip_file = 'a_zip_file.zip' assert not self.GetHistoryInfo().History(), 'Expecting clean history.' - file_url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'downloads', - 'a_zip_file.zip')) - downloaded_file = os.path.join(self.GetDownloadDirectory().value(), - 'a_zip_file.zip') - os.path.exists(downloaded_file) and os.remove(downloaded_file) - self.DownloadAndWaitForStart(file_url) - self.WaitForAllDownloadsToComplete() - os.path.exists(downloaded_file) and os.remove(downloaded_file) + test_utils.DownloadFileFromDownloadsDataDir(self, zip_file) + test_utils.RemoveDownloadedTestFile(self, zip_file) # We shouldn't have any history history = self.GetHistoryInfo().History() self.assertEqual(0, len(history)) @@ -204,6 +200,26 @@ class HistoryTest(pyauto.PyUITest): self.assertTrue('google.com' in history[0]['url']) self.assertTrue(abs(new_time - history[0]['time']) < 1.0) + def testHttpsHistory(self): + """Verify a site using https protocol shows up within history.""" + https_url = 'https://encrypted.google.com/' + url_title = 'Google' + self.NavigateToURL(https_url) + history = self.GetHistoryInfo().History() + self.assertEqual(len(history), 1) + self.assertEqual(url_title, history[0]['title']) + self.assertEqual(https_url, history[0]['url']) + + def testFtpHistory(self): + """Verify a site using ftp protocol shows up within history.""" + ftp_url = 'ftp://ftp.kernel.org/' + ftp_title = 'Index of /' + self.NavigateToURL(ftp_url) + history = self.GetHistoryInfo().History() + self.assertEqual(len(history), 1) + self.assertEqual(ftp_title, history[0]['title']) + self.assertEqual(ftp_url, history[0]['url']) + if __name__ == '__main__': pyauto_functional.Main() diff --git a/chrome/test/functional/infobars.py b/chrome/test/functional/infobars.py index ebfaf18..b0ee05f 100644 --- a/chrome/test/functional/infobars.py +++ b/chrome/test/functional/infobars.py @@ -9,7 +9,7 @@ import re import pyauto_functional # Must be imported before pyauto import pyauto - +import test_utils class InfobarTest(pyauto.PyUITest): """TestCase for Infobars.""" @@ -113,16 +113,15 @@ class InfobarTest(pyauto.PyUITest): def testMultipleDownloadsInfobar(self): """Verify the mutiple downloads infobar.""" + zip_file = 'a_zip_file.zip' + html_file = 'download-a_zip_file.html' assert pyauto.PyUITest.IsEnUS() file_url = self.GetFileURLForPath( - os.path.join(self.DataDir(), 'downloads', 'download-a_zip_file.html')) + os.path.join(self.DataDir(), 'downloads', html_file)) 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) + test_utils.RemoveDownloadedTestFile(self, zip_file) self.DownloadAndWaitForStart(file_url) # trigger page reload, which triggers the download infobar self.GetBrowserWindow(0).GetTab(0).Reload() @@ -135,11 +134,8 @@ class InfobarTest(pyauto.PyUITest): 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) + test_utils.RemoveDownloadedTestFile(self, zip_file) if __name__ == '__main__': diff --git a/chrome/test/functional/passwords.py b/chrome/test/functional/passwords.py index 7d88eb9..55e7d50 100644 --- a/chrome/test/functional/passwords.py +++ b/chrome/test/functional/passwords.py @@ -5,6 +5,7 @@ import pyauto_functional # Must be imported before pyauto import pyauto +import test_utils class PasswordTest(pyauto.PyUITest): @@ -42,6 +43,28 @@ class PasswordTest(pyauto.PyUITest): self.assertTrue(self.AddSavedPassword(password1)) self.assertEquals(self.GetSavedPasswords(), [password1]) + def testDisplayAndSavePasswordInfobar(self): + """Verify password infobar displays and able to save password.""" + url_https = 'https://www.google.com/accounts/' + url_logout = 'https://www.google.com/accounts/Logout' + creds = self.GetPrivateInfo()['test_google_account'] + username = creds['username'] + password = creds['password'] + test_utils.GoogleAccountsLogin(self, ['url'], username, password) + # Wait until page completes loading. + self.WaitUntil( + lambda: self.GetDOMValue('document.readyState'), 'complete') + self.WaitForInfobarCount(1) + infobar = self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'] + self.assertEqual(infobar[0]['type'], 'confirm_infobar') + self.PerformActionOnInfobar('accept', infobar_index=0) + self.NavigateToURL(url_logout) + self.NavigateToURL(url_https) + test_utils.VerifyGoogleAccountCredsFilled(self, username, password) + self.ExecuteJavascript('document.getElementById("gaia_loginform").submit();' + 'window.domAutomationController.send("done")') + test_utils.ClearPasswords(self) + if __name__ == '__main__': pyauto_functional.Main() diff --git a/chrome/test/functional/test_utils.py b/chrome/test/functional/test_utils.py index a5fd8ee..55145f9 100644 --- a/chrome/test/functional/test_utils.py +++ b/chrome/test/functional/test_utils.py @@ -20,14 +20,11 @@ def DownloadFileFromDownloadsDataDir(test, file_name): file_name: name of file to download """ download_dir = os.path.join(os.path.abspath(test.DataDir()), 'downloads') - file_path = os.path.join(download_dir, file_name) - file_url = test.GetFileURLForPath(file_path) downloaded_pkg = os.path.join(test.GetDownloadDirectory().value(), file_name) # Check if file already exists. If so then delete it. if os.path.exists(downloaded_pkg): RemoveDownloadedTestFile(test, file_name) - test.DownloadAndWaitForStart(file_url) test.WaitForAllDownloadsToComplete() @@ -42,3 +39,44 @@ def RemoveDownloadedTestFile(test, file_name): file_name) pyauto_utils.RemovePath(downloaded_pkg) pyauto_utils.RemovePath(downloaded_pkg + '.crdownload') + + +def GoogleAccountsLogin(test, url, username, password): + """Log into Google Accounts. + + Attempts to login to Google by entering the username/password into the google + login page and click submit button. + + Args: + test: derived from pyauto.PyUITest - base class for UI test cases. + username: users login input. + password: users login password input. + """ + test.NavigateToURL('https://www.google.com/accounts/') + email_id = 'document.getElementById("Email").value = \"%s\"; ' \ + 'window.domAutomationController.send("done")' % username + password = 'document.getElementById("Passwd").value = \"%s\"; ' \ + 'window.domAutomationController.send("done")' % password + test.ExecuteJavascript(email_id); + test.ExecuteJavascript(password); + test.ExecuteJavascript('document.getElementById("gaia_loginform").submit();' + 'window.domAutomationController.send("done")') + + +def VerifyGoogleAccountCredsFilled(test, username, password): + """Verify stored/saved user and password values to the values in the field. + + Args: + test: derived from pyauto.PyUITest - base class for UI test cases. + username: user log in input. + password: user log in password input. + """ + email_value = test.GetDOMValue('document.getElementById("Email").value') + passwd_value = test.GetDOMValue('document.getElementById("Passwd").value') + test.assertEqual(email_value, username) + test.assertEqual(passwd_value, password) + + +def ClearPasswords(test): + """Clear saved passwords.""" + test.ClearBrowsingData(['PASSWORDS'], 'EVERYTHING') |