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

Side by Side Diff: chrome/test/functional/browsing_data.py

Issue 2909005: Clear Browsing Data hook added and some small tests. (Closed)
Patch Set: Deleting downloaded file 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 unified diff | Download patch
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import os
7 import time
8
9 import pyauto_functional # Must be imported before pyauto
10 import pyauto
11
12
13 class BrowsingDataTest(pyauto.PyUITest):
14 """Tests that clearing browsing data works correctly."""
15
16 def testClearHistory(self):
17 """Verify that clearing the history works."""
18 url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title2.html'))
19 self.NavigateToURL(url)
20
21 history = self.GetHistoryInfo().History()
22 self.assertEqual(1, len(history))
23
24 self.ClearBrowsingData(['HISTORY'], 'EVERYTHING')
25 history = self.GetHistoryInfo().History()
26 self.assertEqual(0, len(history))
27
28 def testClearHistoryPastHour(self):
29 """Verify that clearing the history of the past hour works and does not
30 clear history older than one hour.
31 """
32 title = 'Google'
33 num_secs_in_hour = 3600
34
35 # Forge a history item for two hours ago
36 now = time.time()
37 last_hour = now - (2 * num_secs_in_hour)
38 self.AddHistoryItem({'title': title,
39 'url': 'http://www.google.com',
40 'time': last_hour})
41
42 # Forge a history item for right now
43 self.AddHistoryItem({'title': 'This Will Be Cleared',
44 'url': 'http://www.dev.chromium.org',
45 'time': now})
46
47 history = self.GetHistoryInfo().History()
48 self.assertEqual(2, len(history))
49
50 self.ClearBrowsingData(['HISTORY'], 'LAST_HOUR')
51 history = self.GetHistoryInfo().History()
52 self.assertEqual(1, len(history))
53 self.assertEqual(title, history[0]['title'])
54
55 def testClearHistoryAndDownloads(self):
56 """Verify that we can clear history and downloads at the same time."""
57 # First build up some history and download something.
58 url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title2.html'))
59 self.NavigateToURL(url)
60
61 test_dir = os.path.join(os.path.abspath(self.DataDir()), 'downloads')
62 file_path = os.path.join(test_dir, 'a_zip_file.zip')
63 file_url = self.GetFileURLForPath(file_path)
64 downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
65 'a_zip_file.zip')
66 os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg)
67 self.DownloadAndWaitForStart(file_url)
68 self.WaitForAllDownloadsToComplete()
69
70 # Verify that the history and download exist.
71 self.assertEqual(1, len(self.GetHistoryInfo().History()))
72 self.assertEqual(1, len(self.GetDownloadsInfo().Downloads()))
73
74 # Clear the history and downloads and verify they're both gone.
75 self.ClearBrowsingData(['HISTORY', 'DOWNLOADS'], 'EVERYTHING')
76 history = self.GetHistoryInfo().History()
77 downloads = self.GetDownloadsInfo().Downloads()
78 self.assertEqual(0, len(history))
79 self.assertEqual(0, len(downloads))
80
81
82 if __name__ == '__main__':
83 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698