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

Commit a91b5c1e authored by Ben Lin's avatar Ben Lin Committed by android-build-merger
Browse files

Merge "Proper refresh when Authentication finishes with Activity.RESULT_OK."...

Merge "Proper refresh when Authentication finishes with Activity.RESULT_OK." into oc-dev am: b624f91a
am: 87ec42d9

Change-Id: I7e50bf93fdd5efeb81ac2081b1fcd54cbf986d32
parents ab4d5476 87ec42d9
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import android.widget.Toolbar;
import com.android.documentsui.AbstractActionHandler.CommonAddons;
import com.android.documentsui.Injector.Injected;
import com.android.documentsui.NavigationViewManager.Breadcrumb;
import com.android.documentsui.archives.ArchivesProvider;
import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.Shared;
@@ -65,7 +64,6 @@ import com.android.documentsui.sidebar.RootsFragment;
import com.android.documentsui.sorting.SortController;
import com.android.documentsui.sorting.SortModel;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+29 −0
Original line number Diff line number Diff line
@@ -517,6 +517,35 @@ public class ActionHandlerTest {
        mActivity.refreshCurrentRootAndDirectory.assertNotCalled();
    }

    @Test
    public void testAuthentication() throws Exception {
        PendingIntent intent = PendingIntent.getActivity(
                InstrumentationRegistry.getInstrumentation().getTargetContext(), 0, new Intent(),
                0);

        mHandler.startAuthentication(intent);
        assertEquals(intent.getIntentSender(), mActivity.startIntentSender.getLastValue().first);
        assertEquals(AbstractActionHandler.CODE_AUTHENTICATION,
                mActivity.startIntentSender.getLastValue().second.intValue());
    }

    @Test
    public void testOnActivityResult_onOK() throws Exception {
        mHandler.onActivityResult(AbstractActionHandler.CODE_AUTHENTICATION, Activity.RESULT_OK,
                null);
        mActivity.refreshCurrentRootAndDirectory.assertCalled();
    }

    @Test
    public void testOnActivityResult_onNotOK() throws Exception {
        mHandler.onActivityResult(0, Activity.RESULT_OK, null);
        mActivity.refreshCurrentRootAndDirectory.assertNotCalled();

        mHandler.onActivityResult(AbstractActionHandler.CODE_AUTHENTICATION,
                Activity.RESULT_CANCELED, null);
        mActivity.refreshCurrentRootAndDirectory.assertNotCalled();
    }

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