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

Commit b4a6245d authored by Raff Tsai's avatar Raff Tsai Committed by Android (Google) Code Review
Browse files

Merge "Fix testcase error"

parents 505ae874 3119f8d4
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import com.android.settings.slices.SliceBackgroundWorker;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
@@ -82,7 +81,6 @@ public class BatteryFixSliceTest {
    }

    @Test
    @Ignore
    public void updateBatteryTipAvailabilityCache_hasImportantTip_shouldReturnTrue() {
        final List<BatteryTip> tips = new ArrayList<>();
        tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false, ""));
@@ -108,7 +106,6 @@ public class BatteryFixSliceTest {
    }

    @Test
    @Ignore
    @Config(shadows = {
            BatteryFixSliceTest.ShadowEarlyWarningTip.class,
            BatteryFixSliceTest.ShadowSliceBackgroundWorker.class
+14 −0
Original line number Diff line number Diff line
@@ -16,16 +16,21 @@

package com.android.settings.testutils.shadow;

import android.util.Log;

import com.android.settingslib.utils.ThreadUtils;

import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.Resetter;

import java.util.concurrent.Callable;

@Implements(ThreadUtils.class)
public class ShadowThreadUtils {

    private static boolean sIsMainThread = true;
    private static final String TAG = "ShadowThreadUtils";

    @Resetter
    public static void reset() {
@@ -37,6 +42,15 @@ public class ShadowThreadUtils {
        runnable.run();
    }

    @Implementation
    protected static void postOnBackgroundThread(Callable callable) {
        try {
            callable.call();
        } catch (Exception e) {
            Log.e(TAG, e.getMessage(), e);
        }
    }

    @Implementation
    protected static void postOnMainThread(Runnable runnable) {
        runnable.run();