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

Side by Side Diff: functional/omnibox.py

Issue 5115007: Omnibox tests for,... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import glob
6 import os 7 import os
7 import re 8 import re
8 import shutil 9 import shutil
9 import tempfile 10 import tempfile
10 import urlparse 11 import urlparse
11 12
12 import pyauto_functional # Must be imported before pyauto 13 import pyauto_functional # Must be imported before pyauto
13 import pyauto 14 import pyauto
14 15
15 16
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 matches = self._GetOmniboxMatchesFor(search_string) 243 matches = self._GetOmniboxMatchesFor(search_string)
243 self.assertTrue(matches) 244 self.assertTrue(matches)
244 self.assertTrue([x for x in matches if x['type'] == 'search-suggest']) 245 self.assertTrue([x for x in matches if x['type'] == 'search-suggest'])
245 # Disable suggest-service 246 # Disable suggest-service
246 self.SetPrefs(pyauto.kSearchSuggestEnabled, False) 247 self.SetPrefs(pyauto.kSearchSuggestEnabled, False)
247 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kSearchSuggestEnabled)) 248 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kSearchSuggestEnabled))
248 matches = self._GetOmniboxMatchesFor(search_string) 249 matches = self._GetOmniboxMatchesFor(search_string)
249 self.assertTrue(matches) 250 self.assertTrue(matches)
250 # Verify there are no suggest results 251 # Verify there are no suggest results
251 self.assertFalse([x for x in matches if x['type'] == 'search-suggest']) 252 self.assertFalse([x for x in matches if x['type'] == 'search-suggest'])
252 253
Nirnimesh 2010/12/22 21:56:10 I still see this stray space char
253 def testAutoCompleteForSearch(self): 254 def testAutoCompleteForSearch(self):
254 """Verify omnibox autocomplete for search.""" 255 """Verify omnibox autocomplete for search."""
255 search_string = 'barac' 256 search_string = 'barac'
256 verify_string = 'barack' 257 verify_string = 'barack'
257 matches = self._GetOmniboxMatchesFor(search_string) 258 matches = self._GetOmniboxMatchesFor(search_string)
258 # retrieve last contents element. 259 # retrieve last contents element.
259 matches_description = matches[-1]['contents'].split() 260 matches_description = matches[-1]['contents'].split()
260 self.assertEqual(verify_string, matches_description[0]) 261 self.assertEqual(verify_string, matches_description[0])
261 262
262 def _CheckBookmarkResultForVariousInputs(self, url, title, windex=0): 263 def _CheckBookmarkResultForVariousInputs(self, url, title, windex=0):
263 """Check if we get the Bookmark for complete and partial inputs.""" 264 """Check if we get the Bookmark for complete and partial inputs."""
264 # Check if the complete URL would get the bookmark. 265 # Check if the complete URL would get the bookmark.
265 url_matches = self._GetOmniboxMatchesFor(url, windex=windex) 266 url_matches = self._GetOmniboxMatchesFor(url, windex=windex)
266 self._VerifyHasBookmarkResult(url_matches) 267 self._VerifyHasBookmarkResult(url_matches)
267 # Check if the complete title would get the bookmark. 268 # Check if the complete title would get the bookmark.
268 title_matches = self._GetOmniboxMatchesFor(title, windex=windex) 269 title_matches = self._GetOmniboxMatchesFor(title, windex=windex)
269 self._VerifyHasBookmarkResult(title_matches) 270 self._VerifyHasBookmarkResult(title_matches)
270 # Check if the partial URL would get the bookmark. 271 # Check if the partial URL would get the bookmark.
271 split_url = urlparse.urlsplit(url) 272 split_url = urlparse.urlsplit(url)
272 partial_url = self._GetOmniboxMatchesFor(split_url.scheme, windex=windex) 273 partial_url = self._GetOmniboxMatchesFor(split_url.scheme, windex=windex)
273 self._VerifyHasBookmarkResult(partial_url) 274 self._VerifyHasBookmarkResult(partial_url)
274 # Check if the partial title would get the bookmark. 275 # Check if the partial title would get the bookmark.
275 split_title = title.split() 276 split_title = title.split()
276 search_term = split_title[len(split_title) - 1] 277 search_term = split_title[len(split_title) - 1]
277 partial_title = self._GetOmniboxMatchesFor(search_term, windex=windex) 278 partial_title = self._GetOmniboxMatchesFor(search_term, windex=windex)
278 self._VerifyHasBookmarkResult(partial_title) 279 self._VerifyHasBookmarkResult(partial_title)
279 280
281 def _CheckMatches(self, old_matches_len, search_text):
282 """Compares omnibox results new count with old one. If new count is greater
Nirnimesh 2010/12/22 21:56:10 Remove the 2nd line, the code explains that. Rena
283 than old_matches_len, returns True else False."""
284 new_matches = self._GetOmniboxMatchesFor(search_text)
285 if len(new_matches) > old_matches_len:
286 return True
287 return False
288
289 def testContentHisotry(self):
290 """Verify omnibox results when entering page content
291
292 Test verifies that visited page shows up in omnibox on entering page
293 content.
294 """
295 search_text = 'British throne'
296 old_matches = self._GetOmniboxMatchesFor(search_text)
297 url = self.GetFileURLForPath(
298 os.path.join(self.DataDir(), 'find_in_page', 'largepage.html'))
299 self.AppendTab(pyauto.GURL(url))
300 self.assertTrue(self.WaitUntil(lambda: self._CheckMatches(len(old_matches),
301 search_text), timeout=1))
302 matches = self._GetOmniboxMatchesFor(search_text)
303 matches_description = [x for x in matches if x['destination_url'] == url]
304 self.assertEqual(1, len(matches_description))
305
306 def testRecentPageHistory(self):
307 """Verify that omnibox shows recent history option in the visited
308 url list."""
309 search_text = 'file'
310 sites = glob.glob(os.path.join(self.DataDir(), 'find_in_page', '*.html'))
311 for site in sites:
312 self.NavigateToURL(self.GetFileURLForPath(site))
313 old_matches = self._GetOmniboxMatchesFor(search_text)
314 # Using max timeout as 40 seconds, since expected page only shows up
315 # after 40 seconds and default timeout is less than that.
316 self.assertTrue(self.WaitUntil(lambda: self._CheckMatches(len(old_matches),
Nirnimesh 2010/12/22 21:56:10 move lambda to next line, indented by 4 spaces onl
317 search_text), timeout=40))
318 matches = self._GetOmniboxMatchesFor(search_text)
319 matches_description = [x for x in matches if x['type'] ==
320 'open-history-page']
321 self.assertEqual(1, len(matches_description))
322
280 def _VerifyHasBookmarkResult(self, matches): 323 def _VerifyHasBookmarkResult(self, matches):
281 """Verify that we have a bookmark result.""" 324 """Verify that we have a bookmark result."""
282 matches_starred = [result for result in matches if result['starred']] 325 matches_starred = [result for result in matches if result['starred']]
283 self.assertTrue(matches_starred) 326 self.assertTrue(matches_starred)
284 self.assertEqual(1, len(matches_starred)) 327 self.assertEqual(1, len(matches_starred))
285 328
286 def testBookmarkResultInNewTabAndWindow(self): 329 def testBookmarkResultInNewTabAndWindow(self):
287 """Verify that omnibox can recognize a bookmark within search options 330 """Verify that omnibox can recognize a bookmark within search options
288 in new tabs and windows.""" 331 in new tabs and windows."""
289 url = self.GetFileURLForDataPath('title2.html') 332 url = self.GetFileURLForDataPath('title2.html')
(...skipping 11 matching lines...) Expand all
301 self.NavigateToURL(url, 1, 0) 344 self.NavigateToURL(url, 1, 0)
302 self._CheckBookmarkResultForVariousInputs(url, title, windex=1) 345 self._CheckBookmarkResultForVariousInputs(url, title, windex=1)
303 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) 346 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
304 self.assertEqual(3, self.GetBrowserWindowCount()) 347 self.assertEqual(3, self.GetBrowserWindowCount())
305 self.NavigateToURL(url, 2, 0) 348 self.NavigateToURL(url, 2, 0)
306 self._CheckBookmarkResultForVariousInputs(url, title, windex=2) 349 self._CheckBookmarkResultForVariousInputs(url, title, windex=2)
307 350
308 351
309 if __name__ == '__main__': 352 if __name__ == '__main__':
310 pyauto_functional.Main() 353 pyauto_functional.Main()
OLDNEW
« 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