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

Commit 119342af authored by Dmitri Plotnikov's avatar Dmitri Plotnikov
Browse files

Fix flaky test, BatteryStatsHistoryIteratorTest

Bug: 202448492
Test: atest --rerun-until-failure 20 FrameworksCoreTests:BatteryStatsHistoryIteratorTest
Change-Id: If8c1c4db31fbec4859af7da2962110500f187372
parent f4d4d89a
Loading
Loading
Loading
Loading
+4 −12
Original line number Diff line number Diff line
@@ -18,15 +18,15 @@ package com.android.internal.os;

import static com.google.common.truth.Truth.assertThat;

import android.content.Context;
import android.os.BatteryManager;
import android.os.BatteryStats;
import android.os.Process;

import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import libcore.testing.io.TestIoUtils;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -43,16 +43,8 @@ public class BatteryStatsHistoryIteratorTest {

    @Before
    public void setup() {
        Context context = InstrumentationRegistry.getContext();

        File historyDir = new File(context.getDataDir(), BatteryStatsHistory.HISTORY_DIR);
        String[] files = historyDir.list();
        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                new File(historyDir, files[i]).delete();
            }
        }
        historyDir.delete();
        final File historyDir =
                TestIoUtils.createTemporaryDirectory(getClass().getSimpleName());
        mBatteryStats = new MockBatteryStatsImpl(mMockClock, historyDir);
    }