InstrumentationProtoResultParser
public
class
InstrumentationProtoResultParser
extends Object
implements
IInstrumentationResultParser
java.lang.Object | |
↳ | com.android.tradefed.result.ddmlib.InstrumentationProtoResultParser |
Parses the 'protoStd output mode' results of an instrumentation test run from shell and informs a ITestRunListener of the results.
Am instrument command with "-m" option outputs test execution status in binary protobuf format
incrementally. The output protobuf message is InstrumentationData.Session
, which has two
fields: 1) a repeated field of InstrumentationData.TestStatus
, 2) InstrumentationData.SessionStatus
. The am instrument command outputs test status message
before/after each test execution. addOutput(byte, int, int)
is invoked with a data
argument
which is a serialized bytes of TestStatus
(es). When all tests are done, the command
outputs SessionStatus
at last.
See https://cs.android.com/android/platform/superproject/+/master:frameworks/base/cmds/am/proto/instrumentation_data.proto for a complete protobuf definition.
InstrumentationProtoResultParser
is a state-machine and states are defined in ERROR(InstrumentationProtoResultParserState/com.android.tradefed.result.ddmlib.InstrumentationProtoResultParser.InstrumentationProtoResultParserState InstrumentationProtoResultParserState)
. The state begins with ERROR(/com.android.tradefed.result.ddmlib.InstrumentationProtoResultParser.InstrumentationProtoResultParserState#NOT_STARTED)
. When it sees a first test case status, it
moves to ERROR(InstrumentationProtoResultParserState.RUNNING/com.android.tradefed.result.ddmlib.InstrumentationProtoResultParser.InstrumentationProtoResultParserState#RUNNING InstrumentationProtoResultParserState.RUNNING)
. The state changes to ERROR(/com.android.tradefed.result.ddmlib.InstrumentationProtoResultParser.InstrumentationProtoResultParserState#FINISHED)
if all tests are done or ERROR(/com.android.tradefed.result.ddmlib.InstrumentationProtoResultParser.InstrumentationProtoResultParserState#CANCELLED)
if it is requested by calling cancel()
.
Every time a new test status is available, it will be informed to the registered listeners.
Summary
Public constructors | |
---|---|
InstrumentationProtoResultParser(String runName,
Constructs |
Public methods | |
---|---|
void
|
addOutput(byte[] data, int offset, int length)
This method is called every time some new data is available. |
void
|
cancel()
|
void
|
flush()
|
void
|
handleTestRunFailed(String errorMsg)
|
boolean
|
isCancelled()
|
Public constructors
InstrumentationProtoResultParser
public InstrumentationProtoResultParser (String runName,listeners)
Constructs InstrumentationProtoResultParser
.
Parameters | |
---|---|
runName |
String : the test run name to provide to ITestRunListener.testRunStarted |
listeners |
: informed of test results as the tests are executing |
Public methods
addOutput
public void addOutput (byte[] data, int offset, int length)
This method is called every time some new data is available.
Parameters | |
---|---|
data |
byte : a serialized data of InstrumentationData.Session message. If data
is an incomplete chunk, they are added into an internal buffer and will be processed in
the next addOutput(byte, int, int) call. |
offset |
int : an offset of the new data stored in data |
length |
int : bytes of a new data in data to be processed. |
cancel
public void cancel ()
flush
public void flush ()
handleTestRunFailed
public void handleTestRunFailed (String errorMsg)
Parameters | |
---|---|
errorMsg |
String |
isCancelled
public boolean isCancelled ()
Returns | |
---|---|
boolean |