| 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 24 matching lines...) Expand all Loading... |
| 35 input_api = self.mox.CreateMockAnything() | 35 input_api = self.mox.CreateMockAnything() |
| 36 input_api.re = re | 36 input_api.re = re |
| 37 output_api = self.mox.CreateMockAnything() | 37 output_api = self.mox.CreateMockAnything() |
| 38 self.checker = resource_checker.ResourceChecker(input_api, output_api) | 38 self.checker = resource_checker.ResourceChecker(input_api, output_api) |
| 39 | 39 |
| 40 def ShouldFailIncludeCheck(self, line): | 40 def ShouldFailIncludeCheck(self, line): |
| 41 """Checks that the '</include>' checker flags |line| as a style error.""" | 41 """Checks that the '</include>' checker flags |line| as a style error.""" |
| 42 error = self.checker.IncludeCheck(1, line) | 42 error = self.checker.IncludeCheck(1, line) |
| 43 self.assertNotEqual('', error, | 43 self.assertNotEqual('', error, |
| 44 'Should be flagged as style error: ' + line) | 44 'Should be flagged as style error: ' + line) |
| 45 self.assertEqual(GetHighlight(line, error), '</include>') | 45 highlight = GetHighlight(line, error).strip() |
| 46 self.assertTrue('include' in highlight and highlight[0] == '<') |
| 46 | 47 |
| 47 def ShouldPassIncludeCheck(self, line): | 48 def ShouldPassIncludeCheck(self, line): |
| 48 """Checks that the '</include>' checker doesn't flag |line| as an error.""" | 49 """Checks that the '</include>' checker doesn't flag |line| as an error.""" |
| 49 self.assertEqual('', self.checker.IncludeCheck(1, line), | 50 self.assertEqual('', self.checker.IncludeCheck(1, line), |
| 50 'Should not be flagged as style error: ' + line) | 51 'Should not be flagged as style error: ' + line) |
| 51 | 52 |
| 52 def testIncludeFails(self): | 53 def testIncludeFails(self): |
| 53 lines = [ | 54 lines = [ |
| 54 "</include> ", | 55 "</include> ", |
| 55 " </include>", | 56 " </include>", |
| 56 " </include> ", | 57 " </include> ", |
| 58 ' <include src="blah.js" /> ', |
| 59 '<include src="blee.js"/>', |
| 57 ] | 60 ] |
| 58 for line in lines: | 61 for line in lines: |
| 59 self.ShouldFailIncludeCheck(line) | 62 self.ShouldFailIncludeCheck(line) |
| 60 | 63 |
| 61 def testIncludePasses(self): | 64 def testIncludePasses(self): |
| 62 lines = [ | 65 lines = [ |
| 63 '<include src="assert.js">', | 66 '<include src="assert.js">', |
| 64 "<include src='../../assert.js'>", | 67 "<include src='../../assert.js'>", |
| 65 "<i>include src='blah'</i>", | 68 "<i>include src='blah'</i>", |
| 66 "</i>nclude", | 69 "</i>nclude", |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 opacity: .0; | 796 opacity: .0; |
| 794 opacity: 0.0; | 797 opacity: 0.0; |
| 795 opacity: 0.; | 798 opacity: 0.; |
| 796 border-width: 0mm; | 799 border-width: 0mm; |
| 797 height: 0cm; | 800 height: 0cm; |
| 798 width: 0in; | 801 width: 0in; |
| 799 """) | 802 """) |
| 800 | 803 |
| 801 if __name__ == '__main__': | 804 if __name__ == '__main__': |
| 802 unittest.main() | 805 unittest.main() |
| OLD | NEW |