OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 unittest | 6 import unittest |
7 | 7 |
8 from api_schema_graph import APISchemaGraph, LookupResult | 8 from api_schema_graph import APISchemaGraph, LookupResult |
9 | 9 |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 'name': 'onUpdated', | 49 'name': 'onUpdated', |
50 'parameters': [ {'name': 'updateInfo'} ] | 50 'parameters': [ {'name': 'updateInfo'} ] |
51 } | 51 } |
52 ] | 52 ] |
53 }] | 53 }] |
54 | 54 |
55 | 55 |
56 class APISchemaGraphTest(unittest.TestCase): | 56 class APISchemaGraphTest(unittest.TestCase): |
57 | 57 |
58 def testLookup(self): | 58 def testLookup(self): |
59 self._testApiSchema(APISchemaGraph(API_SCHEMA)) | 59 self._testAPISchema(APISchemaGraph(API_SCHEMA)) |
60 | 60 |
61 def testIsEmpty(self): | 61 def testIsEmpty(self): |
62 # A few assertions to make sure that Lookup works on empty sets. | 62 # A few assertions to make sure that Lookup works on empty sets. |
63 empty_graph = APISchemaGraph({}) | 63 empty_graph = APISchemaGraph({}) |
64 self.assertTrue(empty_graph.IsEmpty()) | 64 self.assertTrue(empty_graph.IsEmpty()) |
65 self.assertEqual(LookupResult(False, None), | 65 self.assertEqual(LookupResult(False, None), |
66 empty_graph.Lookup('tabs', 'properties', | 66 empty_graph.Lookup('tabs', 'properties', |
67 'TAB_PROPERTY_ONE')) | 67 'TAB_PROPERTY_ONE')) |
68 self.assertEqual(LookupResult(False, None), | 68 self.assertEqual(LookupResult(False, None), |
69 empty_graph.Lookup('tabs', 'functions', 'get', | 69 empty_graph.Lookup('tabs', 'functions', 'get', |
70 'parameters', 'tab')) | 70 'parameters', 'tab')) |
71 self.assertEqual(LookupResult(False, None), | 71 self.assertEqual(LookupResult(False, None), |
72 empty_graph.Lookup('tabs', 'functions', 'get', | 72 empty_graph.Lookup('tabs', 'functions', 'get', |
73 'parameters', 'tabId')) | 73 'parameters', 'tabId')) |
74 self.assertEqual(LookupResult(False, None), | 74 self.assertEqual(LookupResult(False, None), |
75 empty_graph.Lookup('tabs', 'events', 'onActivated', | 75 empty_graph.Lookup('tabs', 'events', 'onActivated', |
76 'parameters', 'activeInfo')) | 76 'parameters', 'activeInfo')) |
77 self.assertEqual(LookupResult(False, None), | 77 self.assertEqual(LookupResult(False, None), |
78 empty_graph.Lookup('tabs', 'events', 'onUpdated', | 78 empty_graph.Lookup('tabs', 'events', 'onUpdated', |
79 'parameters', 'updateInfo')) | 79 'parameters', 'updateInfo')) |
80 | 80 |
81 def testSubtractEmpty(self): | 81 def testSubtractEmpty(self): |
82 self._testApiSchema( | 82 self._testAPISchema( |
83 APISchemaGraph(API_SCHEMA).Subtract(APISchemaGraph({}))) | 83 APISchemaGraph(API_SCHEMA).Subtract(APISchemaGraph({}))) |
84 | 84 |
85 def _testApiSchema(self, api_schema_graph): | 85 def _testAPISchema(self, api_schema_graph): |
86 self.assertEqual(LookupResult(True, None), | 86 self.assertEqual(LookupResult(True, None), |
87 api_schema_graph.Lookup('tabs', 'properties', | 87 api_schema_graph.Lookup('tabs', 'properties', |
88 'TAB_PROPERTY_ONE')) | 88 'TAB_PROPERTY_ONE')) |
89 self.assertEqual(LookupResult(True, None), | 89 self.assertEqual(LookupResult(True, None), |
90 api_schema_graph.Lookup('tabs', 'types', 'Tab')) | 90 api_schema_graph.Lookup('tabs', 'types', 'Tab')) |
91 self.assertEqual(LookupResult(True, None), | 91 self.assertEqual(LookupResult(True, None), |
92 api_schema_graph.Lookup('tabs', 'functions', 'get', | 92 api_schema_graph.Lookup('tabs', 'functions', 'get', |
93 'parameters', 'tab')) | 93 'parameters', 'tab')) |
94 self.assertEqual(LookupResult(True, None), | 94 self.assertEqual(LookupResult(True, None), |
95 api_schema_graph.Lookup('tabs', 'functions', 'get', | 95 api_schema_graph.Lookup('tabs', 'functions', 'get', |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 result.Lookup('tabs', 'functions', | 439 result.Lookup('tabs', 'functions', |
440 'getAllInWindow', 'parameters', | 440 'getAllInWindow', 'parameters', |
441 'callback')) | 441 'callback')) |
442 self.assertEqual(LookupResult(True, 'first'), | 442 self.assertEqual(LookupResult(True, 'first'), |
443 result.Lookup('tabs', 'functions', | 443 result.Lookup('tabs', 'functions', |
444 'getAllInWindow')) | 444 'getAllInWindow')) |
445 | 445 |
446 | 446 |
447 if __name__ == '__main__': | 447 if __name__ == '__main__': |
448 unittest.main() | 448 unittest.main() |
OLD | NEW |