예제 #1
0
    def testGetApiAvailability(self):
        model = _JSCModel(
            self._LoadJSON('test_file.json')[0],
            self._CreateRefResolver('test_file_data_source.json'), False,
            _FakeAvailabilityFinder(),
            TestBranchUtility.CreateWithCannedData(), self._json_cache,
            _FakeTemplateCache(), None)
        # The model namespace is "tester". No predetermined availability is found,
        # so the _FakeAvailabilityFinder instance is used to find availability.
        self.assertEqual(ChannelInfo('stable', '396', 5),
                         model._GetApiAvailability())

        # These APIs have predetermined availabilities in the
        # api_availabilities.json file within CANNED_DATA.
        model._namespace.name = 'trunk_api'
        self.assertEqual(ChannelInfo('trunk', 'trunk', 'trunk'),
                         model._GetApiAvailability())

        model._namespace.name = 'dev_api'
        self.assertEqual(ChannelInfo('dev', '1500', 28),
                         model._GetApiAvailability())

        model._namespace.name = 'beta_api'
        self.assertEqual(ChannelInfo('beta', '1453', 27),
                         model._GetApiAvailability())

        model._namespace.name = 'stable_api'
        self.assertEqual(ChannelInfo('stable', '1132', 20),
                         model._GetApiAvailability())
  def testGetChannelInfo(self):
    trunk_info = ChannelInfo('trunk', 'trunk', 'trunk')
    self.assertEquals(trunk_info, self._branch_util.GetChannelInfo('trunk'))

    dev_info = ChannelInfo('dev', '1500', 28)
    self.assertEquals(dev_info, self._branch_util.GetChannelInfo('dev'))

    beta_info = ChannelInfo('beta', '1453', 27)
    self.assertEquals(beta_info, self._branch_util.GetChannelInfo('beta'))

    stable_info = ChannelInfo('stable', '1410', 26)
    self.assertEquals(stable_info, self._branch_util.GetChannelInfo('stable'))
예제 #3
0
  def testGetChannelInfo(self):
    master_info = ChannelInfo('master', 'master', 'master')
    self.assertEquals(master_info, self._branch_util.GetChannelInfo('master'))

    dev_info = ChannelInfo('dev', '1612', 31)
    self.assertEquals(dev_info, self._branch_util.GetChannelInfo('dev'))

    beta_info = ChannelInfo('beta', '1599', 30)
    self.assertEquals(beta_info, self._branch_util.GetChannelInfo('beta'))

    stable_info = ChannelInfo('stable', '1547', 29)
    self.assertEquals(stable_info, self._branch_util.GetChannelInfo('stable'))
예제 #4
0
 def GetAPINodeAvailability(self, api_name):
     schema_graph = APISchemaGraph()
     api_graph = APISchemaGraph(
         json.loads(CANNED_MASTER_FS_DATA['api'][api_name + '.json']))
     # Give the graph fake ChannelInfo; it's not used in tests.
     channel_info = ChannelInfo('stable', '28', 28)
     schema_graph.Update(api_graph, lambda _: channel_info)
     return schema_graph
예제 #5
0
 def Newer(self, channel_info):
     versions = self._versions.keys()
     index = versions.index(channel_info.version)
     if not index:
         return None
     version = versions[index - 1]
     return ChannelInfo(self.GetChannelForVersion(version),
                        self.GetBranchForVersion(version), version)
예제 #6
0
 def Older(self, channel_info):
     versions = self._versions.keys()
     index = versions.index(channel_info.version)
     if index == len(versions) - 1:
         return None
     version = versions[index + 1]
     return ChannelInfo(self.GetChannelForVersion(version),
                        self.GetBranchForVersion(version), version)
  def setUp(self):
    self._base_path = Server2Path('test_data', 'test_json')

    server_instance = ServerInstance.ForTest(
        TestFileSystem(CANNED_MASTER_FS_DATA, relative_to=CHROME_EXTENSIONS))
    file_system = server_instance.host_file_system_provider.GetMaster()
    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,
                                           'extensions')
    self._api_models = server_instance.platform_bundle.GetAPIModels(
        'extensions')
    self._fake_availability = AvailabilityInfo(ChannelInfo('stable', '396', 5))
  def testOlder(self):
    trunk_info = ChannelInfo('trunk', 'trunk', 'trunk')
    dev_info = ChannelInfo('dev', '1500', 28)
    beta_info = ChannelInfo('beta', '1453', 27)
    stable_info = ChannelInfo('stable', '1410', 26)
    old_stable_info = ChannelInfo('stable', '1364', 25)
    older_stable_info = ChannelInfo('stable', '1312', 24)
    oldest_stable_info = ChannelInfo('stable', '396', 5)

    self.assertEquals(dev_info, self._branch_util.Older(trunk_info))
    self.assertEquals(beta_info, self._branch_util.Older(dev_info))
    self.assertEquals(stable_info, self._branch_util.Older(beta_info))
    self.assertEquals(old_stable_info, self._branch_util.Older(stable_info))
    self.assertEquals(older_stable_info,
                      self._branch_util.Older(old_stable_info))
    # Test the lower limit.
    self.assertEquals(None, self._branch_util.Older(oldest_stable_info))
예제 #9
0
  def testOlder(self):
    master_info = ChannelInfo('master', 'master', 'master')
    dev_info = ChannelInfo('dev', '1612', 31)
    beta_info = ChannelInfo('beta', '1599', 30)
    stable_info = ChannelInfo('stable', '1547', 29)
    old_stable_info = ChannelInfo('stable', '1500', 28)
    older_stable_info = ChannelInfo('stable', '1453', 27)
    oldest_stable_info = ChannelInfo('stable', '396', 5)

    self.assertEquals(dev_info, self._branch_util.Older(master_info))
    self.assertEquals(beta_info, self._branch_util.Older(dev_info))
    self.assertEquals(stable_info, self._branch_util.Older(beta_info))
    self.assertEquals(old_stable_info, self._branch_util.Older(stable_info))
    self.assertEquals(older_stable_info,
                      self._branch_util.Older(old_stable_info))
    # Test the lower limit.
    self.assertEquals(None, self._branch_util.Older(oldest_stable_info))
예제 #10
0
    def testNewer(self):
        oldest_stable_info = ChannelInfo('stable', '963', 17)
        older_stable_info = ChannelInfo('stable', '1025', 18)
        old_stable_info = ChannelInfo('stable', '1084', 19)
        sort_of_old_stable_info = ChannelInfo('stable', '1500', 28)
        stable_info = ChannelInfo('stable', '1547', 29)
        beta_info = ChannelInfo('beta', '1599', 30)
        dev_info = ChannelInfo('dev', '1612', 31)
        master_info = ChannelInfo('master', 'master', 'master')

        self.assertEquals(older_stable_info,
                          self._branch_util.Newer(oldest_stable_info))
        self.assertEquals(old_stable_info,
                          self._branch_util.Newer(older_stable_info))
        self.assertEquals(stable_info,
                          self._branch_util.Newer(sort_of_old_stable_info))
        self.assertEquals(beta_info, self._branch_util.Newer(stable_info))
        self.assertEquals(dev_info, self._branch_util.Newer(beta_info))
        self.assertEquals(master_info, self._branch_util.Newer(dev_info))
        # Test the upper limit.
        self.assertEquals(None, self._branch_util.Newer(master_info))
  def testNewer(self):
    oldest_stable_info = ChannelInfo('stable', '963', 17)
    older_stable_info = ChannelInfo('stable', '1025', 18)
    old_stable_info = ChannelInfo('stable', '1084', 19)
    sort_of_old_stable_info = ChannelInfo('stable', '1364', 25)
    stable_info = ChannelInfo('stable', '1410', 26)
    beta_info = ChannelInfo('beta', '1453', 27)
    dev_info = ChannelInfo('dev', '1500', 28)
    trunk_info = ChannelInfo('trunk', 'trunk', 'trunk')

    self.assertEquals(older_stable_info,
                      self._branch_util.Newer(oldest_stable_info))
    self.assertEquals(old_stable_info,
                      self._branch_util.Newer(older_stable_info))
    self.assertEquals(stable_info,
                      self._branch_util.Newer(sort_of_old_stable_info))
    self.assertEquals(beta_info, self._branch_util.Newer(stable_info))
    self.assertEquals(dev_info, self._branch_util.Newer(beta_info))
    self.assertEquals(trunk_info, self._branch_util.Newer(dev_info))
    # Test the upper limit.
    self.assertEquals(None, self._branch_util.Newer(trunk_info))
예제 #12
0
 def testGetApiAvailability(self):
     api_availabilities = {
         'bluetooth': ChannelInfo('dev', CANNED_BRANCHES[28], 28),
         'contextMenus': ChannelInfo('trunk', CANNED_BRANCHES['trunk'],
                                     'trunk'),
         'jsonStableAPI': ChannelInfo('stable', CANNED_BRANCHES[20], 20),
         'idle': ChannelInfo('stable', CANNED_BRANCHES[5], 5),
         'input.ime': ChannelInfo('stable', CANNED_BRANCHES[18], 18),
         'tabs': ChannelInfo('stable', CANNED_BRANCHES[18], 18)
     }
     for api_name, availability in api_availabilities.iteritems():
         model = _JSCModel(api_name, self._avail_api_models, None, True,
                           self._avail_finder, self._avail_json_cache,
                           _FakeTemplateCache(), None)
         self.assertEquals(availability, model._GetApiAvailability())
예제 #13
0
 def GetStableChannelInfo(self, version):
     return ChannelInfo('stable', self.GetBranchForVersion(version),
                        version)
예제 #14
0
 def GetChannelInfo(self, channel):
     version = self._channels[channel]
     return ChannelInfo(channel, self.GetBranchForVersion(version), version)
예제 #15
0
 def GetApiAvailability(self, version):
     return ChannelInfo('stable', '396', 5)
예제 #16
0
 def GetChannelInfo(self, channel):
     return ChannelInfo(channel, 'fakebranch-%s' % channel,
                        'fakeversion-%s' % channel)
예제 #17
0
    def testGetAPIAvailability(self):
        # Key: Using 'channel' (i.e. 'beta') to represent an availability listing
        # for an API in a _features.json file, and using |channel| (i.e. |dev|) to
        # represent the development channel, or phase of development, where an API's
        # availability is being checked.

        # Testing APIs with predetermined availability.
        self.assertEqual(
            AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
            self._avail_finder.GetAPIAvailability('jsonTrunkAPI'))
        self.assertEqual(
            AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
            self._avail_finder.GetAPIAvailability('jsonDevAPI'))
        self.assertEqual(
            AvailabilityInfo(ChannelInfo('beta', CANNED_BRANCHES[27], 27)),
            self._avail_finder.GetAPIAvailability('jsonBetaAPI'))
        self.assertEqual(
            AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[20], 20)),
            self._avail_finder.GetAPIAvailability('jsonStableAPI'))

        # Testing a whitelisted API.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('beta', CANNED_BRANCHES[27], 27)),
            self._avail_finder.GetAPIAvailability('declarativeWebRequest'))

        # Testing APIs found only by checking file system existence.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[23], 23)),
            self._avail_finder.GetAPIAvailability('windows'))
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[18], 18)),
            self._avail_finder.GetAPIAvailability('tabs'))
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[18], 18)),
            self._avail_finder.GetAPIAvailability('input.ime'))

        # Testing API channel existence for _api_features.json.
        # Listed as 'dev' on |beta|, 'dev' on |dev|.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
            self._avail_finder.GetAPIAvailability('systemInfo.stuff'))
        # Listed as 'stable' on |beta|.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('beta', CANNED_BRANCHES[27], 27),
                             scheduled=28),
            self._avail_finder.GetAPIAvailability('systemInfo.cpu'))

        # Testing API channel existence for _manifest_features.json.
        # Listed as 'trunk' on all channels.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
            self._avail_finder.GetAPIAvailability('sync'))
        # No records of API until |trunk|.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
            self._avail_finder.GetAPIAvailability('history'))
        # Listed as 'dev' on |dev|.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
            self._avail_finder.GetAPIAvailability('storage'))
        # Stable in _manifest_features and into pre-18 versions.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[8], 8)),
            self._avail_finder.GetAPIAvailability('pageAction'))

        # Testing API channel existence for _permission_features.json.
        # Listed as 'beta' on |trunk|.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
            self._avail_finder.GetAPIAvailability('falseBetaAPI'))
        # Listed as 'trunk' on |trunk|.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
            self._avail_finder.GetAPIAvailability('trunkAPI'))
        # Listed as 'trunk' on all development channels.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
            self._avail_finder.GetAPIAvailability('declarativeContent'))
        # Listed as 'dev' on all development channels.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
            self._avail_finder.GetAPIAvailability('bluetooth'))
        # Listed as 'dev' on |dev|.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
            self._avail_finder.GetAPIAvailability('cookies'))
        # Treated as 'stable' APIs.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[24], 24)),
            self._avail_finder.GetAPIAvailability('alarms'))
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[21], 21)),
            self._avail_finder.GetAPIAvailability('bookmarks'))

        # Testing older API existence using extension_api.json.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[6], 6)),
            self._avail_finder.GetAPIAvailability('menus'))
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[5], 5)),
            self._avail_finder.GetAPIAvailability('idle'))

        # Switches between _features.json files across branches.
        # Listed as 'trunk' on all channels, in _api, _permission, or _manifest.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
            self._avail_finder.GetAPIAvailability('contextMenus'))
        # Moves between _permission and _manifest as file system is traversed.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[23], 23)),
            self._avail_finder.GetAPIAvailability('systemInfo.display'))
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[17], 17)),
            self._avail_finder.GetAPIAvailability('webRequest'))

        # Mid-upgrade cases:
        # Listed as 'dev' on |beta| and 'beta' on |dev|.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
            self._avail_finder.GetAPIAvailability('notifications'))
        # Listed as 'beta' on |stable|, 'dev' on |beta| ... until |stable| on trunk.
        self.assertEquals(
            AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
            self._avail_finder.GetAPIAvailability('events'))
예제 #18
0
    def testGetIntroList(self):
        fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability)
        model = _JSCViewBuilder(self._api_models.GetContentScriptAPIs().Get(),
                                self._api_models.GetModel('tester').Get(),
                                fake_avail_finder, self._json_cache,
                                _FakeTemplateCache(), self._features_bundle,
                                None, 'extensions', [])
        expected_list = [{
            'title': 'Description',
            'content': [{
                'text': 'a test api'
            }]
        }, {
            'title':
            'Availability',
            'content': [{
                'partial':
                'motemplate chrome/common/extensions/docs/' +
                'templates/private/intro_tables/stable_message.html',
                'version':
                5,
                'scheduled':
                None
            }]
        }, {
            'title':
            'Permissions',
            'content': [{
                'class': 'override',
                'text': '"tester"'
            }, {
                'text': 'is an API for testing things.'
            }]
        }, {
            'title':
            'Manifest',
            'content': [{
                'class': 'code',
                'text': '"tester": {...}'
            }]
        }, {
            'title':
            'Content Scripts',
            'content': [{
                'partial':
                'motemplate chrome/common/extensions/docs' +
                '/templates/private/intro_tables/content_scripts.html',
                'contentScriptSupport': {
                    'name': 'tester',
                    'restrictedTo': None
                }
            }]
        }, {
            'title':
            'Learn More',
            'content': [{
                'link': 'https://tester.test.com/welcome.html',
                'text': 'Welcome!'
            }]
        }]
        self.assertEquals(model._GetIntroTableList(), expected_list)

        # Tests the same data with a scheduled availability.
        fake_avail_finder = _FakeAvailabilityFinder(
            AvailabilityInfo(ChannelInfo('beta', '1453', 27), scheduled=28))
        model = _JSCViewBuilder(self._api_models.GetContentScriptAPIs().Get(),
                                self._api_models.GetModel('tester').Get(),
                                fake_avail_finder, self._json_cache,
                                _FakeTemplateCache(), self._features_bundle,
                                None, 'extensions', [])
        expected_list[1] = {
            'title':
            'Availability',
            'content': [{
                'partial':
                'motemplate chrome/common/extensions/docs/' +
                'templates/private/intro_tables/beta_message.html',
                'version':
                27,
                'scheduled':
                28
            }]
        }
        self.assertEquals(model._GetIntroTableList(), expected_list)
예제 #19
0
 def GetApiAvailability(self, version):
     return AvailabilityInfo(ChannelInfo('beta', '1453', 27), scheduled=28)
    def testGetAPIAvailability(self):
        # Key: Using 'channel' (i.e. 'beta') to represent an availability listing
        # for an API in a _features.json file, and using |channel| (i.e. |dev|) to
        # represent the development channel, or phase of development, where an API's
        # availability is being checked.

        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))

        # Testing APIs with predetermined availability.
        assertGet(ChannelInfo('trunk', 'trunk', 'trunk'), 'jsonTrunkAPI')
        assertGet(ChannelInfo('dev', CANNED_BRANCHES[31], 31), 'jsonDevAPI')
        assertGet(ChannelInfo('beta', CANNED_BRANCHES[30], 30), 'jsonBetaAPI')
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[20], 20),
                  'jsonStableAPI')

        # Testing a whitelisted API.
        assertGet(ChannelInfo('beta', CANNED_BRANCHES[30], 30),
                  'declarativeWebRequest')

        # Testing APIs found only by checking file system existence.
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[23], 23), 'windows')
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[18], 18), 'tabs')
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[18], 18), 'input.ime')

        # Testing API channel existence for _api_features.json.
        # Listed as 'dev' on |beta|, 'dev' on |dev|.
        assertGet(ChannelInfo('dev', CANNED_BRANCHES[31], 31),
                  'systemInfo.stuff')
        # Listed as 'stable' on |beta|.
        assertGet(ChannelInfo('beta', CANNED_BRANCHES[30], 30),
                  'systemInfo.cpu',
                  scheduled=31)

        # Testing API channel existence for _manifest_features.json.
        # Listed as 'trunk' on all channels.
        assertGet(ChannelInfo('trunk', 'trunk', 'trunk'), 'sync')
        # No records of API until |trunk|.
        assertGet(ChannelInfo('trunk', 'trunk', 'trunk'), 'history')
        # Listed as 'dev' on |dev|.
        assertGet(ChannelInfo('dev', CANNED_BRANCHES[31], 31), 'storage')
        # Stable in _manifest_features and into pre-18 versions.
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[8], 8), 'pageAction')

        # Testing API channel existence for _permission_features.json.
        # Listed as 'beta' on |trunk|.
        assertGet(ChannelInfo('trunk', 'trunk', 'trunk'), 'falseBetaAPI')
        # Listed as 'trunk' on |trunk|.
        assertGet(ChannelInfo('trunk', 'trunk', 'trunk'), 'trunkAPI')
        # Listed as 'trunk' on all development channels.
        assertGet(ChannelInfo('trunk', 'trunk', 'trunk'), 'declarativeContent')
        # Listed as 'dev' on all development channels.
        assertGet(ChannelInfo('dev', CANNED_BRANCHES[31], 31), 'bluetooth')
        # Listed as 'dev' on |dev|.
        assertGet(ChannelInfo('dev', CANNED_BRANCHES[31], 31), 'cookies')
        # Treated as 'stable' APIs.
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[24], 24), 'alarms')
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[21], 21), 'bookmarks')

        # Testing older API existence using extension_api.json.
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[6], 6), 'menus')
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[5], 5), 'idle')

        # Switches between _features.json files across branches.
        # Listed as 'trunk' on all channels, in _api, _permission, or _manifest.
        assertGet(ChannelInfo('trunk', 'trunk', 'trunk'), 'contextMenus')
        # Moves between _permission and _manifest as file system is traversed.
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[23], 23),
                  'systemInfo.display')
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[17], 17), 'webRequest')

        # Mid-upgrade cases:
        # Listed as 'dev' on |beta| and 'beta' on |dev|.
        assertGet(ChannelInfo('dev', CANNED_BRANCHES[31], 31), 'notifications')
        # Listed as 'beta' on |stable|, 'dev' on |beta|...until |stable| on trunk.
        assertGet(ChannelInfo('trunk', 'trunk', 'trunk'), 'events')

        # Check for differing availability across apps|extensions
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[26], 26),
                  'appsFirst',
                  only_on='extensions')
        assertGet(ChannelInfo('stable', CANNED_BRANCHES[25], 25),
                  'appsFirst',
                  only_on='apps')
 def GetAPIAvailability(self, version):
   return AvailabilityInfo(ChannelInfo('stable', '396', 5))