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 json | 6 import json |
7 import unittest | 7 import unittest |
8 | 8 |
9 from api_models import APIModels | 9 from api_models import APIModels |
10 from compiled_file_system import CompiledFileSystem | 10 from compiled_file_system import CompiledFileSystem |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 }, | 52 }, |
53 } | 53 } |
54 | 54 |
55 | 55 |
56 class APIModelsTest(unittest.TestCase): | 56 class APIModelsTest(unittest.TestCase): |
57 def setUp(self): | 57 def setUp(self): |
58 object_store_creator = ObjectStoreCreator.ForTest() | 58 object_store_creator = ObjectStoreCreator.ForTest() |
59 compiled_fs_factory = CompiledFileSystem.Factory(object_store_creator) | 59 compiled_fs_factory = CompiledFileSystem.Factory(object_store_creator) |
60 self._mock_file_system = MockFileSystem( | 60 self._mock_file_system = MockFileSystem( |
61 TestFileSystem(_TEST_DATA, relative_to=CHROME_EXTENSIONS)) | 61 TestFileSystem(_TEST_DATA, relative_to=CHROME_EXTENSIONS)) |
62 features_bundle = FeaturesBundle( | 62 features_bundle = FeaturesBundle(self._mock_file_system, |
63 self._mock_file_system, compiled_fs_factory, object_store_creator) | 63 compiled_fs_factory, |
64 self._api_models = APIModels( | 64 object_store_creator, |
65 features_bundle, compiled_fs_factory, self._mock_file_system) | 65 'extensions') |
| 66 self._api_models = APIModels(features_bundle, |
| 67 compiled_fs_factory, |
| 68 self._mock_file_system, |
| 69 'extensions') |
66 | 70 |
67 def testGetNames(self): | 71 def testGetNames(self): |
68 # Both 'app' and 'app.runtime' appear here because 'app.runtime' has | 72 # Both 'app' and 'app.runtime' appear here because 'app.runtime' has |
69 # noparent:true, but 'app.runtime.foo' etc doesn't so it's a sub-feature of | 73 # noparent:true, but 'app.runtime.foo' etc doesn't so it's a sub-feature of |
70 # 'app.runtime' not a separate API. 'devtools.inspectedWindow' is an API | 74 # 'app.runtime' not a separate API. 'devtools.inspectedWindow' is an API |
71 # because there is no 'devtools'. | 75 # because there is no 'devtools'. |
72 self.assertEqual( | 76 self.assertEqual( |
73 ['alarms', 'app', 'app.runtime', 'declarativeWebRequest', | 77 ['alarms', 'app', 'app.runtime', 'declarativeWebRequest', |
74 'devtools.inspectedWindow', 'input', 'storage'], | 78 'devtools.inspectedWindow', 'input', 'storage'], |
75 sorted(self._api_models.GetNames())) | 79 sorted(self._api_models.GetNames())) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 # No reads (still cached). | 147 # No reads (still cached). |
144 future = self._api_models.GetModel('alarms') | 148 future = self._api_models.GetModel('alarms') |
145 self.assertTrue(*self._mock_file_system.CheckAndReset( | 149 self.assertTrue(*self._mock_file_system.CheckAndReset( |
146 stat_count=len(API_PATHS)*2)) | 150 stat_count=len(API_PATHS)*2)) |
147 future.Get() | 151 future.Get() |
148 self.assertTrue(*self._mock_file_system.CheckAndReset()) | 152 self.assertTrue(*self._mock_file_system.CheckAndReset()) |
149 | 153 |
150 | 154 |
151 if __name__ == '__main__': | 155 if __name__ == '__main__': |
152 unittest.main() | 156 unittest.main() |
OLD | NEW |