| 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 os | 5 import os |
| 6 import sys | 6 import sys |
| 7 import unittest | 7 import unittest |
| 8 | 8 |
| 9 import api_schema_graph | 9 import api_schema_graph |
| 10 from availability_finder import (AvailabilityFinder, | 10 from availability_finder import AvailabilityFinder, AvailabilityInfo |
| 11 AvailabilityInfo, | |
| 12 _GetNamespaceFromFilename) | |
| 13 from branch_utility import BranchUtility, ChannelInfo | 11 from branch_utility import BranchUtility, ChannelInfo |
| 14 from compiled_file_system import CompiledFileSystem | 12 from compiled_file_system import CompiledFileSystem |
| 15 from fake_host_file_system_provider import FakeHostFileSystemProvider | 13 from fake_host_file_system_provider import FakeHostFileSystemProvider |
| 16 from fake_url_fetcher import FakeUrlFetcher | 14 from fake_url_fetcher import FakeUrlFetcher |
| 17 from host_file_system_iterator import HostFileSystemIterator | 15 from host_file_system_iterator import HostFileSystemIterator |
| 18 from mock_function import MockFunction | 16 from mock_function import MockFunction |
| 19 from object_store_creator import ObjectStoreCreator | 17 from object_store_creator import ObjectStoreCreator |
| 20 from platform_util import GetPlatforms | 18 from platform_util import GetPlatforms |
| 21 from test_data.canned_data import (CANNED_API_FILE_SYSTEM_DATA, CANNED_BRANCHES) | 19 from test_data.canned_data import (CANNED_API_FILE_SYSTEM_DATA, CANNED_BRANCHES) |
| 22 from test_data.object_level_availability.tabs import TABS_SCHEMA_BRANCHES | 20 from test_data.object_level_availability.tabs import TABS_SCHEMA_BRANCHES |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 # Continue looping. The iterator will stop after 'trunk' automatically. | 65 # Continue looping. The iterator will stop after 'trunk' automatically. |
| 68 return True | 66 return True |
| 69 | 67 |
| 70 # Use the HostFileSystemIterator created above to change global stat values | 68 # Use the HostFileSystemIterator created above to change global stat values |
| 71 # for the TestFileSystems that it creates. | 69 # for the TestFileSystems that it creates. |
| 72 self._node_fs_iterator.Ascending( | 70 self._node_fs_iterator.Ascending( |
| 73 # The earliest version represented with the tabs' test data is 13. | 71 # The earliest version represented with the tabs' test data is 13. |
| 74 self._branch_utility.GetStableChannelInfo(13), | 72 self._branch_utility.GetStableChannelInfo(13), |
| 75 stat_paths) | 73 stat_paths) |
| 76 | 74 |
| 77 def testGetNamespaceFromFilename(self): | |
| 78 # Test simple name | |
| 79 self.assertEqual('storage', _GetNamespaceFromFilename('storage')) | |
| 80 # Test multi-word names | |
| 81 self.assertEqual('contextMenus', | |
| 82 _GetNamespaceFromFilename('contextMenus')) | |
| 83 self.assertEqual('app.window', _GetNamespaceFromFilename('app_window')) | |
| 84 # Test devtools API | |
| 85 self.assertEqual('devtools.inspectedWindow', | |
| 86 _GetNamespaceFromFilename('devtools/inspectedWindow')) | |
| 87 # Test experimental API | |
| 88 self.assertEqual('experimental.infobars', | |
| 89 _GetNamespaceFromFilename('experimental_infobars')) | |
| 90 # Test experimental API in devtools | |
| 91 self.assertEqual('experimental.devtools.audits', | |
| 92 _GetNamespaceFromFilename('devtools/experimental_audits')) | |
| 93 | |
| 94 def testGraphOptimization(self): | 75 def testGraphOptimization(self): |
| 95 for platform in GetPlatforms(): | 76 for platform in GetPlatforms(): |
| 96 # Keep track of how many times the APISchemaGraph constructor is called. | 77 # Keep track of how many times the APISchemaGraph constructor is called. |
| 97 original_constructor = api_schema_graph.APISchemaGraph | 78 original_constructor = api_schema_graph.APISchemaGraph |
| 98 mock_constructor = MockFunction(original_constructor) | 79 mock_constructor = MockFunction(original_constructor) |
| 99 api_schema_graph.APISchemaGraph = mock_constructor | 80 api_schema_graph.APISchemaGraph = mock_constructor |
| 100 | 81 |
| 101 node_avail_finder = self._create_availability_finder( | 82 node_avail_finder = self._create_availability_finder( |
| 102 self._node_fs_creator, self._node_fs_iterator, platform) | 83 self._node_fs_creator, self._node_fs_iterator, platform) |
| 103 try: | 84 try: |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 self.assertEqual(lookup_result(False, None), | 296 self.assertEqual(lookup_result(False, None), |
| 316 availability_graph.Lookup('functions')) | 297 availability_graph.Lookup('functions')) |
| 317 self.assertEqual(lookup_result(False, None), | 298 self.assertEqual(lookup_result(False, None), |
| 318 availability_graph.Lookup('events', 'onActivated', | 299 availability_graph.Lookup('events', 'onActivated', |
| 319 'parameters', 'activeInfo', | 300 'parameters', 'activeInfo', |
| 320 'tabId')) | 301 'tabId')) |
| 321 | 302 |
| 322 | 303 |
| 323 if __name__ == '__main__': | 304 if __name__ == '__main__': |
| 324 unittest.main() | 305 unittest.main() |
| OLD | NEW |