BugreportCollector

public class BugreportCollector
extends Object implements ITestInvocationListener

java.lang.Object
   ↳ com.android.tradefed.result.BugreportCollector


A pass-through ITestInvocationListener that collects bugreports when configurable events occur and then calls testLog(String, LogDataType, InputStreamSource) on its children after each bugreport is collected.

Behaviors: (FIXME: finish this)

  • Capture after each if any testcases failed
  • Capture after each testcase
  • Capture after each failed testcase
  • Capture

Summary

Nested classes

enum BugreportCollector.Filter

 

enum BugreportCollector.Freq

 

enum BugreportCollector.Noun

 

class BugreportCollector.Predicate

A full predicate describing when to capture a bugreport. 

enum BugreportCollector.Relation

 

interface BugreportCollector.SubPredicate

 

Fields

public static final BugreportCollector.Predicate AFTER_FAILED_TESTCASES

A predefined predicate which fires after each failed testcase

public static final BugreportCollector.Predicate AT_START

A predefined predicate which fires as the first invocation begins

Public constructors

BugreportCollector(ITestInvocationListener listener, ITestDevice testDevice)

Public methods

void addPredicate(BugreportCollector.Predicate p)
void blockUntilIdle()

Block until the collector is not collecting any bugreports.

TestSummary getSummary()

Allows the InvocationListener to return a summary.

void invocationEnded(long elapsedTime)

Reports that the invocation has terminated, whether successfully or due to some error condition.

void invocationFailed(Throwable cause)

Reports an incomplete invocation due to some error condition.

void invocationStarted(IInvocationContext context)

Reports the start of the test invocation.

void setAsynchronous(boolean asynchronous)

Set whether bugreport collection should collect the bugreport in a different thread (asynchronous = true), or block the caller until the bugreport is captured (asynchronous = false).

void setDescriptiveName(String name)

Set the descriptive name to use when recording bugreports.

void setDeviceWaitTime(int waitTime)

Set the time (in seconds) to wait for the device to be Online before we try to capture a bugreport.

void testAssumptionFailure(TestIdentifier test, String trace)

void testEnded(TestIdentifier test, Map<String, String> testMetrics)

void testFailed(TestIdentifier test, String trace)

void testIgnored(TestIdentifier test)

void testLog(String dataName, LogDataType dataType, InputStreamSource dataStream)

Provides the associated log or debug data from the test invocation.

void testRunEnded(long elapsedTime, Map<String, String> runMetrics)

void testRunFailed(String errorMessage)

void testRunStarted(String runName, int testCount)

void testRunStopped(long elapsedTime)

void testStarted(TestIdentifier test)

Fields

AFTER_FAILED_TESTCASES

BugreportCollector.Predicate AFTER_FAILED_TESTCASES

A predefined predicate which fires after each failed testcase

AT_START

BugreportCollector.Predicate AT_START

A predefined predicate which fires as the first invocation begins

Public constructors

BugreportCollector

BugreportCollector (ITestInvocationListener listener, 
                ITestDevice testDevice)

Parameters
listener ITestInvocationListener

testDevice ITestDevice

Public methods

addPredicate

void addPredicate (BugreportCollector.Predicate p)

Parameters
p BugreportCollector.Predicate

blockUntilIdle

void blockUntilIdle ()

Block until the collector is not collecting any bugreports. If the collector isn't actively collecting a bugreport, return immediately

getSummary

TestSummary getSummary ()

Allows the InvocationListener to return a summary.

Returns
TestSummary A TestSummary summarizing the run, or null

invocationEnded

void invocationEnded (long elapsedTime)

Reports that the invocation has terminated, whether successfully or due to some error condition.

Will be automatically called by the TradeFederation framework.

Parameters
elapsedTime long: the elapsed time of the invocation in ms

invocationFailed

void invocationFailed (Throwable cause)

Reports an incomplete invocation due to some error condition.

Will be automatically called by the TradeFederation framework.

Parameters
cause Throwable: the Throwable cause of the failure

invocationStarted

void invocationStarted (IInvocationContext context)

Reports the start of the test invocation.

Will be automatically called by the TradeFederation framework. Reporters need to override this method to support multiple devices reporting.

Parameters
context IInvocationContext: information about the invocation

setAsynchronous

void setAsynchronous (boolean asynchronous)

Set whether bugreport collection should collect the bugreport in a different thread (asynchronous = true), or block the caller until the bugreport is captured (asynchronous = false).

Parameters
asynchronous boolean

setDescriptiveName

void setDescriptiveName (String name)

Set the descriptive name to use when recording bugreports. If null, BugreportCollector will fall back to the default behavior of serializing the name of the event that caused the bugreport to be collected.

Parameters
name String

setDeviceWaitTime

void setDeviceWaitTime (int waitTime)

Set the time (in seconds) to wait for the device to be Online before we try to capture a bugreport. If negative, no check will be performed. Any DeviceNotAvailableException encountered during this check will be logged and ignored.

Parameters
waitTime int

testAssumptionFailure

void testAssumptionFailure (TestIdentifier test, 
                String trace)

Parameters
test TestIdentifier

trace String

testEnded

void testEnded (TestIdentifier test, 
                Map<String, String> testMetrics)

Parameters
test TestIdentifier

testMetrics Map

testFailed

void testFailed (TestIdentifier test, 
                String trace)

Parameters
test TestIdentifier

trace String

testIgnored

void testIgnored (TestIdentifier test)

Parameters
test TestIdentifier

testLog

void testLog (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream)

Provides the associated log or debug data from the test invocation.

Must be called before invocationFailed(Throwable) or invocationEnded(long)

The TradeFederation framework will automatically call this method, providing the host log and if applicable, the device logcat.

Parameters
dataName String: a String descriptive name of the data. e.g. "device_logcat". Note dataName may not be unique per invocation. ie implementers must be able to handle multiple calls with same dataName

dataType LogDataType: the LogDataType of the data

dataStream InputStreamSource: the InputStreamSource of the data. Implementers should call createInputStream to start reading the data, and ensure to close the resulting InputStream when complete. Callers should ensure the source of the data remains present and accessible until the testLog method completes.

testRunEnded

void testRunEnded (long elapsedTime, 
                Map<String, String> runMetrics)

Parameters
elapsedTime long

runMetrics Map

testRunFailed

void testRunFailed (String errorMessage)

Parameters
errorMessage String

testRunStarted

void testRunStarted (String runName, 
                int testCount)

Parameters
runName String

testCount int

testRunStopped

void testRunStopped (long elapsedTime)

Parameters
elapsedTime long

testStarted

void testStarted (TestIdentifier test)

Parameters
test TestIdentifier