OLD | NEW |
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 PyUITest::GetPrefsInfo() or |
| 10 PyUITest::GetLocalStatePrefsInfo(). |
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 Loading... |
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 |
OLD | NEW |