diff options
author | 2017-07-20 16:40:51 -0700 | |
---|---|---|
committer | 2017-07-21 12:51:55 -0700 | |
commit | 79a572b66db3bcda84f67be16afe9840186737d8 (patch) | |
tree | c13b2f19b4cd0accb48f383c9c42cf147b6a98bb | |
parent | 648cc085014877f4521fbaa6f99b90fca451faaf (diff) |
Load zip file when user clicks it in search result.
Test: Added 1 unit test and fixed a related one.
Bug: 63898501
Change-Id: I8dee63c0de571be4076c05c85abf952b66def983
3 files changed, 44 insertions, 4 deletions
diff --git a/src/com/android/documentsui/AbstractActionHandler.java b/src/com/android/documentsui/AbstractActionHandler.java index 0faab6e71..d68bc108b 100644 --- a/src/com/android/documentsui/AbstractActionHandler.java +++ b/src/com/android/documentsui/AbstractActionHandler.java @@ -356,6 +356,13 @@ public abstract class AbstractActionHandler<T extends Activity & CommonAddons> + mState.stack.getRoot()); } + final DocumentInfo top = stack.peek(); + if (top.isArchive()) { + // Swap the zip file in original provider and the one provided by ArchiveProvider. + stack.pop(); + stack.push(mDocs.getArchiveDocument(top.derivedUri)); + } + mState.stack.reset(); // Update navigator to give horizontal breadcrumb a chance to update documents. It // doesn't update its content if the size of document stack doesn't change. diff --git a/src/com/android/documentsui/LoadDocStackTask.java b/src/com/android/documentsui/LoadDocStackTask.java index 1ce4630c9..af106937c 100644 --- a/src/com/android/documentsui/LoadDocStackTask.java +++ b/src/com/android/documentsui/LoadDocStackTask.java @@ -60,7 +60,6 @@ public class LoadDocStackTask extends PairedTask<Activity, Uri, DocumentStack> { @Override public @Nullable DocumentStack run(Uri... uris) { - // assert(Features.OMC_RUNTIME); if (mDocs.isDocumentUri(uris[0])) { final Uri docUri; if (DocumentsContract.isTreeUri(uris[0])) { diff --git a/tests/unit/com/android/documentsui/AbstractActionHandlerTest.java b/tests/unit/com/android/documentsui/AbstractActionHandlerTest.java index e094078f3..54248e020 100644 --- a/tests/unit/com/android/documentsui/AbstractActionHandlerTest.java +++ b/tests/unit/com/android/documentsui/AbstractActionHandlerTest.java @@ -106,7 +106,8 @@ public class AbstractActionHandlerTest { } @Test - public void testOpensContainerDocuments_jumpToNewLocation() throws Exception { + public void testOpensContainerDocuments_OpenFolderInSearch_JumpsToNewLocation() + throws Exception { if (!mEnv.features.isLaunchToDocumentEnabled()) { return; } @@ -114,6 +115,7 @@ public class AbstractActionHandlerTest { mEnv.populateStack(); mEnv.searchViewManager.isSearching = true; + mEnv.docs.nextIsDocumentsUri = true; mEnv.docs.nextPath = new Path( TestProvidersAccess.HOME.rootId, Arrays.asList(TestEnv.FOLDER_1.documentId, TestEnv.FOLDER_2.documentId)); @@ -124,15 +126,18 @@ public class AbstractActionHandlerTest { mEnv.beforeAsserts(); assertEquals(mEnv.docs.nextPath.getPath().size(), mEnv.state.stack.size()); - assertEquals(TestEnv.FOLDER_2, mEnv.state.stack.peek()); + assertEquals(TestEnv.FOLDER_2, mEnv.state.stack.pop()); + assertEquals(TestEnv.FOLDER_1, mEnv.state.stack.pop()); } @Test - public void testOpensContainerDocuments_pushToRootDoc_NoFindPathSupport() throws Exception { + public void testOpensContainerDocuments_ClickFolderInSearch_PushToRootDoc_NoFindPathSupport() + throws Exception { mEnv.populateStack(); mEnv.searchViewManager.isSearching = true; + mEnv.docs.nextIsDocumentsUri = true; mEnv.docs.nextDocuments = Arrays.asList(TestEnv.FOLDER_1, TestEnv.FOLDER_2); mHandler.openContainerDocument(TestEnv.FOLDER_2); @@ -145,6 +150,35 @@ public class AbstractActionHandlerTest { } @Test + public void testOpensContainerDocuments_ClickArchiveInSearch_opensArchiveInArchiveProvider() + throws Exception { + if (!mEnv.features.isLaunchToDocumentEnabled()) { + return; + } + + mEnv.populateStack(); + + mEnv.searchViewManager.isSearching = true; + mEnv.docs.nextIsDocumentsUri = true; + mEnv.docs.nextPath = new Path( + TestProvidersAccess.HOME.rootId, + Arrays.asList(TestEnv.FOLDER_1.documentId, TestEnv.FOLDER_2.documentId, + TestEnv.FILE_ARCHIVE.documentId)); + mEnv.docs.nextDocuments = Arrays.asList( + TestEnv.FOLDER_1, TestEnv.FOLDER_2, TestEnv.FILE_ARCHIVE); + mEnv.docs.nextDocument = TestEnv.FILE_IN_ARCHIVE; + + mHandler.openContainerDocument(TestEnv.FILE_ARCHIVE); + + mEnv.beforeAsserts(); + + assertEquals(mEnv.docs.nextPath.getPath().size(), mEnv.state.stack.size()); + assertEquals(TestEnv.FILE_IN_ARCHIVE, mEnv.state.stack.pop()); + assertEquals(TestEnv.FOLDER_2, mEnv.state.stack.pop()); + assertEquals(TestEnv.FOLDER_1, mEnv.state.stack.pop()); + } + + @Test public void testOpensDocument_AssertionErrorIfAlreadyInStack() throws Exception { mEnv.populateStack(); boolean threw = false; |