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

Commit ce61e43e authored by Omar Elmekkawy's avatar Omar Elmekkawy Committed by Android (Google) Code Review
Browse files

Merge "Add tiling flickr test to break tiling by dragging." into main

parents 6efeb791 f8d69b84
Loading
Loading
Loading
Loading
+71 −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.flicker.tiling

import android.tools.NavBar
import android.tools.flicker.FlickerBuilder
import android.tools.flicker.FlickerTest
import android.tools.flicker.FlickerTestFactory
import android.tools.flicker.assertions.FlickerChecker
import android.tools.flicker.junit.FlickerParametersRunnerFactory
import androidx.test.filters.RequiresDevice
import com.android.wm.shell.Utils
import com.android.wm.shell.flicker.DesktopModeBaseTest
import com.android.wm.shell.flicker.utils.tilingDividerIsInvisibleAtEnd
import com.android.wm.shell.flicker.utils.tilingDividerIsVisibleAtStart
import com.android.wm.shell.scenarios.TileResizingWithDrag
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized

/** Ensures tiling is broken when a tiled header is dragged. */
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
class TilingPairBrokenWhenDraggingHeader(flicker: FlickerTest) : DesktopModeBaseTest(flicker) {
    inner class TileResizingWithDragScenario : TileResizingWithDrag(flicker.scenario.startRotation)

    @Rule
    @JvmField
    val testSetupRule = Utils.testSetupRule(NavBar.MODE_GESTURAL, flicker.scenario.startRotation)
    val scenario = TileResizingWithDragScenario()

    override val transition: FlickerBuilder.() -> Unit
        get() = {
            setup {
                scenario.setup()
                scenario.snapTileAppsWithDrag()
            }
            transitions { scenario.dragLeftAppHeaderToRight() }
            teardown { scenario.teardown() }
        }

    @Test fun dividerInvisibleAtStart() = flicker.tilingDividerIsVisibleAtStart()

    @Test fun dividerBecomesVisibleAtEnd() = flicker.tilingDividerIsInvisibleAtEnd()

    companion object {
        @Parameterized.Parameters(name = "{0}")
        @JvmStatic
        fun getParams(): Collection<FlickerChecker> {
            return FlickerTestFactory.nonRotationTests(
                supportedNavigationModes = listOf(NavBar.MODE_GESTURAL)
            )
        }
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -98,6 +98,10 @@ abstract class TileResizingWithDrag(
        device.drag(startX, startY, endX, startY, 100)
    }

    fun dragLeftAppHeaderToRight() {
        leftTestApp.dragRight(wmHelper, device, 100)
    }

    private fun getDisplayRect(): Rect =
        wmHelper.currentState.wmState.getDefaultDisplay()?.displayRect
            ?: throw IllegalStateException("Default display is null")
+17 −0
Original line number Diff line number Diff line
@@ -535,6 +535,23 @@ open class DesktopModeAppHelper(private val innerHelper: StandardAppHelper) :
            .waitForAndVerify()
    }

    fun dragRight(wmHelper: WindowManagerStateHelper, device: UiDevice, distance: Int) {
        val windowRect = wmHelper.getWindowRegion(innerHelper).bounds
        // Set start x-coordinate as center of app header.
        val startX = windowRect.centerX()
        val startY = windowRect.top

        val endX = startX + distance
        val endY = startY + distance

        // drag the window to to the right by [distance].
        device.drag(startX, startY, endX, endY, /* steps= */ 100)
        wmHelper
            .StateSyncBuilder()
            .withAppTransitionIdle()
            .waitForAndVerify()
    }

    private fun getStartCoordinatesForCornerResize(
        windowRect: Rect,
        corner: Corners