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

Commit 5628fff5 authored by Behnam Heydarshahi's avatar Behnam Heydarshahi Committed by Android (Google) Code Review
Browse files

Merge "Set default val for color a11y repos" into main

parents 56bff5c8 6fde2c56
Loading
Loading
Loading
Loading
+19 −45
Original line number Diff line number Diff line
@@ -58,16 +58,22 @@ class ColorCorrectionRepositoryImplTest : SysuiTestCase() {
            )
    }

    @Test
    fun isEnabled_settingNotInitialized_returnsFalseByDefault() =
        scope.runTest {
            val actualValue by collectLastValue(underTest.isEnabled(testUser1))

            runCurrent()

            Truth.assertThat(actualValue).isFalse()
        }

    @Test
    fun isEnabled_initiallyGetsSettingsValue() =
        scope.runTest {
            val actualValue by collectLastValue(underTest.isEnabled(testUser1))

            settings.putIntForUser(
                SETTING_NAME,
                ENABLED,
                testUser1.identifier
            )
            settings.putIntForUser(SETTING_NAME, ENABLED, testUser1.identifier)
            runCurrent()

            Truth.assertThat(actualValue).isTrue()
@@ -78,25 +84,13 @@ class ColorCorrectionRepositoryImplTest : SysuiTestCase() {
        scope.runTest {
            val flowValues: List<Boolean> by collectValues(underTest.isEnabled(testUser1))

            settings.putIntForUser(
                SETTING_NAME,
                DISABLED,
                testUser1.identifier
            )
            settings.putIntForUser(SETTING_NAME, DISABLED, testUser1.identifier)
            runCurrent()

            settings.putIntForUser(
                SETTING_NAME,
                ENABLED,
                testUser1.identifier
            )
            settings.putIntForUser(SETTING_NAME, ENABLED, testUser1.identifier)
            runCurrent()

            settings.putIntForUser(
                SETTING_NAME,
                DISABLED,
                testUser1.identifier
            )
            settings.putIntForUser(SETTING_NAME, DISABLED, testUser1.identifier)
            runCurrent()

            Truth.assertThat(flowValues.size).isEqualTo(3)
@@ -109,26 +103,14 @@ class ColorCorrectionRepositoryImplTest : SysuiTestCase() {
            val lastValueUser1 by collectLastValue(underTest.isEnabled(testUser1))
            val lastValueUser2 by collectLastValue(underTest.isEnabled(testUser2))

            settings.putIntForUser(
                SETTING_NAME,
                DISABLED,
                testUser1.identifier
            )
            settings.putIntForUser(
                SETTING_NAME,
                DISABLED,
                testUser2.identifier
            )
            settings.putIntForUser(SETTING_NAME, DISABLED, testUser1.identifier)
            settings.putIntForUser(SETTING_NAME, DISABLED, testUser2.identifier)
            runCurrent()

            Truth.assertThat(lastValueUser1).isFalse()
            Truth.assertThat(lastValueUser2).isFalse()

            settings.putIntForUser(
                SETTING_NAME,
                ENABLED,
                testUser1.identifier
            )
            settings.putIntForUser(SETTING_NAME, ENABLED, testUser1.identifier)
            runCurrent()

            Truth.assertThat(lastValueUser1).isTrue()
@@ -142,11 +124,7 @@ class ColorCorrectionRepositoryImplTest : SysuiTestCase() {
            runCurrent()
            Truth.assertThat(success).isTrue()

            val actualValue =
                settings.getIntForUser(
                    SETTING_NAME,
                    testUser1.identifier
                )
            val actualValue = settings.getIntForUser(SETTING_NAME, testUser1.identifier)
            Truth.assertThat(actualValue).isEqualTo(ENABLED)
        }

@@ -157,11 +135,7 @@ class ColorCorrectionRepositoryImplTest : SysuiTestCase() {
            runCurrent()
            Truth.assertThat(success).isTrue()

            val actualValue =
                settings.getIntForUser(
                    SETTING_NAME,
                    testUser1.identifier
                )
            val actualValue = settings.getIntForUser(SETTING_NAME, testUser1.identifier)
            Truth.assertThat(actualValue).isEqualTo(DISABLED)
        }

+12 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.util.settings.FakeSettings
import com.google.common.truth.Truth
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.StandardTestDispatcher
@@ -58,6 +59,16 @@ class ColorInversionRepositoryImplTest : SysuiTestCase() {
            )
    }

    @Test
    fun isEnabled_settingNotInitialized_returnsFalseByDefault() =
        scope.runTest {
            val actualValue by collectLastValue(underTest.isEnabled(testUser1))

            runCurrent()

            Truth.assertThat(actualValue).isFalse()
        }

    @Test
    fun isEnabled_initiallyGetsSettingsValue() =
        scope.runTest {
@@ -72,8 +83,7 @@ class ColorInversionRepositoryImplTest : SysuiTestCase() {
    @Test
    fun isEnabled_settingUpdated_valueUpdated() =
        scope.runTest {
            val flowValues: List<Boolean> by
                collectValues(underTest.isEnabled(testUser1))
            val flowValues: List<Boolean> by collectValues(underTest.isEnabled(testUser1))

            settings.putIntForUser(SETTING_NAME, DISABLED, testUser1.identifier)
            runCurrent()
+2 −1
Original line number Diff line number Diff line
@@ -61,7 +61,8 @@ constructor(
                .observerFlow(userHandle.identifier, SETTING_NAME)
                .onStart { emit(Unit) }
                .map {
                    secureSettings.getIntForUser(SETTING_NAME, userHandle.identifier) == ENABLED
                    secureSettings.getIntForUser(SETTING_NAME, DISABLED, userHandle.identifier) ==
                        ENABLED
                }
                .distinctUntilChanged()
                .flowOn(bgCoroutineContext)
+2 −1
Original line number Diff line number Diff line
@@ -61,7 +61,8 @@ constructor(
                .observerFlow(userHandle.identifier, SETTING_NAME)
                .onStart { emit(Unit) }
                .map {
                    secureSettings.getIntForUser(SETTING_NAME, userHandle.identifier) == ENABLED
                    secureSettings.getIntForUser(SETTING_NAME, DISABLED, userHandle.identifier) ==
                        ENABLED
                }
                .distinctUntilChanged()
                .flowOn(bgCoroutineContext)