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

Side by Side Diff: tools/grit/grit/format/policy_templates/writers/json_writer_unittest.py

Issue 5958014: Policy: Add ProxyMode and deprecate ProxyServerMode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests on all platforms Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python2.4 1 #!/usr/bin/python2.4
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 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.json_writer''' 6 '''Unit tests for grit.format.policy_templates.writers.json_writer'''
7 7
8 8
9 import os 9 import os
10 import sys 10 import sys
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 ' <message name="IDS_POLICY_STRINGPOLICY_CAPTION"></message>' 91 ' <message name="IDS_POLICY_STRINGPOLICY_CAPTION"></message>'
92 ' <message name="IDS_POLICY_STRINGPOLICY_DESC"></message>' 92 ' <message name="IDS_POLICY_STRINGPOLICY_DESC"></message>'
93 '</messages>') 93 '</messages>')
94 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'json', 'en') 94 output = self.GetOutput(grd, 'fr', {'_chromium' : '1'}, 'json', 'en')
95 expected_output = ( 95 expected_output = (
96 '{\n' 96 '{\n'
97 ' "StringPolicy": "hello, world!"\n' 97 ' "StringPolicy": "hello, world!"\n'
98 '}') 98 '}')
99 self.CompareOutputs(output, expected_output) 99 self.CompareOutputs(output, expected_output)
100 100
101 def testEnumPolicy(self): 101 def testIntEnumPolicy(self):
102 # Tests a policy group with a single policy of type 'enum'. 102 # Tests a policy group with a single policy of type 'int-enum'.
103 grd = self.PrepareTest( 103 grd = self.PrepareTest(
104 '{' 104 '{'
105 ' "policy_definitions": [' 105 ' "policy_definitions": ['
106 ' {' 106 ' {'
107 ' "name": "EnumPolicy",' 107 ' "name": "EnumPolicy",'
108 ' "type": "enum",' 108 ' "type": "int-enum",'
109 ' "items": [' 109 ' "items": ['
110 ' {"name": "ProxyServerDisabled", "value": 0},' 110 ' {"name": "ProxyServerDisabled", "value": 0},'
111 ' {"name": "ProxyServerAutoDetect", "value": 1},' 111 ' {"name": "ProxyServerAutoDetect", "value": 1},'
112 ' ],' 112 ' ],'
113 ' "supported_on": ["chrome.linux:8-"],' 113 ' "supported_on": ["chrome.linux:8-"],'
114 ' "annotations": {' 114 ' "annotations": {'
115 ' "example_value": 1' 115 ' "example_value": 1'
116 ' }' 116 ' }'
117 ' },' 117 ' },'
118 ' ],' 118 ' ],'
119 ' "placeholders": [],' 119 ' "placeholders": [],'
120 '}', 120 '}',
121 '<messages>' 121 '<messages>'
122 ' <message name="IDS_POLICY_ENUMPOLICY_CAPTION"></message>' 122 ' <message name="IDS_POLICY_ENUMPOLICY_CAPTION"></message>'
123 ' <message name="IDS_POLICY_ENUMPOLICY_DESC"></message>' 123 ' <message name="IDS_POLICY_ENUMPOLICY_DESC"></message>'
124 ' <message name="IDS_POLICY_ENUM_PROXYSERVERDISABLED_CAPTION">' 124 ' <message name="IDS_POLICY_ENUM_PROXYSERVERDISABLED_CAPTION">'
125 ' </message>' 125 ' </message>'
126 ' <message name="IDS_POLICY_ENUM_PROXYSERVERAUTODETECT_CAPTION">' 126 ' <message name="IDS_POLICY_ENUM_PROXYSERVERAUTODETECT_CAPTION">'
127 ' </message>' 127 ' </message>'
128 '</messages>') 128 '</messages>')
129 output = self.GetOutput(grd, 'fr', {'_google_chrome': '1'}, 'json', 'en') 129 output = self.GetOutput(grd, 'fr', {'_google_chrome': '1'}, 'json', 'en')
130 expected_output = ( 130 expected_output = (
131 '{\n' 131 '{\n'
132 ' "EnumPolicy": 1\n' 132 ' "EnumPolicy": 1\n'
133 '}') 133 '}')
134 self.CompareOutputs(output, expected_output) 134 self.CompareOutputs(output, expected_output)
135 135
136 def testStringEnumPolicy(self):
137 # Tests a policy group with a single policy of type 'string-enum'.
138 grd = self.PrepareTest(
139 '{'
140 ' "policy_definitions": ['
141 ' {'
142 ' "name": "EnumPolicy",'
143 ' "type": "string-enum",'
144 ' "items": ['
145 ' {"name": "ProxyServerDisabled", "value": "one"},'
146 ' {"name": "ProxyServerAutoDetect", "value": "two"},'
147 ' ],'
148 ' "supported_on": ["chrome.linux:8-"],'
149 ' "annotations": {'
150 ' "example_value": "one"'
151 ' }'
152 ' },'
153 ' ],'
154 ' "placeholders": [],'
155 '}',
156 '<messages>'
157 ' <message name="IDS_POLICY_ENUMPOLICY_CAPTION"></message>'
158 ' <message name="IDS_POLICY_ENUMPOLICY_DESC"></message>'
159 ' <message name="IDS_POLICY_ENUM_PROXYSERVERDISABLED_CAPTION">'
160 ' </message>'
161 ' <message name="IDS_POLICY_ENUM_PROXYSERVERAUTODETECT_CAPTION">'
162 ' </message>'
163 '</messages>')
164 output = self.GetOutput(grd, 'fr', {'_google_chrome': '1'}, 'json', 'en')
165 expected_output = (
166 '{\n'
167 ' "EnumPolicy": "one"\n'
168 '}')
169 self.CompareOutputs(output, expected_output)
170
136 def testListPolicy(self): 171 def testListPolicy(self):
137 # Tests a policy group with a single policy of type 'list'. 172 # Tests a policy group with a single policy of type 'list'.
138 grd = self.PrepareTest( 173 grd = self.PrepareTest(
139 '{' 174 '{'
140 ' "policy_definitions": [' 175 ' "policy_definitions": ['
141 ' {' 176 ' {'
142 ' "name": "ListPolicy",' 177 ' "name": "ListPolicy",'
143 ' "type": "list",' 178 ' "type": "list",'
144 ' "supported_on": ["chrome.linux:8-"],' 179 ' "supported_on": ["chrome.linux:8-"],'
145 ' "annotations": {' 180 ' "annotations": {'
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 expected_output = ( 260 expected_output = (
226 '{\n' 261 '{\n'
227 ' "Policy1": ["a", "b"],\n' 262 ' "Policy1": ["a", "b"],\n'
228 ' "Policy2": "c"\n' 263 ' "Policy2": "c"\n'
229 '}') 264 '}')
230 self.CompareOutputs(output, expected_output) 265 self.CompareOutputs(output, expected_output)
231 266
232 267
233 if __name__ == '__main__': 268 if __name__ == '__main__':
234 unittest.main() 269 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698