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 import unittest | 5 import unittest |
6 | 6 |
7 from api_categorizer import APICategorizer | 7 from api_categorizer import APICategorizer |
8 from compiled_file_system import CompiledFileSystem | 8 from compiled_file_system import CompiledFileSystem |
9 from extensions_paths import CHROME_EXTENSIONS | 9 from extensions_paths import CHROME_EXTENSIONS |
10 from object_store_creator import ObjectStoreCreator | 10 from object_store_creator import ObjectStoreCreator |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 'sockets_udp.html' | 50 'sockets_udp.html' |
51 ]), | 51 ]), |
52 }, | 52 }, |
53 }, | 53 }, |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 | 57 |
58 class APICategorizerTest(unittest.TestCase): | 58 class APICategorizerTest(unittest.TestCase): |
59 def setUp(self): | 59 def setUp(self): |
60 self._api_categorizer = APICategorizer( | 60 self._test_file_system = TestFileSystem( |
61 TestFileSystem(_TEST_DATA, relative_to=CHROME_EXTENSIONS), | 61 _TEST_DATA, relative_to=CHROME_EXTENSIONS) |
62 CompiledFileSystem.Factory(ObjectStoreCreator.ForTest())) | 62 self._compiled_file_system = CompiledFileSystem.Factory( |
| 63 ObjectStoreCreator.ForTest()) |
63 | 64 |
64 def testGetAPICategory(self): | 65 def testGetAPICategory(self): |
65 get_category = self._api_categorizer.GetCategory | 66 def assertGetEqual(expected, category, only_on=None): |
66 self.assertEqual('chrome', get_category('apps', 'alarms')) | 67 for platform in ('apps', 'extensions'): |
67 self.assertEqual('chrome', get_category('extensions', 'alarms')) | 68 get_category = APICategorizer( |
68 self.assertEqual('private', get_category('apps', 'musicManagerPrivate')) | 69 self._test_file_system, |
69 self.assertEqual('private', get_category('extensions', 'notDocumentedApi')) | 70 self._compiled_file_system, |
70 self.assertEqual('experimental', | 71 platform if only_on is None else only_on).GetCategory(category) |
71 get_category('apps', 'experimental.bluetooth')) | 72 self.assertEqual(expected, get_category) |
72 self.assertEqual('experimental', | 73 |
73 get_category('extensions', 'experimental.history')) | 74 assertGetEqual('chrome', 'alarms') |
| 75 assertGetEqual('private', 'musicManagerPrivate') |
| 76 assertGetEqual('private', 'notDocumentedApi') |
| 77 assertGetEqual('experimental', 'experimental.bluetooth', only_on='apps') |
| 78 assertGetEqual('experimental', 'experimental.history', only_on='extensions') |
74 | 79 |
75 | 80 |
76 if __name__ == '__main__': | 81 if __name__ == '__main__': |
77 unittest.main() | 82 unittest.main() |
OLD | NEW |