| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 # Check if the partial URL would get the bookmark. | 271 # Check if the partial URL would get the bookmark. |
| 272 split_url = urlparse.urlsplit(url) | 272 split_url = urlparse.urlsplit(url) |
| 273 partial_url = self._GetOmniboxMatchesFor(split_url.scheme, windex=windex) | 273 partial_url = self._GetOmniboxMatchesFor(split_url.scheme, windex=windex) |
| 274 self._VerifyHasBookmarkResult(partial_url) | 274 self._VerifyHasBookmarkResult(partial_url) |
| 275 # Check if the partial title would get the bookmark. | 275 # Check if the partial title would get the bookmark. |
| 276 split_title = title.split() | 276 split_title = title.split() |
| 277 search_term = split_title[len(split_title) - 1] | 277 search_term = split_title[len(split_title) - 1] |
| 278 partial_title = self._GetOmniboxMatchesFor(search_term, windex=windex) | 278 partial_title = self._GetOmniboxMatchesFor(search_term, windex=windex) |
| 279 self._VerifyHasBookmarkResult(partial_title) | 279 self._VerifyHasBookmarkResult(partial_title) |
| 280 | 280 |
| 281 def _GotNewMatches(self, old_matches_len, search_text): | 281 def _GotContentHistory(self, search_text, url): |
| 282 """Determines if omnibox has any new matches""" | 282 """Determines if omnibox returns a previously visited page for given |
| 283 search text |
| 284 """ |
| 283 # Omnibox doesn't change results if searching the same text repeatedly. | 285 # Omnibox doesn't change results if searching the same text repeatedly. |
| 284 # So setting '' in omnibox before the next repeated search. | 286 # So setting '' in omnibox before the next repeated search. |
| 285 self.SetOmniboxText('') | 287 self.SetOmniboxText('') |
| 286 new_matches = self._GetOmniboxMatchesFor(search_text) | 288 matches = self._GetOmniboxMatchesFor(search_text) |
| 287 if len(new_matches) > old_matches_len: | 289 matches_description = [x for x in matches if x['destination_url'] == url] |
| 288 return True | 290 return 1 == len(matches_description) |
| 289 return False | |
| 290 | 291 |
| 291 def testContentHistory(self): | 292 def testContentHistory(self): |
| 292 """Verify omnibox results when entering page content | 293 """Verify omnibox results when entering page content |
| 293 | 294 |
| 294 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 |
| 295 content. | 296 content. |
| 296 """ | 297 """ |
| 297 search_text = 'British throne' | |
| 298 old_matches = self._GetOmniboxMatchesFor(search_text) | |
| 299 url = self.GetFileURLForPath( | 298 url = self.GetFileURLForPath( |
| 300 os.path.join(self.DataDir(), 'find_in_page', 'largepage.html')) | 299 os.path.join(self.DataDir(), 'find_in_page', 'largepage.html')) |
| 301 self.AppendTab(pyauto.GURL(url)) | 300 self.NavigateToURL(url) |
| 302 self.assertTrue(self.WaitUntil(lambda: self._GotNewMatches(len(old_matches), | 301 self.assertTrue(self.WaitUntil( |
| 303 search_text), timeout=1)) | 302 lambda: self._GotContentHistory('British throne', url))) |
| 304 matches = self._GetOmniboxMatchesFor(search_text) | |
| 305 matches_description = [x for x in matches if x['destination_url'] == url] | |
| 306 self.assertEqual(1, len(matches_description)) | |
| 307 | 303 |
| 308 def _GotHistoryPageOption(self, search_text): | 304 def _GotHistoryPageOption(self, search_text): |
| 309 """Determines if omnibox returns an 'open history page' option for given | 305 """Determines if omnibox returns an 'open history page' option for given |
| 310 search text""" | 306 search text""" |
| 311 # Omnibox doesn't change results if searching the same text repeatedly. | 307 # Omnibox doesn't change results if searching the same text repeatedly. |
| 312 # So setting '' in omnibox before the next repeated search. | 308 # So setting '' in omnibox before the next repeated search. |
| 313 self.SetOmniboxText('') | 309 self.SetOmniboxText('') |
| 314 matches = self._GetOmniboxMatchesFor(search_text) | 310 matches = self._GetOmniboxMatchesFor(search_text) |
| 315 matches_description = [x for x in matches if x['type'] == | 311 matches_description = [x for x in matches if x['type'] == |
| 316 'open-history-page'] | 312 'open-history-page'] |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 self.NavigateToURL(url, 1, 0) | 351 self.NavigateToURL(url, 1, 0) |
| 356 self._CheckBookmarkResultForVariousInputs(url, title, windex=1) | 352 self._CheckBookmarkResultForVariousInputs(url, title, windex=1) |
| 357 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) | 353 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
| 358 self.assertEqual(3, self.GetBrowserWindowCount()) | 354 self.assertEqual(3, self.GetBrowserWindowCount()) |
| 359 self.NavigateToURL(url, 2, 0) | 355 self.NavigateToURL(url, 2, 0) |
| 360 self._CheckBookmarkResultForVariousInputs(url, title, windex=2) | 356 self._CheckBookmarkResultForVariousInputs(url, title, windex=2) |
| 361 | 357 |
| 362 | 358 |
| 363 if __name__ == '__main__': | 359 if __name__ == '__main__': |
| 364 pyauto_functional.Main() | 360 pyauto_functional.Main() |
| OLD | NEW |