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

Commit 48f4d347 authored by Sergey Pinkevich's avatar Sergey Pinkevich
Browse files

[E2E test] Ensure that opening a trampoline task in DW only triggers the task limit once

Bug: 410480799
Flag: EXEMPT no flag is needed for instrumented test
Test: atest PlatformScenarioTests:com.android.wm.shell.functional.OpenTrampolineAppInDesktopModeTest

Change-Id: I430fa231c7dc0b63e5fddac97ffd19012dd334a6
parent f1e8a993
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.wm.shell.functional

import android.platform.test.annotations.Postsubmit
import android.platform.test.rule.ScreenRecordRule
import com.android.wm.shell.scenarios.OpenTrampolineAppInDesktopModeTaskLimit
import org.junit.runner.RunWith
import org.junit.runners.BlockJUnit4ClassRunner

/* Functional test for [OpenTrampolineAppInDesktopModeTaskLimit]. */
@RunWith(BlockJUnit4ClassRunner::class)
@Postsubmit
@ScreenRecordRule.ScreenRecord
class OpenTrampolineAppInDesktopModeTaskLimitTest : OpenTrampolineAppInDesktopModeTaskLimit()
 No newline at end of file
+100 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.wm.shell.scenarios

import android.app.Instrumentation
import android.tools.Rotation
import android.tools.device.apphelpers.CalculatorAppHelper
import android.tools.device.apphelpers.ClockAppHelper
import android.tools.device.apphelpers.MessagingAppHelper
import android.tools.flicker.rules.ChangeDisplayOrientationRule
import android.tools.traces.parsers.WindowManagerStateHelper
import android.tools.traces.parsers.toFlickerComponent
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.android.launcher3.tapl.LauncherInstrumentation
import com.android.server.wm.flicker.helpers.DesktopModeAppHelper
import com.android.server.wm.flicker.helpers.MailAppHelper
import com.android.server.wm.flicker.helpers.SimpleAppHelper
import com.android.server.wm.flicker.testapp.ActivityOptions
import com.android.window.flags.Flags
import org.junit.After
import org.junit.Assume
import org.junit.Before
import org.junit.Ignore
import org.junit.Test

@Ignore("Test Base Class")
abstract class OpenTrampolineAppInDesktopModeTaskLimit(val rotation: Rotation = Rotation.ROTATION_0) :
    TestScenarioBase() {

    private val instrumentation: Instrumentation = InstrumentationRegistry.getInstrumentation()
    private val tapl = LauncherInstrumentation()
    private val wmHelper = WindowManagerStateHelper(instrumentation)
    private val device = UiDevice.getInstance(instrumentation)

    private val mailAppHelper = MailAppHelper(instrumentation)
    private val mailAppDesktopHelper = DesktopModeAppHelper(mailAppHelper)
    private val calculatorHelper = CalculatorAppHelper(instrumentation)
    private val clockAppHelper = ClockAppHelper()
    private val messagingAppHelper = MessagingAppHelper(instrumentation)
    private val trampolineAppHelper = SimpleAppHelper(
        instrumentation,
        launcherName = ActivityOptions.TrampolineStartActivity.LABEL,
        component = ActivityOptions.TrampolineStartActivity.COMPONENT.toFlickerComponent()
    )

    @Before
    fun setup() {
        Assume.assumeTrue(Flags.enableDesktopWindowingMode() && Flags.enableDesktopTaskLimitSeparateTransition() && tapl.isTablet)
        tapl.apply {
            setEnableRotation(true)
            setExpectedRotation(rotation.value)
            enableTransientTaskbar(false)
        }
        ChangeDisplayOrientationRule.setRotation(rotation)

        mailAppDesktopHelper.enterDesktopMode(wmHelper, device)
        calculatorHelper.launchViaIntent(wmHelper)
        clockAppHelper.launchViaIntent(wmHelper)
        messagingAppHelper.launchViaIntent(wmHelper)
    }

    @Test
    open fun openTrampolineApp() {
        trampolineAppHelper.launchViaIntent()
        wmHelper.StateSyncBuilder()
            .withAppTransitionIdle()
            // Exactly one app is minimized
            .withWindowSurfaceDisappeared(mailAppHelper.componentMatcher)
            .withLayerVisible(calculatorHelper.componentMatcher)
            .withLayerVisible(clockAppHelper.componentMatcher)
            .withLayerVisible(messagingAppHelper.componentMatcher)
            // We need to verify that the second Activity (opened as trampolined task) is visible
            .withLayerVisible(ActivityOptions.TrampolineFinishActivity.COMPONENT.toFlickerComponent())
            .waitForAndVerify()
    }

    @After
    fun teardown() {
        trampolineAppHelper.exit(wmHelper)
        messagingAppHelper.exit()
        clockAppHelper.exit()
        calculatorHelper.exit()
        mailAppHelper.exit()
    }
}
 No newline at end of file
+13 −0
Original line number Diff line number Diff line
@@ -408,6 +408,19 @@
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity
            android:name=".TrampolineStartActivity"
            android:exported="true"
            android:label=".TrampolineStartActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity
            android:name=".TrampolineFinishActivity"
            android:exported="true"
            android:label=".TrampolineFinishActivity" />
        <service
            android:name=".AssistantInteractionSessionService"
            android:exported="true"
+12 −0
Original line number Diff line number Diff line
@@ -73,6 +73,18 @@ public class ActivityOptions {
        }
    }

    public static class TrampolineStartActivity {
        public static final String LABEL = "TrampolineStartActivity";
        public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE,
                FLICKER_APP_PACKAGE + ".TrampolineStartActivity");
    }

    public static class TrampolineFinishActivity {
        public static final String LABEL = "TrampolineFinishActivity";
        public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE,
                FLICKER_APP_PACKAGE + ".TrampolineFinishActivity");
    }

    public static class NonResizeableActivity {
        public static final String LABEL = "NonResizeableActivity";
        public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE,
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.testapp;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.Nullable;

/**
 * Activity that is launched from {@link TrampolineStartActivity}.
 *
 * <p>This Activity is displayed after the initial trampoline activity has completed its processing.
 */
public class TrampolineFinishActivity extends Activity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_non_resizeable);
    }
}
Loading