diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-29 17:56:47 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-29 17:56:47 +0000 |
commit | 24e2b10503e5f54ce5b4beb96a6403c3a8e7e62f (patch) | |
tree | 5759741f0a93469592cf61eb21ea30000e0ec867 /chrome/test/functional | |
parent | af21820522ebcf2c3752316ee4e6c0424c1bb990 (diff) | |
download | chromium_src-24e2b10503e5f54ce5b4beb96a6403c3a8e7e62f.zip chromium_src-24e2b10503e5f54ce5b4beb96a6403c3a8e7e62f.tar.gz chromium_src-24e2b10503e5f54ce5b4beb96a6403c3a8e7e62f.tar.bz2 |
Add automation hooks for setting/gettting preferences.
Add a test which excercises this, update old test.
Also,
- Remove some old prefs hooks. They were not easy to use and required the user to know what a preference type was, with no way of listing them out.
- replace if-else statements for json handlers with a map.
- Fix json error strings. json prefers " over ' (automation_provider.cc)
BUG=42701
TEST=python chrome/test/functional/prefs.py
Review URL: http://codereview.chromium.org/1712019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45956 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/functional')
-rw-r--r-- | chrome/test/functional/PYAUTO_TESTS | 1 | ||||
-rw-r--r-- | chrome/test/functional/prefs.py | 39 |
2 files changed, 34 insertions, 6 deletions
diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS index f037d48..a955243 100644 --- a/chrome/test/functional/PYAUTO_TESTS +++ b/chrome/test/functional/PYAUTO_TESTS @@ -23,6 +23,7 @@ 'history', 'test_basic.SimpleTest.testCanOpenGoogle', 'downloads', + 'prefs', 'special_tabs', ], diff --git a/chrome/test/functional/prefs.py b/chrome/test/functional/prefs.py index c02332b..31f8937 100644 --- a/chrome/test/functional/prefs.py +++ b/chrome/test/functional/prefs.py @@ -4,6 +4,7 @@ # found in the LICENSE file. import logging +import os import pyauto_functional # Must be imported before pyauto import pyauto @@ -13,24 +14,50 @@ class PrefsTest(pyauto.PyUITest): """TestCase for Preferences.""" def testSessionRestore(self): + """Test session restore preference.""" url1 = 'http://www.google.com/' url2 = 'http://news.google.com/' self.NavigateToURL(url1) self.AppendTab(pyauto.GURL(url2)) num_tabs = self.GetTabCount() # Set pref to restore session on startup - browser = self.GetBrowserWindow(0) - browser.SetIntPreference(pyauto.kRestoreOnStartup, 1) + self.SetPrefs(pyauto.kRestoreOnStartup, 1) logging.debug('Setting %s to 1' % pyauto.kRestoreOnStartup) - self.CloseBrowserAndServer() # Close browser - self.set_clear_profile(False) # Do not clear profile on next startup - self.LaunchBrowserAndServer() # Reopen browser + self.RestartBrowser(clear_profile=False) + # Verify + self.assertEqual(self.GetPrefsInfo().Prefs(pyauto.kRestoreOnStartup), 1) self.assertEqual(num_tabs, self.GetTabCount()) self.ActivateTab(0) self.assertEqual(url1, self.GetActiveTabURL().spec()) self.ActivateTab(1) self.assertEqual(url2, self.GetActiveTabURL().spec()) - self.set_clear_profile(True) # Restore the flag to clear profile next + + def Debug(self): + """Test method for experimentation. + + This method will not run automatically. + """ + import pprint + pp = pprint.PrettyPrinter(indent=2) + while True: + raw_input('Interact with the browser and hit <enter> to dump prefs... ') + pp.pprint(self.GetPrefsInfo().Prefs()) + + def testSessionRestoreURLs(self): + """Verify restore URLs preference.""" + url1 = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title1.html')) + url2 = self.GetFileURLForPath(os.path.join(self.DataDir(), 'title2.html')) + # Set pref to restore given URLs on startup + self.SetPrefs(pyauto.kRestoreOnStartup, 4) # 4 is for restoring URLs + self.SetPrefs(pyauto.kURLsToRestoreOnStartup, [url1, url2]) + self.RestartBrowser(clear_profile=False) + # Verify + self.assertEqual(self.GetPrefsInfo().Prefs(pyauto.kRestoreOnStartup), 4) + self.assertEqual(2, self.GetTabCount()) + self.ActivateTab(0) + self.assertEqual(url1, self.GetActiveTabURL().spec()) + self.ActivateTab(1) + self.assertEqual(url2, self.GetActiveTabURL().spec()) if __name__ == '__main__': |