ResultDBUtil
public
final
class
ResultDBUtil
extends Object
| java.lang.Object | |
| ↳ | com.android.tradefed.result.resultdb.ResultDBUtil |
ResultDB 報告工具的公用程式類別。
摘要
公用建構函式 | |
|---|---|
ResultDBUtil()
|
|
公用方法 | |
|---|---|
static
String
|
bytesToHex(byte[] bytes)
將位元組陣列轉換為十六進位字串。 |
static
String
|
makeValidKey(String key)
確認金鑰適用於 ResultDB。 |
static
String
|
testSkipReasonToSummaryHtml(SkipReason reason, String skipReasonType)
將測試略過原因轉換為摘要 HTML 字串。 |
static
TestIdentifier
|
toTestIdentifier(String moduleName, Variant moduleVariant, TestDescription testDescription)
將 TestDescription 轉換為 TestIdentifier。 |
static
String
|
truncateString(String input, int maxBytes)
Truncates the string to the given max bytes, avoiding breaking up a multi-byte character. |
公用建構函式
ResultDBUtil
public ResultDBUtil ()
公用方法
bytesToHex
public static String bytesToHex (byte[] bytes)
將位元組陣列轉換為十六進位字串。
| 參數 | |
|---|---|
bytes |
byte |
| 傳回 | |
|---|---|
String |
|
makeValidKey
public static String makeValidKey (String key)
確認金鑰適用於 ResultDB。
索引鍵必須符合規則運算式:^[a-z][a-z0-9_]*(/[a-z][a-z0-9_]*)*$
| 參數 | |
|---|---|
key |
String |
| 傳回 | |
|---|---|
String |
|
testSkipReasonToSummaryHtml
public static String testSkipReasonToSummaryHtml (SkipReason reason, String skipReasonType)
將測試略過原因轉換為摘要 HTML 字串。ResultDB 目前還沒有「略過」原因欄位,我們暫時將這些原因放在摘要 HTML 欄位和測試構件中。傳回的字串長度可能會超過摘要 HTML 欄位限制,因此呼叫端應視需要截斷字串。
| 參數 | |
|---|---|
reason |
SkipReason |
skipReasonType |
String |
| 傳回 | |
|---|---|
String |
|
toTestIdentifier
public static TestIdentifier toTestIdentifier (String moduleName,
Variant moduleVariant,
TestDescription testDescription)將 TestDescription 轉換為 TestIdentifier。
| 參數 | |
|---|---|
moduleName |
String:模組名稱 |
moduleVariant |
Variant:模組變體 |
testDescription |
TestDescription:測試說明 |
| 傳回 | |
|---|---|
TestIdentifier |
ResultDB 測試 ID。這個測試 ID 不保證有效 (即 ResultDB 可能會拒絕,並傳回 invalid_argument 錯誤)。這是因為 ResultDB 對測試 ID 的要求較嚴格,例如欄位長度和字元集。 |
truncateString
public static String truncateString (String input,
int maxBytes)將字串截斷為指定位元組數上限,避免截斷多位元組字元。
| 參數 | |
|---|---|
input |
String:要截斷的字串 |
maxBytes |
int:截斷的位元組數上限 (以 UTF-8 編碼) |
| 傳回 | |
|---|---|
String |
截斷的字串 |