Example #1
0
 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()
Example #2
0
 def testTernaryUserMetricsActionWithNewLinesJs(self):
   code = """chrome.send('coreOptionsUserMetricsAction',
     [foo ? 'Foo.Bar' :
     'Bar.Foo']);"""
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE_JS)
   self.assertFalse(finder.FindNextAction())
Example #3
0
 def testUserMetricsActionFromFunctionJs(self):
   code = "chrome.send('coreOptionsUserMetricsAction', [getAction(param)]);"
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE_JS)
   self.assertFalse(finder.FindNextAction())
Example #4
0
 def testUserMetricsActionFromPropertyJs(self):
   code = "chrome.send('coreOptionsUserMetricsAction', [objOrArray[key]]);"
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE_JS)
   self.assertFalse(finder.FindNextAction())
Example #5
0
 def testUserMetricsActionWithMismatchedQuotes(self):
   code = "chrome.send('coreOptionsUserMetricsAction', [\"Foo.Bar']);"
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE_JS)
   self.assertFalse(finder.FindNextAction())
Example #6
0
 def testComputedUserMetricsActionJs(self):
   code = """chrome.send('coreOptionsUserMetricsAction',
     ['Foo.' + foo_bar ? 'Bar' : 'Foo']);"""
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE_JS)
   self.assertFalse(finder.FindNextAction())
Example #7
0
 def testUserMetricsActionWithExtraCharactersJs(self):
   code = """chrome.send('coreOptionsUserMetricsAction',
     ['Foo.Bar' + 1]);"""
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE_JS)
   self.assertFalse(finder.FindNextAction())
Example #8
0
 def testNonLiteralUserMetricsActionJs(self):
   code = "chrome.send('coreOptionsUserMetricsAction',\n[FOO]);"
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE_JS)
   self.assertFalse(finder.FindNextAction())
Example #9
0
 def testUserMetricsActionSpanningTwoLinesJs(self):
   code = "chrome.send('coreOptionsUserMetricsAction',\n['Foo.Bar']);"
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE_JS)
   self.assertEqual('Foo.Bar', finder.FindNextAction())
   self.assertFalse(finder.FindNextAction())
Example #10
0
 def testUserMetricsActionWithExtraWhitespace(self):
   code = """base::UserMetricsAction("Foo.Bar" )"""
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE)
   with self.assertRaises(extract_actions.InvalidStatementException):
     finder.FindNextAction()
Example #11
0
 def testTernaryUserMetricsAction(self):
   code = 'base::UserMetricsAction(foo ? "Foo.Bar" : "Bar.Foo"));'
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE)
   with self.assertRaises(Exception):
     finder.FindNextAction()
Example #12
0
 def testNonLiteralUserMetricsAction(self):
   code = 'base::UserMetricsAction(FOO)'
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE)
   with self.assertRaises(Exception):
     finder.FindNextAction()
Example #13
0
 def testUserMetricsActionAsAParam(self):
   code = 'base::UserMetricsAction("Test.Foo"), "Test.Bar");'
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE)
   self.assertEqual('Test.Foo', finder.FindNextAction())
   self.assertFalse(finder.FindNextAction())
Example #14
0
 def testUserMetricsActionSpanningTwoLines(self):
   code = 'base::UserMetricsAction(\n"Foo.Bar"));'
   finder = extract_actions.ActionNameFinder('dummy', code,
       extract_actions.USER_METRICS_ACTION_RE)
   self.assertEqual('Foo.Bar', finder.FindNextAction())
   self.assertFalse(finder.FindNextAction())