Chromium Code Reviews| Index: grit/format/policy_templates/writers/ios_plist_writer_unittest.py |
| =================================================================== |
| --- grit/format/policy_templates/writers/ios_plist_writer_unittest.py (revision 177) |
| +++ grit/format/policy_templates/writers/ios_plist_writer_unittest.py (working copy) |
| @@ -54,12 +54,19 @@ |
| templates, |
| expected_output, |
| parse, |
| - decode_and_parse): |
| + decode_and_parse, |
| + defines=None): |
| + |
| + _defines = { '_chromium': '1', 'mac_bundle_id': 'com.example.Test' } |
|
pastarmovj
2014/10/07 14:54:35
I'd simplify that and make the test always take th
cschuet1
2014/10/07 15:42:46
Done.
|
| + |
| + if defines is not None: |
| + _defines = dict(_defines.items() + defines.items()) |
| + |
| # Generate the grit output for |templates|. |
| output = self.GetOutput( |
| self.PrepareTest(templates), |
| 'fr', |
| - { '_chromium': '1', 'mac_bundle_id': 'com.example.Test' }, |
| + _defines, |
| 'ios_plist', |
| 'en') |
| @@ -80,12 +87,12 @@ |
| decoded_chrome_policy = decode_and_parse(encoded_chrome_policy) |
| self.assertEquals(decoded_chrome_policy, expected_output) |
| - def _VerifyGeneratedOutput(self, templates, expected): |
| + def _VerifyGeneratedOutput(self, templates, expected, defines=None): |
| # plistlib is available on all Python platforms. |
| parse = functools.partial(self._ParseWithPython, False) |
| decode_and_parse = functools.partial(self._ParseWithPython, True) |
| self._VerifyGeneratedOutputWithParsers( |
| - templates, expected, parse, decode_and_parse) |
| + templates, expected, parse, decode_and_parse, defines) |
| # The Cocoa bindings are available on Mac OS X only. |
| if Cocoa: |
| @@ -92,7 +99,7 @@ |
| parse = functools.partial(self._ParseWithCocoa, False) |
| decode_and_parse = functools.partial(self._ParseWithCocoa, True) |
| self._VerifyGeneratedOutputWithParsers( |
| - templates, expected, parse, decode_and_parse) |
| + templates, expected, parse, decode_and_parse, defines) |
| def _MakeTemplate(self, name, type, example, extra=''): |
| return ''' |
| @@ -124,6 +131,17 @@ |
| expected = {} |
| self._VerifyGeneratedOutput(templates, expected) |
| + def testEmptyVersion(self): |
| + templates = ''' |
| + { |
| + 'policy_definitions': [], |
| + 'placeholders': [], |
| + 'messages': {}, |
| + } |
| + ''' |
| + expected = {} |
| + self._VerifyGeneratedOutput(templates, expected, {'version': '39.0.0.0'}) |
| + |
| def testBoolean(self): |
| templates = self._MakeTemplate('BooleanPolicy', 'main', 'True') |
| expected = { |