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

Commit 5b3ec3e4 authored by Jeremie Boulic's avatar Jeremie Boulic Committed by Android (Google) Code Review
Browse files

Merge "[DocsUI] Fix functional tests failures related to PeekBot dependency" into main

parents 48eeafb8 a66e0702
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ public final class Bots {
    public final UiBot main;
    public final InspectorBot inspector;
    public final NotificationsBot notifications;
    public final PeekBot peek;

    public Bots(UiDevice device, UiAutomation automation, Context context, int timeout) {
        main = new UiBot(device, context, TIMEOUT);
@@ -64,7 +63,6 @@ public final class Bots {
        menu = new MenuBot(device, context, TIMEOUT);
        inspector = new InspectorBot(device, context, TIMEOUT);
        notifications = new NotificationsBot(device, context, TIMEOUT);
        peek = new PeekBot(device, context, TIMEOUT);
    }

    /**
+17 −8
Original line number Diff line number Diff line
@@ -29,10 +29,12 @@ import androidx.test.uiautomator.UiObject2
import androidx.test.uiautomator.Until
import com.android.documentsui.ActivityTestJunit4
import com.android.documentsui.StubProvider
import com.android.documentsui.bots.PeekBot
import com.android.documentsui.files.FilesActivity
import com.android.documentsui.flags.Flags
import com.android.documentsui.rules.TestFilesRule
import junit.framework.Assert
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -49,30 +51,37 @@ class PeekUiTest : ActivityTestJunit4<FilesActivity?>() {
            .createFileInRoot(StubProvider.ROOT_0_ID, "image.png", "image/png")
            .createFileInRoot(StubProvider.ROOT_0_ID, "file0.log", "text/plain")

    private lateinit var peekBot: PeekBot

    @Before
    fun setUpTest() {
        peekBot = PeekBot(device!!, context!!, TIMEOUT)
    }

    fun validatePeekContents(fileName: String) {
        bots!!.peek.assertPeekActive()
        bots!!.peek.assertHasTitle(fileName)
        peekBot.assertPeekActive()
        peekBot.assertHasTitle(fileName)
    }

    @Test
    @Throws(Exception::class)
    fun testSequentialFilePreview() {
        bots!!.peek.assertPeekHidden()
        peekBot.assertPeekHidden()
        bots!!.directory.selectDocument("image.png")
        bots!!.main.clickActionItem("Get info")
        validatePeekContents("image.png")
        bots!!.peek.hide()
        peekBot.hide()

        bots!!.directory.selectDocument("file0.log")
        bots!!.main.clickActionItem("Get info")
        validatePeekContents("file0.log")
        bots!!.peek.hide()
        peekBot.hide()
    }

    @Test
    @Throws(Exception::class)
    fun testFileCantBeSelectedDuringFilePreview() {
        bots!!.peek.assertPeekHidden()
        peekBot.assertPeekHidden()
        // Selecting a document should show the "1 selected" label.
        bots!!.directory.selectDocument("image.png", 1)
        bots!!.main.clickActionItem("Get info")
@@ -98,9 +107,9 @@ class PeekUiTest : ActivityTestJunit4<FilesActivity?>() {
        mActivityScenario!!.recreate()
        validatePeekContents("image.png")

        bots!!.peek.hide()
        peekBot.hide()
        mActivityScenario!!.recreate()
        bots!!.peek.assertPeekHidden()
        peekBot.assertPeekHidden()

        bots!!.directory.selectDocument("file0.log")
        bots!!.main.clickActionItem("Get info")