OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 index = None | 110 index = None |
111 for i, match in enumerate(matches): | 111 for i, match in enumerate(matches): |
112 if match['description'] == title1: | 112 if match['description'] == title1: |
113 index = i | 113 index = i |
114 self.assertTrue(index is not None) | 114 self.assertTrue(index is not None) |
115 self.OmniboxMovePopupSelection(index) # Select |url1| line in popup. | 115 self.OmniboxMovePopupSelection(index) # Select |url1| line in popup. |
116 self.assertEqual(url1, self.GetOmniboxInfo().Text()) | 116 self.assertEqual(url1, self.GetOmniboxInfo().Text()) |
117 self.OmniboxAcceptInput() | 117 self.OmniboxAcceptInput() |
118 self.assertEqual(title1, self.GetActiveTabTitle()) | 118 self.assertEqual(title1, self.GetActiveTabTitle()) |
119 | 119 |
120 def testGoogleSearch(self): | |
121 """Verify Google search item in omnibox results.""" | |
122 search_text = 'hello world' | |
123 verify_str = 'Google Search' | |
124 url_re = 'http://www.google.com/search\?.*q=hello\+world.*' | |
125 matches_description = test_utils.GetOmniboxMatchesFor( | |
126 self, search_text, attr_dict={'description': verify_str}) | |
127 self.assertTrue(matches_description) | |
128 # There should be a least one entry with the description Google. Suggest | |
129 # results may end up having 'Google Search' in them, so use >=. | |
130 self.assertTrue(len(matches_description) >= 1) | |
131 item = matches_description[0] | |
132 self.assertTrue(re.search(url_re, item['destination_url'])) | |
133 self.assertEqual('search-what-you-typed', item['type']) | |
134 | |
135 def testInlineAutoComplete(self): | 120 def testInlineAutoComplete(self): |
136 """Verify inline autocomplete for a pre-visited URL.""" | 121 """Verify inline autocomplete for a pre-visited URL.""" |
137 self.NavigateToURL('http://www.google.com') | 122 self.NavigateToURL('http://www.google.com') |
138 matches = test_utils.GetOmniboxMatchesFor(self, 'goog') | 123 matches = test_utils.GetOmniboxMatchesFor(self, 'goog') |
139 self.assertTrue(matches) | 124 self.assertTrue(matches) |
140 # Omnibox should suggest auto completed URL as the first item. | 125 # Omnibox should suggest auto completed URL as the first item. |
141 matches_description = matches[0] | 126 matches_description = matches[0] |
142 self.assertTrue('www.google.com' in matches_description['contents']) | 127 self.assertTrue('www.google.com' in matches_description['contents']) |
143 self.assertEqual('history-url', matches_description['type']) | 128 self.assertEqual('history-url', matches_description['type']) |
144 # The URL should be inline-autocompleted in the omnibox. | 129 # The URL should be inline-autocompleted in the omnibox. |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
520 self._VerifyAppSearchNewTab(app_name, search_str, app_url) | 505 self._VerifyAppSearchNewTab(app_name, search_str, app_url) |
521 | 506 |
522 def testBeginningPartAppNameSearchInNewTab(self): | 507 def testBeginningPartAppNameSearchInNewTab(self): |
523 """Verify that we can search app with partial app name (beginning part).""" | 508 """Verify that we can search app with partial app name (beginning part).""" |
524 app_name = 'cargo_bridge.crx' | 509 app_name = 'cargo_bridge.crx' |
525 search_str = 'Car' | 510 search_str = 'Car' |
526 app_url = 'http://webstore.limexgames.com/cargo_bridge' | 511 app_url = 'http://webstore.limexgames.com/cargo_bridge' |
527 self._VerifyAppSearchNewTab(app_name, search_str, app_url) | 512 self._VerifyAppSearchNewTab(app_name, search_str, app_url) |
528 | 513 |
529 | 514 |
515 class OmniboxLiveTest(pyauto.PyUITest): | |
516 """Test cases for the omnibox that hit live servers (such as Google).""" | |
517 | |
518 def ExtraChromeFlags(self): | |
519 """Override default list of extra flags used in pyauto tests.""" | |
520 # Force the suggest field trial group. This doesn't guarantee that there | |
521 # will be no experimental behaviour, but there's no other way to disable | |
522 # all suggest field trials at the moment. TODO(mpearson): Consider allowing | |
523 # the suggest_url to be overridden using a flag (so that we can omit the | |
524 # "sugexp=chrome,mod=<n>" CGI param), or provide some other way to turn off | |
525 # all suggest field trials. | |
526 return ['--force-fieldtrials=OmniboxSearchSuggest/0/'] | |
Mark P
2012/08/17 22:49:31
Please use group 10. That will always be a contro
sreeram
2012/08/17 22:57:33
Done.
| |
527 | |
528 def testGoogleSearch(self): | |
Mark P
2012/08/17 22:49:31
I assume you copied this function from earlier; I
sreeram
2012/08/17 22:57:33
Yup. I just moved the code from its earlier locati
| |
529 """Verify Google search item in omnibox results.""" | |
530 search_text = 'hello world' | |
531 verify_str = 'Google Search' | |
532 url_re = 'http://www.google.com/search\?.*q=hello\+world.*' | |
533 matches_description = test_utils.GetOmniboxMatchesFor( | |
534 self, search_text, attr_dict={'description': verify_str}) | |
535 self.assertTrue(matches_description) | |
536 # There should be a least one entry with the description Google. Suggest | |
537 # results may end up having 'Google Search' in them, so use >=. | |
538 self.assertTrue(len(matches_description) >= 1) | |
539 item = matches_description[0] | |
540 self.assertTrue(re.search(url_re, item['destination_url'])) | |
541 self.assertEqual('search-what-you-typed', item['type']) | |
542 | |
543 | |
530 if __name__ == '__main__': | 544 if __name__ == '__main__': |
531 pyauto_functional.Main() | 545 pyauto_functional.Main() |
OLD | NEW |