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

Side by Side Diff: build/android/devil/android/sdk/shared_prefs_test.py

Issue 1316413003: [Android] Add a configurable environment for devil/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: forwarder + md5sum in devil_config.json Created 5 years, 2 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 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 """ 6 """
7 Unit tests for the contents of shared_prefs.py (mostly SharedPrefs). 7 Unit tests for the contents of shared_prefs.py (mostly SharedPrefs).
8 """ 8 """
9 9
10 import logging 10 import logging
11 import os
12 import sys 11 import sys
13 import unittest 12 import unittest
14 13
14 from devil import devil_env
15 from devil.android import device_utils 15 from devil.android import device_utils
16 from devil.android.sdk import shared_prefs 16 from devil.android.sdk import shared_prefs
17 from pylib import constants
18 17
19 sys.path.append(os.path.join( 18 sys.path.append(devil_env.config.pymock_path)
20 constants.DIR_SOURCE_ROOT, 'third_party', 'pymock'))
21 import mock # pylint: disable=import-error 19 import mock # pylint: disable=import-error
22 20
23 21
24 def MockDeviceWithFiles(files=None): 22 def MockDeviceWithFiles(files=None):
25 if files is None: 23 if files is None:
26 files = {} 24 files = {}
27 25
28 def file_exists(path): 26 def file_exists(path):
29 return path in files 27 return path in files
30 28
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 158
161 self.assertEquals(self.device.WriteFile.call_args_list, []) # did not write 159 self.assertEquals(self.device.WriteFile.call_args_list, []) # did not write
162 with shared_prefs.SharedPrefs( 160 with shared_prefs.SharedPrefs(
163 self.device, 'com.some.package', 'prefs.xml') as prefs: 161 self.device, 'com.some.package', 'prefs.xml') as prefs:
164 # contents were not modified 162 # contents were not modified
165 self.assertEquals(prefs.AsDict(), self.expected_data) 163 self.assertEquals(prefs.AsDict(), self.expected_data)
166 164
167 if __name__ == '__main__': 165 if __name__ == '__main__':
168 logging.getLogger().setLevel(logging.DEBUG) 166 logging.getLogger().setLevel(logging.DEBUG)
169 unittest.main(verbosity=2) 167 unittest.main(verbosity=2)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698