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

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: Review comments 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
« no previous file with comments | « chrome/browser/web_dev_style/css_checker.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0d3f00745b452188886b3d627b6d54a5c7c0909e 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 _create_file(self, contents, filename):
+ self.fake_file_name = filename
+ self.fake_file.LocalPath().AndReturn(self.fake_file_name)
self.fake_file.NewContents().AndReturn(contents.splitlines())
+
+ def VerifyContentIsValid(self, contents, filename='fake.css'):
+ self._create_file(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._create_file(contents, filename)
self.output_api.PresubmitPromptWarning(
self.fake_file_name + ':\n' + output.strip()).AndReturn(None)
self.mox.ReplayAll()
@@ -95,7 +97,7 @@ class CssCheckerTest(SuperMoxTestBase):
color: black;""")
def testCssStringWithAt(self):
- self.VerifyContentsIsValid("""
+ self.VerifyContentIsValid("""
#logo {
background-image: url(images/google_logo.png@2x);
}
@@ -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()
« no previous file with comments | « 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