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

Commit 01623534 authored by Eduard Dumitrescul's avatar Eduard Dumitrescul
Browse files

Added tests for MostRecent#isPolicyApplied()

Bug: 285532044

Test: atest ResolutionMechanismTest

Flag: TEST_ONLY
Change-Id: I3ed2620075c57f4599530e6606b21454d877291b
parent 52f97558
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
@@ -225,6 +225,24 @@ class ResolutionMechanismTest {
        }
    }

    @Test
    fun isPolicyApplied_mostRecent_sameValues_returnsTrue() {
        val resolutionMechanism = MostRecent<Int>()

        assertTrue {
            resolutionMechanism.isPolicyApplied(INT_POLICY_A, INT_POLICY_A)
        }
    }

    @Test
    fun isPolicyApplied_mostRecent_differentValues_returnsFalse() {
        val resolutionMechanism = MostRecent<Int>()

        assertFalse {
            resolutionMechanism.isPolicyApplied(INT_POLICY_A, INT_POLICY_AB)
        }
    }

    companion object {
        private const val SYSTEM_USER_ID = UserHandle.USER_SYSTEM
        private val SYSTEM_ADMIN = EnforcingAdmin.createSystemEnforcingAdmin("system_entity")
@@ -239,9 +257,9 @@ class ResolutionMechanismTest {
                SYSTEM_USER_ID,
            )

        private val INT_POLICY_A = IntegerPolicyValue(1 shl 7)
        private val INT_POLICY_B = IntegerPolicyValue(1 shl 8)
        private val INT_POLICY_C = IntegerPolicyValue(1 shl 9)
        private val INT_POLICY_AB = IntegerPolicyValue((1 shl 7) or (1 shl 8))
        private val INT_POLICY_A: PolicyValue<Int> = IntegerPolicyValue(1 shl 7)
        private val INT_POLICY_B: PolicyValue<Int> = IntegerPolicyValue(1 shl 8)
        private val INT_POLICY_C: PolicyValue<Int> = IntegerPolicyValue(1 shl 9)
        private val INT_POLICY_AB: PolicyValue<Int> = IntegerPolicyValue((1 shl 7) or (1 shl 8))
    }
}