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

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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 _GotNewMatches(self, old_matches_len, search_text):
282 """Determines if omnibox has any new matches"""
283 new_matches = self._GetOmniboxMatchesFor(search_text)
284 if len(new_matches) > old_matches_len:
285 return True
286 return False
287
288 def testContentHisotry(self):
289 """Verify omnibox results when entering page content
290
291 Test verifies that visited page shows up in omnibox on entering page
292 content.
293 """
294 search_text = 'British throne'
295 old_matches = self._GetOmniboxMatchesFor(search_text)
296 url = self.GetFileURLForPath(
297 os.path.join(self.DataDir(), 'find_in_page', 'largepage.html'))
298 self.AppendTab(pyauto.GURL(url))
299 self.assertTrue(self.WaitUntil(lambda: self._GotNewMatches(len(old_matches),
300 search_text), timeout=1))
301 matches = self._GetOmniboxMatchesFor(search_text)
302 matches_description = [x for x in matches if x['destination_url'] == url]
303 self.assertEqual(1, len(matches_description))
304
305 def testRecentPageHistory(self):
306 """Verify that omnibox shows recent history option in the visited
307 url list."""
308 search_text = 'file'
309 sites = glob.glob(os.path.join(self.DataDir(), 'find_in_page', '*.html'))
310 for site in sites:
311 self.NavigateToURL(self.GetFileURLForPath(site))
312 old_matches = self._GetOmniboxMatchesFor(search_text)
313 # Using max timeout as 40 seconds, since expected page only shows up
314 # after 40 seconds and default timeout is less than that.
315 self.assertTrue(self.WaitUntil(
316 lambda: self._GotNewMatches(len(old_matches), search_text), timeout=40))
317 matches = self._GetOmniboxMatchesFor(search_text)
318 matches_description = [x for x in matches if x['type'] ==
319 'open-history-page']
320 self.assertEqual(1, len(matches_description))
321
280 def _VerifyHasBookmarkResult(self, matches): 322 def _VerifyHasBookmarkResult(self, matches):
281 """Verify that we have a bookmark result.""" 323 """Verify that we have a bookmark result."""
282 matches_starred = [result for result in matches if result['starred']] 324 matches_starred = [result for result in matches if result['starred']]
283 self.assertTrue(matches_starred) 325 self.assertTrue(matches_starred)
284 self.assertEqual(1, len(matches_starred)) 326 self.assertEqual(1, len(matches_starred))
285 327
286 def testBookmarkResultInNewTabAndWindow(self): 328 def testBookmarkResultInNewTabAndWindow(self):
287 """Verify that omnibox can recognize a bookmark within search options 329 """Verify that omnibox can recognize a bookmark within search options
288 in new tabs and windows.""" 330 in new tabs and windows."""
289 url = self.GetFileURLForDataPath('title2.html') 331 url = self.GetFileURLForDataPath('title2.html')
(...skipping 11 matching lines...) Expand all
301 self.NavigateToURL(url, 1, 0) 343 self.NavigateToURL(url, 1, 0)
302 self._CheckBookmarkResultForVariousInputs(url, title, windex=1) 344 self._CheckBookmarkResultForVariousInputs(url, title, windex=1)
303 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) 345 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
304 self.assertEqual(3, self.GetBrowserWindowCount()) 346 self.assertEqual(3, self.GetBrowserWindowCount())
305 self.NavigateToURL(url, 2, 0) 347 self.NavigateToURL(url, 2, 0)
306 self._CheckBookmarkResultForVariousInputs(url, title, windex=2) 348 self._CheckBookmarkResultForVariousInputs(url, title, windex=2)
307 349
308 350
309 if __name__ == '__main__': 351 if __name__ == '__main__':
310 pyauto_functional.Main() 352 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