OLD | NEW |
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.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 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 ''', '''[Strings] | 141 ''', '''[Strings] |
142 SUPPORTED_WINXPSP2="At least Windows 3.12" | 142 SUPPORTED_WINXPSP2="At least Windows 3.12" |
143 google="Google" | 143 google="Google" |
144 googlechrome="Google Chrome" | 144 googlechrome="Google Chrome" |
145 googlechrome_recommended="Google Chrome - Recommended" | 145 googlechrome_recommended="Google Chrome - Recommended" |
146 MainPolicy_Policy="Caption of main." | 146 MainPolicy_Policy="Caption of main." |
147 MainPolicy_Explain="Description of main."''') | 147 MainPolicy_Explain="Description of main."''') |
148 self.CompareOutputs(output, expected_output) | 148 self.CompareOutputs(output, expected_output) |
149 | 149 |
| 150 def testMainPolicyRecommendedOnly(self): |
| 151 # Tests a policy group with a single policy of type 'main'. |
| 152 grd = self.PrepareTest(''' |
| 153 { |
| 154 'policy_definitions': [ |
| 155 { |
| 156 'name': 'MainPolicy', |
| 157 'type': 'main', |
| 158 'supported_on': ['chrome.win:8-'], |
| 159 'features': { |
| 160 'can_be_recommended': True, |
| 161 'can_be_mandatory': False |
| 162 }, |
| 163 'caption': 'Caption of main.', |
| 164 'desc': 'Description of main.', |
| 165 }, |
| 166 ], |
| 167 'placeholders': [], |
| 168 'messages': { |
| 169 'win_supported_winxpsp2': { |
| 170 'text': 'At least Windows 3.12', 'desc': 'blah' |
| 171 }, |
| 172 'doc_recommended': { |
| 173 'text': 'Recommended', 'desc': 'bleh' |
| 174 } |
| 175 } |
| 176 }''') |
| 177 output = self.GetOutput(grd, 'fr', {'_google_chrome' : '1'}, 'adm', 'en') |
| 178 expected_output = self.ConstructOutput( |
| 179 ['MACHINE', 'USER'], ''' |
| 180 CATEGORY !!google |
| 181 CATEGORY !!googlechrome |
| 182 KEYNAME "Software\\Policies\\Google\\Chrome" |
| 183 |
| 184 END CATEGORY |
| 185 END CATEGORY |
| 186 |
| 187 CATEGORY !!google |
| 188 CATEGORY !!googlechrome_recommended |
| 189 KEYNAME "Software\\Policies\\Google\\Chrome\\Recommended" |
| 190 |
| 191 POLICY !!MainPolicy_Policy |
| 192 #if version >= 4 |
| 193 SUPPORTED !!SUPPORTED_WINXPSP2 |
| 194 #endif |
| 195 EXPLAIN !!MainPolicy_Explain |
| 196 VALUENAME "MainPolicy" |
| 197 VALUEON NUMERIC 1 |
| 198 VALUEOFF NUMERIC 0 |
| 199 END POLICY |
| 200 |
| 201 END CATEGORY |
| 202 END CATEGORY |
| 203 |
| 204 |
| 205 ''', '''[Strings] |
| 206 SUPPORTED_WINXPSP2="At least Windows 3.12" |
| 207 google="Google" |
| 208 googlechrome="Google Chrome" |
| 209 googlechrome_recommended="Google Chrome - Recommended" |
| 210 MainPolicy_Policy="Caption of main." |
| 211 MainPolicy_Explain="Description of main."''') |
| 212 self.CompareOutputs(output, expected_output) |
| 213 |
150 def testStringPolicy(self): | 214 def testStringPolicy(self): |
151 # Tests a policy group with a single policy of type 'string'. | 215 # Tests a policy group with a single policy of type 'string'. |
152 grd = self.PrepareTest(''' | 216 grd = self.PrepareTest(''' |
153 { | 217 { |
154 'policy_definitions': [ | 218 'policy_definitions': [ |
155 { | 219 { |
156 'name': 'StringPolicy', | 220 'name': 'StringPolicy', |
157 'type': 'string', | 221 'type': 'string', |
158 'supported_on': ['chrome.win:8-'], | 222 'supported_on': ['chrome.win:8-'], |
159 'features': { 'can_be_recommended': True }, | 223 'features': { 'can_be_recommended': True }, |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 Policy1_Explain="Description of policy1.\\nWith a newline." | 979 Policy1_Explain="Description of policy1.\\nWith a newline." |
916 Policy1_Part="Caption of policy1." | 980 Policy1_Part="Caption of policy1." |
917 Policy2_Policy="Caption of policy2." | 981 Policy2_Policy="Caption of policy2." |
918 Policy2_Explain="Description of policy2.\\nWith a newline." | 982 Policy2_Explain="Description of policy2.\\nWith a newline." |
919 Policy2_Part="Caption of policy2." | 983 Policy2_Part="Caption of policy2." |
920 ''') | 984 ''') |
921 self.CompareOutputs(output, expected_output) | 985 self.CompareOutputs(output, expected_output) |
922 | 986 |
923 if __name__ == '__main__': | 987 if __name__ == '__main__': |
924 unittest.main() | 988 unittest.main() |
OLD | NEW |