def setUp(self): self._branch_utility = BranchUtility( os.path.join('branch_utility', 'first.json'), os.path.join('branch_utility', 'second.json'), FakeUrlFetcher(Server2Path('test_data')), ObjectStoreCreator.ForTest()) self._api_fs_creator = FakeHostFileSystemProvider( CANNED_API_FILE_SYSTEM_DATA) self._node_fs_creator = FakeHostFileSystemProvider( TABS_SCHEMA_BRANCHES) self._api_fs_iterator = HostFileSystemIterator(self._api_fs_creator, self._branch_utility) self._node_fs_iterator = HostFileSystemIterator( self._node_fs_creator, self._branch_utility) # Imitate the actual SVN file system by incrementing the stats for paths # where an API schema has changed. last_stat = type('last_stat', (object, ), {'val': 0}) def stat_paths(file_system, channel_info): if channel_info.version not in TABS_UNMODIFIED_VERSIONS: last_stat.val += 1 # HACK: |file_system| is a MockFileSystem backed by a TestFileSystem. # Increment the TestFileSystem stat count. file_system._file_system.IncrementStat(by=last_stat.val) # Continue looping. The iterator will stop after 'trunk' automatically. return True # Use the HostFileSystemIterator created above to change global stat values # for the TestFileSystems that it creates. self._node_fs_iterator.Ascending( # The earliest version represented with the tabs' test data is 13. self._branch_utility.GetStableChannelInfo(13), stat_paths)
def setUp(self): tabs_unmodified_versions = (16, 20, 23, 24) self._branch_utility = BranchUtility( os.path.join('branch_utility', 'first.json'), os.path.join('branch_utility', 'second.json'), FakeUrlFetcher(Server2Path('test_data')), ObjectStoreCreator.ForTest()) self._node_fs_creator = FakeHostFileSystemProvider(TABS_SCHEMA_BRANCHES) self._node_fs_iterator = HostFileSystemIterator(self._node_fs_creator, self._branch_utility) test_object_store = ObjectStoreCreator.ForTest() self._avail_finder = AvailabilityFinder( self._branch_utility, CompiledFileSystem.Factory(test_object_store), self._node_fs_iterator, self._node_fs_creator.GetMaster(), test_object_store, 'extensions', SchemaProcessorFactoryForTest()) server_instance = ServerInstance.ForTest( file_system_provider=FakeHostFileSystemProvider( TABS_SCHEMA_BRANCHES)) self._api_models = server_instance.platform_bundle.GetAPIModels( 'extensions') self._json_cache = server_instance.compiled_fs_factory.ForJson( server_instance.host_file_system_provider.GetMaster()) # Imitate the actual SVN file system by incrementing the stats for paths # where an API schema has changed. last_stat = type('last_stat', (object,), {'val': 0}) def stat_paths(file_system, channel_info): if channel_info.version not in tabs_unmodified_versions: last_stat.val += 1 # HACK: |file_system| is a MockFileSystem backed by a TestFileSystem. # Increment the TestFileSystem stat count. file_system._file_system.IncrementStat(by=last_stat.val) # Continue looping. The iterator will stop after 'master' automatically. return True # Use the HostFileSystemIterator created above to change global stat values # for the TestFileSystems that it creates. self._node_fs_iterator.Ascending( # The earliest version represented with the tabs' test data is 13. self._branch_utility.GetStableChannelInfo(13), stat_paths)
def setUp(self): server_instance = ServerInstance.ForTest( file_system_provider=FakeHostFileSystemProvider( CANNED_API_FILE_SYSTEM_DATA)) self._api_models = server_instance.platform_bundle.GetAPIModels( 'extensions') self._json_cache = server_instance.compiled_fs_factory.ForJson( server_instance.host_file_system_provider.GetMaster()) self._avail_finder = server_instance.platform_bundle.GetAvailabilityFinder( 'extensions')
def setUp(self): self._base_path = Server2Path('test_data', 'test_json') server_instance = ServerInstance.ForTest( TestFileSystem(CANNED_TRUNK_FS_DATA, relative_to=CHROME_EXTENSIONS)) file_system = server_instance.host_file_system_provider.GetTrunk() self._json_cache = server_instance.compiled_fs_factory.ForJson(file_system) self._features_bundle = FeaturesBundle(file_system, server_instance.compiled_fs_factory, server_instance.object_store_creator) self._api_models = server_instance.api_models # Used for testGetAPIAvailability() so that valid-ish data is processed. server_instance = ServerInstance.ForTest( file_system_provider=FakeHostFileSystemProvider( CANNED_API_FILE_SYSTEM_DATA)) self._avail_api_models = server_instance.api_models self._avail_json_cache = server_instance.compiled_fs_factory.ForJson( server_instance.host_file_system_provider.GetTrunk()) self._avail_finder = server_instance.availability_finder
class JSCViewWithNodeAvailabilityTest(unittest.TestCase): def setUp(self): tabs_unmodified_versions = (16, 20, 23, 24) self._branch_utility = BranchUtility( os.path.join('branch_utility', 'first.json'), os.path.join('branch_utility', 'second.json'), FakeUrlFetcher(Server2Path('test_data')), ObjectStoreCreator.ForTest()) self._node_fs_creator = FakeHostFileSystemProvider( TABS_SCHEMA_BRANCHES) self._node_fs_iterator = HostFileSystemIterator( self._node_fs_creator, self._branch_utility) test_object_store = ObjectStoreCreator.ForTest() self._avail_finder = AvailabilityFinder( self._branch_utility, CompiledFileSystem.Factory(test_object_store), self._node_fs_iterator, self._node_fs_creator.GetMaster(), test_object_store, 'extensions', SchemaProcessorFactoryForTest()) server_instance = ServerInstance.ForTest( file_system_provider=FakeHostFileSystemProvider( TABS_SCHEMA_BRANCHES)) self._api_models = server_instance.platform_bundle.GetAPIModels( 'extensions') self._json_cache = server_instance.compiled_fs_factory.ForJson( server_instance.host_file_system_provider.GetMaster()) # Imitate the actual SVN file system by incrementing the stats for paths # where an API schema has changed. last_stat = type('last_stat', (object, ), {'val': 0}) def stat_paths(file_system, channel_info): if channel_info.version not in tabs_unmodified_versions: last_stat.val += 1 # HACK: |file_system| is a MockFileSystem backed by a TestFileSystem. # Increment the TestFileSystem stat count. file_system._file_system.IncrementStat(by=last_stat.val) # Continue looping. The iterator will stop after 'master' automatically. return True # Use the HostFileSystemIterator created above to change global stat values # for the TestFileSystems that it creates. self._node_fs_iterator.Ascending( # The earliest version represented with the tabs' test data is 13. self._branch_utility.GetStableChannelInfo(13), stat_paths) @unittest.skipIf(os.name == 'nt', "crbug.com/1114884") def testGetAPINodeAvailability(self): def assertEquals(node, actual): node_availabilities = { 'tabs.Tab': None, 'tabs.fakeTabsProperty1': None, 'tabs.get': None, 'tabs.onUpdated': None, 'tabs.InjectDetails': 25, 'tabs.fakeTabsProperty2': 15, 'tabs.getCurrent': 19, 'tabs.onActivated': 30 } self.assertEquals(node_availabilities[node], actual) model_dict = CreateJSCView( self._api_models.GetContentScriptAPIs().Get(), self._api_models.GetModel('tabs').Get(), self._avail_finder, self._json_cache, _FakeTemplateCache(), _FakeFeaturesBundle(), None, 'extensions', [], Request.ForTest('')) # Test nodes that have the same availability as their parent. # Test type. assertEquals('tabs.Tab', model_dict['types'][0]['availability']) # Test property. assertEquals('tabs.fakeTabsProperty1', model_dict['properties'][1]['availability']) # Test function. assertEquals('tabs.get', model_dict['functions'][1]['availability']) # Test event. assertEquals('tabs.onUpdated', model_dict['events'][1]['availability']) # Test nodes with varying availabilities. # Test type. assertEquals('tabs.InjectDetails', model_dict['types'][1]['availability']['version']) # Test property. assertEquals('tabs.fakeTabsProperty2', model_dict['properties'][3]['availability']['version']) # Test function. assertEquals('tabs.getCurrent', model_dict['functions'][0]['availability']['version']) # Test event. assertEquals('tabs.onActivated', model_dict['events'][0]['availability']['version']) # Test a node that became deprecated. self.assertEquals( { 'scheduled': None, 'version': 26, 'partial': 'motemplate chrome/common/extensions/docs/templates/' + 'private/intro_tables/deprecated_message.html' }, model_dict['types'][2]['availability'])
def testCreateWhatsNewDataSource(self): api_fs_creator = FakeHostFileSystemProvider( CANNED_API_FILE_SYSTEM_DATA) server_instance = ServerInstance.ForTest( file_system_provider=api_fs_creator) whats_new_data_source = WhatsNewDataSource(server_instance, None) expected_whats_new_changes_list = [{ 'version': 22, 'additionsToExistingApis': [{ 'version': 22, 'type': 'additionsToExistingApis', 'id': 'backgroundpages.to-be-non-persistent', 'description': 'backgrounds to be non persistent' }], }, { 'version': 21, 'additionsToExistingApis': [{ 'version': 21, 'type': 'additionsToExistingApis', 'id': 'chromeSetting.set-regular-only-scope', 'description': 'ChromeSetting.set now has a regular_only scope.' }], }, { 'version': 20, 'manifestChanges': [{ 'version': 20, 'type': 'manifestChanges', 'id': 'manifest-v1-deprecated', 'description': 'Manifest version 1 was deprecated in Chrome 18' }], }] expected_new_info_of_apps = [{ 'version': 26, 'apis': [{ 'version': 26, 'type': 'apis', 'name': u'alarm', 'description': u'<code>alarm</code>' }, { 'version': 26, 'type': 'apis', 'name': u'app.window', 'description': u'<code>app.window</code>' }] }] expected_new_info_of_apps.extend(expected_whats_new_changes_list) expected_new_info_of_extensions = [{ 'version': 26, 'apis': [{ 'version': 26, 'type': 'apis', 'name': u'alarm', 'description': u'<code>alarm</code>' }, { 'version': 26, 'type': 'apis', 'name': u'browserAction', 'description': u'<code>browserAction</code>' }] }] expected_new_info_of_extensions.extend(expected_whats_new_changes_list) whats_new_for_apps = whats_new_data_source.get('apps') whats_new_for_extension = whats_new_data_source.get('extensions') self.assertEqual(expected_new_info_of_apps, whats_new_for_apps) self.assertEqual(expected_new_info_of_extensions, whats_new_for_extension)