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

Side by Side Diff: chrome/browser/web_dev_style/html_checker_test.py

Issue 2091903002: [Presubmit] check for single quotes in html properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review changes Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import html_checker 6 import html_checker
7 from os import path as os_path 7 from os import path as os_path
8 import re 8 import re
9 from sys import path as sys_path 9 from sys import path as sys_path
10 import test_util 10 import test_util
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 def testClassesUseDashFormCheckPasses(self): 50 def testClassesUseDashFormCheckPasses(self):
51 lines = [ 51 lines = [
52 ' class="abc" ', 52 ' class="abc" ',
53 'class="foo-bar"', 53 'class="foo-bar"',
54 '<div class="foo-bar" id="classBar"', 54 '<div class="foo-bar" id="classBar"',
55 ] 55 ]
56 for line in lines: 56 for line in lines:
57 self.ShouldPassCheck(line, self.checker.ClassesUseDashFormCheck) 57 self.ShouldPassCheck(line, self.checker.ClassesUseDashFormCheck)
58 58
59 def testSingleQuoteCheckFails(self):
60 lines = [
61 """ <a href='classBar'> """,
62 """<a foo="bar" href='classBar'>""",
63 """<a foo="bar" less="more" href='classBar' kittens="cats">""",
64 """<a cats href='classBar' dogs>""",
Dan Beam 2016/06/23 21:00:47 multi-line?
dschuyler 2016/06/23 22:03:07 Done.
65 ]
66 for line in lines:
67 self.ShouldFailCheck(line, self.checker.DoNotUseSingleQuotesCheck)
68
69 def testSingleQuoteCheckPasses(self):
70 lines = [
71 """<b id="super-valid">SO VALID!</b>""",
72 """<a text="i ain't got invalid quotes">i don't</a>""",
73 """<span>[[i18n('blah')]]</span> """,
74 """<a cats href="classBar" dogs>""",
Dan Beam 2016/06/23 21:00:47 multi-line?
dschuyler 2016/06/23 22:03:07 Done.
75 ]
76 for line in lines:
77 self.ShouldPassCheck(line, self.checker.DoNotUseSingleQuotesCheck)
78
59 def testDoNotCloseSingleTagsCheckFails(self): 79 def testDoNotCloseSingleTagsCheckFails(self):
60 lines = [ 80 lines = [
61 "<input/>", 81 "<input/>",
62 ' <input id="a" /> ', 82 ' <input id="a" /> ',
63 "<div/>", 83 "<div/>",
64 "<br/>", 84 "<br/>",
65 "<br />", 85 "<br />",
66 ] 86 ]
67 for line in lines: 87 for line in lines:
68 self.ShouldFailCheck(line, self.checker.DoNotCloseSingleTagsCheck) 88 self.ShouldFailCheck(line, self.checker.DoNotCloseSingleTagsCheck)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 ' my-for="abc" ', 181 ' my-for="abc" ',
162 ' myfor="abc" ', 182 ' myfor="abc" ',
163 " <for", 183 " <for",
164 ] 184 ]
165 for line in lines: 185 for line in lines:
166 self.ShouldPassCheck(line, self.checker.LabelCheck) 186 self.ShouldPassCheck(line, self.checker.LabelCheck)
167 187
168 188
169 if __name__ == '__main__': 189 if __name__ == '__main__':
170 unittest.main() 190 unittest.main()
OLDNEW
« chrome/browser/web_dev_style/html_checker.py ('K') | « chrome/browser/web_dev_style/html_checker.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698