Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(662)

Unified Diff: chrome/browser/test_presubmit.py

Issue 866753002: Fix the 'for' attribute check in presubmit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test for the presubmit check. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/web_dev_style/html_checker.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/test_presubmit.py
diff --git a/chrome/browser/test_presubmit.py b/chrome/browser/test_presubmit.py
index b112eacd0d61c1a2c9563a5242263414680fc6a2..d37a6b3e6cc72e7412adc23375971c0d587d0fd4 100755
--- a/chrome/browser/test_presubmit.py
+++ b/chrome/browser/test_presubmit.py
@@ -18,7 +18,8 @@ sys.path.extend([
import find_depot_tools # pylint: disable=W0611
from testing_support.super_mox import SuperMoxTestBase
-from web_dev_style import resource_checker, css_checker, js_checker # pylint: disable=F0401
+from web_dev_style import css_checker, html_checker, js_checker, \
+ resource_checker # pylint: disable=F0401
def GetHighlight(line, error):
@@ -28,6 +29,47 @@ def GetHighlight(line, error):
return ''.join(ch1 for (ch1, ch2) in zip(line, highlight) if ch2 == '^')
+class HtmlStyleTest(SuperMoxTestBase):
+ def setUp(self):
+ SuperMoxTestBase.setUp(self)
+
+ input_api = self.mox.CreateMockAnything()
+ input_api.re = re
+ output_api = self.mox.CreateMockAnything()
+ self.checker = html_checker.HtmlChecker(input_api, output_api)
+
+ def ShouldFailLabelCheck(self, line):
+ """Checks that the label checker flags |line| as a style error."""
+ error = self.checker.LabelCheck(1, line)
+ self.assertNotEqual('', error, 'Should be flagged as style error: ' + line)
+ highlight = GetHighlight(line, error).strip()
+ self.assertEqual('for=', highlight)
+
+ def ShouldPassLabelCheck(self, line):
+ """Checks that the label checker doesn't flag |line| as a style error."""
+ error = self.checker.LabelCheck(1, line)
+ self.assertEqual('', error, 'Should not be flagged as style error: ' + line)
+
+ def testForAttributeFails(self):
+ lines = [
+ " for=\"abc\"",
+ "for= ",
+ " \tfor= ",
+ " for="
+ ]
+ for line in lines:
+ self.ShouldFailLabelCheck(line)
+
+ def testOtherAttributesPass(self):
+ lines = [
+ " my-for=\"abc\" ",
+ " myfor=\"abc\" ",
+ " <for",
+ ]
+ for line in lines:
+ self.ShouldPassLabelCheck(line)
+
+
class ResourceStyleGuideTest(SuperMoxTestBase):
def setUp(self):
SuperMoxTestBase.setUp(self)
« no previous file with comments | « no previous file | chrome/browser/web_dev_style/html_checker.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698