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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | PRESUBMIT_test_mocks.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« 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