def test_trace_error_stop_tracing(self):
     setup_battor_test(StartShell_error=False,
                       StartTracing_error=False,
                       StopTracing_error=True,
                       CollectTraceData_error=False)
     agent = battor_trace_agent.BattOrTraceAgent()
     agent.StartAgentTracing(OPTIONS, CATEGORIES)
     self.assertRaises(RuntimeError, agent.StopAgentTracing)
 def test_trace_double_start(self):
     setup_battor_test(StartShell_error=False,
                       StartTracing_error=False,
                       StopTracing_error=False,
                       CollectTraceData_error=False)
     agent = battor_trace_agent.BattOrTraceAgent()
     agent.StartAgentTracing(OPTIONS, CATEGORIES)
     self.assertRaises(AssertionError,
                       lambda: agent.StartAgentTracing(OPTIONS, CATEGORIES))
 def test_trace_error_multiple_battors_no_battor_path(self):
     setup_battor_test(StartShell_error=False,
                       StartTracing_error=False,
                       StopTracing_error=False,
                       CollectTraceData_error=False,
                       battor_paths=['a', 'b'])
     agent = battor_trace_agent.BattOrTraceAgent()
     options = mock_opts('android', 'Phn2', None, None)
     with self.assertRaises(AssertionError):
         agent.StartAgentTracing(options, CATEGORIES)
 def test_trace_complete(self):
     setup_battor_test(StartShell_error=False,
                       StartTracing_error=False,
                       StopTracing_error=False,
                       CollectTraceData_error=False)
     agent = battor_trace_agent.BattOrTraceAgent()
     agent.StartAgentTracing(OPTIONS, CATEGORIES)
     agent.StopAgentTracing()
     x = agent.GetResults()
     self.assertEqual(x.raw_data, 'traceout1\ntraceout2')