| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import re | 7 import re |
| 8 | 8 |
| 9 import pyauto_functional # Must be imported before pyauto | 9 import pyauto_functional # Must be imported before pyauto |
| 10 import pyauto | 10 import pyauto |
| 11 import test_utils |
| 11 | 12 |
| 12 | 13 |
| 13 class SearchEnginesTest(pyauto.PyUITest): | 14 class SearchEnginesTest(pyauto.PyUITest): |
| 14 """TestCase for Search Engines.""" | 15 """TestCase for Search Engines.""" |
| 15 | 16 |
| 16 _localhost_prefix = 'http://localhost:1000/' | 17 _localhost_prefix = 'http://localhost:1000/' |
| 17 | 18 |
| 18 def _GetSearchEngineWithKeyword(self, keyword): | 19 def _GetSearchEngineWithKeyword(self, keyword): |
| 19 """Get search engine info and return an element that matches keyword. | 20 """Get search engine info and return an element that matches keyword. |
| 20 | 21 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 43 | 44 |
| 44 def testDiscoverSearchEngine(self): | 45 def testDiscoverSearchEngine(self): |
| 45 """Test that chrome discovers youtube search engine after searching.""" | 46 """Test that chrome discovers youtube search engine after searching.""" |
| 46 # Take a snapshot of current search engine info. | 47 # Take a snapshot of current search engine info. |
| 47 info = self.GetSearchEngineInfo() | 48 info = self.GetSearchEngineInfo() |
| 48 youtube = self._GetSearchEngineWithKeyword('youtube.com') | 49 youtube = self._GetSearchEngineWithKeyword('youtube.com') |
| 49 self.assertFalse(youtube) | 50 self.assertFalse(youtube) |
| 50 # Use omnibox to invoke search engine discovery. | 51 # Use omnibox to invoke search engine discovery. |
| 51 # Navigating using NavigateToURL does not currently invoke this logic. | 52 # Navigating using NavigateToURL does not currently invoke this logic. |
| 52 self.SetOmniboxText('http://www.youtube.com') | 53 self.SetOmniboxText('http://www.youtube.com') |
| 53 self.OmniboxAcceptInput() | 54 # Due to slow navigation to youtube.com on Leopard test machines, waiting |
| 55 # here 1 min (max). |
| 56 test_utils.CallFunctionWithNewTimeout(self, 1 * 60 * 1000, |
| 57 self.OmniboxAcceptInput) |
| 54 def InfoUpdated(old_info): | 58 def InfoUpdated(old_info): |
| 55 new_info = self.GetSearchEngineInfo() | 59 new_info = self.GetSearchEngineInfo() |
| 56 if len(new_info) > len(old_info): | 60 if len(new_info) > len(old_info): |
| 57 return True | 61 return True |
| 58 return False | 62 return False |
| 59 self.WaitUntil(lambda: InfoUpdated(info)) | 63 self.WaitUntil(lambda: InfoUpdated(info)) |
| 60 youtube = self._GetSearchEngineWithKeyword('youtube.com') | 64 youtube = self._GetSearchEngineWithKeyword('youtube.com') |
| 61 self.assertTrue(youtube) | 65 self.assertTrue(youtube) |
| 62 self.assertTrue(re.search('youtube', youtube['short_name'], | 66 self.assertTrue(re.search('youtube', youtube['short_name'], |
| 63 re.IGNORECASE)) | 67 re.IGNORECASE)) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 self.assertEqual(self._localhost_prefix + '?edited=true&q=foobar', | 181 self.assertEqual(self._localhost_prefix + '?edited=true&q=foobar', |
| 178 self.GetActiveTabURL().spec()) | 182 self.GetActiveTabURL().spec()) |
| 179 # Delete a search engine. | 183 # Delete a search engine. |
| 180 self.assertTrue(self._GetSearchEngineWithKeyword('testspecial@!%^*#.com')) | 184 self.assertTrue(self._GetSearchEngineWithKeyword('testspecial@!%^*#.com')) |
| 181 self.DeleteSearchEngine('testspecial@!%^*#.com') | 185 self.DeleteSearchEngine('testspecial@!%^*#.com') |
| 182 self.assertFalse(self._GetSearchEngineWithKeyword('testspecial@!%^*#.com')) | 186 self.assertFalse(self._GetSearchEngineWithKeyword('testspecial@!%^*#.com')) |
| 183 | 187 |
| 184 | 188 |
| 185 if __name__ == '__main__': | 189 if __name__ == '__main__': |
| 186 pyauto_functional.Main() | 190 pyauto_functional.Main() |
| OLD | NEW |