Fix full-charge timestamp lost in battery chart graph.

Bug: 308917113
Fix: 308917113
Test: manual
Change-Id: Ie87c72a020a3b169a25df6422ea3b456b988c14d
This commit is contained in:
mxyyiyi
2023-11-02 18:43:21 +08:00
parent 1742fa2ed0
commit feaf08a9ba
2 changed files with 28 additions and 1 deletions

View File

@@ -149,4 +149,31 @@ public final class BatteryEventDaoTest {
mBatteryEventDao.clearAll();
assertThat(mBatteryEventDao.getAll()).isEmpty();
}
@Test
public void getAllAfter_filterTimestamp_returnExpectedResult() {
mBatteryEventDao.insert(BatteryEventEntity.newBuilder()
.setTimestamp(100L)
.setBatteryEventType(1)
.setBatteryLevel(66)
.build());
mBatteryEventDao.insert(BatteryEventEntity.newBuilder()
.setTimestamp(200L)
.setBatteryEventType(1)
.setBatteryLevel(88)
.build());
final Cursor cursor = mBatteryEventDao.getAllAfter(200L, List.of(1));
assertThat(cursor.getCount()).isEqualTo(1);
cursor.moveToFirst();
assertThat(cursor.getLong(cursor.getColumnIndex(KEY_TIMESTAMP)))
.isEqualTo(200L);
assertThat(cursor.getInt(cursor.getColumnIndex(KEY_BATTERY_EVENT_TYPE)))
.isEqualTo(1);
assertThat(cursor.getInt(cursor.getColumnIndex(KEY_BATTERY_LEVEL)))
.isEqualTo(88);
mBatteryEventDao.clearAll();
assertThat(mBatteryEventDao.getAll()).isEmpty();
}
}