Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f195150 authored by Jigar Thakkar's avatar Jigar Thakkar
Browse files

Fix BatteryStatsHistoryTest for low ram devices

The test testStartNextFile() fails on low ram devices as the
default max number of files are different. This change initializes
the constants to a common value for consistency

Test: atest BatteryStatsHistoryTest

Change-Id: I6e34edb4a3b4bd02360621dfe6f202ee061c69f7
(cherry picked from commit bb61a3eed53cdd4ec53ed863b97132c0edfc3477)
parent b1c7853e
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -45,7 +45,13 @@ import org.mockito.MockitoAnnotations;
public class BatteryStatsHistoryTest {
    private static final String TAG = "BatteryStatsHistoryTest";
    private static final int MAX_HISTORY_FILES = 32;
    private final BatteryStatsImpl mBatteryStatsImpl = new MockBatteryStatsImpl();
    private static final int MAX_HISTORY_BUFFER_KB = 128;

    // Initializing max history files and buffer to the default values of non-low-ram device
    // to maintain consistency in the tests
    private final BatteryStatsImpl mBatteryStatsImpl = new MockBatteryStatsImpl()
            .setMaxHistoryFiles(MAX_HISTORY_FILES)
            .setMaxHistoryBuffer(MAX_HISTORY_BUFFER_KB * 1024);
    private final Parcel mHistoryBuffer = Parcel.obtain();
    private File mSystemDir;
    private File mHistoryDir;
+13 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.net.NetworkStats;
import android.os.Handler;
import android.os.Looper;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidActiveTimeReader;
import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidClusterTimeReader;
import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidFreqTimeReader;
@@ -193,6 +194,18 @@ public class MockBatteryStatsImpl extends BatteryStatsImpl {
        return this;
    }

    @GuardedBy("this")
    public MockBatteryStatsImpl setMaxHistoryFiles(int maxHistoryFiles) {
        mConstants.MAX_HISTORY_FILES = maxHistoryFiles;
        return this;
    }

    @GuardedBy("this")
    public MockBatteryStatsImpl setMaxHistoryBuffer(int maxHistoryBuffer) {
        mConstants.MAX_HISTORY_BUFFER = maxHistoryBuffer;
        return this;
    }

    public int getAndClearExternalStatsSyncFlags() {
        final int flags = mExternalStatsSync.flags;
        mExternalStatsSync.flags = 0;