def ShouldFailIncludeCheck(self, line): """Checks that the '</include>' checker flags |line| as a style error.""" error = self.checker.IncludeCheck(1, line) self.assertNotEqual('', error, 'Should be flagged as style error: ' + line) highlight = test_util.GetHighlight(line, error).strip() self.assertTrue('include' in highlight and highlight[0] == '<')
def ShouldFailCommentCheck(self, line): """Checks that uncommented "<if>" and "<include>" are a style error.""" error = self.checker.CommentIfAndIncludeCheck(1, line) self.assertNotEqual("", error, "Should be flagged as style error: " + line) highlight = test_util.GetHighlight(line, error).strip() self.assertTrue(highlight.startswith(("<if", "<include")))
def ShouldFailPolymerLocalIdCheck(self, line): """Checks that element.$.localId check marks |line| as a style error.""" error = self.checker.PolymerLocalIdCheck(1, line) self.assertNotEqual('', error, msg='Should be flagged as a style error: ' + line) self.assertTrue('.$' in test_util.GetHighlight(line, error))
def ShouldFailVariableNameCheck(self, line): """Checks that var unix_hacker, $dollar are style errors.""" error = self.checker.VariableNameCheck(1, line) self.assertNotEqual('', error, msg='Should be flagged as style error: ' + line) highlight = test_util.GetHighlight(line, error) self.assertFalse(any(dm in highlight for dm in _DECLARATION_METHODS))
def ShouldFailCommentCheck(self, line): """Checks that uncommented '<if>' and '<include>' are a style error.""" error = self.checker.CommentIfAndIncludeCheck(1, line) self.assertNotEqual('', error, 'Should be flagged as style error: ' + line) highlight = test_util.GetHighlight(line, error).strip() self.assertTrue(highlight.startswith(('<if', '<include')))
def ShouldFailInheritDocCheck(self, line): """Checks that the '@inheritDoc' checker flags |line| as a style error.""" error = self.checker.InheritDocCheck(1, line) self.assertNotEqual('', error, msg='Should be flagged as style error: ' + line) self.assertEqual(test_util.GetHighlight(line, error), '@inheritDoc')
def ShouldFailVarNameCheck(self, line): """Checks that var unix_hacker, $dollar are style errors.""" error = self.checker.VarNameCheck(1, line) self.assertNotEqual('', error, msg='Should be flagged as style error: ' + line) highlight = test_util.GetHighlight(line, error) self.assertFalse('var ' in highlight);
def ShouldFailWrapperTypeCheck(self, line): """Checks that the use of wrapper types (i.e. new Number(), @type {Number}) is a style error. """ error = self.checker.WrapperTypeCheck(1, line) self.assertNotEqual('', error, msg='Should be flagged as style error: ' + line) highlight = test_util.GetHighlight(line, error) self.assertTrue(highlight in ('Boolean', 'Number', 'String'))
def ShouldFailGetElementByIdCheck(self, line): """Checks that the 'getElementById' checker flags |line| as a style error. """ error = self.checker.GetElementByIdCheck(1, line) self.assertNotEqual('', error, 'Should be flagged as style error: ' + line) self.assertEqual(test_util.GetHighlight(line, error), 'document.getElementById')
def ShouldFailInheritDocCheck(self, line): """Checks that the "@inheritDoc" checker flags |line| as a style error.""" error = self.checker.InheritDocCheck(1, line) self.assertNotEqual("", error, "Should be flagged as style error: " + line) self.assertEqual(test_util.GetHighlight(line, error), "@inheritDoc")
def ShouldFailCheck(self, line, checker): """Checks that the |checker| flags |line| as a style error.""" error = checker(1, line) self.assertNotEqual('', error, 'Should be flagged as style error: ' + line) highlight = test_util.GetHighlight(line, error).strip()
def ShouldFailChromeSendCheck(self, line): """Checks that the 'chrome.send' checker flags |line| as a style error.""" error = self.checker.ChromeSendCheck(1, line) self.assertNotEqual('', error, 'Should be flagged as style error: ' + line) self.assertEqual(test_util.GetHighlight(line, error), ', []')
def ShouldFailExtraDotInGenericCheck(self, line): """Checks that Array.< or Object.< is flagged as a style nit.""" error = self.checker.ExtraDotInGenericCheck(1, line) self.assertNotEqual('', error) self.assertTrue(test_util.GetHighlight(line, error).endswith(".<"))
def ShouldFailEndJsDocCommentCheck(self, line): """Checks that the **/ checker flags |line| as a style error.""" error = self.checker.EndJsDocCommentCheck(1, line) self.assertNotEqual('', error, 'Should be flagged as style error: ' + line) self.assertEqual(test_util.GetHighlight(line, error), '**/')
def ShouldFailChromeSendCheck(self, line): """Checks that the "chrome.send" checker flags |line| as a style error.""" error = self.checker.ChromeSendCheck(1, line) self.assertNotEqual("", error, "Should be flagged as style error: " + line) self.assertEqual(test_util.GetHighlight(line, error), ", []")
def ShouldFailBindThisCheck(self, line): error = self.checker.BindThisCheck(1, line) self.assertNotEqual("", error, "Should be flagged as style error: " + line) highlight = test_util.GetHighlight(line, error).strip() self.assertTrue(highlight.startswith(".bind(this"))
def ShouldFailDeprecatedMojoBindingCheck(self, line): error = self.checker.DeprecatedMojoBindingsCheck(1, line) self.assertNotEqual('', error, 'Should be flagged as error: ' + line) self.assertEquals('mojo_bindings.js', test_util.GetHighlight(line, error))
def ShouldFailDisallowIncludeCheck(self, line): error = self.checker.DisallowIncludeCheck('msg', 1, line) self.assertNotEqual('', error, 'Should be flagged as error: ' + line) self.assertEquals('<include', test_util.GetHighlight(line, error))