Merge "Fix BatteryStatsImplTest." into sc-dev am: 4162c032bf

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15291010

Change-Id: Id5ffe3ff3b7b44299955b8b8c9cb322519688021
This commit is contained in:
Dmitri Plotnikov
2021-07-16 02:04:04 +00:00
committed by Automerger Merge Worker
3 changed files with 9 additions and 4 deletions

View File

@@ -1106,8 +1106,9 @@ public class BatteryStatsImpl extends BatteryStats {
@VisibleForTesting @VisibleForTesting
protected PowerProfile mPowerProfile; protected PowerProfile mPowerProfile;
@VisibleForTesting
@GuardedBy("this") @GuardedBy("this")
final Constants mConstants; protected final Constants mConstants;
/* /*
* Holds a SamplingTimer associated with each Resource Power Manager state and voter, * Holds a SamplingTimer associated with each Resource Power Manager state and voter,

View File

@@ -69,11 +69,11 @@ public class BatteryStatsImplTest {
when(mKernelSingleUidTimeReader.singleUidCpuTimesAvailable()).thenReturn(true); when(mKernelSingleUidTimeReader.singleUidCpuTimesAvailable()).thenReturn(true);
mBatteryStatsImpl = new MockBatteryStatsImpl() mBatteryStatsImpl = new MockBatteryStatsImpl()
.setKernelCpuUidFreqTimeReader(mKernelUidCpuFreqTimeReader) .setKernelCpuUidFreqTimeReader(mKernelUidCpuFreqTimeReader)
.setKernelSingleUidTimeReader(mKernelSingleUidTimeReader); .setKernelSingleUidTimeReader(mKernelSingleUidTimeReader)
.setTrackingCpuByProcStateEnabled(true);
} }
@Test @Test
@SkipPresubmit("b/180015146")
public void testUpdateProcStateCpuTimes() { public void testUpdateProcStateCpuTimes() {
mBatteryStatsImpl.setOnBatteryInternal(true); mBatteryStatsImpl.setOnBatteryInternal(true);
mBatteryStatsImpl.updateTimeBasesLocked(false, Display.STATE_ON, 0, 0); mBatteryStatsImpl.updateTimeBasesLocked(false, Display.STATE_ON, 0, 0);
@@ -231,7 +231,6 @@ public class BatteryStatsImplTest {
} }
@Test @Test
@SkipPresubmit("b/180015146")
public void testCopyFromAllUidsCpuTimes() { public void testCopyFromAllUidsCpuTimes() {
mBatteryStatsImpl.setOnBatteryInternal(false); mBatteryStatsImpl.setOnBatteryInternal(false);
mBatteryStatsImpl.updateTimeBasesLocked(false, Display.STATE_ON, 0, 0); mBatteryStatsImpl.updateTimeBasesLocked(false, Display.STATE_ON, 0, 0);

View File

@@ -174,6 +174,11 @@ public class MockBatteryStatsImpl extends BatteryStatsImpl {
return this; return this;
} }
public MockBatteryStatsImpl setTrackingCpuByProcStateEnabled(boolean enabled) {
mConstants.TRACK_CPU_TIMES_BY_PROC_STATE = enabled;
return this;
}
public SparseIntArray getPendingUids() { public SparseIntArray getPendingUids() {
return mPendingUids; return mPendingUids;
} }