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

Side by Side Diff: chrome/test/pyautolib/prefs_info.py

Issue 7067033: Add pyauto commands to access local state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2010 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 """Python representation for Chromium Preferences. 7 """Python representation for Chromium Preferences.
8 8
9 Obtain one of these from PyUITestSuite::GetPrefsInfo() call. 9 Obtain one of these from a call to PyUITestSuite::GetPrefsInfo() or
Nirnimesh 2011/05/24 19:49:02 s/GetLocalStateInfo/GetLocalStatePrefsInfo/ Actua
Miranda Callahan 2011/05/24 20:42:34 Done.
10 PyUITestSuite::GetLocalStateInfo().
10 11
11 Example: 12 Example:
12 class MyTest(pyauto.PyUITest): 13 class MyTest(pyauto.PyUITest):
13 def testBasic(self): 14 def testBasic(self):
14 info = self.GetPrefsInfo() # fetch prefs snapshot 15 info = self.GetPrefsInfo() # fetch prefs snapshot
15 print info.Prefs() # all prefs 16 print info.Prefs() # all prefs
16 print info.Prefs('session.restore_on_startup') # a single pref 17 print info.Prefs('session.restore_on_startup') # a single pref
17 18
18 See more tests in chrome/test/functional/prefs.py. 19 See more tests in chrome/test/functional/prefs.py.
19 """ 20 """
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 list or a plain value. 93 list or a plain value.
93 None, if prefernece for path not found (if path is given). 94 None, if prefernece for path not found (if path is given).
94 """ 95 """
95 all = self.prefsdict.get('prefs', {}) 96 all = self.prefsdict.get('prefs', {})
96 if not path: # No path given. Return all prefs. 97 if not path: # No path given. Return all prefs.
97 return all 98 return all
98 for part in path.split('.'): # Narrow down to the requested prefs path. 99 for part in path.split('.'): # Narrow down to the requested prefs path.
99 all = all.get(part) 100 all = all.get(part)
100 if all is None: return None 101 if all is None: return None
101 return all 102 return all
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698