diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-14 21:10:58 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-14 21:10:58 +0000 |
commit | 53329586a1a78bbe8052f172dea5f865dfa78c60 (patch) | |
tree | b56a208a8c88f92040392e07aafb9fab20ad066d /chrome/test/functional/omnibox.py | |
parent | 72682af437bf85a6f15c052e2c574a3fcf4433ae (diff) | |
download | chromium_src-53329586a1a78bbe8052f172dea5f865dfa78c60.zip chromium_src-53329586a1a78bbe8052f172dea5f865dfa78c60.tar.gz chromium_src-53329586a1a78bbe8052f172dea5f865dfa78c60.tar.bz2 |
Add automation hooks for fetching info about omnibox
1. Make the use of browser explicit for each json handler so that handlers
that need access to Browser* can have it. Omnibox needs it.
2. Add a simple test
TEST=python chrome/test/functional/omnibox.py
Review URL: http://codereview.chromium.org/2015010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/functional/omnibox.py')
-rw-r--r-- | chrome/test/functional/omnibox.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/chrome/test/functional/omnibox.py b/chrome/test/functional/omnibox.py new file mode 100644 index 0000000..b7797c5 --- /dev/null +++ b/chrome/test/functional/omnibox.py @@ -0,0 +1,72 @@ +#!/usr/bin/python +# Copyright (c) 2010 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os + +import pyauto_functional # Must be imported before pyauto +import pyauto + + +class OmniboxTest(pyauto.PyUITest): + """TestCase for Omnibox.""" + + def Debug(self): + """Test method for experimentation. + + This method will not run automatically. + """ + import pprint + import time + pp = pprint.PrettyPrinter(indent=2) + while True: + pp.pprint(self.GetOmniboxInfo().omniboxdict) + time.sleep(1) + + def testHistoryResult(self): + """Verify that omnibox can fetch items from history.""" + url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title2.html')) + title = 'Title Of Awesomeness' + self.AppendTab(pyauto.GURL(url)) + def _VerifyResult(query_text, description): + """Verify result matching given description for given query_text.""" + self.SetOmniboxText(query_text) + self.WaitUntilOmniboxQueryDone() + info = self.GetOmniboxInfo() + self.assertTrue(info.Matches()) + matches = info.MatchesWithAttributes({'description': description}) + self.assertTrue(matches) + self.assertEqual(1, len(matches)) + item = matches[0] + self.assertEqual(url, item['destination_url']) + # Query using URL + _VerifyResult(url, title) + # Query using title + _VerifyResult(title, title) + + def testSelect(self): + """Verify omnibox popup selection.""" + url1 = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title2.html')) + url2 = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title1.html')) + title1 = 'Title Of Awesomeness' + self.NavigateToURL(url1) + self.NavigateToURL(url2) + self.SetOmniboxText('file://') + self.WaitUntilOmniboxQueryDone() + matches = self.GetOmniboxInfo().Matches() + # Find the index of match for url1 + index = None + for i, match in enumerate(matches): + if match['description'] == title1: + index = i + self.assertTrue(index is not None) + self.OmniboxMovePopupSelection(index) # Select url1 line in popup + self.assertEqual(url1, self.GetOmniboxInfo().Text()) + self.OmniboxAcceptInput() + self.assertEqual(title1, self.GetActiveTabTitle()) + + +if __name__ == '__main__': + pyauto_functional.Main() + |