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

Commit ff879bea authored by Nataniel Borges's avatar Nataniel Borges
Browse files

Use SysUI TAPL on notification tests

It's more stable than using only UiAutomator

Flag: TEST_ONLY
Fixes: 380123632
Test: atest FlickerTests
Change-Id: I28be4eecb073d75a4be1ce519d22f5ff93f6d80e
parent 067493a5
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ java_defaults {
        "platform-test-annotations",
        "platform-test-annotations",
        "wm-flicker-common-app-helpers",
        "wm-flicker-common-app-helpers",
        "wm-shell-flicker-utils",
        "wm-shell-flicker-utils",
        "systemui-tapl",
    ],
    ],
    data: [":FlickerTestApp"],
    data: [":FlickerTestApp"],
}
}
+16 −13
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.server.wm.flicker.notification
package com.android.server.wm.flicker.notification


import android.platform.systemui_tapl.controller.NotificationIdentity
import android.platform.systemui_tapl.ui.Root
import android.platform.test.annotations.Postsubmit
import android.platform.test.annotations.Postsubmit
import android.platform.test.annotations.Presubmit
import android.platform.test.annotations.Presubmit
import android.platform.test.rule.DisableNotificationCooldownSettingRule
import android.platform.test.rule.DisableNotificationCooldownSettingRule
@@ -28,8 +30,6 @@ import android.tools.helpers.wakeUpAndGoToHomeScreen
import android.tools.traces.component.ComponentNameMatcher
import android.tools.traces.component.ComponentNameMatcher
import android.view.WindowInsets
import android.view.WindowInsets
import android.view.WindowManager
import android.view.WindowManager
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import com.android.server.wm.flicker.helpers.NotificationAppHelper
import com.android.server.wm.flicker.helpers.NotificationAppHelper
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.navBarLayerIsVisibleAtEnd
import com.android.server.wm.flicker.navBarLayerIsVisibleAtEnd
@@ -87,8 +87,9 @@ open class OpenAppFromNotificationWarmTest(flicker: LegacyFlickerTest) :
            .withWindowSurfaceDisappeared(ComponentNameMatcher.NOTIFICATION_SHADE)
            .withWindowSurfaceDisappeared(ComponentNameMatcher.NOTIFICATION_SHADE)
            .waitForAndVerify()
            .waitForAndVerify()
    }
    }

    protected fun FlickerTestData.openAppFromNotification() {
    protected fun FlickerTestData.openAppFromNotification() {
        doOpenAppAndWait(startY = 10, endY = 3 * device.displayHeight / 4, steps = 25)
        doOpenAppAndWait()
    }
    }


    protected fun FlickerTestData.openAppFromLockNotification() {
    protected fun FlickerTestData.openAppFromLockNotification() {
@@ -101,25 +102,27 @@ open class OpenAppFromNotificationWarmTest(flicker: LegacyFlickerTest) :
                WindowInsets.Type.statusBars() or WindowInsets.Type.displayCutout()
                WindowInsets.Type.statusBars() or WindowInsets.Type.displayCutout()
            )
            )


        doOpenAppAndWait(startY = insets.top + 100, endY = device.displayHeight / 2, steps = 4)
        doOpenAppAndWait()
    }
    }


    protected fun FlickerTestData.doOpenAppAndWait(startY: Int, endY: Int, steps: Int) {
    protected fun FlickerTestData.doOpenAppAndWait() {
        // Swipe down to show the notification shade
        val shade = Root.get().openNotificationShade()
        val x = device.displayWidth / 2
        device.swipe(x, startY, x, endY, steps)
        device.waitForIdle(2000)
        instrumentation.uiAutomation.syncInputTransactions()


        // Launch the activity by clicking the notification
        // Launch the activity by clicking the notification
        // Post notification and ensure that it's collapsed
        val notification =
        val notification =
            device.wait(Until.findObject(By.text("Flicker Test Notification")), 2000L)
            shade.notificationStack.findNotification(
        notification?.click() ?: error("Notification not found")
                NotificationIdentity(
        instrumentation.uiAutomation.syncInputTransactions()
                    type = NotificationIdentity.Type.BY_TEXT,
                    text = "Flicker Test Notification",
                )
            )


        notification.clickToApp()
        // Wait for the app to launch
        // Wait for the app to launch
        wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify()
        wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify()
    }
    }

    @Presubmit @Test override fun appWindowBecomesVisible() = appWindowBecomesVisible_warmStart()
    @Presubmit @Test override fun appWindowBecomesVisible() = appWindowBecomesVisible_warmStart()


    @Presubmit @Test override fun appLayerBecomesVisible() = appLayerBecomesVisible_warmStart()
    @Presubmit @Test override fun appLayerBecomesVisible() = appLayerBecomesVisible_warmStart()