androidx.window.testing.embedding


Classes

ActivityEmbeddingRule

A TestRule that will stub out the behavior of ActivityEmbeddingController and RuleController with a more simple one that will support testing independent of the current platform.

Top-level functions summary

ActivityStack
TestActivityStack(activitiesInProcess: List<Activity>, isEmpty: Boolean)

Creates an ActivityStack instance for testing.

SplitAttributesCalculatorParams
TestSplitAttributesCalculatorParams(
    parentWindowMetrics: WindowMetrics,
    parentConfiguration: Configuration,
    parentWindowLayoutInfo: WindowLayoutInfo,
    defaultSplitAttributes: SplitAttributes,
    areDefaultConstraintsSatisfied: Boolean,
    splitRuleTag: String?
)

Returns an instance of SplitAttributesCalculatorParams for testing.

SplitInfo
TestSplitInfo(
    primaryActivityStack: ActivityStack,
    secondActivityStack: ActivityStack,
    splitAttributes: SplitAttributes
)

Creates a SplitInfo instance for testing.

Top-level functions

TestActivityStack

fun TestActivityStack(
    activitiesInProcess: List<Activity> = emptyList(),
    isEmpty: Boolean = false
): ActivityStack

Creates an ActivityStack instance for testing. The default values are an empty list for activitiesInProcess but a false value for isEmpty. This is the same as being embedded with an Activity from another process.

Parameters
activitiesInProcess: List<Activity> = emptyList()

The Activity list with the same process of the host task with empty list as the default value.

isEmpty: Boolean = false

Indicates whether this ActivityStack contains any Activity regardless of the process with false as the default value.

Returns
ActivityStack

An ActivityStack instance for testing.

TestSplitAttributesCalculatorParams

fun TestSplitAttributesCalculatorParams(
    parentWindowMetrics: WindowMetrics,
    parentConfiguration: Configuration = Configuration(),
    parentWindowLayoutInfo: WindowLayoutInfo = WindowLayoutInfo(Collections.emptyList()),
    defaultSplitAttributes: SplitAttributes = SplitAttributes.Builder().build(),
    areDefaultConstraintsSatisfied: Boolean = true,
    splitRuleTag: String? = null
): SplitAttributesCalculatorParams

Returns an instance of SplitAttributesCalculatorParams for testing. It is used to verify the developer implemented callback set by SplitController.setSplitAttributesCalculator by setting the relevant values in SplitAttributesCalculatorParams with this method.

Parameters
parentWindowMetrics: WindowMetrics

The WindowMetrics of the host task. See SplitAttributesCalculatorParams.parentWindowMetrics.

parentConfiguration: Configuration = Configuration()

The Configuration of the host task with empty Configuration as the default value. See SplitAttributesCalculatorParams.parentConfiguration

parentWindowLayoutInfo: WindowLayoutInfo = WindowLayoutInfo(Collections.emptyList())

Used for reporting the androidx.window.layout.FoldingFeature with empty WindowLayoutInfo as the default value. See androidx.window.testing.layout.TestWindowLayoutInfo and androidx.window.testing.layout.FoldingFeature for how to create test WindowLayoutInfo with androidx.window.layout.FoldingFeature.

defaultSplitAttributes: SplitAttributes = SplitAttributes.Builder().build()

The SplitPairRule.defaultSplitAttributes or the SplitPlaceholderRule.defaultSplitAttributes that the callback is applied a vertical equal SplitAttributes as the default value. See SplitAttributesCalculatorParams.defaultSplitAttributes

areDefaultConstraintsSatisfied: Boolean = true

true to indicate that the parentWindowMetrics satisfies the constraints of SplitPairRule or SplitPlaceholderRule which defaults to true. See SplitAttributesCalculatorParams.areDefaultConstraintsSatisfied

splitRuleTag: String? = null

The SplitPairRule.tag or the SplitPlaceholderRule.tag that the callback is applied with null as the default value. See SplitAttributesCalculatorParams.splitRuleTag.

TestSplitInfo

fun TestSplitInfo(
    primaryActivityStack: ActivityStack = TestActivityStack(),
    secondActivityStack: ActivityStack = TestActivityStack(),
    splitAttributes: SplitAttributes = SplitAttributes.Builder().build()
): SplitInfo

Creates a SplitInfo instance for testing.

It is suggested to construct primaryActivityStack and secondActivityStack by TestActivityStack, and splitAttributes by SplitAttributes.Builder APIs

Parameters
primaryActivityStack: ActivityStack = TestActivityStack()

The primary ActivityStack with an empty ActivityStack as the default value.

secondActivityStack: ActivityStack = TestActivityStack()

The secondary ActivityStack with an empty ActivityStack as the default value.

splitAttributes: SplitAttributes = SplitAttributes.Builder().build()

The current SplitAttributes for this test split, which defaults to split equally with layout direction SplitAttributes.LayoutDirection.LOCALE.

Returns
SplitInfo

A SplitInfo instance for testing