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

Commit 5174816a authored by Tony Huang's avatar Tony Huang Committed by Android (Google) Code Review
Browse files

Merge "Change default root when open document tree"

parents 1401968f 049b22db
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -182,11 +182,11 @@ class ActionHandler<T extends FragmentActivity & Addons> extends AbstractActionH
    private void loadDefaultLocation() {
    private void loadDefaultLocation() {
        switch (mState.action) {
        switch (mState.action) {
            case ACTION_CREATE:
            case ACTION_CREATE:
            case ACTION_OPEN_TREE:
                loadHomeDir();
                loadHomeDir();
                break;
                break;
            case ACTION_GET_CONTENT:
            case ACTION_GET_CONTENT:
            case ACTION_OPEN:
            case ACTION_OPEN:
            case ACTION_OPEN_TREE:
                loadRecent();
                loadRecent();
                break;
                break;
            default:
            default:
+6 −0
Original line number Original line Diff line number Diff line
@@ -89,6 +89,12 @@ public interface ProvidersAccess {
                continue;
                continue;
            }
            }


            if (state.action == State.ACTION_OPEN_TREE && root.isRecents()) {
                if (VERBOSE) Log.v(
                        tag, "Excluding recent root because: ACTION_OPEN_TREE.");
                continue;
            }

            if (!state.showAdvanced && root.isAdvanced()) {
            if (!state.showAdvanced && root.isAdvanced()) {
                if (VERBOSE) Log.v(tag, "Excluding root because: unwanted advanced device.");
                if (VERBOSE) Log.v(tag, "Excluding root because: unwanted advanced device.");
                continue;
                continue;
+17 −10
Original line number Original line Diff line number Diff line
@@ -180,20 +180,13 @@ public class ActionHandlerTest {
    }
    }


    @Test
    @Test
    public void testInitLocation_DefaultToRecents_ActionOpenTree() throws Exception {
    public void testInitLocation_DefaultToDownloads_ActionOpenTree() throws Exception {
        testInitLocationDefaultToRecentsOnAction(State.ACTION_OPEN_TREE);
        testInitLocationDefaultToDownloadsOnAction(State.ACTION_OPEN_TREE);
    }
    }


    @Test
    @Test
    public void testInitLocation_DefaultsToDownloads_ActionCreate() throws Exception {
    public void testInitLocation_DefaultsToDownloads_ActionCreate() throws Exception {
        mEnv.state.action = State.ACTION_CREATE;
        testInitLocationDefaultToDownloadsOnAction(State.ACTION_CREATE);
        mActivity.resources.bools.put(R.bool.show_documents_root, false);

        mActivity.refreshCurrentRootAndDirectory.assertNotCalled();

        mHandler.initLocation(mActivity.getIntent());

        assertRootPicked(TestProvidersAccess.DOWNLOADS.getUri());
    }
    }


    @Test
    @Test
@@ -509,6 +502,20 @@ public class ActionHandlerTest {
        mActivity.refreshCurrentRootAndDirectory.assertCalled();
        mActivity.refreshCurrentRootAndDirectory.assertCalled();
    }
    }


    private void testInitLocationDefaultToDownloadsOnAction(@ActionType int action)
            throws Exception {
        mEnv.state.action = action;
        mActivity.resources.bools.put(R.bool.show_documents_root, false);
        mActivity.resources.strings.put(R.string.default_root_uri,
                TestProvidersAccess.DOWNLOADS.getUri().toString());

        mActivity.refreshCurrentRootAndDirectory.assertNotCalled();

        mHandler.initLocation(mActivity.getIntent());

        assertRootPicked(TestProvidersAccess.DOWNLOADS.getUri());
    }

    private void assertRootPicked(Uri expectedUri) throws Exception {
    private void assertRootPicked(Uri expectedUri) throws Exception {
        mEnv.beforeAsserts();
        mEnv.beforeAsserts();