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

Commit 143d584e authored by Nataniel Borges's avatar Nataniel Borges
Browse files

Compatibilize tests with new runner

Runner now prints each assertion individually to aid debugging.

Bug: 162923992
Test: atest FlickerTests WMShellFlickerTests
Change-Id: I1c9a49ec3c283e5e034f0223573fca3ccafaf64c
parent 930915c2
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -11,8 +11,6 @@
        <option name="force-skip-system-props" value="true" />
        <!-- set WM tracing verbose level to all -->
        <option name="run-command" value="cmd window tracing level all" />
        <!-- inform WM to log all transactions -->
        <option name="run-command" value="cmd window tracing transaction" />
        <!-- restart launcher to activate TAPL -->
        <option name="run-command" value="setprop ro.test_harness 1 ; am force-stop com.google.android.apps.nexuslauncher" />
    </target_preparer>
+34 −61
Original line number Diff line number Diff line
@@ -18,59 +18,59 @@ package com.android.wm.shell.flicker

import android.graphics.Region
import android.view.Surface
import com.android.server.wm.flicker.dsl.EventLogAssertion
import com.android.server.wm.flicker.dsl.LayersAssertion
import com.android.server.wm.flicker.dsl.LayersAssertionBuilder
import com.android.server.wm.flicker.helpers.WindowUtils
import com.android.server.wm.flicker.traces.layers.getVisibleBounds
import com.android.wm.shell.flicker.FlickerTestBase.Companion.DOCKED_STACK_DIVIDER

@JvmOverloads
fun LayersAssertion.appPairsDividerIsVisible(
fun LayersAssertionBuilder.appPairsDividerIsVisible(
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    end("appPairsDividerIsVisible", bugId, enabled) {
        this.showsLayer(FlickerTestBase.APP_PAIR_SPLIT_DIVIDER)
        this.isVisible(FlickerTestBase.APP_PAIR_SPLIT_DIVIDER)
    }
}

@JvmOverloads
fun LayersAssertion.appPairsDividerIsInvisible(
fun LayersAssertionBuilder.appPairsDividerIsInvisible(
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    end("appPairsDividerIsInVisible", bugId, enabled) {
        this.hasNotLayer(FlickerTestBase.APP_PAIR_SPLIT_DIVIDER)
        this.notExists(FlickerTestBase.APP_PAIR_SPLIT_DIVIDER)
    }
}

@JvmOverloads
fun LayersAssertion.appPairsDividerBecomesVisible(
fun LayersAssertionBuilder.appPairsDividerBecomesVisible(
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    all("dividerLayerBecomesVisible") {
        this.hidesLayer(FlickerTestBase.DOCKED_STACK_DIVIDER)
    all("dividerLayerBecomesVisible", bugId, enabled) {
        this.hidesLayer(DOCKED_STACK_DIVIDER)
                .then()
                .showsLayer(FlickerTestBase.DOCKED_STACK_DIVIDER)
                .showsLayer(DOCKED_STACK_DIVIDER)
    }
}

@JvmOverloads
fun LayersAssertion.dockedStackDividerIsVisible(
fun LayersAssertionBuilder.dockedStackDividerIsVisible(
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    end("dockedStackDividerIsVisible", bugId, enabled) {
        this.showsLayer(FlickerTestBase.DOCKED_STACK_DIVIDER)
        this.isVisible(DOCKED_STACK_DIVIDER)
    }
}

@JvmOverloads
fun LayersAssertion.dockedStackDividerBecomesVisible(
fun LayersAssertionBuilder.dockedStackDividerBecomesVisible(
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    all("dividerLayerBecomesVisible") {
    all("dividerLayerBecomesVisible", bugId, enabled) {
        this.hidesLayer(DOCKED_STACK_DIVIDER)
                .then()
                .showsLayer(DOCKED_STACK_DIVIDER)
@@ -78,11 +78,11 @@ fun LayersAssertion.dockedStackDividerBecomesVisible(
}

@JvmOverloads
fun LayersAssertion.dockedStackDividerBecomesInvisible(
fun LayersAssertionBuilder.dockedStackDividerBecomesInvisible(
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    all("dividerLayerBecomesInvisible") {
    all("dividerLayerBecomesInvisible", bugId, enabled) {
        this.showsLayer(DOCKED_STACK_DIVIDER)
                .then()
                .hidesLayer(DOCKED_STACK_DIVIDER)
@@ -90,71 +90,63 @@ fun LayersAssertion.dockedStackDividerBecomesInvisible(
}

@JvmOverloads
fun LayersAssertion.dockedStackDividerIsInvisible(
fun LayersAssertionBuilder.dockedStackDividerIsInvisible(
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    end("dockedStackDividerIsInvisible", bugId, enabled) {
        this.hasNotLayer(FlickerTestBase.DOCKED_STACK_DIVIDER)
        this.notExists(DOCKED_STACK_DIVIDER)
    }
}

@JvmOverloads
fun LayersAssertion.appPairsPrimaryBoundsIsVisible(
fun LayersAssertionBuilder.appPairsPrimaryBoundsIsVisible(
    rotation: Int,
    primaryLayerName: String,
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    end("PrimaryAppBounds", bugId, enabled) {
        val entry = this.trace.entries.firstOrNull()
                ?: throw IllegalStateException("Trace is empty")
        val dividerRegion = entry.getVisibleBounds(FlickerTestBase.APP_PAIR_SPLIT_DIVIDER)
        this.hasVisibleRegion(primaryLayerName, getPrimaryRegion(dividerRegion, rotation))
    }
}

@JvmOverloads
fun LayersAssertion.appPairsSecondaryBoundsIsVisible(
fun LayersAssertionBuilder.appPairsSecondaryBoundsIsVisible(
    rotation: Int,
    secondaryLayerName: String,
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    end("SecondaryAppBounds", bugId, enabled) {
        val entry = this.trace.entries.firstOrNull()
                ?: throw IllegalStateException("Trace is empty")
        val dividerRegion = entry.getVisibleBounds(FlickerTestBase.APP_PAIR_SPLIT_DIVIDER)
        this.hasVisibleRegion(secondaryLayerName, getSecondaryRegion(dividerRegion, rotation))
    }
}

@JvmOverloads
fun LayersAssertion.dockedStackPrimaryBoundsIsVisible(
fun LayersAssertionBuilder.dockedStackPrimaryBoundsIsVisible(
    rotation: Int,
    primaryLayerName: String,
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    end("PrimaryAppBounds", bugId, enabled) {
        val entry = this.trace.entries.firstOrNull()
                ?: throw IllegalStateException("Trace is empty")
        val dividerRegion = entry.getVisibleBounds(FlickerTestBase.DOCKED_STACK_DIVIDER)
        val dividerRegion = entry.getVisibleBounds(DOCKED_STACK_DIVIDER)
        this.hasVisibleRegion(primaryLayerName, getPrimaryRegion(dividerRegion, rotation))
    }
}

@JvmOverloads
fun LayersAssertion.dockedStackSecondaryBoundsIsVisible(
fun LayersAssertionBuilder.dockedStackSecondaryBoundsIsVisible(
    rotation: Int,
    secondaryLayerName: String,
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    end("SecondaryAppBounds", bugId, enabled) {
        val entry = this.trace.entries.firstOrNull()
                ?: throw IllegalStateException("Trace is empty")
        val dividerRegion = entry.getVisibleBounds(FlickerTestBase.DOCKED_STACK_DIVIDER)
        val dividerRegion = entry.getVisibleBounds(DOCKED_STACK_DIVIDER)
        this.hasVisibleRegion(secondaryLayerName, getSecondaryRegion(dividerRegion, rotation))
    }
}
@@ -162,11 +154,11 @@ fun LayersAssertion.dockedStackSecondaryBoundsIsVisible(
fun getPrimaryRegion(dividerRegion: Region, rotation: Int): Region {
    val displayBounds = WindowUtils.getDisplayBounds(rotation)
    return if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) {
        Region(0, 0, displayBounds.getBounds().right,
                dividerRegion.getBounds().bottom - WindowUtils.dockedStackDividerInset)
        Region(0, 0, displayBounds.bounds.right,
                dividerRegion.bounds.bottom - WindowUtils.dockedStackDividerInset)
    } else {
        Region(0, 0, dividerRegion.getBounds().left,
                dividerRegion.getBounds().right - WindowUtils.dockedStackDividerInset)
        Region(0, 0, dividerRegion.bounds.left,
                dividerRegion.bounds.right - WindowUtils.dockedStackDividerInset)
    }
}

@@ -174,31 +166,12 @@ fun getSecondaryRegion(dividerRegion: Region, rotation: Int): Region {
    val displayBounds = WindowUtils.getDisplayBounds(rotation)
    return if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) {
        Region(0,
                dividerRegion.getBounds().bottom - WindowUtils.dockedStackDividerInset,
                displayBounds.getBounds().right,
                displayBounds.getBounds().bottom - WindowUtils.dockedStackDividerInset)
                dividerRegion.bounds.bottom - WindowUtils.dockedStackDividerInset,
                displayBounds.bounds.right,
                displayBounds.bounds.bottom - WindowUtils.dockedStackDividerInset)
    } else {
        Region(dividerRegion.getBounds().right, 0,
                displayBounds.getBounds().right,
                displayBounds.getBounds().bottom - WindowUtils.dockedStackDividerInset)
    }
}

fun EventLogAssertion.focusChanges(
    vararg windows: String,
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    all(enabled = enabled, bugId = bugId) {
        this.focusChanges(windows)
    }
}

fun EventLogAssertion.focusDoesNotChange(
    bugId: Int = 0,
    enabled: Boolean = bugId == 0
) {
    all(enabled = enabled, bugId = bugId) {
        this.focusDoesNotChange()
        Region(dividerRegion.bounds.right, 0,
                displayBounds.bounds.right,
                displayBounds.bounds.bottom - WindowUtils.dockedStackDividerInset)
    }
}
+0 −24
Original line number Diff line number Diff line
@@ -17,28 +17,4 @@
package com.android.wm.shell.flicker

const val IME_WINDOW_NAME = "InputMethod"
const val PIP_MENU_WINDOW_NAME = "PipMenuActivity"

const val SYSTEM_UI_PACKAGE_NAME = "com.android.systemui"
const val TEST_APP_PACKAGE_NAME = "com.android.wm.shell.flicker.testapp"

// Test App > Pip Activity
const val TEST_APP_PIP_ACTIVITY_LABEL = "PipApp"
const val TEST_APP_PIP_MENU_ACTION_NO_OP = "No-Op"
const val TEST_APP_PIP_MENU_ACTION_ON = "On"
const val TEST_APP_PIP_MENU_ACTION_OFF = "Off"
const val TEST_APP_PIP_MENU_ACTION_CLEAR = "Clear"

// Test App > Ime Activity
const val TEST_APP_IME_ACTIVITY_LABEL = "ImeApp"
const val TEST_APP_IME_ACTIVITY_ACTION_OPEN_IME =
        "com.android.wm.shell.flicker.testapp.action.OPEN_IME"
const val TEST_APP_IME_ACTIVITY_ACTION_CLOSE_IME =
        "com.android.wm.shell.flicker.testapp.action.CLOSE_IME"
// Test App > Test Activity
const val TEST_APP_FIXED_ACTIVITY_LABEL = "FixedApp"

// Test App > SplitScreen Activity
const val TEST_APP_SPLITSCREEN_PRIMARY_LABEL = "SplitScreenPrimaryApp"
const val TEST_APP_SPLITSCREEN_SECONDARY_LABEL = "SplitScreenSecondaryApp"
const val TEST_APP_NONRESIZEABLE_LABEL = "NonResizeableApp"
+1 −6
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.server.wm.flicker.navBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.navBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.statusBarLayerIsAlwaysVisible
import com.android.server.wm.flicker.statusBarWindowIsAlwaysVisible
import com.android.server.wm.flicker.traces.layers.getVisibleBounds
import com.android.wm.shell.flicker.appPairsDividerIsInvisible
import com.android.wm.shell.flicker.appPairsDividerIsVisible
import com.android.wm.shell.flicker.helpers.AppPairsHelper
@@ -110,7 +111,6 @@ class AppPairsTest(
                        val dividerRegion = entry.getVisibleBounds(APP_PAIR_SPLIT_DIVIDER)
                        this.hasVisibleRegion(primaryApp.defaultWindowName,
                                appPairsHelper.getPrimaryBounds(dividerRegion))
                                .and()
                                .hasVisibleRegion(secondaryApp.defaultWindowName,
                                        appPairsHelper.getSecondaryBounds(dividerRegion))
                    }
@@ -118,7 +118,6 @@ class AppPairsTest(
                windowManagerTrace {
                    end {
                        showsAppWindow(primaryApp.defaultWindowName)
                                .and()
                                .showsAppWindow(secondaryApp.defaultWindowName)
                    }
                }
@@ -154,20 +153,17 @@ class AppPairsTest(
                        val dividerRegion = entry.getVisibleBounds(APP_PAIR_SPLIT_DIVIDER)
                        this.hasVisibleRegion(primaryApp.defaultWindowName,
                                appPairsHelper.getPrimaryBounds(dividerRegion))
                                .and()
                                .hasVisibleRegion(secondaryApp.defaultWindowName,
                                        appPairsHelper.getSecondaryBounds(dividerRegion))
                    }
                    end("appsEndingBounds", enabled = false) {
                        this.hasNotLayer(primaryApp.defaultWindowName)
                                .and()
                                .hasNotLayer(secondaryApp.defaultWindowName)
                    }
                }
                windowManagerTrace {
                    end {
                        hidesAppWindow(primaryApp.defaultWindowName)
                                .and()
                                .hidesAppWindow(secondaryApp.defaultWindowName)
                    }
                }
@@ -197,7 +193,6 @@ class AppPairsTest(
                windowManagerTrace {
                    end {
                        showsAppWindow(nonResizeableApp.defaultWindowName)
                            .and()
                            .hidesAppWindow(primaryApp.defaultWindowName)
                    }
                }
+2 −2
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ class RotateTwoLaunchedAppTest(
                    statusBarWindowIsAlwaysVisible()
                    end {
                        showsAppWindow(primaryApp.defaultWindowName)
                                .and().showsAppWindow(secondaryApp.defaultWindowName)
                                .showsAppWindow(secondaryApp.defaultWindowName)
                    }
                }
            }
@@ -137,7 +137,7 @@ class RotateTwoLaunchedAppTest(
                    statusBarWindowIsAlwaysVisible()
                    end {
                        showsAppWindow(primaryApp.defaultWindowName)
                                .and().showsAppWindow(secondaryApp.defaultWindowName)
                                .showsAppWindow(secondaryApp.defaultWindowName)
                    }
                }
            }
Loading