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

Commit a9f1d762 authored by Ioana Moraru's avatar Ioana Moraru Committed by Android (Google) Code Review
Browse files

Merge "Add assertions for non-resizeable application"

parents 6907ee9d 014d3f96
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wm.flicker.helpers

import android.app.Instrumentation
import android.content.ComponentName
import android.support.test.launcherhelper.ILauncherStrategy
import android.support.test.launcherhelper.LauncherStrategyFactory
import com.android.server.wm.flicker.testapp.ActivityOptions

class NonResizeableAppHelper @JvmOverloads constructor(
    instr: Instrumentation,
    launcherName: String = ActivityOptions.NON_RESIZEABLE_ACTIVITY_LAUNCHER_NAME,
    component: ComponentName = ActivityOptions.NON_RESIZEABLE_ACTIVITY_COMPONENT_NAME,
    launcherStrategy: ILauncherStrategy = LauncherStrategyFactory
        .getInstance(instr)
        .launcherStrategy
) : StandardAppHelper(instr, launcherName, component, launcherStrategy)
 No newline at end of file
+170 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wm.flicker.launch

import android.platform.test.annotations.Postsubmit
import android.view.Surface
import android.view.WindowManagerPolicyConstants
import androidx.test.filters.FlakyTest
import androidx.test.filters.RequiresDevice
import com.android.server.wm.flicker.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.FlickerTestParameterFactory
import com.android.server.wm.flicker.annotation.Group1
import com.android.server.wm.flicker.helpers.NonResizeableAppHelper
import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.traces.parser.windowmanager.WindowManagerStateHelper
import org.junit.FixMethodOrder
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.MethodSorters
import org.junit.runners.Parameterized

/**
 * Launch an app while the phone is locked
 * To run this test: `atest FlickerTests:OpenAppNonResizeableTest`
 */
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Group1
class OpenAppNonResizeableTest(testSpec: FlickerTestParameter) : OpenAppTransition(testSpec) {
    override val testApp = NonResizeableAppHelper(instrumentation)

    override val transition: FlickerBuilder.(Map<String, Any?>) -> Unit
        get() = {
            super.transition(this, it)
            setup {
                eachRun {
                    device.sleep()
                    wmHelper.waitForAppTransitionIdle()
                }
            }
            teardown {
                eachRun {
                    testApp.exit(wmHelper)
                }
            }
            transitions {
                testApp.launchViaIntent(wmHelper)
                wmHelper.waitForFullScreenApp(testApp.component)
            }
        }

    @Postsubmit
    @Test
    override fun navBarLayerIsVisible() {
        testSpec.assertLayersEnd {
            isVisible(WindowManagerStateHelper.NAV_BAR_COMPONENT)
        }
    }

    @Postsubmit
    @Test
    fun nonResizableAppLayerBecomesVisible() {
        testSpec.assertLayers {
            this.notContains(testApp.component)
                    .then()
                    .isInvisible(testApp.component)
                    .then()
                    .isVisible(testApp.component)
        }
    }

    @Postsubmit
    @Test
    fun nonResizableAppWindowBecomesVisible() {
        testSpec.assertWm {
            this.notContains(testApp.component)
                    .then()
                    .isAppWindowInvisible(testApp.component,
                            ignoreActivity = true, isOptional = true)
                    .then()
                    .isAppWindowVisible(testApp.component, ignoreActivity = true)
        }
    }

    @Postsubmit
    @Test
    fun nonResizableAppWindowBecomesVisibleAtEnd() {
        testSpec.assertWmEnd {
            this.isVisible(testApp.component)
        }
    }

    @FlakyTest
    @Test
    override fun navBarWindowIsVisible() = super.navBarWindowIsVisible()

    @FlakyTest
    @Test
    override fun navBarLayerRotatesAndScales() = super.navBarLayerRotatesAndScales()

    @FlakyTest
    @Test
    override fun statusBarWindowIsVisible() = super.statusBarWindowIsVisible()

    @FlakyTest
    @Test
    override fun statusBarLayerIsVisible() = super.statusBarLayerIsVisible()

    @FlakyTest
    @Test
    override fun statusBarLayerRotatesScales() = super.statusBarLayerRotatesScales()

    @FlakyTest
    @Test
    override fun visibleWindowsShownMoreThanOneConsecutiveEntry() =
            super.visibleWindowsShownMoreThanOneConsecutiveEntry()

    @FlakyTest
    @Test
    override fun visibleLayersShownMoreThanOneConsecutiveEntry() =
            super.visibleLayersShownMoreThanOneConsecutiveEntry()

    @FlakyTest
    @Test
    override fun entireScreenCovered() = super.entireScreenCovered()

    @FlakyTest
    @Test
    override fun focusChanges() = super.focusChanges()

    @FlakyTest
    @Test
    override fun appLayerReplacesLauncher() = super.appLayerReplacesLauncher()

    @FlakyTest
    @Test
    override fun appWindowReplacesLauncherAsTopWindow() =
            super.appWindowReplacesLauncherAsTopWindow()

    companion object {
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): Collection<FlickerTestParameter> {
            return FlickerTestParameterFactory.getInstance()
                    .getConfigNonRotationTests(
                            repetitions = 5,
                            supportedNavigationModes =
                            listOf(WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY),
                            supportedRotations = listOf(Surface.ROTATION_0)
                    )
        }
    }
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ import org.junit.Test

abstract class OpenAppTransition(protected val testSpec: FlickerTestParameter) {
    protected val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    protected val testApp: StandardAppHelper = SimpleAppHelper(instrumentation)
    protected open val testApp: StandardAppHelper = SimpleAppHelper(instrumentation)

    protected open val transition: FlickerBuilder.(Map<String, Any?>) -> Unit = {
        withTestName { testSpec.name }
+11 −0
Original line number Diff line number Diff line
@@ -59,5 +59,16 @@
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name=".NonResizeableActivity"
            android:resizeableActivity="false"
            android:taskAffinity="com.android.server.wm.flicker.testapp.NonResizeableActivity"
            android:label="NonResizeableApp"
            android:exported="true"
            android:showOnLockScreen="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>
+32 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
 Copyright 2021 The Android Open Source Project

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@android:color/holo_orange_light">

  <TextView
      android:id="@+id/NonResizeableTest"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:gravity="center_vertical|center_horizontal"
      android:text="NonResizeableActivity"
      android:textAppearance="?android:attr/textAppearanceLarge"/>

</LinearLayout>
 No newline at end of file
Loading