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

Commit 175cdc37 authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Remove ImeFlickerTests button tap dependency

This fixes some flakes in ImeFlickerTests where the buttons that needed
to be tapped during the test runs were covered by the IME (either due to
small display size, or floating keyboard mode in landscape).

Instead, we use a BroadcastReceiver and create custom intent actions for
the required behaviours.

Test: atest FlickerTestsIme2:OpenImeWindowToFixedPortraitAppTest -- --module-arg FlickerTestsIme2:include-annotation:android.platform.test.annotations.Presubmit --module-arg FlickerTestsIme2:exclude-annotation:android.platform.test.annotations.IwTest
Bug: 310868933
Change-Id: I44baf01a0c5cbfd1f0e51be09075de0a3c7ea967
parent eefc1883
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -23,10 +23,13 @@ import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import android.tools.device.traces.parsers.toFlickerComponent
import androidx.test.filters.FlakyTest
import com.android.server.wm.flicker.BaseTest
import com.android.server.wm.flicker.helpers.ImeAppHelper
import com.android.server.wm.flicker.helpers.SimpleAppHelper
import com.android.server.wm.flicker.testapp.ActivityOptions
import com.android.server.wm.flicker.testapp.ActivityOptions.Ime.Default.ACTION_FINISH_ACTIVITY
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
@@ -53,7 +56,12 @@ class CloseImeToHomeOnFinishActivityTest(flicker: LegacyFlickerTest) : BaseTest(
            testApp.launchViaIntent(wmHelper)
            testApp.openIME(wmHelper)
        }
        transitions { testApp.finishActivity(wmHelper) }
        transitions {
            broadcastActionTrigger.doAction(ACTION_FINISH_ACTIVITY)
            wmHelper.StateSyncBuilder()
                    .withActivityRemoved(ActivityOptions.Ime.Default.COMPONENT.toFlickerComponent())
                    .waitForAndVerify()
        }
        teardown { simpleApp.exit(wmHelper) }
    }

+6 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.tools.device.helpers.WindowUtils
import androidx.test.filters.RequiresDevice
import com.android.server.wm.flicker.BaseTest
import com.android.server.wm.flicker.helpers.ImeShownOnAppStartHelper
import com.android.server.wm.flicker.testapp.ActivityOptions.Ime.Default.ACTION_TOGGLE_ORIENTATION
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
@@ -53,7 +54,11 @@ class OpenImeWindowToFixedPortraitAppTest(flicker: LegacyFlickerTest) : BaseTest
            // Enable letterbox when the app calls setRequestedOrientation
            device.executeShellCommand("cmd window set-ignore-orientation-request true")
        }
        transitions { testApp.toggleFixPortraitOrientation(wmHelper) }
        transitions {
            broadcastActionTrigger.doAction(ACTION_TOGGLE_ORIENTATION)
            // Ensure app relaunching transition finished and the IME was shown
            testApp.waitIMEShown(wmHelper)
        }
        teardown {
            testApp.exit()
            device.executeShellCommand("cmd window set-ignore-orientation-request false")
+1 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ class ShowImeOnAppStartWhenLaunchingAppFromQuickSwitchTest(flicker: LegacyFlicke

    @Presubmit
    @Test
    open fun imeLayerIsVisibleWhenSwitchingToImeApp() {
    fun imeLayerIsVisibleWhenSwitchingToImeApp() {
        flicker.assertLayersStart { isVisible(ComponentNameMatcher.IME) }
        flicker.assertLayersTag(TAG_IME_VISIBLE) { isVisible(ComponentNameMatcher.IME) }
        flicker.assertLayersEnd { isVisible(ComponentNameMatcher.IME) }
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ class ShowImeOnAppStartWhenLaunchingAppTest(flicker: LegacyFlickerTest) : BaseTe
        }
        transitions {
            testApp.launchViaIntent(wmHelper)
            wmHelper.StateSyncBuilder().withImeShown().waitForAndVerify()
            testApp.waitIMEShown(wmHelper)
        }
    }

+9 −2
Original line number Diff line number Diff line
@@ -23,11 +23,14 @@ import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
import android.tools.device.flicker.legacy.FlickerBuilder
import android.tools.device.flicker.legacy.LegacyFlickerTest
import android.tools.device.flicker.legacy.LegacyFlickerTestFactory
import android.tools.device.traces.parsers.toFlickerComponent
import android.view.WindowInsets.Type.ime
import android.view.WindowInsets.Type.navigationBars
import android.view.WindowInsets.Type.statusBars
import com.android.server.wm.flicker.BaseTest
import com.android.server.wm.flicker.helpers.ImeShownOnAppStartHelper
import com.android.server.wm.flicker.testapp.ActivityOptions
import com.android.server.wm.flicker.testapp.ActivityOptions.Ime.Default.ACTION_START_DIALOG_THEMED_ACTIVITY
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.FixMethodOrder
@@ -50,8 +53,12 @@ class ShowImeWhileDismissingThemedPopupDialogTest(flicker: LegacyFlickerTest) :
    override val transition: FlickerBuilder.() -> Unit = {
        setup {
            testApp.launchViaIntent(wmHelper)
            wmHelper.StateSyncBuilder().withImeShown().waitForAndVerify()
            testApp.startDialogThemedActivity(wmHelper)
            testApp.waitIMEShown(wmHelper)
            broadcastActionTrigger.doAction(ACTION_START_DIALOG_THEMED_ACTIVITY)
            wmHelper.StateSyncBuilder()
                    .withFullScreenApp(
                        ActivityOptions.DialogThemedActivity.COMPONENT.toFlickerComponent())
                    .waitForAndVerify()
            // Verify IME insets isn't visible on dialog since it's non-IME focusable window
            assertFalse(testApp.getInsetsVisibleFromDialog(ime()))
            assertTrue(testApp.getInsetsVisibleFromDialog(statusBars()))
Loading