Chromium Code Reviews| 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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 _GotNewMatches(self, old_matches_len, search_text): |
| 282 """Determines if omnibox has any new matches""" | 282 """Determines if omnibox has any new matches""" |
| 283 # On Windows, omnibox doesn't change results if searching the same text | 283 # On Windows, omnibox doesn't change results if searching the same text |
|
Nirnimesh
2011/01/07 22:05:51
and fix this comment
| |
| 284 # repeatedly. So setting '' in omnibox before any search for non-Mac | 284 # repeatedly. So setting '' in omnibox before any search for non-Mac |
| 285 # platforms. | 285 # platforms. |
| 286 if not self.IsMac(): | 286 if not self.IsMac(): |
|
sunandt
2011/01/07 21:41:51
To be consistent, I think you should remove the ch
Nirnimesh
2011/01/07 22:05:51
+1
| |
| 287 self.SetOmniboxText('') | 287 self.SetOmniboxText('') |
| 288 new_matches = self._GetOmniboxMatchesFor(search_text) | 288 new_matches = self._GetOmniboxMatchesFor(search_text) |
| 289 if len(new_matches) > old_matches_len: | 289 if len(new_matches) > old_matches_len: |
| 290 return True | 290 return True |
| 291 return False | 291 return False |
| 292 | 292 |
| 293 def testContentHistory(self): | 293 def testContentHistory(self): |
| 294 """Verify omnibox results when entering page content | 294 """Verify omnibox results when entering page content |
| 295 | 295 |
| 296 Test verifies that visited page shows up in omnibox on entering page | 296 Test verifies that visited page shows up in omnibox on entering page |
| 297 content. | 297 content. |
| 298 """ | 298 """ |
| 299 search_text = 'British throne' | 299 search_text = 'British throne' |
| 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): | 310 def _GotHistoryPageOption(self, search_text): |
| 311 """Determines if omnibox returns an 'open history page' option for given | 311 """Determines if omnibox returns an 'open history page' option for given |
| 312 search text""" | 312 search text""" |
| 313 if not self.IsMac(): | |
|
Nirnimesh
2011/01/07 21:03:03
why not do this even on Mac?
| |
| 314 self.SetOmniboxText('') | |
|
Nirnimesh
2011/01/07 22:05:51
add a comment here
| |
| 313 matches = self._GetOmniboxMatchesFor(search_text) | 315 matches = self._GetOmniboxMatchesFor(search_text) |
| 314 matches_description = [x for x in matches if x['type'] == | 316 matches_description = [x for x in matches if x['type'] == |
| 315 'open-history-page'] | 317 'open-history-page'] |
| 316 return len(matches_description) != 0 | 318 return len(matches_description) != 0 |
| 317 | 319 |
| 318 def testRecentPageHistory(self): | 320 def testRecentPageHistory(self): |
| 319 """Verify that omnibox shows recent history option in the visited | 321 """Verify that omnibox shows recent history option in the visited |
| 320 url list.""" | 322 url list.""" |
| 321 search_text = 'file' | 323 search_text = 'file' |
| 322 sites = glob.glob(os.path.join(self.DataDir(), 'find_in_page', '*.html')) | 324 sites = glob.glob(os.path.join(self.DataDir(), 'find_in_page', '*.html')) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 self.NavigateToURL(url, 1, 0) | 356 self.NavigateToURL(url, 1, 0) |
| 355 self._CheckBookmarkResultForVariousInputs(url, title, windex=1) | 357 self._CheckBookmarkResultForVariousInputs(url, title, windex=1) |
| 356 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) | 358 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
| 357 self.assertEqual(3, self.GetBrowserWindowCount()) | 359 self.assertEqual(3, self.GetBrowserWindowCount()) |
| 358 self.NavigateToURL(url, 2, 0) | 360 self.NavigateToURL(url, 2, 0) |
| 359 self._CheckBookmarkResultForVariousInputs(url, title, windex=2) | 361 self._CheckBookmarkResultForVariousInputs(url, title, windex=2) |
| 360 | 362 |
| 361 | 363 |
| 362 if __name__ == '__main__': | 364 if __name__ == '__main__': |
| 363 pyauto_functional.Main() | 365 pyauto_functional.Main() |
| OLD | NEW |