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

Side by Side Diff: tools/json_schema_compiler/js_externs_generator_test.py

Issue 1513573012: Fix line wrapping in json_schema_compiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Generate -> Append Created 4 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
OLDNEW
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 * @param {function({ 272 * @param {function({
273 * str: string 273 * str: string
274 * }):void} callback The callback to this heinous method 274 * }):void} callback The callback to this heinous method
275 * @return {{ 275 * @return {{
276 * str: string, 276 * str: string,
277 * int: number 277 * int: number
278 * }} 278 * }}
279 * @see https://developer.chrome.com/extensions/fakeJson#method-funcWithInlineOb j 279 * @see https://developer.chrome.com/extensions/fakeJson#method-funcWithInlineOb j
280 */ 280 */
281 chrome.fakeJson.funcWithInlineObj = function(inlineObj, callback) {};""" % 281 chrome.fakeJson.funcWithInlineObj = function(inlineObj, callback) {};""" %
282 (datetime.now().year, sys.argv[0])) 282 (datetime.now().year, sys.argv[0]))
283 283
284 284
285 class JsExternGeneratorTest(unittest.TestCase): 285 class JsExternGeneratorTest(unittest.TestCase):
286 def _GetNamespace(self, fake_content, filename, is_idl): 286 def _GetNamespace(self, fake_content, filename, is_idl):
287 """Returns a namespace object for the given content""" 287 """Returns a namespace object for the given content"""
288 api_def = (idl_schema.Process(fake_content, filename) if is_idl 288 api_def = (idl_schema.Process(fake_content, filename) if is_idl
289 else json_parse.Parse(fake_content)) 289 else json_parse.Parse(fake_content))
290 m = model.Model() 290 m = model.Model()
291 return m.AddNamespace(api_def[0], filename) 291 return m.AddNamespace(api_def[0], filename)
292 292
293 def setUp(self): 293 def setUp(self):
294 self.maxDiff = None # Lets us see the full diff when inequal. 294 self.maxDiff = None # Lets us see the full diff when inequal.
295 295
296 def testBasic(self): 296 def testBasic(self):
297 namespace = self._GetNamespace(fake_idl, 'fake_api.idl', True) 297 namespace = self._GetNamespace(fake_idl, 'fake_api.idl', True)
298 self.assertMultiLineEqual(expected_output, 298 self.assertMultiLineEqual(expected_output,
299 JsExternsGenerator().Generate(namespace).Render()) 299 JsExternsGenerator().Generate(namespace).Render())
300 300
301 def testJsonWithInlineObjects(self): 301 def testJsonWithInlineObjects(self):
302 namespace = self._GetNamespace(fake_json, 'fake_api.json', False) 302 namespace = self._GetNamespace(fake_json, 'fake_api.json', False)
303 self.assertMultiLineEqual(json_expected, 303 self.assertMultiLineEqual(json_expected,
304 JsExternsGenerator().Generate(namespace).Render()) 304 JsExternsGenerator().Generate(namespace).Render())
305 305
306 306
307 if __name__ == '__main__': 307 if __name__ == '__main__':
308 unittest.main() 308 unittest.main()
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/js_externs_generator.py ('k') | tools/json_schema_compiler/js_interface_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698