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

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 68518)
+++ omnibox.py (working copy)
@@ -7,6 +7,7 @@
import re
import shutil
import tempfile
+import urlparse
import pyauto_functional # Must be imported before pyauto
import pyauto
@@ -213,6 +214,54 @@
# Verify there are no suggest results
self.assertFalse([x for x in matches if x['type'] == 'search-suggest'])
+ def _CheckBookmarkResultForVariousInputs(self, url, title, windex=0):
+ """Check if we get the Bookmark for complete and partial inputs."""
+ # Check if the complete URL would get the bookmark
+ url_matches = self._GetOmniboxMatchesFor(url, windex=windex)
+ self._VerifyHasBookmarkResult(url_matches)
+ # Check if the complete title would get the bookmark
+ title_matches = self._GetOmniboxMatchesFor(title, windex=windex)
+ self._VerifyHasBookmarkResult(title_matches)
+ # Check if the partial URL would get the bookmark
+ split_url = urlparse.urlsplit(url)
+ search_term = split_url.path
+ partial_url = self._GetOmniboxMatchesFor(search_term, windex=windex)
+ self._VerifyHasBookmarkResult(partial_url)
+ # Check if the partial title would get the bookmark
+ split_title = title.split()
+ search_term = split_title[len(split_title) - 1]
+ partial_title = self._GetOmniboxMatchesFor(search_term, windex=windex)
+ self._VerifyHasBookmarkResult(partial_title)
+ def _VerifyHasBookmarkResult(self, matches):
+ """Verify that we have a bookmark result."""
+ matches_starred = [result for result in matches if result['starred']]
+ self.assertTrue(matches_starred)
+ self.assertEqual(1, len(matches_starred))
+
+ def testBookmarkResultInNewTabAndWindow(self):
+ """Verify that omnibox can recognize bookmark in the search options
+ in new tabs and Windows.
+ """
+ url = self.GetFileURLForDataPath('title2.html')
+ self.NavigateToURL(url)
+ title = 'This is Awesomeness'
+ bookmarks = self.GetBookmarkModel()
+ bar_id = bookmarks.BookmarkBar()['id']
+ self.AddBookmarkURL(bar_id, 0, title, url)
+ bookmarks = self.GetBookmarkModel()
+ nodes = bookmarks.FindByTitle(title)
+ self.AppendTab(pyauto.GURL(url))
+ self._CheckBookmarkResultForVariousInputs(url, title)
+ self.OpenNewBrowserWindow(True)
+ self.assertEqual(2, self.GetBrowserWindowCount())
+ self.NavigateToURL(url, 1, 0)
+ self._CheckBookmarkResultForVariousInputs(url, title, windex=1)
+ self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
+ self.assertEqual(3, self.GetBrowserWindowCount())
+ self.NavigateToURL(url, 2, 0)
+ self._CheckBookmarkResultForVariousInputs(url, title, windex=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