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

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
« no previous file with comments | « chrome/browser/web_dev_style/html_checker.py ('k') | chrome/browser/web_dev_style/test_util.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>""",
65 """<a cats\n href='classBat\nclassBaz'\n dogs>""",
66 ]
67 for line in lines:
68 self.ShouldFailCheck(line, self.checker.DoNotUseSingleQuotesCheck)
69
70 def testSingleQuoteCheckPasses(self):
71 lines = [
72 """<b id="super-valid">SO VALID!</b>""",
73 """<a text$="i ain't got invalid quotes">i don't</a>""",
74 """<span>[[i18n('blah')]]</span> """,
75 """<a cats href="classBar" dogs>""",
76 """<a cats\n href="classBar"\n dogs>""",
77 ]
78 for line in lines:
79 self.ShouldPassCheck(line, self.checker.DoNotUseSingleQuotesCheck)
80
59 def testDoNotCloseSingleTagsCheckFails(self): 81 def testDoNotCloseSingleTagsCheckFails(self):
60 lines = [ 82 lines = [
61 "<input/>", 83 "<input/>",
62 ' <input id="a" /> ', 84 ' <input id="a" /> ',
63 "<div/>", 85 "<div/>",
64 "<br/>", 86 "<br/>",
65 "<br />", 87 "<br />",
66 ] 88 ]
67 for line in lines: 89 for line in lines:
68 self.ShouldFailCheck(line, self.checker.DoNotCloseSingleTagsCheck) 90 self.ShouldFailCheck(line, self.checker.DoNotCloseSingleTagsCheck)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 ' my-for="abc" ', 183 ' my-for="abc" ',
162 ' myfor="abc" ', 184 ' myfor="abc" ',
163 " <for", 185 " <for",
164 ] 186 ]
165 for line in lines: 187 for line in lines:
166 self.ShouldPassCheck(line, self.checker.LabelCheck) 188 self.ShouldPassCheck(line, self.checker.LabelCheck)
167 189
168 190
169 if __name__ == '__main__': 191 if __name__ == '__main__':
170 unittest.main() 192 unittest.main()
OLDNEW
« no previous file with comments | « chrome/browser/web_dev_style/html_checker.py ('k') | chrome/browser/web_dev_style/test_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698