InstrumentationProtoResultParser

public class InstrumentationProtoResultParser
extends Object implements IInstrumentationResultParser

java.lang.Object
   ↳ com.android.tradefed.result.ddmlib.InstrumentationProtoResultParser


Przetwarza wyniki „tryb wyjścia protoStd” testu instrumentacji uruchomionego z powłoki i informuje o nich interfejs ITestRunListener.

Polecenie am instrument z opcją „-m” wyświetla stan wykonania testu w formacie binarnym protobuf. Komunikat protobuf wyjściowy to InstrumentationData.Session, który ma 2 pola: 1) pole powtarzane InstrumentationData.TestStatus i 2) InstrumentationData.SessionStatus. Polecenie am instrument wyświetla komunikat o stanie testu przed jego wykonaniem i po jego zakończeniu. Funkcja addOutput(byte, int, int) jest wywoływana z argumentem data, który jest zserializowanymi bajtami obiektu TestStatus(es). Gdy wszystkie testy zostaną ukończone, polecenie wyświetli wartość SessionStatus.

Pełną definicję protokołu protobuf znajdziesz na stronie https://cs.android.com/android/platform/superproject/+/master:frameworks/base/cmds/am/proto/instrumentation_data.proto.

InstrumentationProtoResultParser to maszyna stanów, a stany są definiowane w ERROR(InstrumentationProtoResultParserState/com.android.tradefed.result.ddmlib.InstrumentationProtoResultParser.InstrumentationProtoResultParserState InstrumentationProtoResultParserState). Stan zaczyna się od ERROR(/com.android.tradefed.result.ddmlib.InstrumentationProtoResultParser.InstrumentationProtoResultParserState#NOT_STARTED). Gdy zobaczy stan pierwszego przypadku testowego, przechodzi do ERROR(InstrumentationProtoResultParserState.RUNNING/com.android.tradefed.result.ddmlib.InstrumentationProtoResultParser.InstrumentationProtoResultParserState#RUNNING InstrumentationProtoResultParserState.RUNNING). Stan zmienia się na ERROR(/com.android.tradefed.result.ddmlib.InstrumentationProtoResultParser.InstrumentationProtoResultParserState#FINISHED), jeśli wszystkie testy zostały wykonane, lub na ERROR(/com.android.tradefed.result.ddmlib.InstrumentationProtoResultParser.InstrumentationProtoResultParserState#CANCELLED), jeśli nastąpiło wywołanie metody cancel().

Za każdym razem, gdy będzie dostępny nowy stan testu, zarejestrowani słuchacze zostaną o tym powiadomieni.

Podsumowanie

Konstruktory publiczne

InstrumentationProtoResultParser(String runName, listeners)

Tworzy InstrumentationProtoResultParser.

Metody publiczne

void addOutput(byte[] data, int offset, int length)

Ta metoda jest wywoływana za każdym razem, gdy są dostępne nowe dane.

void cancel()
void flush()
void handleTestRunFailed(String errorMsg)
boolean isCancelled()

Konstruktory publiczne

InstrumentationProtoResultParser

public InstrumentationProtoResultParser (String runName, 
                 listeners)

Tworzy InstrumentationProtoResultParser.

Parametry
runName String: nazwa testu, który ma być przekazany do ITestRunListener.testRunStarted

listeners : informowanie o wynikach testów w trakcie ich wykonywania.

Metody publiczne

addOutput

public void addOutput (byte[] data, 
                int offset, 
                int length)

Ta metoda jest wywoływana za każdym razem, gdy są dostępne nowe dane.

Parametry
data byte: serializowane dane wiadomości InstrumentationData.Session. Jeśli data jest niepełnym fragmentem, jest dodawany do wewnętrznego bufora i przetwarzany w następnym wywołaniu funkcji addOutput(byte, int, int).

offset int: przesunięcie nowych danych zapisanych w pliku data

length int: bajty nowych danych w pliku data, które mają zostać przetworzone.

anuluj

public void cancel ()

spłukać

public void flush ()

handleTestRunFailed

public void handleTestRunFailed (String errorMsg)

Parametry
errorMsg String

isCancelled

public boolean isCancelled ()

Zwroty
boolean