ILogSaverListener

public interface ILogSaverListener
implements ITestInvocationListener

com.android.tradefed.result.ILogSaverListener


อนุญาตให้ ITestInvocationListeners ฟังเมื่อมีการบันทึกไฟล์บันทึก

ซึ่งจะช่วยให้ ITestInvocationListener หลายรายการใช้ไฟล์บันทึกที่บันทึกไว้เดียวกันได้เมื่อสร้างรายงาน และหลีกเลี่ยงการให้ผู้ฟังแต่ละคนบันทึกไฟล์แยกกันเมื่อมีการเรียกใช้ ITestLogger.testLog(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource)

คลาสที่ใช้การติดตั้งอินเทอร์เฟซนี้ควรทราบว่าระบบจะเรียกใช้ testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile) ทุกครั้งที่มีการเรียกใช้ ITestLogger.testLog(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource)

คลาสนี้ยังส่งอินสแตนซ์ ILogSaver ส่วนกลางด้วย เพื่อให้ ITestInvocationListener สามารถบันทึกไฟล์เพิ่มเติมในตำแหน่งเดียวกันได้

สรุป

เมธอดสาธารณะ

default void logAssociation(String dataName, LogFile logFile)

ในบางกรณี บันทึกต้องเชื่อมโยงกับกรณีทดสอบอย่างแน่นแฟ้น แต่ไม่สามารถดำเนินการดังกล่าวในtestLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile) การเรียกกลับโดยตรงได้

default void setLogSaver(ILogSaver logSaver)

ตั้งค่า ILogSaver เพื่ออนุญาตให้ผู้ติดตั้งใช้งานบันทึกไฟล์

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

เรียกใช้เมื่อบันทึกบันทึกการทดสอบ

เมธอดสาธารณะ

logAssociation

public void logAssociation (String dataName, 
                LogFile logFile)

ในบางกรณี บันทึกต้องเชื่อมโยงกับกรณีทดสอบอย่างแน่นแฟ้น แต่ไม่สามารถดำเนินการดังกล่าวในtestLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile) การเรียกกลับโดยตรงได้ ดังนั้น Callback นี้จึงช่วยให้คุณเชื่อมโยงได้อย่างชัดเจน

พารามิเตอร์
dataName String: ชื่อของข้อมูล

logFile LogFile: LogFile ที่บันทึกไว้ก่อนหน้านี้และควรเชื่อมโยงกับ กรณีทดสอบ

setLogSaver

public void setLogSaver (ILogSaver logSaver)

ตั้งค่า ILogSaver เพื่ออนุญาตให้ผู้ใช้บันทึกไฟล์

พารามิเตอร์
logSaver ILogSaver: ILogSaver

testLogSaved

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

เรียกใช้เมื่อบันทึกบันทึกการทดสอบ

ควรใช้แทน ITestInvocationListener.testLog(String, LogDataType, InputStreamSource)

พารามิเตอร์
dataName String: Stringชื่อที่สื่อความหมายของข้อมูล เช่น "device_logcat" หมายเหตุ dataName อาจไม่ซ้ำกันต่อการเรียกใช้แต่ละครั้ง กล่าวคือ ผู้ใช้ต้องสามารถจัดการ การเรียกหลายครั้งที่มี dataName เดียวกันได้

dataType LogDataType: LogDataType ของข้อมูล

dataStream InputStreamSource: InputStreamSource ของข้อมูล ผู้ใช้ควรเรียกใช้ createInputStream เพื่อเริ่มอ่านข้อมูล และตรวจสอบว่าได้ปิด InputStream ที่ได้เมื่อเสร็จสิ้น

logFile LogFile: LogFileที่มีข้อมูลเมตาของไฟล์ที่บันทึกไว้