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

Side by Side Diff: chrome/browser/test_presubmit.py

Issue 514403002: [Presubmit] Make CSS checker ignore '@' inside of strings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync. Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/web_dev_style/css_checker.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 self.input_api.re = re 448 self.input_api.re = re
449 self.mox.StubOutWithMock(self.input_api, 'AffectedSourceFiles') 449 self.mox.StubOutWithMock(self.input_api, 'AffectedSourceFiles')
450 self.input_api.AffectedFiles( 450 self.input_api.AffectedFiles(
451 include_deletes=False, file_filter=None).AndReturn([self.fake_file]) 451 include_deletes=False, file_filter=None).AndReturn([self.fake_file])
452 452
453 # Actual creations of PresubmitPromptWarning are defined in each test. 453 # Actual creations of PresubmitPromptWarning are defined in each test.
454 self.output_api = self.mox.CreateMockAnything() 454 self.output_api = self.mox.CreateMockAnything()
455 self.mox.StubOutWithMock(self.output_api, 'PresubmitPromptWarning', 455 self.mox.StubOutWithMock(self.output_api, 'PresubmitPromptWarning',
456 use_mock_anything=True) 456 use_mock_anything=True)
457 457
458 author_msg = ('Was the CSS checker useful? '
459 'Send feedback or hate mail to dbeam@chromium.org.')
460 self.output_api = self.mox.CreateMockAnything() 458 self.output_api = self.mox.CreateMockAnything()
461 self.mox.StubOutWithMock(self.output_api, 'PresubmitNotifyResult', 459 self.mox.StubOutWithMock(self.output_api, 'PresubmitNotifyResult',
462 use_mock_anything=True) 460 use_mock_anything=True)
463 self.output_api.PresubmitNotifyResult(author_msg).AndReturn(None) 461
462 def VerifyContentsIsValid(self, contents):
463 self.fake_file.NewContents().AndReturn(contents.splitlines())
464 self.mox.ReplayAll()
465 css_checker.CSSChecker(self.input_api, self.output_api).RunChecks()
464 466
465 def VerifyContentsProducesOutput(self, contents, output): 467 def VerifyContentsProducesOutput(self, contents, output):
466 self.fake_file.NewContents().AndReturn(contents.splitlines()) 468 self.fake_file.NewContents().AndReturn(contents.splitlines())
469 author_msg = ('Was the CSS checker useful? '
470 'Send feedback or hate mail to dbeam@chromium.org.')
471 self.output_api.PresubmitNotifyResult(author_msg).AndReturn(None)
467 self.output_api.PresubmitPromptWarning( 472 self.output_api.PresubmitPromptWarning(
468 self.fake_file_name + ':\n' + output.strip()).AndReturn(None) 473 self.fake_file_name + ':\n' + output.strip()).AndReturn(None)
469 self.mox.ReplayAll() 474 self.mox.ReplayAll()
470 css_checker.CSSChecker(self.input_api, self.output_api).RunChecks() 475 css_checker.CSSChecker(self.input_api, self.output_api).RunChecks()
471 476
472 def testCssAlphaWithAtBlock(self): 477 def testCssAlphaWithAtBlock(self):
473 self.VerifyContentsProducesOutput(""" 478 self.VerifyContentsProducesOutput("""
474 <include src="../shared/css/cr/ui/overlay.css"> 479 <include src="../shared/css/cr/ui/overlay.css">
475 <include src="chrome://resources/totally-cool.css" /> 480 <include src="chrome://resources/totally-cool.css" />
476 481
(...skipping 24 matching lines...) Expand all
501 opacity: 1; /* TODO(dbeam): Fix this. */ 506 opacity: 1; /* TODO(dbeam): Fix this. */
502 } 507 }
503 </if>""", """ 508 </if>""", """
504 - Alphabetize properties and list vendor specific (i.e. -webkit) above standard. 509 - Alphabetize properties and list vendor specific (i.e. -webkit) above standard.
505 display: block; 510 display: block;
506 color: red; 511 color: red;
507 512
508 z-index: 5; 513 z-index: 5;
509 color: black;""") 514 color: black;""")
510 515
516 def testCssStringWithAt(self):
517 self.VerifyContentsIsValid("""
518 #logo {
519 background-image: url('images/google_logo.png@2x');
520 }
521
522 body.alternate-logo #logo {
523 -webkit-mask-image: url('images/google_logo.png@2x');
524 background: none;
525 }
526
527 .stuff1 {
528 }
529
530 .stuff2 {
531 }
532 """)
533
511 def testCssAlphaWithNonStandard(self): 534 def testCssAlphaWithNonStandard(self):
512 self.VerifyContentsProducesOutput(""" 535 self.VerifyContentsProducesOutput("""
513 div { 536 div {
514 /* A hopefully safely ignored comment and @media statement. /**/ 537 /* A hopefully safely ignored comment and @media statement. /**/
515 color: red; 538 color: red;
516 -webkit-margin-start: 5px; 539 -webkit-margin-start: 5px;
517 }""", """ 540 }""", """
518 - Alphabetize properties and list vendor specific (i.e. -webkit) above standard. 541 - Alphabetize properties and list vendor specific (i.e. -webkit) above standard.
519 color: red; 542 color: red;
520 -webkit-margin-start: 5px;""") 543 -webkit-margin-start: 5px;""")
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 opacity: .0; 793 opacity: .0;
771 opacity: 0.0; 794 opacity: 0.0;
772 opacity: 0.; 795 opacity: 0.;
773 border-width: 0mm; 796 border-width: 0mm;
774 height: 0cm; 797 height: 0cm;
775 width: 0in; 798 width: 0in;
776 """) 799 """)
777 800
778 if __name__ == '__main__': 801 if __name__ == '__main__':
779 unittest.main() 802 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/web_dev_style/css_checker.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698