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

Commit e8e994b2 authored by Bryce Lee's avatar Bryce Lee
Browse files

Correct test logic around SecureSettings#putStringForUser/putIntForUser

This changelist updates test code to mirror production code for how
settings values are stored and retrieved. Settings written as
int/string should only be read as int/string respectively.

Test: atest FontScalingDialogDelegateTest
Test: atest StickyKeysIndicatorViewModelTest
Flag: EXEMPT bugfix
Bug: 402551650
Change-Id: Ie3cb0c6a5f986fb9d62c08ee5477ce6a810c876e
parent c74fcba8
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -83,10 +83,11 @@ class FontScalingDialogDelegateTest : SysuiTestCase() {
        MockitoAnnotations.initMocks(this)
        testableLooper = TestableLooper.get(this)
        val mainHandler = Handler(testableLooper.looper)
        systemSettings = FakeSettings()
        val fakeSettings = FakeSettings()
        systemSettings = fakeSettings
        // Guarantee that the systemSettings always starts with the default font scale.
        systemSettings.putFloatForUser(Settings.System.FONT_SCALE, 1.0f, userTracker.userId)
        secureSettings = FakeSettings()
        secureSettings = fakeSettings
        systemClock = FakeSystemClock()
        backgroundDelayableExecutor = FakeExecutor(systemClock)
        whenever(sysuiState.setFlag(anyLong(), anyBoolean())).thenReturn(sysuiState)
@@ -207,9 +208,9 @@ class FontScalingDialogDelegateTest : SysuiTestCase() {
        dialog.show()

        val iconStartFrame: ViewGroup = dialog.findViewById(R.id.icon_start_frame)!!
        secureSettings.putIntForUser(
        secureSettings.putStringForUser(
            Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED,
            OFF,
            OFF.toString(),
            userTracker.userId,
        )

@@ -220,12 +221,11 @@ class FontScalingDialogDelegateTest : SysuiTestCase() {
        backgroundDelayableExecutor.runAllReady()

        val currentSettings =
            secureSettings.getIntForUser(
            secureSettings.getStringForUser(
                Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED,
                /* def = */ OFF,
                userTracker.userId,
            )
        assertThat(currentSettings).isEqualTo(ON)
        assertThat(currentSettings).isEqualTo(ON.toString())

        dialog.dismiss()
    }
+2 −2
Original line number Diff line number Diff line
@@ -117,9 +117,9 @@ class StickyKeysIndicatorViewModelTest : SysuiTestCase() {
    }

    private fun setStickyKeySetting(enabled: Boolean) {
        val newValue = if (enabled) "1" else "0"
        val newValue = if (enabled) 1 else 0
        val defaultUser = userRepository.getSelectedUserInfo().id
        secureSettings.putStringForUser(ACCESSIBILITY_STICKY_KEYS, newValue, defaultUser)
        secureSettings.putIntForUser(ACCESSIBILITY_STICKY_KEYS, newValue, defaultUser)
    }

    @Test