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

Unified Diff: omnibox.py

Issue 5666001: Adding tests for bookmark search in omnibox (Closed) Base URL: http://src.chromium.org/svn/trunk/src/chrome/test/functional/
Patch Set: Created 10 years 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: omnibox.py
===================================================================
--- omnibox.py (revision 68501)
+++ omnibox.py (working copy)
@@ -52,6 +52,16 @@
attr_dict=attr_dict)
return matches
+ def _AddBookmark(self, url, title):
Nirnimesh 2010/12/09 00:52:21 Move this closer to where it's actually used
deepakg 2010/12/09 01:59:50 Done.
+ """Adds a new bookmark with the given URL and title."""
+ bookmarks = self.GetBookmarkModel()
+ bar_id = bookmarks.BookmarkBar()['id']
+ self.AddBookmarkURL(bar_id, 0, title, url)
+ bookmarks = self.GetBookmarkModel()
+ nodes = bookmarks.FindByTitle(title)
+ self.assertEqual(1, len(nodes))
Nirnimesh 2010/12/09 00:52:21 Remove the asserts
deepakg 2010/12/09 01:59:50 Done.
+ self.assertTrue(nodes[0]['name'] == title)
+
def testHistoryResult(self):
"""Verify that omnibox can fetch items from history."""
url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title2.html'))
@@ -213,6 +223,60 @@
# Verify there are no suggest results
self.assertFalse([x for x in matches if x['type'] == 'search-suggest'])
+ def _CheckBookmarkResultForVariousInputs(self, url, title, windex):
+ """Check if we get the Bookmark for complete and partial inputs."""
+ # Check if the complete URL would get the bookmark
+ urlMatches = self._GetOmniboxMatchesFor(url, windex)
Nirnimesh 2010/12/09 00:52:21 use named arg wherever possible. windex=windex
Nirnimesh 2010/12/09 00:52:21 camelCase var names not allowed. rename: url_match
deepakg 2010/12/09 01:59:50 Done.
deepakg 2010/12/09 01:59:50 Done.
+ self._CheckIfBookmarkMatches(urlMatches)
+ # Check if the complete title would get the bookmark
+ titleMatches = self._GetOmniboxMatchesFor(title, windex)
Nirnimesh 2010/12/09 00:52:21 use named arg windex=windex
deepakg 2010/12/09 01:59:50 Done.
+ self._CheckIfBookmarkMatches(titleMatches)
+ # Check if the partial URL would get the bookmark
+ split_url = url.split('/')
Nirnimesh 2010/12/09 00:52:21 use split* family of functions in urllib
deepakg 2010/12/09 01:59:50 Done. Have done this but urlparse.urlsplit would
+ term = split_url[len(split_url) - 1]
+ search_term = term.split('.') # we don't need the .html extension
+ partialURL = self._GetOmniboxMatchesFor(search_term[0], windex)
Nirnimesh 2010/12/09 00:52:21 use named arg windex=windex
deepakg 2010/12/09 01:59:50 Done.
+ self._CheckIfBookmarkMatches(partialURL)
+ # Check if the partial title would get the bookmark
+ split_title = title.split()
+ search_term = split_title[len(split_title) -1]
Nirnimesh 2010/12/09 00:52:21 need space after -
deepakg 2010/12/09 01:59:50 Done.
+ partialTitle = self._GetOmniboxMatchesFor(search_term, windex)
Nirnimesh 2010/12/09 00:52:21 use named arg windex=windex
deepakg 2010/12/09 01:59:50 Done.
+ self._CheckIfBookmarkMatches(partialTitle)
+ def _CheckIfBookmarkMatches(self, matches):
Nirnimesh 2010/12/09 00:52:21 Rename: _VerifyHasBookmarkResult
deepakg 2010/12/09 01:59:50 Done.
+ """Verify that the Omnibox options have the bookmark."""
Nirnimesh 2010/12/09 00:52:21 Verify that we have a bookmark result
deepakg 2010/12/09 01:59:50 Done.
+ matches_starred = [result for result in matches if result['starred']]
+ self.assertTrue(matches_starred)
+ self.assertEqual(1, len(matches_starred))
+
+ def testBookmarkResultInNewTab(self):
+ """Verify that omnibox can recognize bookmark in the search options
+ for multiple tabs.
+ """
+ url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title2.html'))
Nirnimesh 2010/12/09 00:52:21 use self.GetFileURLForDataPath('title2.html')
deepakg 2010/12/09 01:59:50 Done.
+ self.NavigateToURL(url)
+ title = 'This is Awesomeness'
+ self._AddBookmark(url, title)
+ # Check in a new tab
+ self.AppendTab(pyauto.GURL(url))
+ self._CheckBookmarkResultForVariousInputs(url, title, 0)
Nirnimesh 2010/12/09 00:52:21 use named arg. tab_index=0
deepakg 2010/12/09 01:59:50 Done.
+
+ def testBookmarkResultInNewWindow(self):
Nirnimesh 2010/12/09 00:52:21 Most of this test is similar to the last one. Mer
deepakg 2010/12/09 01:59:50 Done.
+ """Verify the bookmarks title are found in a normal and
+ incognito window.
+ """
+ url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title2.html'))
+ title = 'This is Awesomeness'
+ self._AddBookmark(url, title)
+ self.OpenNewBrowserWindow(True)
+ self.assertEqual(2, self.GetBrowserWindowCount())
+ self.NavigateToURL(url, 1, 0)
+ self._CheckBookmarkResultForVariousInputs(url, title, 1)
+ self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
+ self.assertEqual(3, self.GetBrowserWindowCount())
+ self.NavigateToURL(url, 2, 0)
+ self._CheckBookmarkResultForVariousInputs(url, title, 2)
+
+
if __name__ == '__main__':
pyauto_functional.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