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

Commit b18a526e authored by Ben Lin's avatar Ben Lin
Browse files

Fix tests that were broken when running on ARC++ devices.

AuthUI test does not apply to ARC++ devices (The API isn't there), so it
is now an no-op.
RecentsLoaderTest calls on the underlying new query method introduced in
O if feature is on; TestFeatures had everything on by default. Passing
mEnv.features will now enable/disable features according to the device
the tests are running on.

Bug: 37962414
Bug: 37358647
Change-Id: If996c138e74ae0cdb0c8c40ab3eccd5e764bb33b
parent 8c465e98
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.support.test.uiautomator.UiObjectNotFoundException;
import android.test.ActivityInstrumentationTestCase2;
import android.view.MotionEvent;

import com.android.documentsui.base.Features;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.bots.Bots;
import com.android.documentsui.bots.UiBot;
@@ -61,6 +62,7 @@ public abstract class ActivityTest<T extends Activity> extends ActivityInstrumen
    public Context context;
    public UiAutomation automation;

    public Features features;
    public RootInfo rootDir0;
    public RootInfo rootDir1;
    protected ContentResolver mResolver;
@@ -104,6 +106,7 @@ public abstract class ActivityTest<T extends Activity> extends ActivityInstrumen
        // NOTE: Must be the "target" context, else security checks in content provider will fail.
        context = getInstrumentation().getTargetContext();
        automation = getInstrumentation().getUiAutomation();
        features = new Features.RuntimeFeatures(context.getResources(), null);

        bots = new Bots(device, automation, context, TIMEOUT);

+8 −5
Original line number Diff line number Diff line
@@ -62,11 +62,14 @@ public class FilesActivityUiTest extends ActivityTest<FilesActivity> {
    }

    public void testProtectedFolder_showsAuthenticationUi() throws Exception {
        // If feature is disabled, this test is a no-op.
        if (features.isRemoteActionsEnabled()) {
            bots.roots.openRoot("Demo Root");
            bots.main.switchToListMode();
            bots.directory.openDocument("throw a authentication exception");
            bots.directory.assertHeaderMessageText(
                    "To view this directory, sign in to DocumentsUI Tests");
        }

    }

+1 −3
Original line number Diff line number Diff line
@@ -43,19 +43,17 @@ public class RecentsLoaderTests {
    private TestEnv mEnv;
    private TestActivity mActivity;
    private RecentsLoader mLoader;
    private TestFeatures mFeatures;

    @Before
    public void setUp() {
        mEnv = TestEnv.create();
        mActivity = TestActivity.create(mEnv);
        mActivity.activityManager = ActivityManagers.create(false);
        mFeatures = new TestFeatures();

        mEnv.state.action = State.ACTION_BROWSE;
        mEnv.state.acceptMimes = new String[] { "*/*" };

        mLoader = new RecentsLoader(mActivity, mEnv.providers, mEnv.state, mFeatures,
        mLoader = new RecentsLoader(mActivity, mEnv.providers, mEnv.state, mEnv.features,
                TestImmediateExecutor.createLookup());
    }