summaryrefslogtreecommitdiffstats
path: root/chrome/test/pyautolib
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-07 17:27:29 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-07 17:27:29 +0000
commitbbe6aa04e14d5c7d176f303c199e2bf85ea40de7 (patch)
tree860ebcf3339fc0446c17a94b78f358ccff11425e /chrome/test/pyautolib
parent99f0c0818d6e612e6581f38bd0d53edceae44863 (diff)
downloadchromium_src-bbe6aa04e14d5c7d176f303c199e2bf85ea40de7.zip
chromium_src-bbe6aa04e14d5c7d176f303c199e2bf85ea40de7.tar.gz
chromium_src-bbe6aa04e14d5c7d176f303c199e2bf85ea40de7.tar.bz2
Add an AddHistoryItem() API to PyAuto with example use.
Change GetHistory time value from int to float to keep precision. BUG=none TEST=run pyautolib Review URL: http://codereview.chromium.org/2036004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/pyautolib')
-rw-r--r--chrome/test/pyautolib/pyauto.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 6438c5f..700d156 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -330,6 +330,32 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
return history_info.HistoryInfo(
self._SendJSONRequest(0, json.dumps(cmd_dict)))
+ def AddHistoryItem(self, item):
+ """Forge a history item for Chrome.
+
+ Args:
+ item: a python dictionary representing the history item. Example:
+ {
+ # URL is the only mandatory item.
+ 'url': 'http://news.google.com',
+ # Title is optional.
+ 'title': 'Google News',
+ # Time is optional; if not set, assume "now". Time is in
+ # seconds since the Epoch. The python construct to get "Now"
+ # in the right scale is "time.time()". Can be float or int.
+ 'time': 1271781612
+ }
+ """
+ cmd_dict = { # Prepare command for the json interface
+ 'command': 'AddHistoryItem',
+ 'item': item
+ }
+ if not 'url' in item:
+ raise JSONInterfaceError('must specify url')
+ ret_dict = json.loads(self._SendJSONRequest(0, json.dumps(cmd_dict)))
+ if ret_dict.has_key('error'):
+ raise JSONInterfaceError(ret_dict['error'])
+
def GetPluginsInfo(self):
"""Return info about plugins.