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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 def VerifyContentsProducesOutput(self, contents, output): | 54 def VerifyContentsProducesOutput(self, contents, output): |
55 self.fake_file.NewContents().AndReturn(contents.splitlines()) | 55 self.fake_file.NewContents().AndReturn(contents.splitlines()) |
56 self.output_api.PresubmitError( | 56 self.output_api.PresubmitError( |
57 self.fake_file_name + ':\n' + output.strip()).AndReturn(None) | 57 self.fake_file_name + ':\n' + output.strip()).AndReturn(None) |
58 self.mox.ReplayAll() | 58 self.mox.ReplayAll() |
59 css_checker.CSSChecker(self.input_api, self.output_api).RunChecks() | 59 css_checker.CSSChecker(self.input_api, self.output_api).RunChecks() |
60 | 60 |
61 def testCssAlphaWithAtBlock(self): | 61 def testCssAlphaWithAtBlock(self): |
62 self.VerifyContentsProducesOutput(""" | 62 self.VerifyContentsProducesOutput(""" |
| 63 <include src="../shared/css/cr/ui/overlay.css"> |
| 64 <include src="chrome://resources/totally-cool.css" /> |
| 65 |
63 /* A hopefully safely ignored comment and @media statement. /**/ | 66 /* A hopefully safely ignored comment and @media statement. /**/ |
64 @media print { | 67 @media print { |
65 div { | 68 div { |
66 display: block; | 69 display: block; |
67 color: red; | 70 color: red; |
68 } | 71 } |
69 }""", """ | 72 <if expr="not is macosx"> |
| 73 background-image: url(chrome://resources/BLAH); /* TODO(dbeam): Fix this. */ |
| 74 background-color: rgb(235, 239, 249); |
| 75 </if> |
| 76 <if expr="is_macosx"> |
| 77 background-color: white; |
| 78 background-image: url(chrome://resources/BLAH2); |
| 79 </if> |
| 80 } |
| 81 |
| 82 <if expr="is_macosx"> |
| 83 .language-options-right { |
| 84 visibility: hidden; |
| 85 opacity: 1; /* TODO(dbeam): Fix this. */ |
| 86 } |
| 87 </if>""", """ |
70 - Alphabetize properties and list vendor specific (i.e. -webkit) above standard. | 88 - Alphabetize properties and list vendor specific (i.e. -webkit) above standard. |
71 display: block; | 89 display: block; |
72 color: red;""") | 90 color: red;""") |
73 | 91 |
74 def testCssAlphaWithNonStandard(self): | 92 def testCssAlphaWithNonStandard(self): |
75 self.VerifyContentsProducesOutput(""" | 93 self.VerifyContentsProducesOutput(""" |
76 div { | 94 div { |
77 /* A hopefully safely ignored comment and @media statement. /**/ | 95 /* A hopefully safely ignored comment and @media statement. /**/ |
78 color: red; | 96 color: red; |
79 -webkit-margin-start: 5px; | 97 -webkit-margin-start: 5px; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 background-position-x: 0em; | 280 background-position-x: 0em; |
263 background-position-y: 0ex; | 281 background-position-y: 0ex; |
264 border-width: 0em; | 282 border-width: 0em; |
265 border-width: 0mm; | 283 border-width: 0mm; |
266 height: 0cm; | 284 height: 0cm; |
267 width: 0in; | 285 width: 0in; |
268 """) | 286 """) |
269 | 287 |
270 if __name__ == '__main__': | 288 if __name__ == '__main__': |
271 unittest.main() | 289 unittest.main() |
OLD | NEW |