CoverageMetadataCollector

public final class CoverageMetadataCollector
extends Object implements IConfigurationReceiver, ILogSaverListener

java.lang.Object
   ↳ com.google.android.tradefed.result.CoverageMetadataCollector


A ILogSaverListener which collects logged coverage measurements and generates a CoverageMetadataProto for processing by the Android Code Coverage service.

Summary

Public constructors

CoverageMetadataCollector()

Public methods

void invocationStarted(IInvocationContext context)

Reports the start of the test invocation.

void logAssociation(String unusedDataName, LogFile logFile)

In some cases, log must be strongly associated with a test cases, but the opportunity to do so on the direct testLogSaved(String,LogDataType,InputStreamSource,LogFile) callback is not possible.

void setConfiguration(IConfiguration configuration)

Injects the IConfiguration in use.

void setLogSaver(ILogSaver logSaver)

Set the ILogSaver to allow the implementor to save files.

void testLogSaved(String unusedDataName, LogDataType dataType, InputStreamSource unusedDataStream, LogFile logFile)

Called when the test log is saved.

void testModuleEnded()

Reports the end of a module run.

void testModuleStarted(IInvocationContext moduleContext)

Reports the beginning of a module running.

void testRunEnded(long elapsedTime, HashMap<String, MetricMeasurement.Metric> runMetrics)

Reports end of test run.

void testRunStarted(String runName, int testCount)

Reports the start of a test run.

Public constructors

CoverageMetadataCollector

public CoverageMetadataCollector ()

Public methods

invocationStarted

public 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

logAssociation

public void logAssociation (String unusedDataName, 
                LogFile logFile)

In some cases, log must be strongly associated with a test cases, but the opportunity to do so on the direct testLogSaved(String,LogDataType,InputStreamSource,LogFile) callback is not possible. Thus, this callback allows to provide a strong association explicitly.

Parameters
unusedDataName String: The name of the data

logFile LogFile: the LogFile that was logged before and should be associated with the test case.

setConfiguration

public void setConfiguration (IConfiguration configuration)

Injects the IConfiguration in use.

Parameters
configuration IConfiguration

setLogSaver

public void setLogSaver (ILogSaver logSaver)

Set the ILogSaver to allow the implementor to save files.

Parameters
logSaver ILogSaver: the ILogSaver

testLogSaved

public void testLogSaved (String unusedDataName, 
                LogDataType dataType, 
                InputStreamSource unusedDataStream, 
                LogFile logFile)

Called when the test log is saved.

Should be used in place of ITestInvocationListener.testLog(String,LogDataType,InputStreamSource).

Parameters
unusedDataName 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

unusedDataStream InputStreamSource: the InputStreamSource of the data. Implementers should call createInputStream to start reading the data, and ensure to close the resulting InputStream when complete.

logFile LogFile: the LogFile containing the meta data of the saved file.

testModuleEnded

public void testModuleEnded ()

Reports the end of a module run.

testModuleStarted

public void testModuleStarted (IInvocationContext moduleContext)

Reports the beginning of a module running. This callback is associated with testModuleEnded() and is optional in the sequence. It is only used during a run that uses modules: suite based runners.

Parameters
moduleContext IInvocationContext: the IInvocationContext of the module.

testRunEnded

public void testRunEnded (long elapsedTime, 
                HashMap<String, MetricMeasurement.Metric> runMetrics)

Reports end of test run. FIXME: We cannot have two Map<> interfaces with different type, so we have to use HashMap here.

Parameters
elapsedTime long: device reported elapsed time, in milliseconds

runMetrics HashMap: key-value pairs reported at the end of a test run with Metric.

testRunStarted

public void testRunStarted (String runName, 
                int testCount)

Reports the start of a test run.

Parameters
runName String: the test run name

testCount int: total number of tests in test run