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

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

Issue 10659021: Move chrome.appWindow to chrome.app.window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « tools/json_schema_compiler/schema_util.py ('k') | no next file » | 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 schema_util 6 from schema_util import JsFunctionNameToClassName
7 from schema_util import PrefixSchemasWithNamespace
8 from schema_util import StripSchemaNamespace
7 import unittest 9 import unittest
8 10
9 class SchemaUtilTest(unittest.TestCase): 11 class SchemaUtilTest(unittest.TestCase):
10 def testStripSchemaNamespace(self): 12 def testStripSchemaNamespace(self):
11 self.assertEquals('Bar', schema_util.StripSchemaNamespace('foo.Bar')) 13 self.assertEquals('Bar', StripSchemaNamespace('foo.Bar'))
12 self.assertEquals('Baz', schema_util.StripSchemaNamespace('Baz')) 14 self.assertEquals('Baz', StripSchemaNamespace('Baz'))
13 15
14 def testPrefixSchemasWithNamespace(self): 16 def testPrefixSchemasWithNamespace(self):
15 schemas = [ 17 schemas = [
16 { 'namespace': 'n1', 18 { 'namespace': 'n1',
17 'types': [ 19 'types': [
18 { 20 {
19 'id': 'T1', 21 'id': 'T1',
20 'customBindings': 'T1', 22 'customBindings': 'T1',
21 'properties': { 23 'properties': {
22 'p1': {'$ref': 'T1'}, 24 'p1': {'$ref': 'T1'},
(...skipping 13 matching lines...) Expand all
36 'events': [ 38 'events': [
37 { 39 {
38 'parameters': [ 40 'parameters': [
39 { '$ref': 'T1' }, 41 { '$ref': 'T1' },
40 { '$ref': 'fully.qualified.T' }, 42 { '$ref': 'fully.qualified.T' },
41 ], 43 ],
42 }, 44 },
43 ], 45 ],
44 }, 46 },
45 ] 47 ]
46 schema_util.PrefixSchemasWithNamespace(schemas) 48 PrefixSchemasWithNamespace(schemas)
47 self.assertEquals('n1.T1', schemas[0]['types'][0]['id']) 49 self.assertEquals('n1.T1', schemas[0]['types'][0]['id'])
48 self.assertEquals('n1.T1', schemas[0]['types'][0]['customBindings']) 50 self.assertEquals('n1.T1', schemas[0]['types'][0]['customBindings'])
49 self.assertEquals('n1.T1', 51 self.assertEquals('n1.T1',
50 schemas[0]['types'][0]['properties']['p1']['$ref']) 52 schemas[0]['types'][0]['properties']['p1']['$ref'])
51 self.assertEquals('fully.qualified.T', 53 self.assertEquals('fully.qualified.T',
52 schemas[0]['types'][0]['properties']['p2']['$ref']) 54 schemas[0]['types'][0]['properties']['p2']['$ref'])
53 55
54 self.assertEquals('n1.T1', 56 self.assertEquals('n1.T1',
55 schemas[0]['functions'][0]['parameters'][0]['$ref']) 57 schemas[0]['functions'][0]['parameters'][0]['$ref'])
56 self.assertEquals('fully.qualified.T', 58 self.assertEquals('fully.qualified.T',
57 schemas[0]['functions'][0]['parameters'][1]['$ref']) 59 schemas[0]['functions'][0]['parameters'][1]['$ref'])
58 self.assertEquals('n1.T1', 60 self.assertEquals('n1.T1',
59 schemas[0]['functions'][0]['returns']['$ref']) 61 schemas[0]['functions'][0]['returns']['$ref'])
60 62
61 self.assertEquals('n1.T1', 63 self.assertEquals('n1.T1',
62 schemas[0]['events'][0]['parameters'][0]['$ref']) 64 schemas[0]['events'][0]['parameters'][0]['$ref'])
63 self.assertEquals('fully.qualified.T', 65 self.assertEquals('fully.qualified.T',
64 schemas[0]['events'][0]['parameters'][1]['$ref']) 66 schemas[0]['events'][0]['parameters'][1]['$ref'])
65 67
68
69 def testJsFunctionNameToClassName(self):
70 self.assertEquals('FooBar', JsFunctionNameToClassName('foo', 'bar'))
71 self.assertEquals('FooBar',
72 JsFunctionNameToClassName('experimental.foo', 'bar'))
73 self.assertEquals('FooBarBaz',
74 JsFunctionNameToClassName('foo.bar', 'baz'))
75 self.assertEquals('FooBarBaz',
76 JsFunctionNameToClassName('experimental.foo.bar', 'baz'))
77
66 if __name__ == '__main__': 78 if __name__ == '__main__':
67 unittest.main() 79 unittest.main()
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/schema_util.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698