Merge "[AE Flicker Test] From a split A|B, let A launch C with alwaysExpand=true, expect C to overlay split A|B." into udc-qpr-dev
This commit is contained in:
@@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 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.activityembedding
|
||||||
|
|
||||||
|
import android.platform.test.annotations.Presubmit
|
||||||
|
import android.tools.device.flicker.junit.FlickerParametersRunnerFactory
|
||||||
|
import android.tools.device.flicker.legacy.FlickerBuilder
|
||||||
|
import android.tools.device.flicker.legacy.FlickerTest
|
||||||
|
import android.tools.device.flicker.legacy.FlickerTestFactory
|
||||||
|
import androidx.test.filters.RequiresDevice
|
||||||
|
import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper
|
||||||
|
import org.junit.FixMethodOrder
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.junit.runners.MethodSorters
|
||||||
|
import org.junit.runners.Parameterized
|
||||||
|
import android.tools.common.datatypes.Rect
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test launching an activity with AlwaysExpand rule.
|
||||||
|
*
|
||||||
|
* Setup: Launch A|B in split with B being the secondary activity.
|
||||||
|
* Transitions:
|
||||||
|
* A start C with alwaysExpand=true, expect C to launch in fullscreen and cover split A|B.
|
||||||
|
*
|
||||||
|
* To run this test: `atest FlickerTests:MainActivityStartsSecondaryWithAlwaysExpandTest`
|
||||||
|
*/
|
||||||
|
@RequiresDevice
|
||||||
|
@RunWith(Parameterized::class)
|
||||||
|
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
|
||||||
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
|
class MainActivityStartsSecondaryWithAlwaysExpandTest(flicker: FlickerTest) :
|
||||||
|
ActivityEmbeddingTestBase(flicker) {
|
||||||
|
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
override val transition: FlickerBuilder.() -> Unit = {
|
||||||
|
setup {
|
||||||
|
tapl.setExpectedRotationCheckEnabled(false)
|
||||||
|
// Launch a split
|
||||||
|
testApp.launchViaIntent(wmHelper)
|
||||||
|
testApp.launchSecondaryActivity(wmHelper)
|
||||||
|
startDisplayBounds =
|
||||||
|
wmHelper.currentState.layerState.physicalDisplayBounds ?: error("Display not found")
|
||||||
|
}
|
||||||
|
transitions {
|
||||||
|
// Launch C with alwaysExpand
|
||||||
|
testApp.launchAlwaysExpandActivity(wmHelper)
|
||||||
|
}
|
||||||
|
teardown {
|
||||||
|
tapl.goHome()
|
||||||
|
testApp.exit(wmHelper)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Transition begins with a split. */
|
||||||
|
@Presubmit
|
||||||
|
@Test
|
||||||
|
fun startsWithSplit() {
|
||||||
|
flicker.assertWmStart {
|
||||||
|
this.isAppWindowVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
|
||||||
|
}
|
||||||
|
flicker.assertWmStart {
|
||||||
|
this.isAppWindowVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Main activity should become invisible after being covered by always expand activity. */
|
||||||
|
@Presubmit
|
||||||
|
@Test
|
||||||
|
fun mainActivityLayerBecomesInvisible() {
|
||||||
|
flicker.assertLayers {
|
||||||
|
isVisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
|
||||||
|
.then()
|
||||||
|
.isInvisible(ActivityEmbeddingAppHelper.MAIN_ACTIVITY_COMPONENT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Secondary activity should become invisible after being covered by always expand activity. */
|
||||||
|
@Presubmit
|
||||||
|
@Test
|
||||||
|
fun secondaryActivityLayerBecomesInvisible() {
|
||||||
|
flicker.assertLayers {
|
||||||
|
isVisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
|
||||||
|
.then()
|
||||||
|
.isInvisible(ActivityEmbeddingAppHelper.SECONDARY_ACTIVITY_COMPONENT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** At the end of transition always expand activity is in fullscreen. */
|
||||||
|
@Presubmit
|
||||||
|
@Test
|
||||||
|
fun endsWithAlwaysExpandActivityCoveringFullScreen() {
|
||||||
|
flicker.assertWmEnd {
|
||||||
|
this.visibleRegion(ActivityEmbeddingAppHelper.ALWAYS_EXPAND_ACTIVITY_COMPONENT)
|
||||||
|
.coversExactly(startDisplayBounds)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Always expand activity is on top of the split. */
|
||||||
|
@Presubmit
|
||||||
|
@Test
|
||||||
|
fun endsWithAlwaysExpandActivityOnTop() {
|
||||||
|
flicker.assertWmEnd {
|
||||||
|
this.isAppWindowOnTop(
|
||||||
|
ActivityEmbeddingAppHelper.ALWAYS_EXPAND_ACTIVITY_COMPONENT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
/** {@inheritDoc} */
|
||||||
|
private var startDisplayBounds = Rect.EMPTY
|
||||||
|
/**
|
||||||
|
* Creates the test configurations.
|
||||||
|
*
|
||||||
|
* See [FlickerTestFactory.nonRotationTests] for configuring screen orientation and
|
||||||
|
* navigation modes.
|
||||||
|
*/
|
||||||
|
@Parameterized.Parameters(name = "{0}")
|
||||||
|
@JvmStatic
|
||||||
|
fun getParams(): Collection<FlickerTest> {
|
||||||
|
return FlickerTestFactory.nonRotationTests()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -75,6 +75,29 @@ constructor(
|
|||||||
.StateSyncBuilder()
|
.StateSyncBuilder()
|
||||||
.withActivityRemoved(SECONDARY_ACTIVITY_COMPONENT)
|
.withActivityRemoved(SECONDARY_ACTIVITY_COMPONENT)
|
||||||
.waitForAndVerify()
|
.waitForAndVerify()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clicks the button to launch a secondary activity with alwaysExpand enabled, which will launch
|
||||||
|
* a fullscreen window on top of the visible region.
|
||||||
|
*/
|
||||||
|
fun launchAlwaysExpandActivity(wmHelper: WindowManagerStateHelper) {
|
||||||
|
val launchButton =
|
||||||
|
uiDevice.wait(
|
||||||
|
Until.findObject(
|
||||||
|
By.res(getPackage(),
|
||||||
|
"launch_always_expand_activity_button")),
|
||||||
|
FIND_TIMEOUT
|
||||||
|
)
|
||||||
|
require(launchButton != null) {
|
||||||
|
"Can't find launch always expand activity button on screen."
|
||||||
|
}
|
||||||
|
launchButton.click()
|
||||||
|
wmHelper
|
||||||
|
.StateSyncBuilder()
|
||||||
|
.withActivityState(ALWAYS_EXPAND_ACTIVITY_COMPONENT, PlatformConsts.STATE_RESUMED)
|
||||||
|
.withActivityState(MAIN_ACTIVITY_COMPONENT, PlatformConsts.STATE_PAUSED)
|
||||||
|
.waitForAndVerify()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,6 +128,9 @@ constructor(
|
|||||||
val SECONDARY_ACTIVITY_COMPONENT =
|
val SECONDARY_ACTIVITY_COMPONENT =
|
||||||
ActivityOptions.ActivityEmbedding.SecondaryActivity.COMPONENT.toFlickerComponent()
|
ActivityOptions.ActivityEmbedding.SecondaryActivity.COMPONENT.toFlickerComponent()
|
||||||
|
|
||||||
|
val ALWAYS_EXPAND_ACTIVITY_COMPONENT =
|
||||||
|
ActivityOptions.ActivityEmbedding.AlwaysExpandActivity.COMPONENT.toFlickerComponent()
|
||||||
|
|
||||||
val PLACEHOLDER_PRIMARY_COMPONENT =
|
val PLACEHOLDER_PRIMARY_COMPONENT =
|
||||||
ActivityOptions.ActivityEmbedding.PlaceholderPrimaryActivity.COMPONENT
|
ActivityOptions.ActivityEmbedding.PlaceholderPrimaryActivity.COMPONENT
|
||||||
.toFlickerComponent()
|
.toFlickerComponent()
|
||||||
|
|||||||
@@ -197,6 +197,13 @@
|
|||||||
android:theme="@style/CutoutShortEdges"
|
android:theme="@style/CutoutShortEdges"
|
||||||
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout"
|
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout"
|
||||||
android:exported="false"/>
|
android:exported="false"/>
|
||||||
|
<activity
|
||||||
|
android:name=".ActivityEmbeddingAlwaysExpandActivity"
|
||||||
|
android:label="ActivityEmbedding AlwaysExpand"
|
||||||
|
android:taskAffinity="com.android.server.wm.flicker.testapp.ActivityEmbedding"
|
||||||
|
android:theme="@style/CutoutShortEdges"
|
||||||
|
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout"
|
||||||
|
android:exported="false"/>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ActivityEmbeddingPlaceholderPrimaryActivity"
|
android:name=".ActivityEmbeddingPlaceholderPrimaryActivity"
|
||||||
android:label="ActivityEmbedding Placeholder Primary"
|
android:label="ActivityEmbedding Placeholder Primary"
|
||||||
|
|||||||
@@ -37,4 +37,12 @@
|
|||||||
android:onClick="launchPlaceholderSplit"
|
android:onClick="launchPlaceholderSplit"
|
||||||
android:text="Launch Placeholder Split" />
|
android:text="Launch Placeholder Split" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/launch_always_expand_activity_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:onClick="launchAlwaysExpandActivity"
|
||||||
|
android:text="Launch Always Expand Activity" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 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.graphics.Color;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activity with alwaysExpand=true (launched via R.id.launch_always_expand_activity_button)
|
||||||
|
*/
|
||||||
|
public class ActivityEmbeddingAlwaysExpandActivity extends Activity {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_embedding_base_layout);
|
||||||
|
findViewById(R.id.root_activity_layout).setBackgroundColor(Color.GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -23,6 +23,9 @@ import android.util.ArraySet;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.window.embedding.ActivityFilter;
|
||||||
|
import androidx.window.embedding.ActivityRule;
|
||||||
|
import androidx.window.embedding.RuleController;
|
||||||
import androidx.window.extensions.embedding.ActivityEmbeddingComponent;
|
import androidx.window.extensions.embedding.ActivityEmbeddingComponent;
|
||||||
import androidx.window.extensions.embedding.EmbeddingRule;
|
import androidx.window.extensions.embedding.EmbeddingRule;
|
||||||
import androidx.window.extensions.embedding.SplitPairRule;
|
import androidx.window.extensions.embedding.SplitPairRule;
|
||||||
@@ -30,6 +33,7 @@ import androidx.window.extensions.embedding.SplitPlaceholderRule;
|
|||||||
|
|
||||||
import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper;
|
import com.android.server.wm.flicker.helpers.ActivityEmbeddingAppHelper;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/** Main activity of the ActivityEmbedding test app to launch other embedding activities. */
|
/** Main activity of the ActivityEmbedding test app to launch other embedding activities. */
|
||||||
@@ -50,6 +54,23 @@ public class ActivityEmbeddingMainActivity extends Activity {
|
|||||||
ActivityOptions.ActivityEmbedding.SecondaryActivity.COMPONENT));
|
ActivityOptions.ActivityEmbedding.SecondaryActivity.COMPONENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** R.id.launch_always_expand_activity_button onClick */
|
||||||
|
public void launchAlwaysExpandActivity(View view) {
|
||||||
|
final Set<ActivityFilter> activityFilters = new HashSet<>();
|
||||||
|
activityFilters.add(
|
||||||
|
new ActivityFilter(ActivityOptions.ActivityEmbedding.AlwaysExpandActivity.COMPONENT,
|
||||||
|
null));
|
||||||
|
final ActivityRule activityRule = new ActivityRule.Builder(activityFilters)
|
||||||
|
.setAlwaysExpand(true)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
RuleController rc = RuleController.getInstance(this);
|
||||||
|
|
||||||
|
rc.addRule(activityRule);
|
||||||
|
startActivity(new Intent().setComponent(
|
||||||
|
ActivityOptions.ActivityEmbedding.AlwaysExpandActivity.COMPONENT));
|
||||||
|
}
|
||||||
|
|
||||||
/** R.id.launch_placeholder_split_button onClick */
|
/** R.id.launch_placeholder_split_button onClick */
|
||||||
public void launchPlaceholderSplit(View view) {
|
public void launchPlaceholderSplit(View view) {
|
||||||
initializeSplitRules(createSplitPlaceholderRules());
|
initializeSplitRules(createSplitPlaceholderRules());
|
||||||
|
|||||||
@@ -99,6 +99,12 @@ public class ActivityOptions {
|
|||||||
FLICKER_APP_PACKAGE + ".ActivityEmbeddingSecondaryActivity");
|
FLICKER_APP_PACKAGE + ".ActivityEmbeddingSecondaryActivity");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class AlwaysExpandActivity {
|
||||||
|
public static final String LABEL = "ActivityEmbeddingAlwaysExpandActivity";
|
||||||
|
public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE,
|
||||||
|
FLICKER_APP_PACKAGE + ".ActivityEmbeddingAlwaysExpandActivity");
|
||||||
|
}
|
||||||
|
|
||||||
public static class PlaceholderPrimaryActivity {
|
public static class PlaceholderPrimaryActivity {
|
||||||
public static final String LABEL = "ActivityEmbeddingPlaceholderPrimaryActivity";
|
public static final String LABEL = "ActivityEmbeddingPlaceholderPrimaryActivity";
|
||||||
public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE,
|
public static final ComponentName COMPONENT = new ComponentName(FLICKER_APP_PACKAGE,
|
||||||
|
|||||||
Reference in New Issue
Block a user