OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 import idl_schema | 6 import idl_schema |
7 import json_parse | 7 import json_parse |
8 from js_externs_generator import JsExternsGenerator | 8 from js_externs_generator import JsExternsGenerator |
9 from datetime import datetime | 9 from datetime import datetime |
10 import model | 10 import model |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 | 157 |
158 fake_json = """// Copyright 2014 The Chromium Authors. All rights reserved. | 158 fake_json = """// Copyright 2014 The Chromium Authors. All rights reserved. |
159 // Use of this source code is governed by a BSD-style license that can be | 159 // Use of this source code is governed by a BSD-style license that can be |
160 // found in the LICENSE file. | 160 // found in the LICENSE file. |
161 | 161 |
162 [ | 162 [ |
163 { | 163 { |
164 "namespace": "fakeJson", | 164 "namespace": "fakeJson", |
165 "description": "Fake JSON API Stuff", | 165 "description": "Fake JSON API Stuff", |
| 166 "types": [ { |
| 167 "id": "CrazyEnum", |
| 168 "type": "string", |
| 169 "enum": ["camelCaseEnum", "Non-Characters", "5NumFirst", \ |
| 170 "3Just-plainOld_MEAN"] |
| 171 } ], |
166 "functions": [ { | 172 "functions": [ { |
167 "name": "funcWithInlineObj", | 173 "name": "funcWithInlineObj", |
168 "type": "function", | 174 "type": "function", |
169 "parameters": [ | 175 "parameters": [ |
170 { | 176 { |
171 "type": "object", | 177 "type": "object", |
172 "name": "inlineObj", | 178 "name": "inlineObj", |
173 "description": "Evil inline object! With a super duper duper long\ | 179 "description": "Evil inline object! With a super duper duper long\ |
174 string description that causes problems!", | 180 string description that causes problems!", |
175 "properties": { | 181 "properties": { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 // found in the LICENSE file. | 230 // found in the LICENSE file. |
225 | 231 |
226 /** @fileoverview Externs generated from namespace: fakeJson */ | 232 /** @fileoverview Externs generated from namespace: fakeJson */ |
227 | 233 |
228 /** | 234 /** |
229 * @const | 235 * @const |
230 */ | 236 */ |
231 chrome.fakeJson = {}; | 237 chrome.fakeJson = {}; |
232 | 238 |
233 /** | 239 /** |
| 240 * @enum {string} |
| 241 * @see https://developer.chrome.com/extensions/fakeJson#type-CrazyEnum |
| 242 */ |
| 243 chrome.fakeJson.CrazyEnum = { |
| 244 CAMEL_CASE_ENUM: 'camelCaseEnum', |
| 245 NON_CHARACTERS: 'Non-Characters', |
| 246 _5NUM_FIRST: '5NumFirst', |
| 247 _3JUST_PLAIN_OLD_MEAN: '3Just-plainOld_MEAN', |
| 248 }; |
| 249 |
| 250 /** |
234 * @param {{ | 251 * @param {{ |
235 * foo: (boolean|undefined), | 252 * foo: (boolean|undefined), |
236 * bar: number, | 253 * bar: number, |
237 * baz: { | 254 * baz: { |
238 * depth: number | 255 * depth: number |
239 * } | 256 * } |
240 * }} inlineObj Evil inline object! With a super duper duper long string | 257 * }} inlineObj Evil inline object! With a super duper duper long string |
241 * description that causes problems! | 258 * description that causes problems! |
242 * @param {function({ | 259 * @param {function({ |
243 * str: string | 260 * str: string |
(...skipping 25 matching lines...) Expand all Loading... |
269 JsExternsGenerator().Generate(namespace).Render()) | 286 JsExternsGenerator().Generate(namespace).Render()) |
270 | 287 |
271 def testJsonWithInlineObjects(self): | 288 def testJsonWithInlineObjects(self): |
272 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) | 289 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) |
273 self.assertMultiLineEqual(json_expected, | 290 self.assertMultiLineEqual(json_expected, |
274 JsExternsGenerator().Generate(namespace).Render()) | 291 JsExternsGenerator().Generate(namespace).Render()) |
275 | 292 |
276 | 293 |
277 if __name__ == '__main__': | 294 if __name__ == '__main__': |
278 unittest.main() | 295 unittest.main() |
OLD | NEW |