OLD | NEW |
---|---|
1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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.adm_writer''' | 6 '''Unit tests for grit.format.policy_templates.writers.adm_writer''' |
7 | 7 |
8 | 8 |
9 import os | 9 import os |
10 import sys | 10 import sys |
11 if __name__ == '__main__': | 11 if __name__ == '__main__': |
12 sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '../../../..')) | 12 sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '../../../..')) |
13 | 13 |
14 import tempfile | 14 import tempfile |
15 import unittest | 15 import unittest |
16 import StringIO | 16 import StringIO |
17 | 17 |
18 from grit.format.policy_templates.writers import writer_unittest_common | 18 from grit.format.policy_templates.writers import writer_unittest_common |
19 from grit import grd_reader | 19 from grit import grd_reader |
20 from grit import util | 20 from grit import util |
21 from grit.tool import build | 21 from grit.tool import build |
22 | 22 |
23 | 23 |
24 class AdmWriterUnittest(writer_unittest_common.WriterUnittestCommon): | 24 class AdmWriterUnittest(writer_unittest_common.WriterUnittestCommon): |
25 '''Unit tests for AdmWriter.''' | 25 '''Unit tests for AdmWriter.''' |
26 | 26 |
27 def ConstructOutput(self, classes, body, strings): | |
28 result = [] | |
29 for clazz in classes: | |
30 result.append('CLASS '+clazz) | |
Jakob Kummerow
2011/01/24 16:52:28
nit: spaces around '+'
gfeher
2011/01/25 10:42:21
Done.
| |
31 result.append(body) | |
32 result.append(strings) | |
33 return ''.join(result) | |
34 | |
27 def CompareOutputs(self, output, expected_output): | 35 def CompareOutputs(self, output, expected_output): |
28 '''Compares the output of the adm_writer with its expected output. | 36 '''Compares the output of the adm_writer with its expected output. |
29 | 37 |
30 Args: | 38 Args: |
31 output: The output of the adm writer as returned by grit. | 39 output: The output of the adm writer as returned by grit. |
32 expected_output: The expected output. | 40 expected_output: The expected output. |
33 | 41 |
34 Raises: | 42 Raises: |
35 AssertionError: if the two strings are not equivalent. | 43 AssertionError: if the two strings are not equivalent. |
36 ''' | 44 ''' |
37 self.assertEquals( | 45 self.assertEquals( |
38 output.strip(), | 46 output.strip(), |
39 expected_output.strip().replace('\n', '\r\n')) | 47 expected_output.strip().replace('\n', '\r\n')) |
40 | 48 |
41 def testEmpty(self): | 49 def testEmpty(self): |
42 # Test PListWriter in case of empty polices. | 50 # Test PListWriter in case of empty polices. |
43 grd = self.PrepareTest(''' | 51 grd = self.PrepareTest(''' |
44 { | 52 { |
45 'policy_definitions': [], | 53 'policy_definitions': [], |
46 'placeholders': [], | 54 'placeholders': [], |
47 'messages': { | 55 'messages': { |
48 'win_supported_winxpsp2': { | 56 'win_supported_winxpsp2': { |
49 'text': 'At least "Windows 3.11', 'desc': 'blah' | 57 'text': 'At least "Windows 3.11', 'desc': 'blah' |
50 } | 58 } |
51 } | 59 } |
52 }''') | 60 }''') |
53 output = self.GetOutput(grd, 'fr', {'_chromium': '1',}, 'adm', 'en') | 61 output = self.GetOutput(grd, 'fr', {'_chromium': '1',}, 'adm', 'en') |
54 expected_output = '''CLASS MACHINE | 62 expected_output = self.ConstructOutput( |
63 ['MACHINE', 'USER'], ''' | |
55 CATEGORY !!chromium | 64 CATEGORY !!chromium |
56 KEYNAME "Software\\Policies\\Chromium" | 65 KEYNAME "Software\\Policies\\Chromium" |
57 | 66 |
58 END CATEGORY | 67 END CATEGORY |
59 | 68 |
60 [Strings] | 69 ''', '''[Strings] |
61 SUPPORTED_WINXPSP2="At least "Windows 3.11" | 70 SUPPORTED_WINXPSP2="At least "Windows 3.11" |
62 chromium="Chromium"''' | 71 chromium="Chromium"''') |
63 self.CompareOutputs(output, expected_output) | 72 self.CompareOutputs(output, expected_output) |
64 | 73 |
65 def testMainPolicy(self): | 74 def testMainPolicy(self): |
66 # Tests a policy group with a single policy of type 'main'. | 75 # Tests a policy group with a single policy of type 'main'. |
67 grd = self.PrepareTest(''' | 76 grd = self.PrepareTest(''' |
68 { | 77 { |
69 'policy_definitions': [ | 78 'policy_definitions': [ |
70 { | 79 { |
71 'name': 'MainPolicy', | 80 'name': 'MainPolicy', |
72 'type': 'main', | 81 'type': 'main', |
73 'supported_on': ['chrome.win:8-'], | 82 'supported_on': ['chrome.win:8-'], |
74 'caption': 'Caption of main.', | 83 'caption': 'Caption of main.', |
75 'desc': 'Description of main.', | 84 'desc': 'Description of main.', |
76 }, | 85 }, |
77 ], | 86 ], |
78 'placeholders': [], | 87 'placeholders': [], |
79 'messages': { | 88 'messages': { |
80 'win_supported_winxpsp2': { | 89 'win_supported_winxpsp2': { |
81 'text': 'At least Windows 3.12', 'desc': 'blah' | 90 'text': 'At least Windows 3.12', 'desc': 'blah' |
82 } | 91 } |
83 } | 92 } |
84 }''') | 93 }''') |
85 output = self.GetOutput(grd, 'fr', {'_google_chrome' : '1'}, 'adm', 'en') | 94 output = self.GetOutput(grd, 'fr', {'_google_chrome' : '1'}, 'adm', 'en') |
86 expected_output = '''CLASS MACHINE | 95 expected_output = self.ConstructOutput( |
96 ['MACHINE', 'USER'], ''' | |
87 CATEGORY !!google | 97 CATEGORY !!google |
88 CATEGORY !!googlechrome | 98 CATEGORY !!googlechrome |
89 KEYNAME "Software\\Policies\\Google\\Chrome" | 99 KEYNAME "Software\\Policies\\Google\\Chrome" |
90 | 100 |
91 POLICY !!MainPolicy_Policy | 101 POLICY !!MainPolicy_Policy |
92 #if version >= 4 | 102 #if version >= 4 |
93 SUPPORTED !!SUPPORTED_WINXPSP2 | 103 SUPPORTED !!SUPPORTED_WINXPSP2 |
94 #endif | 104 #endif |
95 EXPLAIN !!MainPolicy_Explain | 105 EXPLAIN !!MainPolicy_Explain |
96 VALUENAME "MainPolicy" | 106 VALUENAME "MainPolicy" |
97 VALUEON NUMERIC 1 | 107 VALUEON NUMERIC 1 |
98 VALUEOFF NUMERIC 0 | 108 VALUEOFF NUMERIC 0 |
99 END POLICY | 109 END POLICY |
100 | 110 |
101 END CATEGORY | 111 END CATEGORY |
102 END CATEGORY | 112 END CATEGORY |
103 | 113 |
104 [Strings] | 114 ''', '''[Strings] |
105 SUPPORTED_WINXPSP2="At least Windows 3.12" | 115 SUPPORTED_WINXPSP2="At least Windows 3.12" |
106 google="Google" | 116 google="Google" |
107 googlechrome="Google Chrome" | 117 googlechrome="Google Chrome" |
108 MainPolicy_Policy="Caption of main." | 118 MainPolicy_Policy="Caption of main." |
109 MainPolicy_Explain="Description of main."''' | 119 MainPolicy_Explain="Description of main."''') |
110 self.CompareOutputs(output, expected_output) | 120 self.CompareOutputs(output, expected_output) |
111 | 121 |
112 def testStringPolicy(self): | 122 def testStringPolicy(self): |
113 # Tests a policy group with a single policy of type 'string'. | 123 # Tests a policy group with a single policy of type 'string'. |
114 grd = self.PrepareTest(''' | 124 grd = self.PrepareTest(''' |
115 { | 125 { |
116 'policy_definitions': [ | 126 'policy_definitions': [ |
117 { | 127 { |
118 'name': 'StringPolicy', | 128 'name': 'StringPolicy', |
119 'type': 'string', | 129 'type': 'string', |
120 'supported_on': ['chrome.win:8-'], | 130 'supported_on': ['chrome.win:8-'], |
121 'desc': """Description of group. | 131 'desc': """Description of group. |
122 With a newline.""", | 132 With a newline.""", |
123 'caption': 'Caption of policy.', | 133 'caption': 'Caption of policy.', |
124 }, | 134 }, |
125 ], | 135 ], |
126 'placeholders': [], | 136 'placeholders': [], |
127 'messages': { | 137 'messages': { |
128 'win_supported_winxpsp2': { | 138 'win_supported_winxpsp2': { |
129 'text': 'At least Windows 3.13', 'desc': 'blah' | 139 'text': 'At least Windows 3.13', 'desc': 'blah' |
130 } | 140 } |
131 } | 141 } |
132 }''') | 142 }''') |
133 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en') | 143 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en') |
134 expected_output = '''CLASS MACHINE | 144 expected_output = self.ConstructOutput( |
145 ['MACHINE', 'USER'], ''' | |
135 CATEGORY !!chromium | 146 CATEGORY !!chromium |
136 KEYNAME "Software\\Policies\\Chromium" | 147 KEYNAME "Software\\Policies\\Chromium" |
137 | 148 |
138 POLICY !!StringPolicy_Policy | 149 POLICY !!StringPolicy_Policy |
139 #if version >= 4 | 150 #if version >= 4 |
140 SUPPORTED !!SUPPORTED_WINXPSP2 | 151 SUPPORTED !!SUPPORTED_WINXPSP2 |
141 #endif | 152 #endif |
142 EXPLAIN !!StringPolicy_Explain | 153 EXPLAIN !!StringPolicy_Explain |
143 | 154 |
144 PART !!StringPolicy_Part EDITTEXT | 155 PART !!StringPolicy_Part EDITTEXT |
145 VALUENAME "StringPolicy" | 156 VALUENAME "StringPolicy" |
146 END PART | 157 END PART |
147 END POLICY | 158 END POLICY |
148 | 159 |
149 END CATEGORY | 160 END CATEGORY |
150 | 161 |
151 [Strings] | 162 ''', '''[Strings] |
152 SUPPORTED_WINXPSP2="At least Windows 3.13" | 163 SUPPORTED_WINXPSP2="At least Windows 3.13" |
153 chromium="Chromium" | 164 chromium="Chromium" |
154 StringPolicy_Policy="Caption of policy." | 165 StringPolicy_Policy="Caption of policy." |
155 StringPolicy_Explain="Description of group.\\nWith a newline." | 166 StringPolicy_Explain="Description of group.\\nWith a newline." |
156 StringPolicy_Part="Caption of policy." | 167 StringPolicy_Part="Caption of policy." |
157 ''' | 168 ''') |
158 self.CompareOutputs(output, expected_output) | 169 self.CompareOutputs(output, expected_output) |
159 | 170 |
160 def testIntPolicy(self): | 171 def testIntPolicy(self): |
161 # Tests a policy group with a single policy of type 'string'. | 172 # Tests a policy group with a single policy of type 'string'. |
162 grd = self.PrepareTest(''' | 173 grd = self.PrepareTest(''' |
163 { | 174 { |
164 'policy_definitions': [ | 175 'policy_definitions': [ |
165 { | 176 { |
166 'name': 'IntPolicy', | 177 'name': 'IntPolicy', |
167 'type': 'int', | 178 'type': 'int', |
168 'caption': 'Caption of policy.', | 179 'caption': 'Caption of policy.', |
169 'desc': 'Description of policy.', | 180 'desc': 'Description of policy.', |
170 'supported_on': ['chrome.win:8-'] | 181 'supported_on': ['chrome.win:8-'] |
171 }, | 182 }, |
172 ], | 183 ], |
173 'placeholders': [], | 184 'placeholders': [], |
174 'messages': { | 185 'messages': { |
175 'win_supported_winxpsp2': { | 186 'win_supported_winxpsp2': { |
176 'text': 'At least Windows 3.13', 'desc': 'blah' | 187 'text': 'At least Windows 3.13', 'desc': 'blah' |
177 } | 188 } |
178 } | 189 } |
179 }''') | 190 }''') |
180 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en') | 191 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en') |
181 expected_output = '''CLASS MACHINE | 192 expected_output = self.ConstructOutput( |
193 ['MACHINE', 'USER'], ''' | |
182 CATEGORY !!chromium | 194 CATEGORY !!chromium |
183 KEYNAME "Software\\Policies\\Chromium" | 195 KEYNAME "Software\\Policies\\Chromium" |
184 | 196 |
185 POLICY !!IntPolicy_Policy | 197 POLICY !!IntPolicy_Policy |
186 #if version >= 4 | 198 #if version >= 4 |
187 SUPPORTED !!SUPPORTED_WINXPSP2 | 199 SUPPORTED !!SUPPORTED_WINXPSP2 |
188 #endif | 200 #endif |
189 EXPLAIN !!IntPolicy_Explain | 201 EXPLAIN !!IntPolicy_Explain |
190 | 202 |
191 PART !!IntPolicy_Part NUMERIC | 203 PART !!IntPolicy_Part NUMERIC |
192 VALUENAME "IntPolicy" | 204 VALUENAME "IntPolicy" |
193 END PART | 205 END PART |
194 END POLICY | 206 END POLICY |
195 | 207 |
196 END CATEGORY | 208 END CATEGORY |
197 | 209 |
198 [Strings] | 210 ''', '''[Strings] |
199 SUPPORTED_WINXPSP2="At least Windows 3.13" | 211 SUPPORTED_WINXPSP2="At least Windows 3.13" |
200 chromium="Chromium" | 212 chromium="Chromium" |
201 IntPolicy_Policy="Caption of policy." | 213 IntPolicy_Policy="Caption of policy." |
202 IntPolicy_Explain="Description of policy." | 214 IntPolicy_Explain="Description of policy." |
203 IntPolicy_Part="Caption of policy." | 215 IntPolicy_Part="Caption of policy." |
204 ''' | 216 ''') |
205 self.CompareOutputs(output, expected_output) | 217 self.CompareOutputs(output, expected_output) |
206 | 218 |
207 def testIntEnumPolicy(self): | 219 def testIntEnumPolicy(self): |
208 # Tests a policy group with a single policy of type 'int-enum'. | 220 # Tests a policy group with a single policy of type 'int-enum'. |
209 grd = self.PrepareTest(''' | 221 grd = self.PrepareTest(''' |
210 { | 222 { |
211 'policy_definitions': [ | 223 'policy_definitions': [ |
212 { | 224 { |
213 'name': 'EnumPolicy', | 225 'name': 'EnumPolicy', |
214 'type': 'int-enum', | 226 'type': 'int-enum', |
(...skipping 15 matching lines...) Expand all Loading... | |
230 }, | 242 }, |
231 ], | 243 ], |
232 'placeholders': [], | 244 'placeholders': [], |
233 'messages': { | 245 'messages': { |
234 'win_supported_winxpsp2': { | 246 'win_supported_winxpsp2': { |
235 'text': 'At least Windows 3.14', 'desc': 'blah' | 247 'text': 'At least Windows 3.14', 'desc': 'blah' |
236 } | 248 } |
237 } | 249 } |
238 }''') | 250 }''') |
239 output = self.GetOutput(grd, 'fr', {'_google_chrome': '1'}, 'adm', 'en') | 251 output = self.GetOutput(grd, 'fr', {'_google_chrome': '1'}, 'adm', 'en') |
240 expected_output = '''CLASS MACHINE | 252 expected_output = self.ConstructOutput( |
253 ['MACHINE', 'USER'], ''' | |
241 CATEGORY !!google | 254 CATEGORY !!google |
242 CATEGORY !!googlechrome | 255 CATEGORY !!googlechrome |
243 KEYNAME "Software\\Policies\\Google\\Chrome" | 256 KEYNAME "Software\\Policies\\Google\\Chrome" |
244 | 257 |
245 POLICY !!EnumPolicy_Policy | 258 POLICY !!EnumPolicy_Policy |
246 #if version >= 4 | 259 #if version >= 4 |
247 SUPPORTED !!SUPPORTED_WINXPSP2 | 260 SUPPORTED !!SUPPORTED_WINXPSP2 |
248 #endif | 261 #endif |
249 EXPLAIN !!EnumPolicy_Explain | 262 EXPLAIN !!EnumPolicy_Explain |
250 | 263 |
251 PART !!EnumPolicy_Part DROPDOWNLIST | 264 PART !!EnumPolicy_Part DROPDOWNLIST |
252 VALUENAME "EnumPolicy" | 265 VALUENAME "EnumPolicy" |
253 ITEMLIST | 266 ITEMLIST |
254 NAME !!ProxyServerDisabled_DropDown VALUE NUMERIC 0 | 267 NAME !!ProxyServerDisabled_DropDown VALUE NUMERIC 0 |
255 NAME !!ProxyServerAutoDetect_DropDown VALUE NUMERIC 1 | 268 NAME !!ProxyServerAutoDetect_DropDown VALUE NUMERIC 1 |
256 END ITEMLIST | 269 END ITEMLIST |
257 END PART | 270 END PART |
258 END POLICY | 271 END POLICY |
259 | 272 |
260 END CATEGORY | 273 END CATEGORY |
261 END CATEGORY | 274 END CATEGORY |
262 | 275 |
263 [Strings] | 276 ''', '''[Strings] |
264 SUPPORTED_WINXPSP2="At least Windows 3.14" | 277 SUPPORTED_WINXPSP2="At least Windows 3.14" |
265 google="Google" | 278 google="Google" |
266 googlechrome="Google Chrome" | 279 googlechrome="Google Chrome" |
267 EnumPolicy_Policy="Caption of policy." | 280 EnumPolicy_Policy="Caption of policy." |
268 EnumPolicy_Explain="Description of policy." | 281 EnumPolicy_Explain="Description of policy." |
269 EnumPolicy_Part="Caption of policy." | 282 EnumPolicy_Part="Caption of policy." |
270 ProxyServerDisabled_DropDown="Option1" | 283 ProxyServerDisabled_DropDown="Option1" |
271 ProxyServerAutoDetect_DropDown="Option2" | 284 ProxyServerAutoDetect_DropDown="Option2" |
272 ''' | 285 ''') |
273 self.CompareOutputs(output, expected_output) | 286 self.CompareOutputs(output, expected_output) |
274 | 287 |
275 def testStringEnumPolicy(self): | 288 def testStringEnumPolicy(self): |
276 # Tests a policy group with a single policy of type 'int-enum'. | 289 # Tests a policy group with a single policy of type 'int-enum'. |
277 grd = self.PrepareTest(''' | 290 grd = self.PrepareTest(''' |
278 { | 291 { |
279 'policy_definitions': [ | 292 'policy_definitions': [ |
280 { | 293 { |
281 'name': 'EnumPolicy', | 294 'name': 'EnumPolicy', |
282 'type': 'string-enum', | 295 'type': 'string-enum', |
283 'caption': 'Caption of policy.', | 296 'caption': 'Caption of policy.', |
284 'desc': 'Description of policy.', | 297 'desc': 'Description of policy.', |
285 'items': [ | 298 'items': [ |
286 {'name': 'ProxyServerDisabled', 'value': 'one', | 299 {'name': 'ProxyServerDisabled', 'value': 'one', |
287 'caption': 'Option1'}, | 300 'caption': 'Option1'}, |
288 {'name': 'ProxyServerAutoDetect', 'value': 'two', | 301 {'name': 'ProxyServerAutoDetect', 'value': 'two', |
289 'caption': 'Option2'}, | 302 'caption': 'Option2'}, |
290 ], | 303 ], |
291 'supported_on': ['chrome.win:8-'] | 304 'supported_on': ['chrome.win:8-'] |
292 }, | 305 }, |
293 ], | 306 ], |
294 'placeholders': [], | 307 'placeholders': [], |
295 'messages': { | 308 'messages': { |
296 'win_supported_winxpsp2': { | 309 'win_supported_winxpsp2': { |
297 'text': 'At least Windows 3.14', 'desc': 'blah' | 310 'text': 'At least Windows 3.14', 'desc': 'blah' |
298 } | 311 } |
299 } | 312 } |
300 }''') | 313 }''') |
301 output = self.GetOutput(grd, 'fr', {'_google_chrome': '1'}, 'adm', 'en') | 314 output = self.GetOutput(grd, 'fr', {'_google_chrome': '1'}, 'adm', 'en') |
302 expected_output = '''CLASS MACHINE | 315 expected_output = self.ConstructOutput( |
316 ['MACHINE', 'USER'], ''' | |
303 CATEGORY !!google | 317 CATEGORY !!google |
304 CATEGORY !!googlechrome | 318 CATEGORY !!googlechrome |
305 KEYNAME "Software\\Policies\\Google\\Chrome" | 319 KEYNAME "Software\\Policies\\Google\\Chrome" |
306 | 320 |
307 POLICY !!EnumPolicy_Policy | 321 POLICY !!EnumPolicy_Policy |
308 #if version >= 4 | 322 #if version >= 4 |
309 SUPPORTED !!SUPPORTED_WINXPSP2 | 323 SUPPORTED !!SUPPORTED_WINXPSP2 |
310 #endif | 324 #endif |
311 EXPLAIN !!EnumPolicy_Explain | 325 EXPLAIN !!EnumPolicy_Explain |
312 | 326 |
313 PART !!EnumPolicy_Part DROPDOWNLIST | 327 PART !!EnumPolicy_Part DROPDOWNLIST |
314 VALUENAME "EnumPolicy" | 328 VALUENAME "EnumPolicy" |
315 ITEMLIST | 329 ITEMLIST |
316 NAME !!ProxyServerDisabled_DropDown VALUE "one" | 330 NAME !!ProxyServerDisabled_DropDown VALUE "one" |
317 NAME !!ProxyServerAutoDetect_DropDown VALUE "two" | 331 NAME !!ProxyServerAutoDetect_DropDown VALUE "two" |
318 END ITEMLIST | 332 END ITEMLIST |
319 END PART | 333 END PART |
320 END POLICY | 334 END POLICY |
321 | 335 |
322 END CATEGORY | 336 END CATEGORY |
323 END CATEGORY | 337 END CATEGORY |
324 | 338 |
325 [Strings] | 339 ''', '''[Strings] |
326 SUPPORTED_WINXPSP2="At least Windows 3.14" | 340 SUPPORTED_WINXPSP2="At least Windows 3.14" |
327 google="Google" | 341 google="Google" |
328 googlechrome="Google Chrome" | 342 googlechrome="Google Chrome" |
329 EnumPolicy_Policy="Caption of policy." | 343 EnumPolicy_Policy="Caption of policy." |
330 EnumPolicy_Explain="Description of policy." | 344 EnumPolicy_Explain="Description of policy." |
331 EnumPolicy_Part="Caption of policy." | 345 EnumPolicy_Part="Caption of policy." |
332 ProxyServerDisabled_DropDown="Option1" | 346 ProxyServerDisabled_DropDown="Option1" |
333 ProxyServerAutoDetect_DropDown="Option2" | 347 ProxyServerAutoDetect_DropDown="Option2" |
334 ''' | 348 ''') |
335 self.CompareOutputs(output, expected_output) | 349 self.CompareOutputs(output, expected_output) |
336 | 350 |
337 def testListPolicy(self): | 351 def testListPolicy(self): |
338 # Tests a policy group with a single policy of type 'list'. | 352 # Tests a policy group with a single policy of type 'list'. |
339 grd = self.PrepareTest(''' | 353 grd = self.PrepareTest(''' |
340 { | 354 { |
341 'policy_definitions': [ | 355 'policy_definitions': [ |
342 { | 356 { |
343 'name': 'ListPolicy', | 357 'name': 'ListPolicy', |
344 'type': 'list', | 358 'type': 'list', |
345 'supported_on': ['chrome.win:8-'], | 359 'supported_on': ['chrome.win:8-'], |
346 'desc': """Description of list policy. | 360 'desc': """Description of list policy. |
347 With a newline.""", | 361 With a newline.""", |
348 'caption': 'Caption of list policy.', | 362 'caption': 'Caption of list policy.', |
349 'label': 'Label of list policy.' | 363 'label': 'Label of list policy.' |
350 }, | 364 }, |
351 ], | 365 ], |
352 'placeholders': [], | 366 'placeholders': [], |
353 'messages': { | 367 'messages': { |
354 'win_supported_winxpsp2': { | 368 'win_supported_winxpsp2': { |
355 'text': 'At least Windows 3.15', 'desc': 'blah' | 369 'text': 'At least Windows 3.15', 'desc': 'blah' |
356 } | 370 } |
357 }, | 371 }, |
358 }''') | 372 }''') |
359 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en') | 373 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en') |
360 expected_output = '''CLASS MACHINE | 374 expected_output = self.ConstructOutput( |
375 ['MACHINE', 'USER'], ''' | |
361 CATEGORY !!chromium | 376 CATEGORY !!chromium |
362 KEYNAME "Software\\Policies\\Chromium" | 377 KEYNAME "Software\\Policies\\Chromium" |
363 | 378 |
364 POLICY !!ListPolicy_Policy | 379 POLICY !!ListPolicy_Policy |
365 #if version >= 4 | 380 #if version >= 4 |
366 SUPPORTED !!SUPPORTED_WINXPSP2 | 381 SUPPORTED !!SUPPORTED_WINXPSP2 |
367 #endif | 382 #endif |
368 EXPLAIN !!ListPolicy_Explain | 383 EXPLAIN !!ListPolicy_Explain |
369 | 384 |
370 PART !!ListPolicy_Part LISTBOX | 385 PART !!ListPolicy_Part LISTBOX |
371 KEYNAME "Software\\Policies\\Chromium\\ListPolicy" | 386 KEYNAME "Software\\Policies\\Chromium\\ListPolicy" |
372 VALUEPREFIX "" | 387 VALUEPREFIX "" |
373 END PART | 388 END PART |
374 END POLICY | 389 END POLICY |
375 | 390 |
376 END CATEGORY | 391 END CATEGORY |
377 | 392 |
378 [Strings] | 393 ''', '''[Strings] |
379 SUPPORTED_WINXPSP2="At least Windows 3.15" | 394 SUPPORTED_WINXPSP2="At least Windows 3.15" |
380 chromium="Chromium" | 395 chromium="Chromium" |
381 ListPolicy_Policy="Caption of list policy." | 396 ListPolicy_Policy="Caption of list policy." |
382 ListPolicy_Explain="Description of list policy.\\nWith a newline." | 397 ListPolicy_Explain="Description of list policy.\\nWith a newline." |
383 ListPolicy_Part="Label of list policy." | 398 ListPolicy_Part="Label of list policy." |
384 ''' | 399 ''') |
385 self.CompareOutputs(output, expected_output) | 400 self.CompareOutputs(output, expected_output) |
386 | 401 |
387 def testNonSupportedPolicy(self): | 402 def testNonSupportedPolicy(self): |
388 # Tests a policy that is not supported on Windows, so it shouldn't | 403 # Tests a policy that is not supported on Windows, so it shouldn't |
389 # be included in the ADM file. | 404 # be included in the ADM file. |
390 grd = self.PrepareTest(''' | 405 grd = self.PrepareTest(''' |
391 { | 406 { |
392 'policy_definitions': [ | 407 'policy_definitions': [ |
393 { | 408 { |
394 'name': 'NonWinGroup', | 409 'name': 'NonWinGroup', |
(...skipping 10 matching lines...) Expand all Loading... | |
405 }, | 420 }, |
406 ], | 421 ], |
407 'placeholders': [], | 422 'placeholders': [], |
408 'messages': { | 423 'messages': { |
409 'win_supported_winxpsp2': { | 424 'win_supported_winxpsp2': { |
410 'text': 'At least Windows 3.16', 'desc': 'blah' | 425 'text': 'At least Windows 3.16', 'desc': 'blah' |
411 } | 426 } |
412 } | 427 } |
413 }''') | 428 }''') |
414 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en') | 429 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en') |
415 expected_output = '''CLASS MACHINE | 430 expected_output = self.ConstructOutput( |
431 ['MACHINE', 'USER'], ''' | |
416 CATEGORY !!chromium | 432 CATEGORY !!chromium |
417 KEYNAME "Software\\Policies\\Chromium" | 433 KEYNAME "Software\\Policies\\Chromium" |
418 | 434 |
419 END CATEGORY | 435 END CATEGORY |
420 | 436 |
421 [Strings] | 437 ''', '''[Strings] |
422 SUPPORTED_WINXPSP2="At least Windows 3.16" | 438 SUPPORTED_WINXPSP2="At least Windows 3.16" |
423 chromium="Chromium" | 439 chromium="Chromium" |
424 ''' | 440 ''') |
425 self.CompareOutputs(output, expected_output) | 441 self.CompareOutputs(output, expected_output) |
426 | 442 |
427 def testPolicyGroup(self): | 443 def testPolicyGroup(self): |
428 # Tests a policy group that has more than one policies. | 444 # Tests a policy group that has more than one policies. |
429 grd = self.PrepareTest(''' | 445 grd = self.PrepareTest(''' |
430 { | 446 { |
431 'policy_definitions': [ | 447 'policy_definitions': [ |
432 { | 448 { |
433 'name': 'Group1', | 449 'name': 'Group1', |
434 'type': 'group', | 450 'type': 'group', |
(...skipping 17 matching lines...) Expand all Loading... | |
452 }, | 468 }, |
453 ], | 469 ], |
454 'placeholders': [], | 470 'placeholders': [], |
455 'messages': { | 471 'messages': { |
456 'win_supported_winxpsp2': { | 472 'win_supported_winxpsp2': { |
457 'text': 'At least Windows 3.16', 'desc': 'blah' | 473 'text': 'At least Windows 3.16', 'desc': 'blah' |
458 } | 474 } |
459 } | 475 } |
460 }''') | 476 }''') |
461 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en') | 477 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'adm', 'en') |
462 expected_output = '''CLASS MACHINE | 478 expected_output = self.ConstructOutput( |
479 ['MACHINE', 'USER'], ''' | |
463 CATEGORY !!chromium | 480 CATEGORY !!chromium |
464 KEYNAME "Software\\Policies\\Chromium" | 481 KEYNAME "Software\\Policies\\Chromium" |
465 | 482 |
466 CATEGORY !!Group1_Category | 483 CATEGORY !!Group1_Category |
467 POLICY !!Policy1_Policy | 484 POLICY !!Policy1_Policy |
468 #if version >= 4 | 485 #if version >= 4 |
469 SUPPORTED !!SUPPORTED_WINXPSP2 | 486 SUPPORTED !!SUPPORTED_WINXPSP2 |
470 #endif | 487 #endif |
471 EXPLAIN !!Policy1_Explain | 488 EXPLAIN !!Policy1_Explain |
472 | 489 |
473 PART !!Policy1_Part LISTBOX | 490 PART !!Policy1_Part LISTBOX |
474 KEYNAME "Software\\Policies\\Chromium\\Policy1" | 491 KEYNAME "Software\\Policies\\Chromium\\Policy1" |
475 VALUEPREFIX "" | 492 VALUEPREFIX "" |
476 END PART | 493 END PART |
477 END POLICY | 494 END POLICY |
478 | 495 |
479 POLICY !!Policy2_Policy | 496 POLICY !!Policy2_Policy |
480 #if version >= 4 | 497 #if version >= 4 |
481 SUPPORTED !!SUPPORTED_WINXPSP2 | 498 SUPPORTED !!SUPPORTED_WINXPSP2 |
482 #endif | 499 #endif |
483 EXPLAIN !!Policy2_Explain | 500 EXPLAIN !!Policy2_Explain |
484 | 501 |
485 PART !!Policy2_Part EDITTEXT | 502 PART !!Policy2_Part EDITTEXT |
486 VALUENAME "Policy2" | 503 VALUENAME "Policy2" |
487 END PART | 504 END PART |
488 END POLICY | 505 END POLICY |
489 | 506 |
490 END CATEGORY | 507 END CATEGORY |
508 | |
491 END CATEGORY | 509 END CATEGORY |
492 | 510 |
493 [Strings] | 511 ''', '''[Strings] |
494 SUPPORTED_WINXPSP2="At least Windows 3.16" | 512 SUPPORTED_WINXPSP2="At least Windows 3.16" |
495 chromium="Chromium" | 513 chromium="Chromium" |
496 Group1_Category="Caption of group." | 514 Group1_Category="Caption of group." |
497 Policy1_Policy="Caption of policy1." | 515 Policy1_Policy="Caption of policy1." |
498 Policy1_Explain="Description of policy1.\\nWith a newline." | 516 Policy1_Explain="Description of policy1.\\nWith a newline." |
499 Policy1_Part="Caption of policy1." | 517 Policy1_Part="Caption of policy1." |
500 Policy2_Policy="Caption of policy2." | 518 Policy2_Policy="Caption of policy2." |
501 Policy2_Explain="Description of policy2.\\nWith a newline." | 519 Policy2_Explain="Description of policy2.\\nWith a newline." |
502 Policy2_Part="Caption of policy2." | 520 Policy2_Part="Caption of policy2." |
503 ''' | 521 ''') |
504 self.CompareOutputs(output, expected_output) | 522 self.CompareOutputs(output, expected_output) |
505 | 523 |
506 if __name__ == '__main__': | 524 if __name__ == '__main__': |
507 unittest.main() | 525 unittest.main() |
OLD | NEW |