Index: PRESUBMIT_test.py |
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py |
index ad391d3cbcfe49dcc0f4114b122fda03842f50c5..8b642c4efb5039f3c7972a40c5b9dbe680249d56 100755 |
--- a/PRESUBMIT_test.py |
+++ b/PRESUBMIT_test.py |
@@ -775,5 +775,39 @@ class TryServerMasterTest(unittest.TestCase): |
bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) |
+class UserMetricsActionTest(unittest.TestCase): |
+ def testUserMetricsActionInActions(self): |
+ input_api = MockInputApi() |
+ file_with_user_action = 'file_with_user_action.cc' |
+ contents_with_user_action = [ |
+ 'base::UserMetricsAction("AboutChrome")' |
+ ] |
+ |
+ input_api.files = [MockFile(file_with_user_action, |
+ contents_with_user_action)] |
+ |
+ self.assertEqual( |
+ [], PRESUBMIT._CheckUserActionUpdate(input_api, MockOutputApi())) |
+ |
+ |
+ def testUserMetricsActionNotAddedToActions(self): |
+ input_api = MockInputApi() |
+ file_with_user_action = 'file_with_user_action.cc' |
+ contents_with_user_action = [ |
+ 'base::UserMetricsAction("NotInActionsXml")' |
+ ] |
+ |
+ input_api.files = [MockFile(file_with_user_action, |
+ contents_with_user_action)] |
+ |
+ output = PRESUBMIT._CheckUserActionUpdate(input_api, MockOutputApi()) |
+ self.assertEqual( |
+ ('File %s line %d: %s is missing in ' |
+ 'tools/metrics/actions/actions.xml. Please run ' |
+ 'tools/metrics/actions/extract_actions.py to update.' |
+ % (file_with_user_action, 1, 'NotInActionsXml')), |
+ output[0].message) |
+ |
+ |
if __name__ == '__main__': |
unittest.main() |