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

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

Issue 56543003: Add "implemented_in" key in IDL schema compiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address kalman's comment 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 expected = ['chromeos', 'chromeos_touch', 'linux', 'mac', 'win'] 122 expected = ['chromeos', 'chromeos_touch', 'linux', 'mac', 'win']
123 self.assertEquals(expected, schema['platforms']) 123 self.assertEquals(expected, schema['platforms'])
124 124
125 def testNonSpecificPlatformsNamespace(self): 125 def testNonSpecificPlatformsNamespace(self):
126 schema = idl_schema.Load('test/idl_namespace_non_specific_platforms.idl')[0] 126 schema = idl_schema.Load('test/idl_namespace_non_specific_platforms.idl')[0]
127 self.assertEquals('idl_namespace_non_specific_platforms', 127 self.assertEquals('idl_namespace_non_specific_platforms',
128 schema['namespace']) 128 schema['namespace'])
129 expected = None 129 expected = None
130 self.assertEquals(expected, schema['platforms']) 130 self.assertEquals(expected, schema['platforms'])
131 131
132 def testSpecificImplementNamespace(self):
133 schema = idl_schema.Load('test/idl_namespace_specific_implement.idl')[0]
134 self.assertEquals('idl_namespace_specific_implement',
135 schema['namespace'])
136 expected = "idl_namespace_specific_implement.idl"
sergeygs 2013/11/02 06:20:44 Single quotes?
Haojian Wu 2013/11/03 01:56:16 Done.
137 self.assertEquals(expected, schema['compiler_options']['implemented_in'])
138
139 def testSpecificImplementOnChromeOSNamespace(self):
140 schema = idl_schema.Load(
141 'test/idl_namespace_specific_implement_chromeos.idl')[0]
142 self.assertEquals('idl_namespace_specific_implement_chromeos',
143 schema['namespace'])
144 expected_implemented_path = "idl_namespace_specific_implement_chromeos.idl"
sergeygs 2013/11/02 06:20:44 Single quotes?
Haojian Wu 2013/11/03 01:56:16 Done.
145 expected_platform = ['chromeos']
146 self.assertEquals(expected_implemented_path,
147 schema['compiler_options']['implemented_in'])
148 self.assertEquals(expected_platform, schema['platforms'])
149
132 def testCallbackComment(self): 150 def testCallbackComment(self):
133 schema = self.idl_basics 151 schema = self.idl_basics
134 self.assertEquals('A comment on a callback.', 152 self.assertEquals('A comment on a callback.',
135 getParams(schema, 'function16')[0]['description']) 153 getParams(schema, 'function16')[0]['description'])
136 self.assertEquals( 154 self.assertEquals(
137 'A parameter.', 155 'A parameter.',
138 getParams(schema, 'function16')[0]['parameters'][0]['description']) 156 getParams(schema, 'function16')[0]['parameters'][0]['description'])
139 self.assertEquals( 157 self.assertEquals(
140 'Just a parameter comment, with no comment on the callback.', 158 'Just a parameter comment, with no comment on the callback.',
141 getParams(schema, 'function17')[0]['parameters'][0]['description']) 159 getParams(schema, 'function17')[0]['parameters'][0]['description'])
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 mytype = getType(schema, 'MyType') 195 mytype = getType(schema, 'MyType')
178 self.assertEquals('string', mytype['properties']['interface']['type']) 196 self.assertEquals('string', mytype['properties']['interface']['type'])
179 197
180 params = getParams(schema, 'static') 198 params = getParams(schema, 'static')
181 self.assertEquals('Foo', params[0]['$ref']) 199 self.assertEquals('Foo', params[0]['$ref'])
182 self.assertEquals('enum', params[1]['$ref']) 200 self.assertEquals('enum', params[1]['$ref'])
183 201
184 202
185 if __name__ == '__main__': 203 if __name__ == '__main__':
186 unittest.main() 204 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698