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

Skip to content
Commit 37d64fa5 authored by Eric Biggers's avatar Eric Biggers
Browse files

LockPatternUtilsTest: use dependency injection for ILockSettings

LockPatternUtilsTest is spying on LockPatternUtils to try to inject a
mock ILockSettings.  Using "spy" is an anti-pattern, and it doesn't seem
to work properly as the following test failure occurs:

    [8/17] com.android.internal.util.LockPatternUtilsTest#isLockScreenDisabled_isSecureAndDemoUser_false: FAILED (3ms)

    STACKTRACE:
    java.lang.AssertionError
            at org.junit.Assert.fail(Assert.java:87)
            at org.junit.Assert.assertTrue(Assert.java:42)
            at org.junit.Assert.assertFalse(Assert.java:65)
            at org.junit.Assert.assertFalse(Assert.java:75)
            at com.android.internal.util.LockPatternUtilsTest.isLockScreenDisabled_isSecureAndDemoUser_false(LockPatternUtilsTest.java:148)

This CL fixes the bug by making LockPatternUtils optionally take an
ILockSettings via constructor.

Note: LockPatternUtils#getLockSettings() cannot yet be changed to
private because it actually has a caller in non-test code.

Bug: 321737173
Ignore-AOSP-First: Conflict due to security fix ag/25939141
Flag: NA
Test: atest FrameworksUtilTests:com.android.internal.util.LockPatternUtilsTest
Change-Id: I242d3bdfe62c0be5a40df6028c6d34fad8f0abe2
parent ef057fc5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment