コード例 #1
0
  def testAddRules(self):
    fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability)
    dict_ = JSCView(self._api_models.GetContentScriptAPIs().Get(),
                    self._api_models.GetModel('add_rules_tester').Get(),
                    fake_avail_finder,
                    self._json_cache,
                    _FakeTemplateCache(),
                    self._features_bundle,
                    self._FakeLoadAddRulesSchema(),
                    'extensions').ToDict()

    # Check that the first event has the addRulesFunction defined.
    self.assertEquals('add_rules_tester', dict_['name'])
    self.assertEquals('rules', dict_['events'][0]['name'])
    self.assertEquals('notable_name_to_check_for',
                      dict_['events'][0]['byName']['addRules'][
                          'parameters'][0]['name'])

    # Check that the second event has addListener defined.
    self.assertEquals('noRules', dict_['events'][1]['name'])
    self.assertEquals('add_rules_tester', dict_['name'])
    self.assertEquals('noRules', dict_['events'][1]['name'])
    self.assertEquals('callback',
                      dict_['events'][0]['byName']['addListener'][
                          'parameters'][0]['name'])
コード例 #2
0
    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 = JSCView(self._api_models.GetContentScriptAPIs().Get(),
                             self._api_models.GetModel('tabs').Get(),
                             self._avail_finder, self._json_cache,
                             _FakeTemplateCache(), _FakeFeaturesBundle(), None,
                             'extensions').ToDict()

        # 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'][0]['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'][2]['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':
                'handlebar chrome/common/extensions/docs/templates/' +
                'private/intro_tables/deprecated_message.html'
            }, model_dict['types'][2]['availability'])
コード例 #3
0
 def DISABLED_testToDict(self):
     fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability)
     expected_json = self._LoadJSON('expected_tester.json')
     dict_ = JSCView(self._api_models.GetContentScriptAPIs().Get(),
                     self._api_models.GetModel('tester').Get(),
                     fake_avail_finder, self._json_cache,
                     _FakeTemplateCache(), self._features_bundle, None,
                     'extensions').ToDict()
     self.assertEquals(expected_json, dict_)
コード例 #4
0
 def testCreateId(self):
     fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability)
     dict_ = JSCView(self._api_models.GetContentScriptAPIs().Get(),
                     self._api_models.GetModel('tester').Get(),
                     fake_avail_finder, self._json_cache,
                     _FakeTemplateCache(), self._features_bundle, None,
                     'extensions').ToDict()
     self.assertEquals('type-TypeA', dict_['types'][0]['id'])
     self.assertEquals('property-TypeA-b',
                       dict_['types'][0]['properties'][0]['id'])
     self.assertEquals('method-get', dict_['functions'][0]['id'])
     self.assertEquals('event-EventA', dict_['events'][0]['id'])
コード例 #5
0
 def testGetAPIAvailability(self):
     api_availabilities = {
         'bluetooth': 31,
         'contextMenus': 'trunk',
         'jsonStableAPI': 20,
         'idle': 5,
         'input.ime': 18,
         'tabs': 18
     }
     for api_name, availability in api_availabilities.iteritems():
         model_dict = JSCView(self._api_models.GetContentScriptAPIs().Get(),
                              self._api_models.GetModel(api_name).Get(),
                              self._avail_finder, self._json_cache,
                              _FakeTemplateCache(), _FakeFeaturesBundle(),
                              None, 'extensions').ToDict()
         self.assertEquals(
             availability,
             model_dict['introList'][1]['content'][0]['version'])
コード例 #6
0
    def testGetIntroList(self):
        fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability)
        model = JSCView(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':
                'handlebar 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': 'handlebar 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 = JSCView(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':
                'handlebar chrome/common/extensions/docs/' +
                'templates/private/intro_tables/beta_message.html',
                'version':
                27,
                'scheduled':
                28
            }]
        }
        self.assertEquals(model._GetIntroTableList(), expected_list)
コード例 #7
0
  def testGetIntroList(self):
    fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability)
    model = JSCView(self._api_models.GetContentScriptAPIs().Get(),
                    self._api_models.GetModel('tester').Get(),
                    fake_avail_finder,
                    self._json_cache,
                    _FakeTemplateCache(),
                    self._features_bundle,
                    None)
    expected_list = [
      { 'title': 'Description',
        'content': [
          { 'text': 'a test api' }
        ]
      },
      { 'title': 'Availability',
        'content': [
          { 'partial': 'handlebar 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': 'handlebar 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 = JSCView(self._api_models.GetContentScriptAPIs().Get(),
                    self._api_models.GetModel('tester').Get(),
                    fake_avail_finder,
                    self._json_cache,
                    _FakeTemplateCache(),
                    self._features_bundle,
                    None)
    expected_list[1] = {
      'title': 'Availability',
      'content': [
        { 'partial': 'handlebar chrome/common/extensions/docs/' +
                     'templates/private/intro_tables/beta_message.html',
          'version': 27,
          'scheduled': 28
        }
      ]
    }
    self.assertEquals(model._GetIntroTableList(), expected_list)