Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 pyauto_functional # Must be imported before pyauto | 6 import pyauto_functional # Must be imported before pyauto |
| 7 import pyauto | 7 import pyauto |
| 8 from webdriver_pages import settings | 8 from webdriver_pages import settings |
| 9 from webdriver_pages.settings import Behaviors, ContentTypes | 9 from webdriver_pages.settings import Behaviors, ContentTypes |
| 10 | 10 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 """ | 52 """ |
| 53 page = settings.ManageExceptionsPage.FromNavigation( | 53 page = settings.ManageExceptionsPage.FromNavigation( |
| 54 self._driver, content_type) | 54 self._driver, content_type) |
| 55 self.assertTrue(page.GetExceptions().has_key(hostname_pattern), | 55 self.assertTrue(page.GetExceptions().has_key(hostname_pattern), |
| 56 msg=('No displayed host name matches pattern "%s"' | 56 msg=('No displayed host name matches pattern "%s"' |
| 57 % hostname_pattern)) | 57 % hostname_pattern)) |
| 58 self.assertEqual(behavior, page.GetExceptions()[hostname_pattern], | 58 self.assertEqual(behavior, page.GetExceptions()[hostname_pattern], |
| 59 msg=('Displayed behavior "%s" does not match behavior "%s"' | 59 msg=('Displayed behavior "%s" does not match behavior "%s"' |
| 60 % (page.GetExceptions()[hostname_pattern], behavior))) | 60 % (page.GetExceptions()[hostname_pattern], behavior))) |
| 61 | 61 |
| 62 def _VerifyIncognitoContentExceptionUI( | |
| 63 self, content_type, hostname_pattern, behavior): | |
| 64 """Find hostname pattern and behavior within UI on content exceptions page. | |
| 65 | |
| 66 Args: | |
| 67 content_type: The string content settings type to manage. | |
| 68 hostname_pattern: The URL or pattern associated with the behavior. | |
| 69 behavior: The exception to allow or block the hostname. | |
| 70 """ | |
| 71 page = settings.ManageExceptionsPage.FromNavigation( | |
| 72 self._driver, content_type) | |
| 73 self.assertTrue( | |
| 74 page.GetExceptions(incognito=True).has_key(hostname_pattern), | |
| 75 msg=('No displayed host name matches pattern "%s"' % hostname_pattern)) | |
|
Nirnimesh
2012/02/24 23:49:47
remove inner params
dyu1
2012/02/27 20:54:45
Done.
| |
| 76 self.assertEqual( | |
| 77 behavior, page.GetExceptions(incognito=True)[hostname_pattern], | |
| 78 msg=('Displayed behavior "%s" does not match behavior "%s"' | |
| 79 % (page.GetExceptions(incognito=True)[hostname_pattern], | |
| 80 behavior))) | |
| 81 | |
| 62 def testLocationSettingOptionsUI(self): | 82 def testLocationSettingOptionsUI(self): |
| 63 """Verify the location options setting UI. | 83 """Verify the location options setting UI. |
| 64 | 84 |
| 65 Set the options through the UI using webdriver and verify the settings in | 85 Set the options through the UI using webdriver and verify the settings in |
| 66 pyAuto. | 86 pyAuto. |
| 67 """ | 87 """ |
| 68 page = settings.ContentSettingsPage.FromNavigation(self._driver) | 88 page = settings.ContentSettingsPage.FromNavigation(self._driver) |
| 69 page.SetContentTypeOption(ContentTypes.GEOLOCATION, Behaviors.ALLOW) | 89 page.SetContentTypeOption(ContentTypes.GEOLOCATION, Behaviors.ALLOW) |
| 70 self.assertEqual( | 90 self.assertEqual( |
| 71 1, self.GetPrefsInfo().Prefs(pyauto.kGeolocationDefaultContentSetting)) | 91 1, self.GetPrefsInfo().Prefs(pyauto.kGeolocationDefaultContentSetting)) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 self.SetPrefs(pyauto.kGeolocationContentSettings, geo_exception) | 127 self.SetPrefs(pyauto.kGeolocationContentSettings, geo_exception) |
| 108 self._VerifyContentExceptionUI( | 128 self._VerifyContentExceptionUI( |
| 109 ContentTypes.GEOLOCATION, 'http://maps.google.com:80', | 129 ContentTypes.GEOLOCATION, 'http://maps.google.com:80', |
| 110 Behaviors.ALLOW) | 130 Behaviors.ALLOW) |
| 111 geo_exception = ( | 131 geo_exception = ( |
| 112 {'http://maps.google.com:80/': {'http://maps.google.com:80': 3}}) | 132 {'http://maps.google.com:80/': {'http://maps.google.com:80': 3}}) |
| 113 self.SetPrefs(pyauto.kGeolocationContentSettings, geo_exception) | 133 self.SetPrefs(pyauto.kGeolocationContentSettings, geo_exception) |
| 114 self._VerifyContentExceptionUI( | 134 self._VerifyContentExceptionUI( |
| 115 ContentTypes.GEOLOCATION, 'http://maps.google.com:80', Behaviors.ASK) | 135 ContentTypes.GEOLOCATION, 'http://maps.google.com:80', Behaviors.ASK) |
| 116 | 136 |
| 137 def testIncognitoExceptionsEntryCorrectlyDisplayed(self): | |
| 138 """Verify exceptions entry is correctly displayed in the incognito UI.""" | |
| 139 geo_exception = ( | |
| 140 {'http://maps.google.com:80/': {'http://maps.google.com': 2}}) | |
| 141 self.SetPrefs(pyauto.kGeolocationContentSettings, geo_exception) | |
| 142 self._VerifyIncognitoContentExceptionUI( | |
| 143 ContentTypes.GEOLOCATION, 'http://maps.google.com:80', | |
| 144 Behaviors.BLOCK) | |
| 145 geo_exception = ( | |
| 146 {'http://maps.google.com:80/': {'http://maps.google.com:80': 1}}) | |
| 147 self.SetPrefs(pyauto.kGeolocationContentSettings, geo_exception) | |
| 148 self._VerifyIncognitoContentExceptionUI( | |
| 149 ContentTypes.GEOLOCATION, 'http://maps.google.com:80', | |
| 150 Behaviors.ALLOW) | |
| 151 geo_exception = ( | |
| 152 {'http://maps.google.com:80/': {'http://maps.google.com:80': 3}}) | |
| 153 self.SetPrefs(pyauto.kGeolocationContentSettings, geo_exception) | |
| 154 self._VerifyIncognitoContentExceptionUI( | |
| 155 ContentTypes.GEOLOCATION, 'http://maps.google.com:80', Behaviors.ASK) | |
| 156 | |
| 117 def testAddNewExceptionUI(self): | 157 def testAddNewExceptionUI(self): |
| 118 """Verify new exception added for hostname pattern and behavior in UI.""" | 158 """Verify new exception added for hostname pattern and behavior in UI.""" |
| 119 content_type = ContentTypes.PLUGINS | 159 content_type = ContentTypes.PLUGINS |
| 120 page = settings.ManageExceptionsPage.FromNavigation( | 160 page = settings.ManageExceptionsPage.FromNavigation( |
| 121 self._driver, content_type) | 161 self._driver, content_type) |
| 122 | 162 |
| 123 pattern, behavior = ('bing.com', Behaviors.BLOCK) | 163 pattern, behavior = ('bing.com', Behaviors.BLOCK) |
| 124 page.AddNewException(pattern, behavior) | 164 page.AddNewException(pattern, behavior) |
| 125 self.assertEqual(page.GetExceptions()[pattern], Behaviors.BLOCK, | 165 self.assertEqual(page.GetExceptions()[pattern], Behaviors.BLOCK, |
| 126 msg='The behavior "%s" was not added for pattern "%s"' | 166 msg='The behavior "%s" was not added for pattern "%s"' |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 def testNoInitialLineEntryInUI(self): | 198 def testNoInitialLineEntryInUI(self): |
| 159 """Verify no initial line entry is displayed in UI.""" | 199 """Verify no initial line entry is displayed in UI.""" |
| 160 # Ask for permission when site wants to track. | 200 # Ask for permission when site wants to track. |
| 161 self.SetPrefs(pyauto.kGeolocationDefaultContentSetting, 3) | 201 self.SetPrefs(pyauto.kGeolocationDefaultContentSetting, 3) |
| 162 self.assertEqual( | 202 self.assertEqual( |
| 163 3, self.GetPrefsInfo().Prefs(pyauto.kGeolocationDefaultContentSetting)) | 203 3, self.GetPrefsInfo().Prefs(pyauto.kGeolocationDefaultContentSetting)) |
| 164 page = settings.ManageExceptionsPage.FromNavigation( | 204 page = settings.ManageExceptionsPage.FromNavigation( |
| 165 self._driver, ContentTypes.GEOLOCATION) | 205 self._driver, ContentTypes.GEOLOCATION) |
| 166 self.assertEqual(0, len(page.GetExceptions())) | 206 self.assertEqual(0, len(page.GetExceptions())) |
| 167 | 207 |
| 208 def testInitialLineEntryInIncognitoUI(self): | |
| 209 """Verify initial line entry is displayed in Incognito UI.""" | |
| 210 # Ask for permission when site wants to track. | |
| 211 self.SetPrefs(pyauto.kGeolocationDefaultContentSetting, 3) | |
| 212 self.assertEqual( | |
| 213 3, self.GetPrefsInfo().Prefs(pyauto.kGeolocationDefaultContentSetting)) | |
| 214 page = settings.ManageExceptionsPage.FromNavigation( | |
| 215 self._driver, ContentTypes.GEOLOCATION) | |
| 216 self.assertEqual(1, len(page.GetExceptions(incognito=True))) | |
| 217 | |
| 168 | 218 |
| 169 if __name__ == '__main__': | 219 if __name__ == '__main__': |
| 170 pyauto_functional.Main() | 220 pyauto_functional.Main() |
| OLD | NEW |