| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Unit tests for Web Development Style Guide checker.""" | 6 """Unit tests for Web Development Style Guide checker.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import sys | 10 import sys |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 .class_name { | 118 .class_name { |
| 119 display: block; | 119 display: block; |
| 120 }""", """ | 120 }""", """ |
| 121 - Classes use .dash-form. | 121 - Classes use .dash-form. |
| 122 .className, | 122 .className, |
| 123 .ClassName, | 123 .ClassName, |
| 124 .class_name {""") | 124 .class_name {""") |
| 125 | 125 |
| 126 def testCssCloseBraceOnNewLine(self): | 126 def testCssCloseBraceOnNewLine(self): |
| 127 self.VerifyContentsProducesOutput(""" | 127 self.VerifyContentsProducesOutput(""" |
| 128 @media { /* TODO(dbeam) Fix this case. | 128 @media { /* TODO(dbeam) Fix this case. */ |
| 129 .rule { | 129 .rule { |
| 130 display: block; | 130 display: block; |
| 131 }} | 131 }} |
| 132 | 132 |
| 133 #rule { | 133 #rule { |
| 134 rule: value; }""", """ | 134 rule: value; }""", """ |
| 135 - Always put a rule closing brace (}) on a new line. | 135 - Always put a rule closing brace (}) on a new line. |
| 136 rule: value; }""") | 136 rule: value; }""") |
| 137 | 137 |
| 138 def testCssColonsHaveSpaceAfter(self): | 138 def testCssColonsHaveSpaceAfter(self): |
| 139 self.VerifyContentsProducesOutput(""" | 139 self.VerifyContentsProducesOutput(""" |
| 140 div:not(.class):not([attr]) /* We should not catch this. */ { | 140 div:not(.class):not([attr=5]), /* We should not catch this. */ |
| 141 div:not(.class):not([attr]) /* Nor this. */ { |
| 142 background: -webkit-linear-gradient(left, red, |
| 143 80% blah blee blar); |
| 144 color: red; |
| 141 display:block; | 145 display:block; |
| 142 }""", """ | 146 }""", """ |
| 143 - Colons (:) should have a space after them. | 147 - Colons (:) should have a space after them. |
| 144 display:block;""") | 148 display:block;""") |
| 145 | 149 |
| 146 def testCssFavorSingleQuotes(self): | 150 def testCssFavorSingleQuotes(self): |
| 147 self.VerifyContentsProducesOutput(""" | 151 self.VerifyContentsProducesOutput(""" |
| 148 html[dir="rtl"] body, | 152 html[dir="rtl"] body, |
| 149 html[dir=ltr] body /* TODO(dbeam): Require '' around rtl in future? */ { | 153 html[dir=ltr] body /* TODO(dbeam): Require '' around rtl in future? */ { |
| 150 background: url("chrome://resources/BLAH"); | 154 background: url("chrome://resources/BLAH"); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 177 transform: two .1s; | 181 transform: two .1s; |
| 178 transform: tree 1s; | 182 transform: tree 1s; |
| 179 transform: four 300ms; | 183 transform: four 300ms; |
| 180 }""", """ | 184 }""", """ |
| 181 - Use milliseconds for time measurements under 1 second. | 185 - Use milliseconds for time measurements under 1 second. |
| 182 transform: one 0.2s; (replace with 200ms) | 186 transform: one 0.2s; (replace with 200ms) |
| 183 transform: two .1s; (replace with 100ms)""") | 187 transform: two .1s; (replace with 100ms)""") |
| 184 | 188 |
| 185 def testCssOneRulePerLine(self): | 189 def testCssOneRulePerLine(self): |
| 186 self.VerifyContentsProducesOutput(""" | 190 self.VerifyContentsProducesOutput(""" |
| 191 a:not([hidden]):not(.custom-appearance):not([version=1]):first-of-type, |
| 192 a:not([hidden]):not(.custom-appearance):not([version=1]):first-of-type ~ |
| 193 input[type='checkbox']:not([hidden]), |
| 187 div { | 194 div { |
| 195 background: url(chrome://resources/BLAH); |
| 188 rule: value; /* rule: value; */ | 196 rule: value; /* rule: value; */ |
| 189 rule: value; rule: value; | 197 rule: value; rule: value; |
| 190 }""", """ | 198 }""", """ |
| 191 - One rule per line (what not to do: color: red; margin: 0;). | 199 - One rule per line (what not to do: color: red; margin: 0;). |
| 192 rule: value; rule: value;""") | 200 rule: value; rule: value;""") |
| 193 | 201 |
| 194 def testCssOneSelectorPerLine(self): | 202 def testCssOneSelectorPerLine(self): |
| 195 self.VerifyContentsProducesOutput(""" | 203 self.VerifyContentsProducesOutput(""" |
| 196 a, | 204 a, |
| 197 div,a, | 205 div,a, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 background-position-x: 0em; | 270 background-position-x: 0em; |
| 263 background-position-y: 0ex; | 271 background-position-y: 0ex; |
| 264 border-width: 0em; | 272 border-width: 0em; |
| 265 border-width: 0mm; | 273 border-width: 0mm; |
| 266 height: 0cm; | 274 height: 0cm; |
| 267 width: 0in; | 275 width: 0in; |
| 268 """) | 276 """) |
| 269 | 277 |
| 270 if __name__ == '__main__': | 278 if __name__ == '__main__': |
| 271 unittest.main() | 279 unittest.main() |
| OLD | NEW |