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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 .class_name { | 285 .class_name { |
286 display: block; | 286 display: block; |
287 }""", """ | 287 }""", """ |
288 - Classes use .dash-form. | 288 - Classes use .dash-form. |
289 .className, | 289 .className, |
290 .ClassName, | 290 .ClassName, |
291 .class_name {""") | 291 .class_name {""") |
292 | 292 |
293 def testCssCloseBraceOnNewLine(self): | 293 def testCssCloseBraceOnNewLine(self): |
294 self.VerifyContentsProducesOutput(""" | 294 self.VerifyContentsProducesOutput(""" |
295 @media { /* TODO(dbeam) Fix this case. | 295 @media { /* TODO(dbeam) Fix this case. */ |
296 .rule { | 296 .rule { |
297 display: block; | 297 display: block; |
298 }} | 298 }} |
299 | 299 |
300 #rule { | 300 #rule { |
301 rule: value; }""", """ | 301 rule: value; }""", """ |
302 - Always put a rule closing brace (}) on a new line. | 302 - Always put a rule closing brace (}) on a new line. |
303 rule: value; }""") | 303 rule: value; }""") |
304 | 304 |
305 def testCssColonsHaveSpaceAfter(self): | 305 def testCssColonsHaveSpaceAfter(self): |
306 self.VerifyContentsProducesOutput(""" | 306 self.VerifyContentsProducesOutput(""" |
307 div:not(.class):not([attr]) /* We should not catch this. */ { | 307 div:not(.class):not([attr=5]), /* We should not catch this. */ |
| 308 div:not(.class):not([attr]) /* Nor this. */ { |
| 309 background: -webkit-linear-gradient(left, red, |
| 310 80% blah blee blar); |
| 311 color: red; |
308 display:block; | 312 display:block; |
309 }""", """ | 313 }""", """ |
310 - Colons (:) should have a space after them. | 314 - Colons (:) should have a space after them. |
311 display:block;""") | 315 display:block;""") |
312 | 316 |
313 def testCssFavorSingleQuotes(self): | 317 def testCssFavorSingleQuotes(self): |
314 self.VerifyContentsProducesOutput(""" | 318 self.VerifyContentsProducesOutput(""" |
315 html[dir="rtl"] body, | 319 html[dir="rtl"] body, |
316 html[dir=ltr] body /* TODO(dbeam): Require '' around rtl in future? */ { | 320 html[dir=ltr] body /* TODO(dbeam): Require '' around rtl in future? */ { |
317 background: url("chrome://resources/BLAH"); | 321 background: url("chrome://resources/BLAH"); |
(...skipping 26 matching lines...) Expand all Loading... |
344 transform: two .1s; | 348 transform: two .1s; |
345 transform: tree 1s; | 349 transform: tree 1s; |
346 transform: four 300ms; | 350 transform: four 300ms; |
347 }""", """ | 351 }""", """ |
348 - Use milliseconds for time measurements under 1 second. | 352 - Use milliseconds for time measurements under 1 second. |
349 transform: one 0.2s; (replace with 200ms) | 353 transform: one 0.2s; (replace with 200ms) |
350 transform: two .1s; (replace with 100ms)""") | 354 transform: two .1s; (replace with 100ms)""") |
351 | 355 |
352 def testCssOneRulePerLine(self): | 356 def testCssOneRulePerLine(self): |
353 self.VerifyContentsProducesOutput(""" | 357 self.VerifyContentsProducesOutput(""" |
| 358 a:not([hidden]):not(.custom-appearance):not([version=1]):first-of-type, |
| 359 a:not([hidden]):not(.custom-appearance):not([version=1]):first-of-type ~ |
| 360 input[type='checkbox']:not([hidden]), |
354 div { | 361 div { |
| 362 background: url(chrome://resources/BLAH); |
355 rule: value; /* rule: value; */ | 363 rule: value; /* rule: value; */ |
356 rule: value; rule: value; | 364 rule: value; rule: value; |
357 }""", """ | 365 }""", """ |
358 - One rule per line (what not to do: color: red; margin: 0;). | 366 - One rule per line (what not to do: color: red; margin: 0;). |
359 rule: value; rule: value;""") | 367 rule: value; rule: value;""") |
360 | 368 |
361 def testCssOneSelectorPerLine(self): | 369 def testCssOneSelectorPerLine(self): |
362 self.VerifyContentsProducesOutput(""" | 370 self.VerifyContentsProducesOutput(""" |
363 a, | 371 a, |
364 div,a, | 372 div,a, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 background-position-x: 0em; | 437 background-position-x: 0em; |
430 background-position-y: 0ex; | 438 background-position-y: 0ex; |
431 border-width: 0em; | 439 border-width: 0em; |
432 border-width: 0mm; | 440 border-width: 0mm; |
433 height: 0cm; | 441 height: 0cm; |
434 width: 0in; | 442 width: 0in; |
435 """) | 443 """) |
436 | 444 |
437 if __name__ == '__main__': | 445 if __name__ == '__main__': |
438 unittest.main() | 446 unittest.main() |
OLD | NEW |