Chromium Code Reviews| Index: grit/format/policy_templates/writers/plist_writer_unittest.py |
| =================================================================== |
| --- grit/format/policy_templates/writers/plist_writer_unittest.py (revision 177) |
| +++ grit/format/policy_templates/writers/plist_writer_unittest.py (working copy) |
| @@ -52,9 +52,64 @@ |
| </dict> |
| </plist>''' % (product_name, bundle_id, policies) |
| + def _GetExpectedOutputsWithVersion(self, product_name, bundle_id, policies, version): |
|
Joao da Silva
2014/10/15 13:04:37
break lines longer than 80 columns
cschuet (SLOW)
2014/10/15 15:23:14
Done.
|
| + '''Substitutes the variable parts into a plist template. The result |
| + of this function can be used as an expected result to test the output |
| + of PListWriter. |
| + |
| + Args: |
| + product_name: The name of the product, normally Chromium or Google Chrome. |
| + bundle_id: The mac bundle id of the product. |
| + policies: The list of policies. |
| + |
| + Returns: |
| + The text of a plist template with the variable parts substituted. |
| + ''' |
| + return ''' |
| +<?xml version="1.0" ?> |
| +<!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN' 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'> |
| +<plist version="1"> |
| + <dict> |
| + <key>pfm_name</key> |
| + <string>%s</string> |
| + <key>pfm_description</key> |
| + <string/> |
| + <key>pfm_title</key> |
| + <string/> |
| + <key>pfm_version</key> |
| + <string>1</string> |
| + <key>pfm_domain</key> |
| + <string>%s</string> |
| + <key>pfm_subkeys</key> |
| + %s |
| + </dict> |
| + <!--%s--> |
| +</plist>''' % (product_name, bundle_id, policies, version) |
| + |
| + |
| + |
|
Joao da Silva
2014/10/15 13:04:37
one newline is enough
cschuet (SLOW)
2014/10/15 15:23:14
Done.
|
| def testEmpty(self): |
| # Test PListWriter in case of empty polices. |
| grd = self.PrepareTest(''' |
| + { |
| + 'policy_definitions': [], |
| + 'placeholders': [], |
| + 'messages': {}, |
|
Joao da Silva
2014/10/15 13:04:37
keep the indentation that this had before
cschuet (SLOW)
2014/10/15 15:23:14
Done.
|
| + }''') |
| + |
| + output = self.GetOutput( |
| + grd, |
| + 'fr', |
| + {'_chromium': '1', 'mac_bundle_id': 'com.example.Test'}, |
| + 'plist', |
| + 'en') |
| + expected_output = self._GetExpectedOutputs( |
| + 'Chromium', 'com.example.Test', '<array/>') |
| + self.assertEquals(output.strip(), expected_output.strip()) |
| + |
| + def testEmptyVersion(self): |
| + # Test PListWriter in case of empty polices. |
| + grd = self.PrepareTest(''' |
| { |
| 'policy_definitions': [], |
| 'placeholders': [], |
| @@ -64,13 +119,17 @@ |
| output = self.GetOutput( |
| grd, |
| 'fr', |
| - {'_chromium': '1', 'mac_bundle_id': 'com.example.Test'}, |
| + {'_chromium': '1', |
| + 'mac_bundle_id': 'com.example.Test', |
| + 'version': '39.0.0.0'}, |
| 'plist', |
| 'en') |
| - expected_output = self._GetExpectedOutputs( |
| - 'Chromium', 'com.example.Test', '<array/>') |
| + expected_output = self._GetExpectedOutputsWithVersion( |
| + 'Chromium', 'com.example.Test', '<array/>', 'chromium version: 39.0.0.0') |
|
Joao da Silva
2014/10/15 13:04:37
seems like this line is longer than 80 columns too
cschuet (SLOW)
2014/10/15 15:23:14
Done.
|
| self.assertEquals(output.strip(), expected_output.strip()) |
| + |
| + |
|
Joao da Silva
2014/10/15 13:04:37
remove these newlines
cschuet (SLOW)
2014/10/15 15:23:14
Done.
|
| def testMainPolicy(self): |
| # Tests a policy group with a single policy of type 'main'. |
| grd = self.PrepareTest(''' |