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

Commit 34329941 authored by William Xiao's avatar William Xiao
Browse files

Fix DreamServiceTest not properly setting flag values

EnableFlags annotation needs the rule to actually work. Also removed
flag enablement from testRedirect as it does not depend on the
flag state.

Test: atest DreamServiceTest
Bug: N/A, drive-by test fix
Flag: NONE test fix
Change-Id: Iec5933e6cfc64bb0bff98177b3ea523282d0d6fe
parent 626cf178
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -14,11 +14,12 @@ android_test {

    static_libs: [
        "androidx.test.ext.truth",
        "flag-junit",
        "frameworks-base-testutils",
        "mockito-target-minus-junit4",
        "services.core",
        "mockingservicestests-utils-mockito",
        "mockito-target-minus-junit4",
        "platform-test-annotations",
        "services.core",
        "servicestests-utils",
        "testables",
    ],
+6 −2
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.content.pm.ServiceInfo;
import android.content.res.TypedArray;
import android.os.Looper;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.service.dreams.DreamService;
import android.service.dreams.Flags;
import android.service.dreams.IDreamOverlayCallback;
@@ -46,6 +47,7 @@ import androidx.test.runner.AndroidJUnit4;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
@@ -53,6 +55,9 @@ import org.mockito.Mockito;
@SmallTest
@RunWith(AndroidJUnit4.class)
public class DreamServiceTest {
    @Rule
    public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();

    private static final String TEST_PACKAGE_NAME = "com.android.frameworks.dreamservicetests";

    private TestableLooper mTestableLooper;
@@ -191,7 +196,6 @@ public class DreamServiceTest {
    }

    @Test
    @EnableFlags(Flags.FLAG_DREAM_WAKE_REDIRECT)
    public void testRedirect() throws Exception {
        TestDreamEnvironment environment = new TestDreamEnvironment.Builder(mTestableLooper)
                .setDreamOverlayPresent(true)
@@ -248,7 +252,7 @@ public class DreamServiceTest {
        environment.comeToFront();
        mTestableLooper.processAllMessages();

        // Overlay client receives call.
        // Overlay client does not receives call.
        verify(environment.getDreamOverlayClient(), never()).comeToFront();
    }
}