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

Commit 80638719 authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Properly destroy tiles in tests

This prevents test leaking

Fixes: 376459027
Test: atest SystemUITests
Flag: TEST_ONLY
Change-Id: I9f749898ebefaa3a14bd39293c4d82564959be8d
parent df9a25c1
Loading
Loading
Loading
Loading
+30 −21
Original line number Diff line number Diff line
@@ -26,11 +26,9 @@ import android.testing.TestableLooper
import android.testing.TestableLooper.RunWithLooper
import androidx.test.filters.SmallTest
import com.android.internal.logging.MetricsLogger
import com.android.systemui.Flags
import com.android.systemui.Flags.FLAG_SCENE_CONTAINER
import com.android.systemui.SysuiTestCase
import com.android.systemui.classifier.FalsingManagerFake
import com.android.systemui.flags.setFlagValue
import com.android.systemui.keyguard.KeyguardWmStateRefactor
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.statusbar.StatusBarStateController
@@ -42,7 +40,6 @@ import com.android.systemui.qs.logging.QSLogger
import com.android.systemui.qs.tiles.dialog.InternetDialogManager
import com.android.systemui.qs.tiles.dialog.WifiStateWorker
import com.android.systemui.res.R
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.shade.shared.flag.DualShade
import com.android.systemui.statusbar.connectivity.AccessPointController
import com.android.systemui.statusbar.notification.shared.NotificationThrottleHun
@@ -65,6 +62,7 @@ import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -150,11 +148,18 @@ class InternetTileNewImplTest(flags: FlagsParameterization) : SysuiTestCase() {
            )

        underTest.initialize()

        underTest.setListening(Object(), true)

        looper.processAllMessages()
    }

    @After
    fun tearDown() {
        underTest.destroy()
        looper.processAllMessages()
    }

    @Test
    fun noDefaultConnection_noNetworkAvailable() =
        testScope.runTest {
@@ -272,7 +277,8 @@ class InternetTileNewImplTest(flags: FlagsParameterization) : SysuiTestCase() {
        underTest.click(null)
        looper.processAllMessages()

        verify(dialogManager, times(1)).create(
        verify(dialogManager, times(1))
            .create(
                aboveStatusBar = true,
                accessPointController.canConfigMobileData(),
                accessPointController.canConfigWifi(),
@@ -282,18 +288,21 @@ class InternetTileNewImplTest(flags: FlagsParameterization) : SysuiTestCase() {

    @Test
    @EnableFlags(
        value = [
        value =
            [
                QsDetailedView.FLAG_NAME,
                FLAG_SCENE_CONTAINER,
                KeyguardWmStateRefactor.FLAG_NAME,
                NotificationThrottleHun.FLAG_NAME,
            DualShade.FLAG_NAME]
                DualShade.FLAG_NAME,
            ]
    )
    fun click_withQsDetailedViewEnabled() {
        underTest.click(null)
        looper.processAllMessages()

        verify(dialogManager, times(0)).create(
        verify(dialogManager, times(0))
            .create(
                aboveStatusBar = true,
                accessPointController.canConfigMobileData(),
                accessPointController.canConfigWifi(),
+7 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import java.util.concurrent.Executors
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -123,6 +124,12 @@ class RecordIssueTileTest : SysuiTestCase() {
            )
    }

    @After
    fun teardown() {
        tile.destroy()
        testableLooper.processAllMessages()
    }

    @Test
    fun qsTileUi_shouldLookCorrect_whenInactive() {
        whenever(issueRecordingState.isRecording).thenReturn(false)