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