示例#1
0
  def test_context_with_api_usages(self):
    """Tests a context with some API usages is highlighted."""
    context = """chrome.power.requestKeepAwake();
chrome.app.runtime.onLaunched.addListener(makeWindow);
notAChromeAppCall();"""

    highlighted = report.highlight_relevant_line(context, 0, self.apis)
    self.assertEqual(highlighted,
      """<span class="ca-feature none">chrome.power.requestKeepAwake</span>();
chrome.app.runtime.onLaunched.addListener(makeWindow);
notAChromeAppCall();""")

    highlighted = report.highlight_relevant_line(context, 1, self.apis)
    self.assertEqual(highlighted,
      """chrome.power.requestKeepAwake();
<span class="ca-feature none">chrome.app.runtime.onLaunched.addListener</span>\
(makeWindow);\nnotAChromeAppCall();""")
示例#2
0
  def test_context_with_no_api_usages(self):
    """Tests a context with no API usages is not highlighted."""
    context = """// hello world
javascript();
var fun = function() {
  anotherCall();
}"""
    highlighted = report.highlight_relevant_line(context, 2, self.apis)
    self.assertEqual(highlighted, context)
示例#3
0
    def test_context_with_api_usages(self):
        """Tests a context with some API usages is highlighted."""
        context = """chrome.power.requestKeepAwake();
chrome.app.runtime.onLaunched.addListener(makeWindow);
notAChromeAppCall();"""

        highlighted = report.highlight_relevant_line(context, 0, self.apis)
        self.assertEqual(
            highlighted,
            """<span class="ca-feature none">chrome.power.requestKeepAwake</span>();
chrome.app.runtime.onLaunched.addListener(makeWindow);
notAChromeAppCall();""")

        highlighted = report.highlight_relevant_line(context, 1, self.apis)
        self.assertEqual(
            highlighted, """chrome.power.requestKeepAwake();
<span class="ca-feature none">chrome.app.runtime.onLaunched.addListener</span>\
(makeWindow);\nnotAChromeAppCall();""")
示例#4
0
    def test_context_with_no_api_usages(self):
        """Tests a context with no API usages is not highlighted."""
        context = """// hello world
javascript();
var fun = function() {
  anotherCall();
}"""
        highlighted = report.highlight_relevant_line(context, 2, self.apis)
        self.assertEqual(highlighted, context)
示例#5
0
 def test_empty_context(self):
   """Tests that highlighting an empty context returns the empty string."""
   highlighted = report.highlight_relevant_line("", 0, self.apis)
   self.assertEqual(highlighted, '')
示例#6
0
 def test_empty_context(self):
     """Tests that highlighting an empty context returns the empty string."""
     highlighted = report.highlight_relevant_line("", 0, self.apis)
     self.assertEqual(highlighted, '')