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

Side by Side Diff: grit/format/policy_templates/writers/plist_writer_unittest.py

Issue 544113002: Add optional mandatory policy setting for template generation (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: rebase Created 6 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 '''Unit tests for grit.format.policy_templates.writers.plist_writer''' 6 '''Unit tests for grit.format.policy_templates.writers.plist_writer'''
7 7
8 8
9 import os 9 import os
10 import sys 10 import sys
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 <key>pfm_targets</key> 111 <key>pfm_targets</key>
112 <array> 112 <array>
113 <string>user-managed</string> 113 <string>user-managed</string>
114 </array> 114 </array>
115 <key>pfm_type</key> 115 <key>pfm_type</key>
116 <string>boolean</string> 116 <string>boolean</string>
117 </dict> 117 </dict>
118 </array>''') 118 </array>''')
119 self.assertEquals(output.strip(), expected_output.strip()) 119 self.assertEquals(output.strip(), expected_output.strip())
120 120
121 def testRecommendedPolicy(self):
122 # Tests a policy group with a single policy of type 'main'.
123 grd = self.PrepareTest('''
124 {
125 'policy_definitions': [
126 {
127 'name': 'MainGroup',
128 'type': 'group',
129 'policies': [{
130 'name': 'MainPolicy',
131 'type': 'main',
132 'desc': '',
133 'caption': '',
134 'features': {
135 'can_be_recommended' : True
136 },
137 'supported_on': ['chrome.mac:8-'],
138 }],
139 'desc': '',
140 'caption': '',
141 },
142 ],
143 'placeholders': [],
144 'messages': {}
145 }''')
146 output = self.GetOutput(
147 grd,
148 'fr',
149 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'},
150 'plist',
151 'en')
152 expected_output = self._GetExpectedOutputs(
153 'Chromium', 'com.example.Test', '''<array>
154 <dict>
155 <key>pfm_name</key>
156 <string>MainPolicy</string>
157 <key>pfm_description</key>
158 <string/>
159 <key>pfm_title</key>
160 <string/>
161 <key>pfm_targets</key>
162 <array>
163 <string>user</string>
164 <string>user-managed</string>
165 </array>
166 <key>pfm_type</key>
167 <string>boolean</string>
168 </dict>
169 </array>''')
170 self.assertEquals(output.strip(), expected_output.strip())
171
172 def testRecommendedOnlyPolicy(self):
173 # Tests a policy group with a single policy of type 'main'.
174 grd = self.PrepareTest('''
175 {
176 'policy_definitions': [
177 {
178 'name': 'MainGroup',
179 'type': 'group',
180 'policies': [{
181 'name': 'MainPolicy',
182 'type': 'main',
183 'desc': '',
184 'caption': '',
185 'features': {
186 'can_be_recommended' : True,
187 'can_be_mandatory' : False
188 },
189 'supported_on': ['chrome.mac:8-'],
190 }],
191 'desc': '',
192 'caption': '',
193 },
194 ],
195 'placeholders': [],
196 'messages': {}
197 }''')
198 output = self.GetOutput(
199 grd,
200 'fr',
201 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'},
202 'plist',
203 'en')
204 expected_output = self._GetExpectedOutputs(
205 'Chromium', 'com.example.Test', '''<array>
206 <dict>
207 <key>pfm_name</key>
208 <string>MainPolicy</string>
209 <key>pfm_description</key>
210 <string/>
211 <key>pfm_title</key>
212 <string/>
213 <key>pfm_targets</key>
214 <array>
215 <string>user</string>
216 </array>
217 <key>pfm_type</key>
218 <string>boolean</string>
219 </dict>
220 </array>''')
221 self.assertEquals(output.strip(), expected_output.strip())
222
121 def testStringPolicy(self): 223 def testStringPolicy(self):
122 # Tests a policy group with a single policy of type 'string'. 224 # Tests a policy group with a single policy of type 'string'.
123 grd = self.PrepareTest(''' 225 grd = self.PrepareTest('''
124 { 226 {
125 'policy_definitions': [ 227 'policy_definitions': [
126 { 228 {
127 'name': 'StringGroup', 229 'name': 'StringGroup',
128 'type': 'group', 230 'type': 'group',
129 'desc': '', 231 'desc': '',
130 'caption': '', 232 'caption': '',
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 {'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'}, 623 {'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'},
522 'plist', 624 'plist',
523 'en') 625 'en')
524 expected_output = self._GetExpectedOutputs( 626 expected_output = self._GetExpectedOutputs(
525 'Google_Chrome', 'com.example.Test2', '''<array/>''') 627 'Google_Chrome', 'com.example.Test2', '''<array/>''')
526 self.assertEquals(output.strip(), expected_output.strip()) 628 self.assertEquals(output.strip(), expected_output.strip())
527 629
528 630
529 if __name__ == '__main__': 631 if __name__ == '__main__':
530 unittest.main() 632 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/policy_templates/writers/plist_writer.py ('k') | grit/format/policy_templates/writers/reg_writer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698