Exemplo n.º 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()
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 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()
Exemplo n.º 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())
Exemplo n.º 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())