ShardMainResultForwarder

public class ShardMainResultForwarder
extends ResultForwarder implements ILogSaverListener

java.lang.Object
com.android.tradefed.result.ResultForwarder
com.android.tradefed.invoker.ShardMainResultForwarder


一個ResultForwarder ,它結合了分片測試調用的結果。它僅在所有分片調用完成後才向偵聽器報告調用完成。

這個類不是線程安全的。預計客戶端在發送測試結果時會鎖定該類,以防止調用回調被亂序調用。

概括

公共構造函數

ShardMainResultForwarder ( listeners, int expectedShards) ShardMainResultForwarder ( listeners, int expectedShards)

創建一個ShardMainResultForwarder

公共方法

getListeners ()

獲取聽眾列表。

void invocationEnded (long elapsedTime)

報告調用已終止,無論是成功終止還是由於某些錯誤情況。

void invocationEnded (long elapsedTime, IInvocationContext context)

更詳細的回調來區分哪個分片完成了。

void invocationFailed ( FailureDescription failure)

報告由於某些錯誤情況導致的不完整調用。

void invocationFailed (Throwable cause)

報告由於某些錯誤情況導致的不完整調用。

void invocationStarted ( IInvocationContext context)

報告測試調用的開始。

void logAssociation (String dataName, LogFile logFile)

在某些情況下,日誌必須與測試用例強關聯,但有機會這樣做就直接testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile)回調是不可能的。

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

只轉發測試日誌,而不是先保存日誌。

void testLogSaved (String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)

保存測試日誌時調用。

公共構造函數

ShardMainResultForwarder

public ShardMainResultForwarder ( listeners, 
                int expectedShards)

創建一個ShardMainResultForwarder

參數
listeners : ITestInvocationListener列表,當所有分片完成時將結果轉發到

expectedShards int : 分片數量

公共方法

獲取監聽器

public  getListeners ()

獲取聽眾列表。僅供子類使用。

退貨
ITestInvocationListener的列表。

調用結束

public void invocationEnded (long elapsedTime)

報告調用已終止,無論是成功終止還是由於某些錯誤情況。

將由 TradeFederation 框架自動調用。

參數
elapsedTime long :調用經過的時間(以毫秒為單位)

調用結束

public void invocationEnded (long elapsedTime, 
                IInvocationContext context)

更詳細的回調來區分哪個分片完成了。

參數
elapsedTime long

context IInvocationContext

調用失敗

public void invocationFailed (FailureDescription failure)

報告由於某些錯誤情況導致的不完整調用。

將由 TradeFederation 框架自動調用。

參數
failure FailureDescription :描述失敗原因的FailureDescription

調用失敗

public void invocationFailed (Throwable cause)

報告由於某些錯誤情況導致的不完整調用。

將由 TradeFederation 框架自動調用。

參數
cause Throwable : 失敗的ERROR(/Throwable)原因

調用開始

public void invocationStarted (IInvocationContext context)

報告測試調用的開始。

將由 TradeFederation 框架自動調用。記者需要覆蓋此方法以支持多設備報告。

參數
context IInvocationContext :有關調用的信息

日誌關聯

public void logAssociation (String dataName, 
                LogFile logFile)

在某些情況下,日誌必須與測試用例強關聯,但有機會這樣做就直接testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile)回調是不可能的。因此,此回調允許顯式提供強關聯。

參數
dataName String :數據的名稱

logFile LogFile :之前記錄的LogFile ,應該與測試用例相關聯。

測試日誌轉發

public void testLogForward (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream)

只轉發測試日誌,而不是先保存日誌。

參數
dataName String

dataType LogDataType

dataStream InputStreamSource

測試日誌已保存

public void testLogSaved (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream, 
                LogFile logFile)

保存測試日誌時調用。

應該用來代替ITestInvocationListener#testLog(String, LogDataType, InputStreamSource)

參數
dataName String :數據的ERROR(/String)描述性名稱。例如“device_logcat”。注意 dataName 每次調用可能不是唯一的。即實現者必須能夠處理具有相同數據名的多個調用

dataType LogDataType :數據的LogDataType

dataStream InputStreamSource :數據的InputStreamSource 。實施者應調用 createInputStream 開始讀取數據,並確保在完成後關閉生成的 InputStream。

logFile LogFile :包含已保存文件的元數據的LogFile