| OLD | NEW | 
|---|
| 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 | 
| 11 import sys | 12 import sys | 
| 12 import unittest | 13 import unittest | 
| 13 | 14 | 
| 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 | 
| 17 | 18 | 
| 18 sys.path.append(devil_env.config.pymock_path) | 19 sys.path.append(os.path.join( | 
|  | 20     constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) | 
| 19 import mock # pylint: disable=import-error | 21 import mock # pylint: disable=import-error | 
| 20 | 22 | 
| 21 | 23 | 
| 22 def MockDeviceWithFiles(files=None): | 24 def MockDeviceWithFiles(files=None): | 
| 23   if files is None: | 25   if files is None: | 
| 24     files = {} | 26     files = {} | 
| 25 | 27 | 
| 26   def file_exists(path): | 28   def file_exists(path): | 
| 27     return path in files | 29     return path in files | 
| 28 | 30 | 
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 158 | 160 | 
| 159     self.assertEquals(self.device.WriteFile.call_args_list, []) # did not write | 161     self.assertEquals(self.device.WriteFile.call_args_list, []) # did not write | 
| 160     with shared_prefs.SharedPrefs( | 162     with shared_prefs.SharedPrefs( | 
| 161         self.device, 'com.some.package', 'prefs.xml') as prefs: | 163         self.device, 'com.some.package', 'prefs.xml') as prefs: | 
| 162       # contents were not modified | 164       # contents were not modified | 
| 163       self.assertEquals(prefs.AsDict(), self.expected_data) | 165       self.assertEquals(prefs.AsDict(), self.expected_data) | 
| 164 | 166 | 
| 165 if __name__ == '__main__': | 167 if __name__ == '__main__': | 
| 166   logging.getLogger().setLevel(logging.DEBUG) | 168   logging.getLogger().setLevel(logging.DEBUG) | 
| 167   unittest.main(verbosity=2) | 169   unittest.main(verbosity=2) | 
| OLD | NEW | 
|---|