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

Unified Diff: tools/metrics/actions/extract_actions_test.py

Issue 848453002: Improve script to find user actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address more comments. Created 5 years, 11 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 | « tools/metrics/actions/extract_actions.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/metrics/actions/extract_actions_test.py
diff --git a/tools/metrics/actions/extract_actions_test.py b/tools/metrics/actions/extract_actions_test.py
index a5cfd387717a1b2498ebdc099c991e5e0d8611be..2e68ff7379e4aa08ad28d593065d698059598b65 100755
--- a/tools/metrics/actions/extract_actions_test.py
+++ b/tools/metrics/actions/extract_actions_test.py
@@ -194,6 +194,38 @@ class ActionXmlTest(unittest.TestCase):
comment=COMMENT)
self.assertEqual(COMMENT_EXPECTED_XML, xml_result)
+ def testUserMetricsActionSpanningTwoLines(self):
+ code = 'base::UserMetricsAction(\n"Foo.Bar"));'
+ finder = extract_actions.ActionNameFinder('dummy', code)
+ self.assertEqual('Foo.Bar', finder.FindNextAction())
+ self.assertFalse(finder.FindNextAction())
+
+ def testUserMetricsActionAsAParam(self):
+ code = 'base::UserMetricsAction("Test.Foo"), "Test.Bar");'
+ finder = extract_actions.ActionNameFinder('dummy', code)
+ self.assertEqual('Test.Foo', finder.FindNextAction())
+ self.assertFalse(finder.FindNextAction())
+
+ def testNonLiteralUserMetricsAction(self):
+ code = 'base::UserMetricsAction(FOO)'
+ finder = extract_actions.ActionNameFinder('dummy', code)
+ with self.assertRaises(Exception):
+ finder.FindNextAction()
+
+ def testTernaryUserMetricsAction(self):
+ code = 'base::UserMetricsAction(foo ? "Foo.Bar" : "Bar.Foo"));'
+ finder = extract_actions.ActionNameFinder('dummy', code)
+ with self.assertRaises(Exception):
+ finder.FindNextAction()
+
+ def testTernaryUserMetricsActionWithNewLines(self):
+ code = """base::UserMetricsAction(
+ foo_bar ? "Bar.Foo" :
+ "Foo.Car")"""
+ finder = extract_actions.ActionNameFinder('dummy', code)
+ with self.assertRaises(extract_actions.InvalidStatementException):
+ finder.FindNextAction()
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « tools/metrics/actions/extract_actions.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698