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

Unified Diff: chrome/browser/web_dev_style/css_checker_test.py

Issue 1639863004: Add support for inline CSS in HTML files to CSS Presubmit checker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
Index: chrome/browser/web_dev_style/css_checker_test.py
diff --git a/chrome/browser/web_dev_style/css_checker_test.py b/chrome/browser/web_dev_style/css_checker_test.py
index 84acc79490a44f2b58987d73b3c8890a481aee57..100547cbc5c336c2d8c0075b6369ff024a85a1da 100755
--- a/chrome/browser/web_dev_style/css_checker_test.py
+++ b/chrome/browser/web_dev_style/css_checker_test.py
@@ -20,12 +20,9 @@ class CssCheckerTest(SuperMoxTestBase):
def setUp(self):
SuperMoxTestBase.setUp(self)
- self.fake_file_name = 'fake.css'
-
self.fake_file = self.mox.CreateMockAnything()
+ # Actual calls to NewContents() and LocalPath() are defined in each test.
self.mox.StubOutWithMock(self.fake_file, 'LocalPath')
- self.fake_file.LocalPath().AndReturn(self.fake_file_name)
- # Actual calls to NewContents() are defined in each test.
self.mox.StubOutWithMock(self.fake_file, 'NewContents')
self.input_api = self.mox.CreateMockAnything()
@@ -43,13 +40,18 @@ class CssCheckerTest(SuperMoxTestBase):
self.mox.StubOutWithMock(self.output_api, 'PresubmitNotifyResult',
use_mock_anything=True)
- def VerifyContentsIsValid(self, contents):
+ def CreateFile(self, contents, filename):
Dan Beam 2016/01/27 02:50:45 nit: this should probably be _create_file or __cre
tsergeant 2016/01/27 03:12:14 Done.
+ self.fake_file_name = filename
+ self.fake_file.LocalPath().AndReturn(self.fake_file_name)
self.fake_file.NewContents().AndReturn(contents.splitlines())
+
+ def VerifyContentsIsValid(self, contents, filename='fake.css'):
Dan Beam 2016/01/27 02:50:45 nit: "contents are" or "content is"
tsergeant 2016/01/27 03:12:14 Done.
+ self.CreateFile(contents, filename)
self.mox.ReplayAll()
css_checker.CSSChecker(self.input_api, self.output_api).RunChecks()
- def VerifyContentsProducesOutput(self, contents, output):
- self.fake_file.NewContents().AndReturn(contents.splitlines())
+ def VerifyContentsProducesOutput(self, contents, output, filename='fake.css'):
+ self.CreateFile(contents, filename)
self.output_api.PresubmitPromptWarning(
self.fake_file_name + ':\n' + output.strip()).AndReturn(None)
self.mox.ReplayAll()
@@ -428,6 +430,28 @@ body.alternate-logo #logo {
width: 0in;
""")
+ def testHtmlInlineStyle(self):
+ self.VerifyContentsProducesOutput("""<!doctype html>
+<html>
+<head>
+ <!-- Don't warn about problems outside of style tags
+ html,
+ body {
+ margin: 0;
+ height: 100%;
+ }
+ -->
+ <style>
+ body {
+ flex-direction:column;
+ }
+ </style>
+</head>
+</html>""", """
+- Colons (:) should have a space after them.
+ flex-direction:column;
+""", filename='test.html')
+
if __name__ == '__main__':
unittest.main()
« chrome/browser/web_dev_style/css_checker.py ('K') | « chrome/browser/web_dev_style/css_checker.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698