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

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: Add test 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
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 testAllPlatformsNamespace(self):
112 schema = idl_schema.Load('test/idl_namespace_all_platforms.idl')[0]
113 self.assertEquals('idl_namespace_all_platforms', schema['namespace'])
114 expected = ['chromeos', 'chromeos_touch', 'linux', 'mac', 'win']
115 self.assertEquals(expected, schema['platforms'])
116
117 def testChromeOSPlatformsNamespace(self):
118 schema = idl_schema.Load('test/idl_namespace_chromeos.idl')[0]
119 self.assertEquals('idl_namespace_chromeos', schema['namespace'])
120 expected = ['chromeos']
121 self.assertEquals(expected, schema['platforms'])
122
111 def testCallbackComment(self): 123 def testCallbackComment(self):
112 schema = self.idl_basics 124 schema = self.idl_basics
113 self.assertEquals('A comment on a callback.', 125 self.assertEquals('A comment on a callback.',
114 getParams(schema, 'function16')[0]['description']) 126 getParams(schema, 'function16')[0]['description'])
115 self.assertEquals( 127 self.assertEquals(
116 'A parameter.', 128 'A parameter.',
117 getParams(schema, 'function16')[0]['parameters'][0]['description']) 129 getParams(schema, 'function16')[0]['parameters'][0]['description'])
118 self.assertEquals( 130 self.assertEquals(
119 'Just a parameter comment, with no comment on the callback.', 131 'Just a parameter comment, with no comment on the callback.',
120 getParams(schema, 'function17')[0]['parameters'][0]['description']) 132 getParams(schema, 'function17')[0]['parameters'][0]['description'])
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 mytype = getType(schema, 'MyType') 166 mytype = getType(schema, 'MyType')
155 self.assertEquals('string', mytype['properties']['interface']['type']) 167 self.assertEquals('string', mytype['properties']['interface']['type'])
156 168
157 params = getParams(schema, 'static') 169 params = getParams(schema, 'static')
158 self.assertEquals('Foo', params[0]['$ref']) 170 self.assertEquals('Foo', params[0]['$ref'])
159 self.assertEquals('enum', params[1]['$ref']) 171 self.assertEquals('enum', params[1]['$ref'])
160 172
161 173
162 if __name__ == '__main__': 174 if __name__ == '__main__':
163 unittest.main() 175 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698