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

Side by Side Diff: PRESUBMIT_test.py

Issue 966703003: Add PRESUBMIT tests for _CheckUserActionUpdate function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | PRESUBMIT_test_mocks.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 import glob 6 import glob
7 import json 7 import json
8 import os 8 import os
9 import re 9 import re
10 import subprocess 10 import subprocess
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 'win_rel_naclmore', 768 'win_rel_naclmore',
769 ], 769 ],
770 } 770 }
771 for master, bots in bots.iteritems(): 771 for master, bots in bots.iteritems():
772 for bot in bots: 772 for bot in bots:
773 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), 773 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot),
774 'bot=%s: expected %s, computed %s' % ( 774 'bot=%s: expected %s, computed %s' % (
775 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) 775 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot)))
776 776
777 777
778 class UserMetricsActionTest(unittest.TestCase):
779 def testUserMetricsActionInActions(self):
780 input_api = MockInputApi()
781 file_with_user_action = 'file_with_user_action.cc'
782 contents_with_user_action = [
783 'base::UserMetricsAction("AboutChrome")'
784 ]
785
786 input_api.files = [MockFile(file_with_user_action,
787 contents_with_user_action)]
788
789 self.assertEqual(
790 [], PRESUBMIT._CheckUserActionUpdate(input_api, MockOutputApi()))
791
792
793 def testUserMetricsActionNotAddedToActions(self):
794 input_api = MockInputApi()
795 file_with_user_action = 'file_with_user_action.cc'
796 contents_with_user_action = [
797 'base::UserMetricsAction("NotInActionsXml")'
798 ]
799
800 input_api.files = [MockFile(file_with_user_action,
801 contents_with_user_action)]
802
803 output = PRESUBMIT._CheckUserActionUpdate(input_api, MockOutputApi())
804 self.assertEqual(
805 ('File %s line %d: %s is missing in '
806 'tools/metrics/actions/actions.xml. Please run '
807 'tools/metrics/actions/extract_actions.py to update.'
808 % (file_with_user_action, 1, 'NotInActionsXml')),
809 output[0].message)
810
811
778 if __name__ == '__main__': 812 if __name__ == '__main__':
779 unittest.main() 813 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | PRESUBMIT_test_mocks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698