| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 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 cgi | 7 import cgi |
| 8 import os | 8 import os |
| 9 | 9 |
| 10 import pyauto_functional # Must be imported before pyauto | 10 import pyauto_functional # Must be imported before pyauto |
| 11 import pyauto | 11 import pyauto |
| 12 | 12 |
| 13 | 13 |
| 14 class InstantSettingsTest(pyauto.PyUITest): | 14 class InstantSettingsTest(pyauto.PyUITest): |
| 15 """Test Chrome Instant settings.""" | 15 """Test Chrome Instant settings.""" |
| 16 | 16 |
| 17 def testEnableDisableInstant(self): | 17 def testEnableDisableInstant(self): |
| 18 """Test to verify default Chrome Instant setting. | 18 """Test to verify default Chrome Instant setting. |
| 19 Check if the setting can be enabled and disabled.""" | 19 Check if the setting can be enabled and disabled.""" |
| 20 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kInstantEnabled), | 20 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kInstantEnabled), |
| 21 msg='Instant is enabled by default.') | 21 msg='Instant is enabled by default.') |
| 22 # Enable instant. | 22 # Enable instant. |
| 23 self.SetPrefs(pyauto.kInstantEnabled, True) | 23 self.SetPrefs(pyauto.kInstantEnabled, True) |
| 24 self.SetPrefs(pyauto.kInstantEnabledOnce, True) | |
| 25 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kInstantEnabled), | 24 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kInstantEnabled), |
| 26 msg='Instant is not enabled.') | 25 msg='Instant is not enabled.') |
| 27 self.SetOmniboxText('google.com') | 26 self.SetOmniboxText('google.com') |
| 28 self.assertTrue(self.WaitUntil( | 27 self.assertTrue(self.WaitUntil( |
| 29 lambda: self.GetInstantInfo().get('current') and not | 28 lambda: self.GetInstantInfo().get('current') and not |
| 30 self.GetInstantInfo().get('loading'))) | 29 self.GetInstantInfo().get('loading'))) |
| 31 title = self.GetInstantInfo()['title'] | 30 title = self.GetInstantInfo()['title'] |
| 32 self.assertEqual('Google', title, msg='Instant did not load.') | 31 self.assertEqual('Google', title, msg='Instant did not load.') |
| 33 # Disable Instant. | 32 # Disable Instant. |
| 34 self.SetPrefs(pyauto.kInstantEnabled, False) | 33 self.SetPrefs(pyauto.kInstantEnabled, False) |
| 35 self.assertFalse(self.GetInstantInfo()['enabled'], | 34 self.assertFalse(self.GetInstantInfo()['enabled'], |
| 36 msg='Instant is not disabled.') | 35 msg='Instant is not disabled.') |
| 37 | 36 |
| 38 | 37 |
| 39 class InstantTest(pyauto.PyUITest): | 38 class InstantTest(pyauto.PyUITest): |
| 40 """TestCase for Omnibox Instant feature.""" | 39 """TestCase for Omnibox Instant feature.""" |
| 41 | 40 |
| 42 def setUp(self): | 41 def setUp(self): |
| 43 pyauto.PyUITest.setUp(self) | 42 pyauto.PyUITest.setUp(self) |
| 44 self.SetPrefs(pyauto.kInstantEnabled, True) | 43 self.SetPrefs(pyauto.kInstantEnabled, True) |
| 45 self.SetPrefs(pyauto.kInstantEnabledOnce, True) | |
| 46 | 44 |
| 47 def _DoneLoading(self): | 45 def _DoneLoading(self): |
| 48 info = self.GetInstantInfo() | 46 info = self.GetInstantInfo() |
| 49 return info.get('current') and not info.get('loading') | 47 return info.get('current') and not info.get('loading') |
| 50 | 48 |
| 51 def _DoneLoadingGoogleQuery(self, query): | 49 def _DoneLoadingGoogleQuery(self, query): |
| 52 """Wait for Omnibox Instant to load Google search result | 50 """Wait for Omnibox Instant to load Google search result |
| 53 and verify location URL contains the specifed query. | 51 and verify location URL contains the specifed query. |
| 54 | 52 |
| 55 Args: | 53 Args: |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 """Test that instant loads PNG file.""" | 265 """Test that instant loads PNG file.""" |
| 268 self._AssertInstantLoadsFile(os.path.join('save_page', '1.png')) | 266 self._AssertInstantLoadsFile(os.path.join('save_page', '1.png')) |
| 269 | 267 |
| 270 def testInstantLoadsSVG(self): | 268 def testInstantLoadsSVG(self): |
| 271 """Test that instant loads SVG file.""" | 269 """Test that instant loads SVG file.""" |
| 272 self._AssertInstantLoadsFile(os.path.join('circle.svg')) | 270 self._AssertInstantLoadsFile(os.path.join('circle.svg')) |
| 273 | 271 |
| 274 | 272 |
| 275 if __name__ == '__main__': | 273 if __name__ == '__main__': |
| 276 pyauto_functional.Main() | 274 pyauto_functional.Main() |
| OLD | NEW |