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

Unified Diff: tools/json_schema_compiler/idl_schema_test.py

Issue 10054039: Support array types for function and callback arguments in IDL APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: tools/json_schema_compiler/idl_schema_test.py
diff --git a/tools/json_schema_compiler/idl_schema_test.py b/tools/json_schema_compiler/idl_schema_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..59fcd6da00710da317b60d1bf3296bae4166b169
--- /dev/null
+++ b/tools/json_schema_compiler/idl_schema_test.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import idl_schema
+import unittest
+
+def getFunction(schema, name):
+ for item in schema['functions']:
+ if item['name'] == name:
+ return item
+ raise KeyError('Missing function %s' % name)
+
+def getParams(schema, name):
+ function = getFunction(schema, name)
+ return function['parameters']
+
+class IdlSchemaTest(unittest.TestCase):
+ def setUp(self):
+ loaded = idl_schema.Load('test/idl_basics.idl')
+ self.assertEquals(1, len(loaded))
+ self.assertEquals('idl_basics', loaded[0]['namespace'])
+ self.idl_basics = loaded[0]
+
+ def testSimpleCallbacks(self):
+ schema = self.idl_basics
+ expected = [{'type':'function', 'name':'Callback1', 'parameters':[]}]
+ self.assertEquals(expected, getParams(schema, 'function4'))
+
+ expected = [{'type':'function', 'name':'Callback2',
+ 'parameters':[{'name':'x', 'type':'integer'}]}]
+ self.assertEquals(expected, getParams(schema, 'function5'))
+
+ expected = [{'type':'function', 'name':'Callback3',
+ 'parameters':[{'name':'arg', '$ref':'MyType1'}]}]
+ self.assertEquals(expected, getParams(schema, 'function6'))
+
+ def testCallbackWithArrayArgument(self):
+ schema = self.idl_basics
+ expected = [{'type':'function', 'name':'Callback4',
+ 'parameters':[{'name':'arg', 'type':'array',
+ 'items':{'$ref':'MyType2'}}]}]
+ self.assertEquals(expected, getParams(schema, 'function12'))
+
+if __name__ == '__main__':
+ unittest.main()

Powered by Google App Engine
This is Rietveld 408576698