Refine optimize page log pattern

- Add timestamp and prefix string
 - Chagne Action.MANUAL to LEAVE for better readability
 screenshot: https://screenshot.googleplex.com/ALTvMaPWVEq8y7c.png

Bug: 192523697
Test: make SettingsRoboTests
Change-Id: I69d1beceb98444d823f6ffc3a015cf61a7d7a66d
This commit is contained in:
Wesley Wang
2023-05-10 17:34:44 +08:00
parent f5a3485300
commit 1f78ebd8aa
4 changed files with 13 additions and 7 deletions

View File

@@ -57,17 +57,18 @@ public final class BatteryHistoricalLogUtilTest {
BatteryHistoricalLogUtil.writeLog(mContext, Action.APPLY, "pkg1", "logs");
BatteryHistoricalLogUtil.printBatteryOptimizeHistoricalLog(mContext, mTestPrintWriter);
assertThat(mTestStringWriter.toString()).contains("pkg1\tAction:APPLY\tEvent:logs");
assertThat(mTestStringWriter.toString()).contains(
"pkg1\tAction:APPLY\tEvent:logs\tTimestamp:");
}
@Test
public void writeLog_multipleLogs_withCorrectCounts() {
for (int i = 0; i < BatteryHistoricalLogUtil.MAX_ENTRIES; i++) {
BatteryHistoricalLogUtil.writeLog(mContext, Action.MANUAL, "pkg" + i, "logs");
BatteryHistoricalLogUtil.writeLog(mContext, Action.LEAVE, "pkg" + i, "logs");
}
BatteryHistoricalLogUtil.printBatteryOptimizeHistoricalLog(mContext, mTestPrintWriter);
assertThat(mTestStringWriter.toString().split("MANUAL").length).isEqualTo(41);
assertThat(mTestStringWriter.toString().split("LEAVE").length).isEqualTo(41);
}
@Test