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

Commit fb7db269 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[flexiglass] Converts tests to deviceless.

All unit and integration tests are converted into shared tests so they
can run with or without a device.

PinInputViewModel needed some internal things to be made public so the
test module can see them.

SceneContainterFlagsTest was left unconverted because it's a
non-screenshot parameterized test, which is not yet supported.

Fix: 302542615
Test: N/A these are tests
Change-Id: I709ccbe91293fbcaae3bc84250f4c987e92d7730
parent c8b2a14b
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -319,6 +319,8 @@ filegroup {
        "tests/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/prod/WifiRepositoryImplTest.kt",
        "tests/src/com/android/systemui/statusbar/pipeline/wifi/domain/interactor/WifiInteractorImplTest.kt",
        "tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelTest.kt",
        "tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/FakeMobileIconsInteractor.kt",
        "tests/src/com/android/systemui/statusbar/pipeline/mobile/domain/interactor/FakeMobileIconInteractor.kt",

        /* Bouncer UI tests */
        "tests/src/com/android/keyguard/KeyguardPasswordViewControllerTest.kt",
@@ -365,6 +367,42 @@ filegroup {
        "tests/src/com/android/systemui/qs/pipeline/shared/TileSpecTest.kt",
        "tests/src/com/android/systemui/qs/tiles/base/**/*.kt",
        "tests/src/com/android/systemui/qs/tiles/viewmodel/**/*.kt",

        /* Authentication */
        "tests/src/com/android/systemui/authentication/data/repository/AuthenticationRepositoryTest.kt",
        "tests/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractorTest.kt",

        /* Device entry */
        "tests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryRepositoryTest.kt",
        "tests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractorTest.kt",

        /* Bouncer scene */
        "tests/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractorTest.kt",
        "tests/src/com/android/systemui/bouncer/ui/viewmodel/AuthMethodBouncerViewModelTest.kt",
        "tests/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModelTest.kt",
        "tests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt",
        "tests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt",
        "tests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt",
        "tests/src/com/android/systemui/bouncer/ui/viewmodel/PinInputViewModelTest.kt",

        /* Lockscreen scene */
        "tests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt",

        /* Shade scene */
        "tests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt",
        "tests/src/com/android/systemui/shade/ui/viewmodel/ShadeHeaderViewModelTest.kt",

        /* Quick Settings scene */
        "tests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt",

        /* Flexiglass / Scene framework tests */
        "tests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt",
        "tests/src/com/android/systemui/scene/data/repository/SceneContainerRepositoryTest.kt",
        "tests/src/com/android/systemui/scene/data/repository/WindowRootViewVisibilityRepositoryTest.kt",
        "tests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt",
        "tests/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractorTest.kt",
        "tests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt",
        "tests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt",
    ],
    path: "tests/src",
}
+4 −8
Original line number Diff line number Diff line
@@ -35,10 +35,8 @@ import com.android.systemui.bouncer.ui.viewmodel.EntryToken.Digit
 * The input is guaranteed to always contain a initial [ClearAll] token as a sentinel, thus clients
 * can always assume there is a 'ClearAll' watermark available.
 */
data class PinInputViewModel
internal constructor(
    @get:VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
    internal val input: List<EntryToken>
data class PinInputViewModel(
    @get:VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) val input: List<EntryToken>
) {
    init {
        require(input.firstOrNull() is ClearAll) { "input does not begin with a ClearAll token" }
@@ -132,8 +130,7 @@ sealed interface EntryToken : Comparable<EntryToken> {
    val sequenceNumber: Int

    /** The pin bouncer [input] as digits 0-9. */
    data class Digit
    internal constructor(val input: Int, override val sequenceNumber: Int = nextSequenceNumber++) :
    data class Digit(val input: Int, override val sequenceNumber: Int = nextSequenceNumber++) :
        EntryToken {
        init {
            check(input in 0..9)
@@ -144,8 +141,7 @@ sealed interface EntryToken : Comparable<EntryToken> {
     * Marker to indicate the input is completely cleared, and subsequent [EntryToken]s mark a new
     * pin entry.
     */
    data class ClearAll
    internal constructor(override val sequenceNumber: Int = nextSequenceNumber++) : EntryToken
    data class ClearAll(override val sequenceNumber: Int = nextSequenceNumber++) : EntryToken

    override fun compareTo(other: EntryToken): Int =
        compareValuesBy(this, other, EntryToken::sequenceNumber)
+2 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ package com.android.systemui.authentication.data.repository
import android.app.admin.DevicePolicyManager
import android.content.Intent
import android.content.pm.UserInfo
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.internal.widget.LockPatternUtils
import com.android.keyguard.KeyguardSecurityModel
@@ -40,13 +41,12 @@ import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.Mock
import org.mockito.MockitoAnnotations

@SmallTest
@RunWith(JUnit4::class)
@RunWith(AndroidJUnit4::class)
class AuthenticationRepositoryTest : SysuiTestCase() {

    @Mock private lateinit var lockPatternUtils: LockPatternUtils
+2 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.authentication.domain.interactor

import android.app.admin.DevicePolicyManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.authentication.data.model.AuthenticationMethodModel as DataLayerAuthenticationMethodModel
@@ -35,11 +36,10 @@ import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@RunWith(JUnit4::class)
@RunWith(AndroidJUnit4::class)
class AuthenticationInteractorTest : SysuiTestCase() {

    private val utils = SceneTestUtils(this)
+2 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.bouncer.domain.interactor

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.authentication.data.model.AuthenticationMethodModel
@@ -38,11 +39,10 @@ import kotlinx.coroutines.test.runTest
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@RunWith(JUnit4::class)
@RunWith(AndroidJUnit4::class)
class BouncerInteractorTest : SysuiTestCase() {

    private val utils = SceneTestUtils(this)
Loading