Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1014)

Side by Side Diff: chrome/test/functional/prefs.py

Issue 22272003: Deleting Prefs related pyauto tests which are already being converted to browser_tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 logging 6 import logging
7 import os 7 import os
8 import shutil 8 import shutil
9 9
10 import pyauto_functional # Must be imported before pyauto 10 import pyauto_functional # Must be imported before pyauto
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 self.SetPrefs(pyauto.kURLsToRestoreOnStartup, [url1, url2]) 78 self.SetPrefs(pyauto.kURLsToRestoreOnStartup, [url1, url2])
79 self.RestartBrowser(clear_profile=False) 79 self.RestartBrowser(clear_profile=False)
80 # Verify 80 # Verify
81 self.assertEqual(self.GetPrefsInfo().Prefs(pyauto.kRestoreOnStartup), 4) 81 self.assertEqual(self.GetPrefsInfo().Prefs(pyauto.kRestoreOnStartup), 4)
82 self.assertEqual(2, self.GetTabCount()) 82 self.assertEqual(2, self.GetTabCount())
83 self.ActivateTab(0) 83 self.ActivateTab(0)
84 self.assertEqual(url1, self.GetActiveTabURL().spec()) 84 self.assertEqual(url1, self.GetActiveTabURL().spec())
85 self.ActivateTab(1) 85 self.ActivateTab(1)
86 self.assertEqual(url2, self.GetActiveTabURL().spec()) 86 self.assertEqual(url2, self.GetActiveTabURL().spec())
87 87
88 def testSessionRestoreShowBookmarkBar(self):
89 """Verify restore for bookmark bar visibility."""
90 assert not self.GetPrefsInfo().Prefs(pyauto.kShowBookmarkBar)
91 self.SetPrefs(pyauto.kShowBookmarkBar, True)
92 self.assertEqual(True, self.GetPrefsInfo().Prefs(pyauto.kShowBookmarkBar))
93 self.RestartBrowser(clear_profile=False)
94 self.assertEqual(True, self.GetPrefsInfo().Prefs(pyauto.kShowBookmarkBar))
95 self.assertTrue(self.GetBookmarkBarVisibility())
96
97 def testDownloadDirPref(self):
98 """Verify download dir pref."""
99 test_dir = os.path.join(self.DataDir(), 'downloads')
100 file_url = self.GetFileURLForPath(os.path.join(test_dir, 'a_zip_file.zip'))
101 download_dir = self.GetDownloadDirectory().value()
102 new_dl_dir = os.path.join(download_dir, 'My+Downloads Folder')
103 downloaded_pkg = os.path.join(new_dl_dir, 'a_zip_file.zip')
104 os.path.exists(new_dl_dir) and shutil.rmtree(new_dl_dir)
105 os.makedirs(new_dl_dir)
106 # Set pref to download in new_dl_dir
107 self.SetPrefs(pyauto.kDownloadDefaultDirectory, new_dl_dir)
108 self.DownloadAndWaitForStart(file_url)
109 self.WaitForAllDownloadsToComplete()
110 self.assertTrue(os.path.exists(downloaded_pkg))
111 shutil.rmtree(new_dl_dir, ignore_errors=True) # cleanup
112
113 def testToolbarButtonsPref(self):
114 """Verify toolbar buttons prefs."""
115 # Assert defaults first
116 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kShowHomeButton))
117 self.SetPrefs(pyauto.kShowHomeButton, True)
118 self.RestartBrowser(clear_profile=False)
119 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kShowHomeButton))
120
121 def testNetworkPredictionEnabledPref(self):
122 """Verify DNS prefetching pref."""
123 # Assert default
124 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kNetworkPredictionEnabled))
125 self.SetPrefs(pyauto.kNetworkPredictionEnabled, False)
126 self.RestartBrowser(clear_profile=False)
127 self.assertFalse(self.GetPrefsInfo().Prefs(
128 pyauto.kNetworkPredictionEnabled))
129
130 def testHomepagePrefs(self): 88 def testHomepagePrefs(self):
131 """Verify homepage prefs.""" 89 """Verify homepage prefs."""
132 # "Use the New Tab page" 90 # "Use the New Tab page"
133 self.SetPrefs(pyauto.kHomePageIsNewTabPage, True) 91 self.SetPrefs(pyauto.kHomePageIsNewTabPage, True)
134 logging.debug('Setting %s to 1' % pyauto.kHomePageIsNewTabPage) 92 logging.debug('Setting %s to 1' % pyauto.kHomePageIsNewTabPage)
135 self.RestartBrowser(clear_profile=False) 93 self.RestartBrowser(clear_profile=False)
136 self.assertEqual(self.GetPrefsInfo().Prefs(pyauto.kHomePageIsNewTabPage), 94 self.assertEqual(self.GetPrefsInfo().Prefs(pyauto.kHomePageIsNewTabPage),
137 True) 95 True)
138 # "Open this page" 96 # "Open this page"
139 url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title1.html')) 97 url = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title1.html'))
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 pyauto.kAlternateErrorPagesEnabled, 139 pyauto.kAlternateErrorPagesEnabled,
182 pyauto.kSearchSuggestEnabled] 140 pyauto.kSearchSuggestEnabled]
183 for pref in pref_list: 141 for pref in pref_list:
184 # Verify the default value 142 # Verify the default value
185 self.assertEqual(self.GetPrefsInfo().Prefs(pref), True) 143 self.assertEqual(self.GetPrefsInfo().Prefs(pref), True)
186 self.SetPrefs(pref, False) 144 self.SetPrefs(pref, False)
187 self.RestartBrowser(clear_profile=False) 145 self.RestartBrowser(clear_profile=False)
188 for pref in pref_list: 146 for pref in pref_list:
189 self.assertEqual(self.GetPrefsInfo().Prefs(pref), False) 147 self.assertEqual(self.GetPrefsInfo().Prefs(pref), False)
190 148
191 def testJavaScriptEnableDisable(self):
192 """Verify enabling disabling javascript prefs work """
193 self.assertTrue(
194 self.GetPrefsInfo().Prefs(pyauto.kWebKitJavascriptEnabled))
195 url = self.GetFileURLForDataPath(
196 os.path.join('javaScriptTitle.html'))
197 title1 = 'Title from script javascript enabled'
198 self.NavigateToURL(url)
199 self.assertEqual(title1, self.GetActiveTabTitle())
200 self.SetPrefs(pyauto.kWebKitJavascriptEnabled, False)
201 title = 'This is html title'
202 self.NavigateToURL(url)
203 self.assertEqual(title, self.GetActiveTabTitle())
204
205 def testHaveLocalStatePrefs(self): 149 def testHaveLocalStatePrefs(self):
206 """Verify that we have some Local State prefs.""" 150 """Verify that we have some Local State prefs."""
207 self.assertTrue(self.GetLocalStatePrefsInfo()) 151 self.assertTrue(self.GetLocalStatePrefsInfo())
208 152
209 def testAllowSelectedGeoTracking(self): 153 def testAllowSelectedGeoTracking(self):
210 """Verify hostname pattern and behavior for allowed tracking.""" 154 """Verify hostname pattern and behavior for allowed tracking."""
211 # Default location tracking option "Ask me". 155 # Default location tracking option "Ask me".
212 self.SetPrefs(pyauto.kGeolocationDefaultContentSetting, 3) 156 self.SetPrefs(pyauto.kGeolocationDefaultContentSetting, 3)
213 self.NavigateToURL( 157 self.NavigateToURL(
214 self.GetHttpURLForDataPath('geolocation', 'geolocation_on_load.html')) 158 self.GetHttpURLForDataPath('geolocation', 'geolocation_on_load.html'))
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 for (i=0; i < document.images.length; i++) { 220 for (i=0; i < document.images.length; i++) {
277 if ((document.images[i].naturalWidth != 0) && 221 if ((document.images[i].naturalWidth != 0) &&
278 (document.images[i].naturalHeight != 0)) { 222 (document.images[i].naturalHeight != 0)) {
279 window.domAutomationController.send(true); 223 window.domAutomationController.send(true);
280 } 224 }
281 } 225 }
282 window.domAutomationController.send(false); 226 window.domAutomationController.send(false);
283 """ 227 """
284 return self.ExecuteJavascript(script, windex=windex, tab_index=tab_index) 228 return self.ExecuteJavascript(script, windex=windex, tab_index=tab_index)
285 229
286 def testImageContentSettings(self):
287 """Verify image content settings show or hide images."""
288 url = self.GetHttpURLForDataPath('settings', 'image_page.html')
289 self.NavigateToURL(url)
290 self.assertTrue(self._CheckForVisibleImage(),
291 msg='No visible images found.')
292 # Set to block all images from loading.
293 self.SetPrefs(pyauto.kDefaultContentSettings, {'images': 2})
294 self.NavigateToURL(url)
295 self.assertFalse(self._CheckForVisibleImage(),
296 msg='At least one visible image found.')
297
298 def testImagesNotBlockedInIncognito(self): 230 def testImagesNotBlockedInIncognito(self):
299 """Verify images are not blocked in Incognito mode.""" 231 """Verify images are not blocked in Incognito mode."""
300 url = self.GetHttpURLForDataPath('settings', 'image_page.html') 232 url = self.GetHttpURLForDataPath('settings', 'image_page.html')
301 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) 233 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)
302 self.NavigateToURL(url, 1, 0) 234 self.NavigateToURL(url, 1, 0)
303 self.assertTrue(self._CheckForVisibleImage(windex=1), 235 self.assertTrue(self._CheckForVisibleImage(windex=1),
304 msg='No visible images found in Incognito mode.') 236 msg='No visible images found in Incognito mode.')
305 237
306 def testBlockImagesForHostname(self): 238 def testBlockImagesForHostname(self):
307 """Verify images blocked for defined hostname pattern.""" 239 """Verify images blocked for defined hostname pattern."""
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 self.assertTrue( 273 self.assertTrue(
342 self._driver.execute_script( 274 self._driver.execute_script(
343 'return doesQueryConformsToProtocol("%s", "%s")' 275 'return doesQueryConformsToProtocol("%s", "%s")'
344 % (asked_handler_dict['query_key'], 276 % (asked_handler_dict['query_key'],
345 asked_handler_dict['query_value'])), 277 asked_handler_dict['query_value'])),
346 msg='Protocol did not register correctly.') 278 msg='Protocol did not register correctly.')
347 279
348 280
349 if __name__ == '__main__': 281 if __name__ == '__main__':
350 pyauto_functional.Main() 282 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/PYAUTO_TESTS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698