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

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

Issue 38573008: Add "platforms" key in IDL schema compiler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments Created 7 years, 1 month 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
« no previous file with comments | « tools/json_schema_compiler/idl_schema.py ('k') | tools/json_schema_compiler/model.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import idl_schema 6 import idl_schema
7 import unittest 7 import unittest
8 8
9 def getFunction(schema, name): 9 def getFunction(schema, name):
10 for item in schema['functions']: 10 for item in schema['functions']:
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 enum_with_nodoc = getType(schema, 'EnumTypeWithNoDoc') 101 enum_with_nodoc = getType(schema, 'EnumTypeWithNoDoc')
102 self.assertTrue(enum_with_nodoc is not None) 102 self.assertTrue(enum_with_nodoc is not None)
103 self.assertTrue(enum_with_nodoc['nodoc']) 103 self.assertTrue(enum_with_nodoc['nodoc'])
104 104
105 def testInternalNamespace(self): 105 def testInternalNamespace(self):
106 idl_basics = self.idl_basics 106 idl_basics = self.idl_basics
107 self.assertEquals('idl_basics', idl_basics['namespace']) 107 self.assertEquals('idl_basics', idl_basics['namespace'])
108 self.assertTrue(idl_basics['internal']) 108 self.assertTrue(idl_basics['internal'])
109 self.assertFalse(idl_basics['nodoc']) 109 self.assertFalse(idl_basics['nodoc'])
110 110
111 def testChromeOSPlatformsNamespace(self):
112 schema = idl_schema.Load('test/idl_namespace_chromeos.idl')[0]
113 self.assertEquals('idl_namespace_chromeos', schema['namespace'])
114 expected = ['chromeos']
115 self.assertEquals(expected, schema['platforms'])
116
117 def testAllPlatformsNamespace(self):
118 schema = idl_schema.Load('test/idl_namespace_all_platforms.idl')[0]
119 self.assertEquals('idl_namespace_all_platforms', schema['namespace'])
120 expected = ['chromeos', 'chromeos_touch', 'linux', 'mac', 'win']
121 self.assertEquals(expected, schema['platforms'])
122
123 def testNonSpecificPlatformsNamespace(self):
124 schema = idl_schema.Load('test/idl_namespace_non_specific_platforms.idl')[0]
125 self.assertEquals('idl_namespace_non_specific_platforms',
126 schema['namespace'])
127 expected = None
128 self.assertEquals(expected, schema['platforms'])
129
111 def testCallbackComment(self): 130 def testCallbackComment(self):
112 schema = self.idl_basics 131 schema = self.idl_basics
113 self.assertEquals('A comment on a callback.', 132 self.assertEquals('A comment on a callback.',
114 getParams(schema, 'function16')[0]['description']) 133 getParams(schema, 'function16')[0]['description'])
115 self.assertEquals( 134 self.assertEquals(
116 'A parameter.', 135 'A parameter.',
117 getParams(schema, 'function16')[0]['parameters'][0]['description']) 136 getParams(schema, 'function16')[0]['parameters'][0]['description'])
118 self.assertEquals( 137 self.assertEquals(
119 'Just a parameter comment, with no comment on the callback.', 138 'Just a parameter comment, with no comment on the callback.',
120 getParams(schema, 'function17')[0]['parameters'][0]['description']) 139 getParams(schema, 'function17')[0]['parameters'][0]['description'])
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 mytype = getType(schema, 'MyType') 173 mytype = getType(schema, 'MyType')
155 self.assertEquals('string', mytype['properties']['interface']['type']) 174 self.assertEquals('string', mytype['properties']['interface']['type'])
156 175
157 params = getParams(schema, 'static') 176 params = getParams(schema, 'static')
158 self.assertEquals('Foo', params[0]['$ref']) 177 self.assertEquals('Foo', params[0]['$ref'])
159 self.assertEquals('enum', params[1]['$ref']) 178 self.assertEquals('enum', params[1]['$ref'])
160 179
161 180
162 if __name__ == '__main__': 181 if __name__ == '__main__':
163 unittest.main() 182 unittest.main()
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/idl_schema.py ('k') | tools/json_schema_compiler/model.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698