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 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 Loading... |
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() |
OLD | NEW |