Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3292)

Unified Diff: chrome/test/functional/browsing_data.py

Issue 3030022: New pyauto tests for clearing browsing data. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Nits Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/browsing_data.py
diff --git a/chrome/test/functional/browsing_data.py b/chrome/test/functional/browsing_data.py
index f217c5bab2f5d53ce78e036e29a2b1a3547e0b12..c5ead1a627f1a96eeb59b873903739512844e107 100644
--- a/chrome/test/functional/browsing_data.py
+++ b/chrome/test/functional/browsing_data.py
@@ -13,17 +13,54 @@ import pyauto
class BrowsingDataTest(pyauto.PyUITest):
"""Tests that clearing browsing data works correctly."""
+ def _DownloadTestFile(self, file_name):
+ """Downloads the specified file from the 'downloads' directory and waits
+ for downloads to complete.
+ """
+ test_dir = os.path.join(self.DataDir(), 'downloads')
+ file_path = os.path.join(test_dir, file_name)
+ file_url = self.GetFileURLForPath(file_path)
+ downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
+ file_name)
+ os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg)
+ self.DownloadAndWaitForStart(file_url)
+ self.WaitForAllDownloadsToComplete()
+
+ def _GetURLForFile(self, file_name):
+ """Returns the url for the file in the 'data' directory."""
+ return self.GetFileURLForPath(os.path.join(self.DataDir(), file_name))
+
def testClearHistory(self):
"""Verify that clearing the history works."""
- url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title2.html'))
- self.NavigateToURL(url)
-
+ self.NavigateToURL(self._GetURLForFile('title2.html'))
history = self.GetHistoryInfo().History()
self.assertEqual(1, len(history))
self.ClearBrowsingData(['HISTORY'], 'EVERYTHING')
history = self.GetHistoryInfo().History()
- self.assertEqual(0, len(history))
+ self.assertFalse(history)
+
+ def testClearCookies(self):
+ """Verify clearing cookies."""
+ # First build up some data with cookies.
+ cookie_url = pyauto.GURL(self._GetURLForFile('title2.html'))
+ cookie_val = 'foo=bar'
+ self.SetCookie(cookie_url, cookie_val)
+ self.assertEqual(cookie_val, self.GetCookie(cookie_url))
+ # Then clear the cookies.
+ self.ClearBrowsingData(['COOKIES'], 'EVERYTHING')
+ cookie_data = self.GetCookie(cookie_url)
+ self.assertFalse(cookie_data)
+
+ def testClearDownloads(self):
+ """Verify clearing downloads."""
+ # First build up some data with downloads.
+ self._DownloadTestFile('a_zip_file.zip')
+ self.assertEqual(1, len(self.GetDownloadsInfo().Downloads()))
+ # Clear the downloads and verify they're gone.
+ self.ClearBrowsingData(['DOWNLOADS'], 'EVERYTHING')
+ downloads = self.GetDownloadsInfo().Downloads()
+ self.assertFalse(downloads)
def testClearHistoryPastHour(self):
"""Verify that clearing the history of the past hour works and does not
@@ -55,17 +92,8 @@ class BrowsingDataTest(pyauto.PyUITest):
def testClearHistoryAndDownloads(self):
"""Verify that we can clear history and downloads at the same time."""
# First build up some history and download something.
- url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title2.html'))
- self.NavigateToURL(url)
-
- test_dir = os.path.join(os.path.abspath(self.DataDir()), 'downloads')
- file_path = os.path.join(test_dir, 'a_zip_file.zip')
- file_url = self.GetFileURLForPath(file_path)
- 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)
- self.WaitForAllDownloadsToComplete()
+ self.NavigateToURL(self._GetURLForFile('title2.html'))
+ self._DownloadTestFile('a_zip_file.zip')
# Verify that the history and download exist.
self.assertEqual(1, len(self.GetHistoryInfo().History()))
@@ -75,8 +103,25 @@ class BrowsingDataTest(pyauto.PyUITest):
self.ClearBrowsingData(['HISTORY', 'DOWNLOADS'], 'EVERYTHING')
history = self.GetHistoryInfo().History()
downloads = self.GetDownloadsInfo().Downloads()
- self.assertEqual(0, len(history))
- self.assertEqual(0, len(downloads))
+ self.assertFalse(history)
+ self.assertFalse(downloads)
+
+ def testClearingAccuracy(self):
+ """Verify that clearing one thing does not clear another."""
+ # First build up some history and download something.
+ self.NavigateToURL(self._GetURLForFile('title2.html'))
+ self._DownloadTestFile('a_zip_file.zip')
+
+ # Verify that the history and download exist.
+ self.assertEqual(1, len(self.GetHistoryInfo().History()))
+ self.assertEqual(1, len(self.GetDownloadsInfo().Downloads()))
+
+ # Clear history and verify that downloads exist.
+ self.ClearBrowsingData(['HISTORY'], 'EVERYTHING')
+ history = self.GetHistoryInfo().History()
+ downloads = self.GetDownloadsInfo().Downloads()
+ self.assertFalse(history)
+ self.assertEqual(1, len(downloads))
if __name__ == '__main__':
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698