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

Commit 2ba67434 authored by Vincent Wang's avatar Vincent Wang Committed by Android (Google) Code Review
Browse files

Merge "[Flicker tests for bubbles]"

parents 2f9962d6 96d24e35
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.app.NotificationManager
import android.content.Context
import android.os.ServiceManager
import android.view.Surface
import androidx.test.filters.FlakyTest
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiObject2
@@ -34,7 +33,6 @@ import com.android.server.wm.flicker.dsl.FlickerBuilder
import com.android.server.wm.flicker.helpers.SYSTEMUI_PACKAGE
import com.android.server.wm.flicker.repetitions
import com.android.wm.shell.flicker.helpers.LaunchBubbleHelper
import org.junit.Test
import org.junit.runners.Parameterized

/**
@@ -86,14 +84,6 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) {
        }
    }

    @FlakyTest
    @Test
    fun testAppIsAlwaysVisible() {
        testSpec.assertLayers {
            this.isVisible(testApp.component)
        }
    }

    @FlickerBuilderProvider
    fun buildFlicker(): FlickerBuilder {
        return FlickerBuilder(instrumentation).apply {
@@ -112,6 +102,7 @@ abstract class BaseBubbleScreen(protected val testSpec: FlickerTestParameter) {
        }

        const val FIND_OBJECT_TIMEOUT = 2000L
        const val WINDOW_UPDAT_TIMEOUT = 2000L
        const val SYSTEM_UI_PACKAGE = SYSTEMUI_PACKAGE
        const val BUBBLE_RES_NAME = "bubble_view"
    }
+10 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context
import android.graphics.Point
import android.util.DisplayMetrics
import android.view.WindowManager
import androidx.test.filters.FlakyTest
import androidx.test.filters.RequiresDevice
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
@@ -28,6 +29,7 @@ import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.annotation.Group4
import com.android.server.wm.flicker.dsl.FlickerBuilder
import org.junit.runner.RunWith
import org.junit.Test
import org.junit.runners.Parameterized

/**
@@ -62,4 +64,12 @@ class DismissBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen(tes
                showBubble?.run { drag(dist, 1000) } ?: error("Show bubble not found")
            }
        }

    @FlakyTest
    @Test
    fun testAppIsAlwaysVisible() {
        testSpec.assertLayers {
            this.isVisible(testApp.component)
        }
    }
}
+10 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.wm.shell.flicker.bubble

import androidx.test.filters.FlakyTest
import androidx.test.filters.RequiresDevice
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
@@ -24,6 +25,7 @@ import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.annotation.Group4
import com.android.server.wm.flicker.dsl.FlickerBuilder
import org.junit.runner.RunWith
import org.junit.Test
import org.junit.runners.Parameterized

/**
@@ -53,7 +55,14 @@ class ExpandBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen(test
                val showBubble = device.wait(Until.findObject(
                        By.res("com.android.systemui", "bubble_view")), FIND_OBJECT_TIMEOUT)
                showBubble?.run { showBubble.click() } ?: error("Bubble notify not found")
                device.pressBack()
            }
        }

    @FlakyTest
    @Test
    fun testAppIsAlwaysVisible() {
        testSpec.assertLayers {
            this.isVisible(testApp.component)
        }
    }
}
+76 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.bubble

import android.os.SystemClock
import androidx.test.filters.FlakyTest
import androidx.test.filters.RequiresDevice
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import com.android.server.wm.flicker.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.annotation.Group4
import com.android.server.wm.flicker.dsl.FlickerBuilder
import org.junit.runner.RunWith
import org.junit.Test
import org.junit.runners.Parameterized

/**
 * Test launching a new activity from bubble.
 *
 * To run this test: `atest WMShellFlickerTests:LaunchBubbleFromLockScreen`
 *
 * Actions:
 *     Launch an bubble from notification on lock screen
 */
@RequiresDevice
@RunWith(Parameterized::class)
@Parameterized.UseParametersRunnerFactory(FlickerParametersRunnerFactory::class)
@Group4
class LaunchBubbleFromLockScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen(testSpec) {

    override val transition: FlickerBuilder.(Map<String, Any?>) -> Unit
        get() = buildTransition() {
            setup {
                eachRun {
                    addBubbleBtn?.click() ?: error("Bubble widget not found")
                    device.sleep()
                    SystemClock.sleep(2000)
                    device.wakeUp()
                }
            }
            transitions {
                val notification = device.wait(Until.findObject(
                    By.text("BubbleChat")), FIND_OBJECT_TIMEOUT)
                notification?.click() ?: error("Notification not found")
                instrumentation.getUiAutomation().syncInputTransactions()
                val showBubble = device.wait(Until.findObject(
                        By.res("com.android.systemui", "bubble_view")), FIND_OBJECT_TIMEOUT)
                showBubble?.click() ?: error("Bubble notify not found")
                instrumentation.getUiAutomation().syncInputTransactions()
                cancelAllBtn?.click() ?: error("Cancel widget not found")
            }
        }

    @FlakyTest
    @Test
    fun testAppisVisibleAtEnd() {
        testSpec.assertLayersEnd {
            this.isVisible(testApp.component)
        }
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -16,12 +16,14 @@

package com.android.wm.shell.flicker.bubble

import androidx.test.filters.FlakyTest
import androidx.test.filters.RequiresDevice
import com.android.server.wm.flicker.FlickerParametersRunnerFactory
import com.android.server.wm.flicker.FlickerTestParameter
import com.android.server.wm.flicker.annotation.Group4
import com.android.server.wm.flicker.dsl.FlickerBuilder
import org.junit.runner.RunWith
import org.junit.Test
import org.junit.runners.Parameterized

/**
@@ -45,4 +47,12 @@ class LaunchBubbleScreen(testSpec: FlickerTestParameter) : BaseBubbleScreen(test
                addBubbleBtn?.run { addBubbleBtn.click() } ?: error("Bubble widget not found")
            }
        }

    @FlakyTest
    @Test
    fun testAppIsAlwaysVisible() {
        testSpec.assertLayers {
            this.isVisible(testApp.component)
        }
    }
}
Loading