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
2 files changed