def _GenerateTestResult(self, test, instr_result_code, instr_result_bundle,
                         statuses, start_ms, duration_ms):
     results = instrumentation_test_instance.GenerateTestResults(
         instr_result_code, instr_result_bundle, statuses, start_ms,
         duration_ms)
     for r in results:
         if r.GetName() == test:
             return r
     logging.error('Could not find result for test: %s', test)
     return test_result.InstrumentationTestResult(
         test, base_test_result.ResultType.UNKNOWN, start_ms, duration_ms)
 def testGenerateJUnitTestResults_testSkipped_true(self):
   statuses = [
     (1, {
       'class': 'test.package.TestClass',
       'test': 'testMethod',
     }),
     (-3, {
       'class': 'test.package.TestClass',
       'test': 'testMethod',
     }),
   ]
   results = instrumentation_test_instance.GenerateTestResults(
       None, None, statuses, 1000, None, None)
   self.assertEqual(1, len(results))
   self.assertEqual(base_test_result.ResultType.SKIP, results[0].GetType())
 def testGenerateTestResults_testFailed(self):
   statuses = [
     (1, {
       'class': 'test.package.TestClass',
       'test': 'testMethod',
     }),
     (-2, {
       'class': 'test.package.TestClass',
       'test': 'testMethod',
     }),
   ]
   results = instrumentation_test_instance.GenerateTestResults(
       None, None, statuses, 0, 1000)
   self.assertEqual(1, len(results))
   self.assertEqual(base_test_result.ResultType.FAIL, results[0].GetType())
 def testGenerateTestResults_testUnknownException(self):
   stacktrace = 'long\nstacktrace'
   statuses = [
     (1, {
       'class': 'test.package.TestClass',
       'test': 'testMethod',
     }),
     (-1, {
       'class': 'test.package.TestClass',
       'test': 'testMethod',
       'stack': stacktrace,
     }),
   ]
   results = instrumentation_test_instance.GenerateTestResults(
       None, None, statuses, 1000, None, None)
   self.assertEqual(1, len(results))
   self.assertEqual(base_test_result.ResultType.FAIL, results[0].GetType())
   self.assertEqual(stacktrace, results[0].GetLog())
 def testGenerateTestResults_testSkipped_false(self):
   statuses = [
     (1, {
       'class': 'test.package.TestClass',
       'test': 'testMethod',
     }),
     (0, {
       'test_skipped': 'false',
     }),
     (0, {
       'class': 'test.package.TestClass',
       'test': 'testMethod',
     }),
   ]
   results = instrumentation_test_instance.GenerateTestResults(
       None, None, statuses, 0, 1000)
   self.assertEqual(1, len(results))
   self.assertEqual(base_test_result.ResultType.PASS, results[0].GetType())
 def testGenerateTestResults_noStatus(self):
     results = instrumentation_test_instance.GenerateTestResults(
         None, None, [], 0, 1000)
     self.assertEqual([], results)