LogSaverResultForwarder

public class LogSaverResultForwarder
extends ResultForwarder implements ILogSaverListener

java.lang.Object
   ↳ com.android.tradefed.result.ResultForwarder
     ↳ com.android.tradefed.result.LogSaverResultForwarder


ResultForwarder,用於透過全域檔案儲存工具儲存記錄。

摘要

公用建構函式

LogSaverResultForwarder(ILogSaver logSaver, List<ITestInvocationListener> listeners, IConfiguration config)
LogSaverResultForwarder(ILogSaver logSaver, List<ITestInvocationListener> listeners, IConfiguration config, boolean setLogSaver)

公用方法

void invocationEnded(long elapsedTime)

回報是否因某種錯誤狀況而終止呼叫 (無論是否成功)。

void invocationStarted(IInvocationContext context)

Reports the start of the test invocation.

void logAssociation(String dataName, LogFile logFile)

在某些情況下,記錄必須與測試案例密切相關,但無法在直接 testLogSaved(String,LogDataType,InputStreamSource,LogFile) 回呼中執行這項操作。

static void logFile(List<ITestInvocationListener> listeners, ILogSaver saver, InputStreamSource source, String name, LogDataType type)

在完成前記錄最終檔案

static void reportEndHostLog(List<ITestInvocationListener> listeners, ILogSaver saver, String name)

Reports host_log from session in progress.

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

提供測試呼叫的相關記錄或偵錯資料。

此外,請使用全域 ILogSaver 儲存記錄檔,並為實作 ILogSaverListener 介面的監聽器呼叫 ILogSaverListener.testLogSaved(String,LogDataType,InputStreamSource,LogFile)

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

請直接轉寄 testLog,不要先儲存記錄。

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

測試記錄儲存完畢時呼叫。

如果 LogSaverResultForwarder 納入另一個包裝中,請確保我們將 testLogSaved 回呼轉送至其下方的事件監聽器。

void testModuleEnded()

回報模組執行作業的結束時間。

void testModuleStarted(IInvocationContext moduleContext)

回報模組的執行開始時間。

公用建構函式

LogSaverResultForwarder

public LogSaverResultForwarder (ILogSaver logSaver, 
                List<ITestInvocationListener> listeners, 
                IConfiguration config)

參數
logSaver ILogSaver

listeners List

config IConfiguration

LogSaverResultForwarder

public LogSaverResultForwarder (ILogSaver logSaver, 
                List<ITestInvocationListener> listeners, 
                IConfiguration config, 
                boolean setLogSaver)

參數
logSaver ILogSaver

listeners List

config IConfiguration

setLogSaver boolean

公用方法

invocationEnded

public void invocationEnded (long elapsedTime)

回報是否因某種錯誤情況而終止呼叫 (無論是否成功)。

TradeFederation 架構會自動呼叫。

參數
elapsedTime long:以毫秒為單位的呼叫經過時間

invocationStarted

public void invocationStarted (IInvocationContext context)

回報測試呼叫的開始時間。

TradeFederation 架構會自動呼叫這個方法。檢舉者需要覆寫這個方法,才能支援多部裝置回報。

參數
context IInvocationContext:叫用相關資訊

logAssociation

public void logAssociation (String dataName, 
                LogFile logFile)

在某些情況下,記錄必須與測試案例密切相關,但無法在直接 testLogSaved(String,LogDataType,InputStreamSource,LogFile) 回呼中執行此操作。因此,這個回呼可明確提供強關聯。

參數
dataName String:資料名稱

logFile LogFile:先前記錄的 LogFile,應與測試案例建立關聯。

logFile

public static void logFile (List<ITestInvocationListener> listeners, 
                ILogSaver saver, 
                InputStreamSource source, 
                String name, 
                LogDataType type)

在完成前記錄最終檔案

參數
listeners List

saver ILogSaver

source InputStreamSource

name String

type LogDataType

reportEndHostLog

public static void reportEndHostLog (List<ITestInvocationListener> listeners, 
                ILogSaver saver, 
                String name)

從進行中的工作階段回報 host_log。

參數
listeners List

saver ILogSaver

name String

testLog

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

提供測試呼叫的相關記錄或偵錯資料。

必須在 ERROR(ITestInvocationListener.invocationFailed(Throwable)/ITestInvocationListener#invocationFailed(java.lang.Throwable) ITestInvocationListener.invocationFailed(Throwable))ERROR(/ITestInvocationListener#invocationEnded(long)) 之前呼叫

TradeFederation 架構會自動呼叫這個方法,提供主機記錄,以及裝置 logcat (如適用)。

此外,請使用全域 ILogSaver 儲存記錄檔,並為實作 ILogSaverListener 介面的事件監聽器呼叫 ILogSaverListener.testLogSaved(String,LogDataType,InputStreamSource,LogFile)

參數
dataName String:資料的String說明名稱,例如「device_logcat」。注意:dataName 在每次呼叫時可能不具唯一性,也就是說,實作者必須能夠處理具有相同 dataName 的多項呼叫。

dataType LogDataType:資料的 LogDataType

dataStream InputStreamSource:資料的 InputStreamSource。實作者應呼叫 createInputStream 開始讀取資料,並確保在完成時關閉產生的 InputStream。呼叫端應確保資料來源持續存在且可存取,直到 testLog 方法完成為止。

testLogForward

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

直接轉寄 testLog,不必先儲存記錄。

參數
dataName String

dataType LogDataType

dataStream InputStreamSource

testLogSaved

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

測試記錄儲存完畢時呼叫。

應取代 ITestInvocationListener.testLog(String,LogDataType,InputStreamSource) 使用。

如果 LogSaverResultForwarder 包裝在另一個函式中,請務必將 testLogSaved 回呼轉送至其下方的監聽器。

參數
dataName String:資料的String說明名稱,例如「device_logcat」。注意:dataName 在每次呼叫時可能不具唯一性,也就是說,實作者必須能夠處理具有相同 dataName 的多項呼叫。

dataType LogDataType:資料的 LogDataType

dataStream InputStreamSource:資料的 InputStreamSource。實作者應呼叫 createInputStream 開始讀取資料,並確保在完成時關閉產生的 InputStream。

logFile LogFile:包含已儲存檔案中繼資料的 LogFile

testModuleEnded

public void testModuleEnded ()

回報模組執行作業的結束時間。

testModuleStarted

public void testModuleStarted (IInvocationContext moduleContext)

回報模組的執行開始時間。這個回呼與 testModuleEnded() 相關聯,且在序列中為選用項目。只有在使用模組的執行期間,才會使用這個標記:以套件為基礎的執行器。

參數
moduleContext IInvocationContext:模組的 IInvocationContext