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

Commit c40cc07c authored by Ben Reich's avatar Ben Reich
Browse files

Convert InternalStorageUiTest to Junit 4

This also allows for access to the underlying userId from
ActivityTestJunit4 and updates the click on the delete dialog to use
the non-soft keyboard closing method.

Bug: 407646510
Test: atest com.android.documentsui.InternalStorageUiTest
Flag: EXEMPT test change
Change-Id: I3a97a40b89ae65e15f0f22ef9954099bab8c8ff5
parent 69c54cf6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -53,7 +53,9 @@ abstract class ActivityTestJunit4<T : Activity?> {

    @JvmField
    var context: Context? = null
    var userId: UserId? = null

    @JvmField
    protected var userId: UserId? = null
    var automation: UiAutomation? = null

    @JvmField
+14 −14
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.documentsui;

import static org.junit.Assert.assertNull;

import androidx.test.filters.LargeTest;

import com.android.documentsui.base.Providers;
@@ -23,26 +25,24 @@ import com.android.documentsui.base.RootInfo;
import com.android.documentsui.files.FilesActivity;
import com.android.documentsui.filters.HugeLongTest;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * A Ui test will do tests in the internal storage root. It is implemented because some operations
 * is failed and its result will different from the test on the StubProvider. b/115304092 is a
 * example which only happen on root from ExternalStorageProvidrer.
 * example which only happen on root from ExternalStorageProvider.
 */
@LargeTest
public class InternalStorageUiTest extends ActivityTest<FilesActivity> {
public class InternalStorageUiTest extends ActivityTestJunit4<FilesActivity> {

    private static final String fileName = "!Test3345678";
    private static final String newFileName = "!9527Test";
    private RootInfo rootPrimary;

    public InternalStorageUiTest() {
        super(FilesActivity.class);
    }

    @Override
    public void setUp() throws Exception {
        super.setUp();

    @Before
    public void setUpTest() throws Exception {
        mDocsHelper = new DocumentsProviderHelper(userId, Providers.AUTHORITY_STORAGE, context,
                Providers.AUTHORITY_STORAGE);
        rootPrimary = mDocsHelper.getRoot(Providers.ROOT_ID_DEVICE);
@@ -51,13 +51,13 @@ public class InternalStorageUiTest extends ActivityTest<FilesActivity> {
        deleteTestFiles();
    }

    @Override
    public void tearDown() throws Exception {
    @After
    public void tearDownTest() throws Exception {
        deleteTestFiles();
        super.tearDown();
    }

    @HugeLongTest
    @Test
    public void testRenameFile() throws Exception {
        createTestFiles();

@@ -97,7 +97,7 @@ public class InternalStorageUiTest extends ActivityTest<FilesActivity> {
        if (selected) {
            bots.main.clickDelete();
            device.waitForIdle();
            bots.main.clickDialogOkButton();
            bots.main.clickNonTextDialogOkButton();
        }
    }
}