OLD | NEW |
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 glob |
7 import os | 7 import os |
8 import re | 8 import re |
9 import shutil | 9 import shutil |
10 import tempfile | 10 import tempfile |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 old_matches = self._GetOmniboxMatchesFor(search_text) | 300 old_matches = self._GetOmniboxMatchesFor(search_text) |
301 url = self.GetFileURLForPath( | 301 url = self.GetFileURLForPath( |
302 os.path.join(self.DataDir(), 'find_in_page', 'largepage.html')) | 302 os.path.join(self.DataDir(), 'find_in_page', 'largepage.html')) |
303 self.AppendTab(pyauto.GURL(url)) | 303 self.AppendTab(pyauto.GURL(url)) |
304 self.assertTrue(self.WaitUntil(lambda: self._GotNewMatches(len(old_matches), | 304 self.assertTrue(self.WaitUntil(lambda: self._GotNewMatches(len(old_matches), |
305 search_text), timeout=1)) | 305 search_text), timeout=1)) |
306 matches = self._GetOmniboxMatchesFor(search_text) | 306 matches = self._GetOmniboxMatchesFor(search_text) |
307 matches_description = [x for x in matches if x['destination_url'] == url] | 307 matches_description = [x for x in matches if x['destination_url'] == url] |
308 self.assertEqual(1, len(matches_description)) | 308 self.assertEqual(1, len(matches_description)) |
309 | 309 |
| 310 def _GotHistoryPageOption(self, search_text): |
| 311 """Determines if omnibox returns an 'open history page' option for given |
| 312 search text""" |
| 313 matches = self._GetOmniboxMatchesFor(search_text) |
| 314 matches_description = [x for x in matches if x['type'] == |
| 315 'open-history-page'] |
| 316 return len(matches_description) != 0 |
| 317 |
310 def testRecentPageHistory(self): | 318 def testRecentPageHistory(self): |
311 """Verify that omnibox shows recent history option in the visited | 319 """Verify that omnibox shows recent history option in the visited |
312 url list.""" | 320 url list.""" |
313 search_text = 'file' | 321 search_text = 'file' |
314 sites = glob.glob(os.path.join(self.DataDir(), 'find_in_page', '*.html')) | 322 sites = glob.glob(os.path.join(self.DataDir(), 'find_in_page', '*.html')) |
315 for site in sites: | 323 for site in sites: |
316 self.NavigateToURL(self.GetFileURLForPath(site)) | 324 self.NavigateToURL(self.GetFileURLForPath(site)) |
317 old_matches = self._GetOmniboxMatchesFor(search_text) | |
318 # Using max timeout as 120 seconds, since expected page only shows up | 325 # Using max timeout as 120 seconds, since expected page only shows up |
319 # after > 60 seconds on some machines and default timeout is less than that. | 326 # after > 60 seconds on some machines and default timeout is less than that. |
320 # TODO (Nirnimesh): design an api using which we can push history changes to | 327 # TODO (Nirnimesh): design an api using which we can push history changes to |
321 # omnibox results. | 328 # omnibox results. |
322 self.assertTrue(self.WaitUntil( | 329 self.assertTrue(self.WaitUntil( |
323 lambda: self._GotNewMatches(len(old_matches), search_text), | 330 lambda: self._GotHistoryPageOption(search_text), |
324 timeout=120)) | 331 timeout=120)) |
325 matches = self._GetOmniboxMatchesFor(search_text) | |
326 matches_description = [x for x in matches if x['type'] == | |
327 'open-history-page'] | |
328 self.assertEqual(1, len(matches_description)) | |
329 | 332 |
330 def _VerifyHasBookmarkResult(self, matches): | 333 def _VerifyHasBookmarkResult(self, matches): |
331 """Verify that we have a bookmark result.""" | 334 """Verify that we have a bookmark result.""" |
332 matches_starred = [result for result in matches if result['starred']] | 335 matches_starred = [result for result in matches if result['starred']] |
333 self.assertTrue(matches_starred) | 336 self.assertTrue(matches_starred) |
334 self.assertEqual(1, len(matches_starred)) | 337 self.assertEqual(1, len(matches_starred)) |
335 | 338 |
336 def testBookmarkResultInNewTabAndWindow(self): | 339 def testBookmarkResultInNewTabAndWindow(self): |
337 """Verify that omnibox can recognize a bookmark within search options | 340 """Verify that omnibox can recognize a bookmark within search options |
338 in new tabs and windows.""" | 341 in new tabs and windows.""" |
(...skipping 12 matching lines...) Expand all Loading... |
351 self.NavigateToURL(url, 1, 0) | 354 self.NavigateToURL(url, 1, 0) |
352 self._CheckBookmarkResultForVariousInputs(url, title, windex=1) | 355 self._CheckBookmarkResultForVariousInputs(url, title, windex=1) |
353 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) | 356 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
354 self.assertEqual(3, self.GetBrowserWindowCount()) | 357 self.assertEqual(3, self.GetBrowserWindowCount()) |
355 self.NavigateToURL(url, 2, 0) | 358 self.NavigateToURL(url, 2, 0) |
356 self._CheckBookmarkResultForVariousInputs(url, title, windex=2) | 359 self._CheckBookmarkResultForVariousInputs(url, title, windex=2) |
357 | 360 |
358 | 361 |
359 if __name__ == '__main__': | 362 if __name__ == '__main__': |
360 pyauto_functional.Main() | 363 pyauto_functional.Main() |
OLD | NEW |