Exemplo n.º 1
0
 def GetRefreshPaths(self):
   tasks = []
   for platform in GetPlatforms():
     tasks += ['%s/%s' % (platform, api)
               for api in
                   self._platform_bundle.GetAPIModels(platform).GetNames()]
   return tasks
    def testGraphOptimization(self):
        for platform in GetPlatforms():
            # Keep track of how many times the APISchemaGraph constructor is called.
            original_constructor = api_schema_graph.APISchemaGraph
            mock_constructor = MockFunction(original_constructor)
            api_schema_graph.APISchemaGraph = mock_constructor

            node_avail_finder = self._create_availability_finder(
                self._node_fs_creator, self._node_fs_iterator, platform)
            try:
                # The test data includes an extra branch where the API does not exist.
                num_versions = len(TABS_SCHEMA_BRANCHES) - 1
                # We expect an APISchemaGraph to be created only when an API schema file
                # has different stat data from the previous version's schema file.
                num_graphs_created = num_versions - len(
                    TABS_UNMODIFIED_VERSIONS)

                # Run the logic for object-level availability for an API.
                node_avail_finder.GetAPINodeAvailability('tabs')

                self.assertTrue(*api_schema_graph.APISchemaGraph.CheckAndReset(
                    num_graphs_created))
            finally:
                # Ensure that the APISchemaGraph constructor is reset to be the original
                # constructor.
                api_schema_graph.APISchemaGraph = original_constructor
 def assertGet(ch_info, api, only_on=None, scheduled=None):
     for platform in GetPlatforms():
         get_availability = self._create_availability_finder(
             self._api_fs_creator, self._api_fs_iterator, platform
             if only_on is None else only_on).GetAPIAvailability
         self.assertEqual(
             AvailabilityInfo(ch_info, scheduled=scheduled),
             get_availability(api))
Exemplo n.º 4
0
 def Cron(self):
     futures = []
     for platform in GetPlatforms():
         futures += [
             self._GetImpl(platform, name) for name in
             self._platform_bundle.GetAPIModels(platform).GetNames()
         ]
     return All(futures, except_pass=FileNotFoundError)
Exemplo n.º 5
0
 def __init__(self, branch_utility, compiled_fs_factory, host_fs_at_master,
              host_file_system_iterator, object_store_creator, base_path):
     self._branch_utility = branch_utility
     self._compiled_fs_factory = compiled_fs_factory
     self._host_fs_at_master = host_fs_at_master
     self._host_file_system_iterator = host_file_system_iterator
     self._object_store_creator = object_store_creator
     self._base_path = base_path
     self._platform_data = dict(
         (p, _PlatformData()) for p in GetPlatforms())
Exemplo n.º 6
0
    def _CreateManifestData(self):
        manifest_data_futures = dict(
            (p, self._CreateManifestDataForPlatform(p))
            for p in GetPlatforms())

        def resolve():
            return dict(
                (platform, future.Get())
                for platform, future in manifest_data_futures.iteritems())

        return Future(callback=resolve)
Exemplo n.º 7
0
    def _CreatePermissionsData(self):
        permissions_data_futures = dict(
            (platform, self._CreatePermissionsDataForPlatform(platform))
            for platform in GetPlatforms())

        def resolve():
            return dict(
                ('declare_' + platform, future.Get())
                for platform, future in permissions_data_futures.iteritems())

        return Future(callback=resolve)
Exemplo n.º 8
0
    def Refresh(self):
        def get_api_schema(platform, api):
            return self._GetSchemaView(platform, api)

        def get_platform_schemas(platform):
            return All([
                get_api_schema(platform, api) for api in
                self._platform_bundle.GetAPIModels(platform).GetNames()
            ],
                       except_pass=FileNotFoundError)

        return All(
            [get_platform_schemas(platform) for platform in GetPlatforms()])
Exemplo n.º 9
0
  def Refresh(self):
    def get_api_schema(platform, api):
      return self._GetSchemaView(platform, api)

    def get_platform_schemas(platform):
      # Internal APIs are an internal implementation detail. Do not pass them to
      # templates.
      return All([get_api_schema(platform, api)
                  for api in self._platform_bundle.GetAPIModels(platform)
                  .GetNames()
                  if self._platform_bundle.GetAPICategorizer(platform)
                  .GetCategory(api) != 'internal'],
                 except_pass=FileNotFoundError)

    return All([get_platform_schemas(platform) for platform in GetPlatforms()])
 def resolve():
     return dict((platform, _MakeDictByPlatform(platform))
                 for platform in GetPlatforms())
    def testGetAPINodeAvailability(self):
        def assertEquals(found, channel_info, actual, scheduled=None):
            lookup_result = api_schema_graph.LookupResult
            if channel_info is None:
                self.assertEquals(lookup_result(found, None), actual)
            else:
                self.assertEquals(
                    lookup_result(
                        found,
                        AvailabilityInfo(channel_info, scheduled=scheduled)),
                    actual)

        for platform in GetPlatforms():
            # Allow the LookupResult constructions below to take just one line.
            avail_finder = self._create_availability_finder(
                self._node_fs_creator, self._node_fs_iterator, platform)
            tabs_graph = avail_finder.GetAPINodeAvailability('tabs')
            fake_tabs_graph = avail_finder.GetAPINodeAvailability('fakeTabs')

            assertEquals(
                True, self._branch_utility.GetChannelInfo('trunk'),
                tabs_graph.Lookup('tabs', 'properties', 'fakeTabsProperty3'))
            assertEquals(True,
                         self._branch_utility.GetChannelInfo('dev'),
                         tabs_graph.Lookup('tabs', 'events', 'onActivated',
                                           'parameters', 'activeInfo',
                                           'properties', 'windowId'),
                         scheduled=31)
            assertEquals(True,
                         self._branch_utility.GetChannelInfo('dev'),
                         tabs_graph.Lookup('tabs', 'events', 'onUpdated',
                                           'parameters', 'tab'),
                         scheduled=31)
            assertEquals(True,
                         self._branch_utility.GetChannelInfo('beta'),
                         tabs_graph.Lookup('tabs', 'events', 'onActivated'),
                         scheduled=30)
            assertEquals(True,
                         self._branch_utility.GetChannelInfo('beta'),
                         tabs_graph.Lookup('tabs', 'functions', 'get',
                                           'parameters', 'tabId'),
                         scheduled=30)
            assertEquals(
                True, self._branch_utility.GetChannelInfo('stable'),
                tabs_graph.Lookup('tabs', 'types', 'InjectDetails',
                                  'properties', 'code'))
            assertEquals(
                True, self._branch_utility.GetChannelInfo('stable'),
                tabs_graph.Lookup('tabs', 'types', 'InjectDetails',
                                  'properties', 'file'))
            assertEquals(True, self._branch_utility.GetStableChannelInfo(25),
                         tabs_graph.Lookup('tabs', 'types', 'InjectDetails'))

            # Test inlined type.
            assertEquals(True, self._branch_utility.GetChannelInfo('trunk'),
                         tabs_graph.Lookup('tabs', 'types', 'InlinedType'))

            # Test implicitly inlined type.
            assertEquals(
                True, self._branch_utility.GetStableChannelInfo(25),
                fake_tabs_graph.Lookup('fakeTabs', 'types',
                                       'WasImplicitlyInlinedType'))

            # Test a node that was restricted to dev channel when it was introduced.
            assertEquals(True,
                         self._branch_utility.GetChannelInfo('beta'),
                         tabs_graph.Lookup('tabs', 'functions',
                                           'restrictedFunc'),
                         scheduled=30)

            # Test an explicitly scheduled node.
            assertEquals(True,
                         self._branch_utility.GetChannelInfo('dev'),
                         tabs_graph.Lookup('tabs', 'functions',
                                           'scheduledFunc'),
                         scheduled=31)

            # Nothing new in version 24 or 23.

            assertEquals(
                True, self._branch_utility.GetStableChannelInfo(22),
                tabs_graph.Lookup('tabs', 'types', 'Tab', 'properties',
                                  'windowId'))
            assertEquals(
                True, self._branch_utility.GetStableChannelInfo(21),
                tabs_graph.Lookup('tabs', 'types', 'Tab', 'properties',
                                  'selected'))

            # Nothing new in version 20.

            assertEquals(True, self._branch_utility.GetStableChannelInfo(19),
                         tabs_graph.Lookup('tabs', 'functions', 'getCurrent'))
            assertEquals(
                True, self._branch_utility.GetStableChannelInfo(18),
                tabs_graph.Lookup('tabs', 'types', 'Tab', 'properties',
                                  'index'))
            assertEquals(
                True, self._branch_utility.GetStableChannelInfo(17),
                tabs_graph.Lookup('tabs', 'events', 'onUpdated', 'parameters',
                                  'changeInfo'))

            # Nothing new in version 16.

            assertEquals(
                True, self._branch_utility.GetStableChannelInfo(15),
                tabs_graph.Lookup('tabs', 'properties', 'fakeTabsProperty2'))

            # Everything else is available at the API's release, version 14 here.
            assertEquals(True, self._branch_utility.GetStableChannelInfo(14),
                         tabs_graph.Lookup('tabs', 'types', 'Tab'))
            assertEquals(
                True, self._branch_utility.GetStableChannelInfo(14),
                tabs_graph.Lookup('tabs', 'types', 'Tab', 'properties', 'url'))
            assertEquals(
                True, self._branch_utility.GetStableChannelInfo(14),
                tabs_graph.Lookup('tabs', 'properties', 'fakeTabsProperty1'))
            assertEquals(
                True, self._branch_utility.GetStableChannelInfo(14),
                tabs_graph.Lookup('tabs', 'functions', 'get', 'parameters',
                                  'callback'))
            assertEquals(True, self._branch_utility.GetStableChannelInfo(14),
                         tabs_graph.Lookup('tabs', 'events', 'onUpdated'))

            # Test things that aren't available.
            assertEquals(False, None,
                         tabs_graph.Lookup('tabs', 'types', 'UpdateInfo'))
            assertEquals(
                False, None,
                tabs_graph.Lookup('tabs', 'functions', 'get', 'parameters',
                                  'callback', 'parameters', 'tab', 'id'))
            assertEquals(False, None, tabs_graph.Lookup('functions'))
            assertEquals(
                False, None,
                tabs_graph.Lookup('events', 'onActivated', 'parameters',
                                  'activeInfo', 'tabId'))
Exemplo n.º 12
0
 def Refresh(self):
   return All(self._GetImpl(platform) for platform in GetPlatforms())
Exemplo n.º 13
0
 def make_api_dict(content_script_apis):
     api_dict = dict((platform, make_dict_for_platform(platform))
                     for platform in GetPlatforms())
     api_dict['contentScripts'] = content_script_apis
     return api_dict
 def Cron(self):
     return All([self._GetImpl(platform) for platform in GetPlatforms()])
Exemplo n.º 15
0
 def GetRefreshPaths(self):
     return [platform for platform in GetPlatforms()]
Exemplo n.º 16
0
 def testGetPlatforms(self):
     self.assertEqual(('apps', 'extensions'), GetPlatforms())