diff options
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__': |