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

Side by Side Diff: chrome/test/pyautolib/pyauto.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/browsing_data.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """PyAuto: Python Interface to Chromium's Automation Proxy. 7 """PyAuto: Python Interface to Chromium's Automation Proxy.
8 8
9 PyAuto uses swig to expose Automation Proxy interfaces to Python. 9 PyAuto uses swig to expose Automation Proxy interfaces to Python.
10 For complete documentation on the functionality available, 10 For complete documentation on the functionality available,
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 if ret_dict.has_key('error'): 750 if ret_dict.has_key('error'):
751 raise JSONInterfaceError(ret_dict['error']) 751 raise JSONInterfaceError(ret_dict['error'])
752 try: 752 try:
753 f = open(filename) 753 f = open(filename)
754 all_data = f.read() 754 all_data = f.read()
755 f.close() 755 f.close()
756 return all_data 756 return all_data
757 finally: 757 finally:
758 shutil.rmtree(tempdir) 758 shutil.rmtree(tempdir)
759 759
760 def ClearBrowsingData(self, to_remove, time_period):
761 """Clear the specified browsing data. Implements the features available in
762 the "ClearBrowsingData" UI.
763
764 Args:
765 to_remove: a list of strings indicating which types of browsing data
766 should be removed. Strings that can be in the list are:
767 HISTORY, DOWNLOADS, COOKIES, PASSWORDS, FORM_DATA, CACHE
768 time_period: a string indicating the time period for the removal.
769 Possible strings are:
770 LAST_HOUR, LAST_DAY, LAST_WEEK, FOUR_WEEKS, EVERYTHING
771
772 Raises:
773 pyauto_errors.JSONInterfaceError if the automation call returns an error.
774 """
775 cmd_dict = { # Prepare command for the json interface
776 'command': 'ClearBrowsingData',
777 'to_remove': to_remove,
778 'time_period': time_period
779 }
780 ret_dict = json.loads(self._SendJSONRequest(0, json.dumps(cmd_dict)))
781 if ret_dict.has_key('error'):
782 raise JSONInterfaceError(ret_dict['error'])
783 return ret_dict
784
760 def SetTheme(self, crx_file_path): 785 def SetTheme(self, crx_file_path):
761 """Installs the given theme synchronously. 786 """Installs the given theme synchronously.
762 787
763 A theme file is file with .crx suffix, like an extension. 788 A theme file is file with .crx suffix, like an extension.
764 This method call waits until theme is installed and will trigger the 789 This method call waits until theme is installed and will trigger the
765 "theme installed" infobar. 790 "theme installed" infobar.
766 791
767 Uses InstallExtension(). 792 Uses InstallExtension().
768 793
769 Returns: 794 Returns:
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 if self._options.verbose: 1080 if self._options.verbose:
1056 verbosity = 2 1081 verbosity = 2
1057 result = unittest.TextTestRunner(verbosity=verbosity).run(pyauto_suite) 1082 result = unittest.TextTestRunner(verbosity=verbosity).run(pyauto_suite)
1058 del loaded_tests # Need to destroy test cases before the suite 1083 del loaded_tests # Need to destroy test cases before the suite
1059 del pyauto_suite 1084 del pyauto_suite
1060 sys.exit(not result.wasSuccessful()) 1085 sys.exit(not result.wasSuccessful())
1061 1086
1062 1087
1063 if __name__ == '__main__': 1088 if __name__ == '__main__':
1064 Main() 1089 Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/browsing_data.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698