Merge "Implement pause search history"
diff --git a/res/menu/action_mode_menu.xml b/res/menu/action_mode_menu.xml
index f0ae09e..a7a9046 100644
--- a/res/menu/action_mode_menu.xml
+++ b/res/menu/action_mode_menu.xml
@@ -42,6 +42,10 @@
android:title="@string/menu_select_all"
android:showAsAction="never" />
<item
+ android:id="@+id/action_menu_deselect_all"
+ android:title="@string/menu_deselect_all"
+ android:showAsAction="never" />
+ <item
android:id="@+id/action_menu_copy_to"
android:title="@string/menu_copy"
android:showAsAction="never"
diff --git a/res/menu/container_context_menu.xml b/res/menu/container_context_menu.xml
index 2f70d82..bd8b6c3 100644
--- a/res/menu/container_context_menu.xml
+++ b/res/menu/container_context_menu.xml
@@ -34,6 +34,10 @@
<item
android:id="@+id/dir_menu_select_all"
android:title="@string/menu_select_all" />
+
+ <item
+ android:id="@+id/dir_menu_deselect_all"
+ android:title="@string/menu_deselect_all" />
</group>
<group
android:id="@+id/menu_extras_group">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 5559545..e8aa2b9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -57,6 +57,8 @@
<string name="menu_delete">Delete</string>
<!-- Menu item title that selects all documents in the current directory [CHAR LIMIT=28] -->
<string name="menu_select_all">Select all</string>
+ <!-- Menu item title that deselects all documents in the current directory [CHAR LIMIT=28] -->
+ <string name="menu_deselect_all">Deselect all</string>
<!-- Menu item title that selects documents in the current directory [CHAR LIMIT=28] -->
<string name="menu_select">Select</string>
<!-- Menu item title that sort documents in the current directory [CHAR LIMIT=28] -->
diff --git a/src/com/android/documentsui/AbstractActionHandler.java b/src/com/android/documentsui/AbstractActionHandler.java
index 555d13c..94b4d42 100644
--- a/src/com/android/documentsui/AbstractActionHandler.java
+++ b/src/com/android/documentsui/AbstractActionHandler.java
@@ -302,6 +302,11 @@
}
@Override
+ public void deselectAllFiles() {
+ mSelectionMgr.clearSelection();
+ }
+
+ @Override
public void showCreateDirectoryDialog() {
Metrics.logUserAction(MetricConsts.USER_ACTION_CREATE_DIR);
diff --git a/src/com/android/documentsui/ActionHandler.java b/src/com/android/documentsui/ActionHandler.java
index 437b456..a6b5349 100644
--- a/src/com/android/documentsui/ActionHandler.java
+++ b/src/com/android/documentsui/ActionHandler.java
@@ -106,6 +106,11 @@
void selectAllFiles();
+ /**
+ * Attempts to deselect all selected files.
+ */
+ void deselectAllFiles();
+
void showCreateDirectoryDialog();
void showInspector(DocumentInfo doc);
diff --git a/src/com/android/documentsui/MenuManager.java b/src/com/android/documentsui/MenuManager.java
index 5fcbe7b..2c12e5f 100644
--- a/src/com/android/documentsui/MenuManager.java
+++ b/src/com/android/documentsui/MenuManager.java
@@ -35,23 +35,27 @@
import java.util.List;
import java.util.function.IntFunction;
+import java.util.function.IntSupplier;
public abstract class MenuManager {
private final static String TAG = "MenuManager";
- final protected SearchViewManager mSearchManager;
- final protected State mState;
- final protected DirectoryDetails mDirDetails;
+ protected final SearchViewManager mSearchManager;
+ protected final State mState;
+ protected final DirectoryDetails mDirDetails;
+ protected final IntSupplier mFilesCountSupplier;
protected Menu mOptionMenu;
public MenuManager(
SearchViewManager searchManager,
State displayState,
- DirectoryDetails dirDetails) {
+ DirectoryDetails dirDetails,
+ IntSupplier filesCountSupplier) {
mSearchManager = searchManager;
mState = displayState;
mDirDetails = dirDetails;
+ mFilesCountSupplier = filesCountSupplier;
}
/** @see ActionModeController */
@@ -61,7 +65,8 @@
updateShare(menu.findItem(R.id.action_menu_share), selection);
updateRename(menu.findItem(R.id.action_menu_rename), selection);
updateSelect(menu.findItem(R.id.action_menu_select), selection);
- updateSelectAll(menu.findItem(R.id.action_menu_select_all));
+ updateSelectAll(menu.findItem(R.id.action_menu_select_all), selection);
+ updateDeselectAll(menu.findItem(R.id.action_menu_deselect_all), selection);
updateMoveTo(menu.findItem(R.id.action_menu_move_to), selection);
updateCopyTo(menu.findItem(R.id.action_menu_copy_to), selection);
updateCompress(menu.findItem(R.id.action_menu_compress), selection);
@@ -114,7 +119,15 @@
// Pickers don't have any context menu at this moment.
}
- public void inflateContextMenuForContainer(Menu menu, MenuInflater inflater) {
+ /**
+ * Called when container context menu needs to be inflated.
+ *
+ * @param menu context menu from activity or fragment
+ * @param inflater the MenuInflater
+ * @param selectionDetails selection of files
+ */
+ public void inflateContextMenuForContainer(
+ Menu menu, MenuInflater inflater, SelectionDetails selectionDetails) {
throw new UnsupportedOperationException("Pickers don't allow context menu.");
}
@@ -207,14 +220,16 @@
* Called when user tries to generate a context menu anchored to an empty pane.
*/
@VisibleForTesting
- public void updateContextMenuForContainer(Menu menu) {
+ public void updateContextMenuForContainer(Menu menu, SelectionDetails selectionDetails) {
MenuItem paste = menu.findItem(R.id.dir_menu_paste_from_clipboard);
MenuItem selectAll = menu.findItem(R.id.dir_menu_select_all);
+ MenuItem deselectAll = menu.findItem(R.id.dir_menu_deselect_all);
MenuItem createDir = menu.findItem(R.id.dir_menu_create_dir);
MenuItem inspect = menu.findItem(R.id.dir_menu_inspect);
paste.setEnabled(mDirDetails.hasItemsToPaste() && mDirDetails.canCreateDoc());
- updateSelectAll(selectAll);
+ updateSelectAll(selectAll, selectionDetails);
+ updateDeselectAll(deselectAll, selectionDetails);
updateCreateDir(createDir);
updateInspect(inspect);
}
@@ -350,6 +365,9 @@
}
protected abstract void updateSelectAll(MenuItem selectAll);
+ protected abstract void updateSelectAll(MenuItem selectAll, SelectionDetails selectionDetails);
+ protected abstract void updateDeselectAll(
+ MenuItem deselectAll, SelectionDetails selectionDetails);
protected abstract void updateCreateDir(MenuItem createDir);
/**
diff --git a/src/com/android/documentsui/dirlist/DirectoryFragment.java b/src/com/android/documentsui/dirlist/DirectoryFragment.java
index 129f465..91836cc 100644
--- a/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -449,7 +449,8 @@
// TODO: inject DirectoryDetails into MenuManager constructor
// Since both classes are supplied by Activity and created
// at the same time.
- mInjector.menuManager.inflateContextMenuForContainer(menu, inflater);
+ mInjector.menuManager.inflateContextMenuForContainer(
+ menu, inflater, mSelectionMetadata);
} else {
mInjector.menuManager.inflateContextMenuForDocs(
menu, inflater, mSelectionMetadata);
@@ -724,6 +725,11 @@
mActions.selectAllFiles();
return true;
+ case R.id.action_menu_deselect_all:
+ case R.id.dir_menu_deselect_all:
+ mActions.deselectAllFiles();
+ return true;
+
case R.id.action_menu_rename:
case R.id.dir_menu_rename:
renameDocuments(selection);
diff --git a/src/com/android/documentsui/files/FilesActivity.java b/src/com/android/documentsui/files/FilesActivity.java
index a9da4a7..9547961 100644
--- a/src/com/android/documentsui/files/FilesActivity.java
+++ b/src/com/android/documentsui/files/FilesActivity.java
@@ -123,7 +123,8 @@
getApplicationContext(),
mInjector.selectionMgr,
mProviders::getApplicationName,
- mInjector.getModel()::getItemUri);
+ mInjector.getModel()::getItemUri,
+ mInjector.getModel()::getItemCount);
mInjector.actionModeController = new ActionModeController(
this,
diff --git a/src/com/android/documentsui/files/MenuManager.java b/src/com/android/documentsui/files/MenuManager.java
index ab7c630..73c58e5 100644
--- a/src/com/android/documentsui/files/MenuManager.java
+++ b/src/com/android/documentsui/files/MenuManager.java
@@ -40,6 +40,7 @@
import java.util.List;
import java.util.function.IntFunction;
+import java.util.function.IntSupplier;
public final class MenuManager extends com.android.documentsui.MenuManager {
@@ -57,9 +58,10 @@
Context context,
SelectionTracker<String> selectionManager,
Lookup<String, String> appNameLookup,
- Lookup<String, Uri> uriLookup) {
+ Lookup<String, Uri> uriLookup,
+ IntSupplier filesCountSupplier) {
- super(searchManager, displayState, dirDetails);
+ super(searchManager, displayState, dirDetails, filesCountSupplier);
mFeatures = features;
mContext = context;
@@ -103,9 +105,10 @@
}
@Override
- public void inflateContextMenuForContainer(Menu menu, MenuInflater inflater) {
+ public void inflateContextMenuForContainer(
+ Menu menu, MenuInflater inflater, SelectionDetails selectionDetails) {
inflater.inflate(R.menu.container_context_menu, menu);
- updateContextMenuForContainer(menu);
+ updateContextMenuForContainer(menu, selectionDetails);
}
@Override
@@ -224,6 +227,20 @@
}
@Override
+ protected void updateSelectAll(MenuItem selectAll, SelectionDetails selectionDetails) {
+ final boolean visible = selectionDetails.size() < mFilesCountSupplier.getAsInt();
+ selectAll.setVisible(visible);
+ selectAll.setEnabled(visible);
+ }
+
+ @Override
+ protected void updateDeselectAll(MenuItem deselectAll, SelectionDetails selectionDetails) {
+ final boolean visible = selectionDetails.size() == mFilesCountSupplier.getAsInt();
+ deselectAll.setVisible(visible);
+ deselectAll.setEnabled(visible);
+ }
+
+ @Override
protected void updateCreateDir(MenuItem createDir) {
createDir.setVisible(true);
createDir.setEnabled(mDirDetails.canCreateDirectory());
diff --git a/src/com/android/documentsui/picker/MenuManager.java b/src/com/android/documentsui/picker/MenuManager.java
index b9e68ec..ac05571 100644
--- a/src/com/android/documentsui/picker/MenuManager.java
+++ b/src/com/android/documentsui/picker/MenuManager.java
@@ -30,21 +30,25 @@
import android.view.MenuItem;
import com.android.documentsui.Model;
+import com.android.documentsui.R;
import com.android.documentsui.base.MimeTypes;
import com.android.documentsui.base.State;
import com.android.documentsui.queries.SearchViewManager;
import java.util.List;
import java.util.function.IntFunction;
-import com.android.documentsui.R;
+import java.util.function.IntSupplier;
public final class MenuManager extends com.android.documentsui.MenuManager {
private boolean mOnlyDirectory;
- public MenuManager(SearchViewManager searchManager, State displayState, DirectoryDetails dirDetails) {
- super(searchManager, displayState, dirDetails);
-
+ public MenuManager(
+ SearchViewManager searchManager,
+ State displayState,
+ DirectoryDetails dirDetails,
+ IntSupplier filesCountSupplier) {
+ super(searchManager, displayState, dirDetails, filesCountSupplier);
}
@Override
@@ -102,6 +106,24 @@
}
@Override
+ protected void updateSelectAll(MenuItem selectAll, SelectionDetails selectionDetails) {
+ final boolean visible = mState.allowMultiple
+ && selectionDetails.size() < mFilesCountSupplier.getAsInt();
+ final boolean enabled = visible && !mOnlyDirectory;
+ selectAll.setVisible(visible);
+ selectAll.setEnabled(enabled);
+ }
+
+ @Override
+ protected void updateDeselectAll(MenuItem deselectAll, SelectionDetails selectionDetails) {
+ final boolean visible = mState.allowMultiple
+ && selectionDetails.size() == mFilesCountSupplier.getAsInt();
+ final boolean enabled = visible && !mOnlyDirectory;
+ deselectAll.setVisible(visible);
+ deselectAll.setEnabled(enabled);
+ }
+
+ @Override
protected void updateCreateDir(MenuItem createDir) {
createDir.setVisible(picking());
createDir.setEnabled(picking() && mDirDetails.canCreateDirectory());
diff --git a/src/com/android/documentsui/picker/PickActivity.java b/src/com/android/documentsui/picker/PickActivity.java
index 794e785..d240422 100644
--- a/src/com/android/documentsui/picker/PickActivity.java
+++ b/src/com/android/documentsui/picker/PickActivity.java
@@ -108,7 +108,11 @@
this::focusSidebar,
getColor(R.color.primary));
- mInjector.menuManager = new MenuManager(mSearchManager, mState, new DirectoryDetails(this));
+ mInjector.menuManager = new MenuManager(
+ mSearchManager,
+ mState,
+ new DirectoryDetails(this),
+ mInjector.getModel()::getItemCount);
mInjector.actionModeController = new ActionModeController(
this,
diff --git a/tests/common/com/android/documentsui/testing/TestMenu.java b/tests/common/com/android/documentsui/testing/TestMenu.java
index 61a7b4d..4ad8406 100644
--- a/tests/common/com/android/documentsui/testing/TestMenu.java
+++ b/tests/common/com/android/documentsui/testing/TestMenu.java
@@ -47,6 +47,7 @@
R.id.dir_menu_paste_from_clipboard,
R.id.dir_menu_create_dir,
R.id.dir_menu_select_all,
+ R.id.dir_menu_deselect_all,
R.id.dir_menu_rename,
R.id.dir_menu_delete,
R.id.dir_menu_view_in_owner,
@@ -62,6 +63,7 @@
R.id.action_menu_delete,
R.id.action_menu_select,
R.id.action_menu_select_all,
+ R.id.action_menu_deselect_all,
R.id.action_menu_copy_to,
R.id.action_menu_extract_to,
R.id.action_menu_move_to,
diff --git a/tests/unit/com/android/documentsui/files/MenuManagerTest.java b/tests/unit/com/android/documentsui/files/MenuManagerTest.java
index 6f79c94..0f2ed3b 100644
--- a/tests/unit/com/android/documentsui/files/MenuManagerTest.java
+++ b/tests/unit/com/android/documentsui/files/MenuManagerTest.java
@@ -63,6 +63,7 @@
private TestMenuItem dirPasteFromClipboard;
private TestMenuItem dirCreateDir;
private TestMenuItem dirSelectAll;
+ private TestMenuItem mDirDeselectAll;
private TestMenuItem dirRename;
private TestMenuItem dirDelete;
private TestMenuItem dirViewInOwner;
@@ -82,6 +83,7 @@
private TestMenuItem actionModeShare;
private TestMenuItem actionModeDelete;
private TestMenuItem actionModeSelectAll;
+ private TestMenuItem mActionModeDeselectAll;
private TestMenuItem actionModeCopyTo;
private TestMenuItem actionModeExtractTo;
private TestMenuItem actionModeMoveTo;
@@ -118,6 +120,8 @@
private TestActivity activity = TestActivity.create(TestEnv.create());
private SelectionTracker<String> selectionManager;
+ private int mFilesCount;
+
@Before
public void setUp() {
testMenu = TestMenu.create();
@@ -131,6 +135,7 @@
dirPasteFromClipboard = testMenu.findItem(R.id.dir_menu_paste_from_clipboard);
dirCreateDir = testMenu.findItem(R.id.dir_menu_create_dir);
dirSelectAll = testMenu.findItem(R.id.dir_menu_select_all);
+ mDirDeselectAll = testMenu.findItem(R.id.dir_menu_deselect_all);
dirRename = testMenu.findItem(R.id.dir_menu_rename);
dirDelete = testMenu.findItem(R.id.dir_menu_delete);
dirViewInOwner = testMenu.findItem(R.id.dir_menu_view_in_owner);
@@ -148,6 +153,7 @@
actionModeShare = testMenu.findItem(R.id.action_menu_share);
actionModeDelete = testMenu.findItem(R.id.action_menu_delete);
actionModeSelectAll = testMenu.findItem(R.id.action_menu_select_all);
+ mActionModeDeselectAll = testMenu.findItem(R.id.action_menu_deselect_all);
actionModeCopyTo = testMenu.findItem(R.id.action_menu_copy_to);
actionModeExtractTo = testMenu.findItem(R.id.action_menu_extract_to);
actionModeMoveTo = testMenu.findItem(R.id.action_menu_move_to);
@@ -186,6 +192,9 @@
selectionManager = SelectionHelpers.createTestInstance(TestData.create(1));
selectionManager.select("0");
+ selectionDetails.size = 1;
+ mFilesCount = 10;
+
mgr = new MenuManager(
features,
testSearchManager,
@@ -194,7 +203,8 @@
activity,
selectionManager,
this::getApplicationNameFromAuthority,
- this::getUriFromModelId);
+ this::getUriFromModelId,
+ this::getFilesCount);
testRootInfo = new RootInfo();
testDocInfo = new DocumentInfo();
@@ -204,10 +214,15 @@
private Uri getUriFromModelId(String id) {
return Uri.EMPTY;
}
+
private String getApplicationNameFromAuthority(String authority) {
return "TestApp";
}
+ private int getFilesCount() {
+ return mFilesCount;
+ }
+
@Test
public void testActionMenu() {
selectionDetails.canDelete = true;
@@ -226,6 +241,10 @@
actionModeViewInOwner.assertInvisible();
actionModeSort.assertVisible();
actionModeSort.assertEnabled();
+ actionModeSelectAll.assertVisible();
+ actionModeSelectAll.assertEnabled();
+ mActionModeDeselectAll.assertInvisible();
+ mActionModeDeselectAll.assertDisabled();
}
@Test
@@ -308,7 +327,8 @@
activity,
selectionManager,
this::getApplicationNameFromAuthority,
- this::getUriFromModelId);
+ this::getUriFromModelId,
+ this::getFilesCount);
selectionDetails.canViewInOwner = true;
mgr.updateActionMenu(testMenu, selectionDetails);
@@ -410,6 +430,19 @@
}
@Test
+ public void testActionMenu_CanDeselectAll() {
+ selectionDetails.size = 1;
+ mFilesCount = 1;
+
+ mgr.updateActionMenu(testMenu, selectionDetails);
+
+ actionModeSelectAll.assertInvisible();
+ actionModeSelectAll.assertDisabled();
+ mActionModeDeselectAll.assertVisible();
+ mActionModeDeselectAll.assertEnabled();
+ }
+
+ @Test
public void testOptionMenu() {
mgr.updateOptionMenu(testMenu);
@@ -501,10 +534,12 @@
@Test
public void testContextMenu_EmptyArea() {
- mgr.updateContextMenuForContainer(testMenu);
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
dirSelectAll.assertVisible();
dirSelectAll.assertEnabled();
+ mDirDeselectAll.assertInvisible();
+ mDirDeselectAll.assertDisabled();
dirPasteFromClipboard.assertVisible();
dirPasteFromClipboard.assertDisabled();
dirCreateDir.assertVisible();
@@ -512,11 +547,24 @@
}
@Test
+ public void testContextMenu_EmptyArea_CanDeselectAll() {
+ selectionDetails.size = 1;
+ mFilesCount = 1;
+
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
+
+ dirSelectAll.assertInvisible();
+ dirSelectAll.assertDisabled();
+ mDirDeselectAll.assertVisible();
+ mDirDeselectAll.assertEnabled();
+ }
+
+ @Test
public void testContextMenu_EmptyArea_NoItemToPaste() {
dirDetails.hasItemsToPaste = false;
dirDetails.canCreateDoc = true;
- mgr.updateContextMenuForContainer(testMenu);
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
dirSelectAll.assertVisible();
dirSelectAll.assertEnabled();
@@ -531,7 +579,7 @@
dirDetails.hasItemsToPaste = true;
dirDetails.canCreateDoc = false;
- mgr.updateContextMenuForContainer(testMenu);
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
dirSelectAll.assertVisible();
dirSelectAll.assertEnabled();
@@ -546,7 +594,7 @@
dirDetails.hasItemsToPaste = true;
dirDetails.canCreateDoc = true;
- mgr.updateContextMenuForContainer(testMenu);
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
dirSelectAll.assertVisible();
dirSelectAll.assertEnabled();
@@ -560,7 +608,7 @@
public void testContextMenu_EmptyArea_CanCreateDirectory() {
dirDetails.canCreateDirectory = true;
- mgr.updateContextMenuForContainer(testMenu);
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
dirSelectAll.assertVisible();
dirSelectAll.assertEnabled();
@@ -640,7 +688,7 @@
public void testContextMenu_CanInspectContainer() {
features.inspector = true;
dirDetails.canInspectDirectory = true;
- mgr.updateContextMenuForContainer(testMenu);
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
dirInspect.assertVisible();
dirInspect.assertEnabled();
}
diff --git a/tests/unit/com/android/documentsui/picker/MenuManagerTest.java b/tests/unit/com/android/documentsui/picker/MenuManagerTest.java
index 8287e9f..5e14cb9 100644
--- a/tests/unit/com/android/documentsui/picker/MenuManagerTest.java
+++ b/tests/unit/com/android/documentsui/picker/MenuManagerTest.java
@@ -63,6 +63,7 @@
private TestMenuItem dirPasteFromClipboard;
private TestMenuItem dirCreateDir;
private TestMenuItem dirSelectAll;
+ private TestMenuItem mDirDeselectAll;
private TestMenuItem dirRename;
private TestMenuItem dirDelete;
private TestMenuItem dirViewInOwner;
@@ -82,6 +83,7 @@
private TestMenuItem actionModeShare;
private TestMenuItem actionModeDelete;
private TestMenuItem actionModeSelectAll;
+ private TestMenuItem mActionModeDeselectAll;
private TestMenuItem actionModeCopyTo;
private TestMenuItem actionModeExtractTo;
private TestMenuItem actionModeMoveTo;
@@ -111,6 +113,8 @@
private DocumentInfo testDocInfo;
private MenuManager mgr;
+ private int mFilesCount;
+
@Before
public void setUp() {
testMenu = TestMenu.create();
@@ -122,6 +126,7 @@
dirPasteFromClipboard = testMenu.findItem(R.id.dir_menu_paste_from_clipboard);
dirCreateDir = testMenu.findItem(R.id.dir_menu_create_dir);
dirSelectAll = testMenu.findItem(R.id.dir_menu_select_all);
+ mDirDeselectAll = testMenu.findItem(R.id.dir_menu_deselect_all);
dirRename = testMenu.findItem(R.id.dir_menu_rename);
dirDelete = testMenu.findItem(R.id.dir_menu_delete);
dirViewInOwner = testMenu.findItem(R.id.dir_menu_view_in_owner);
@@ -138,6 +143,7 @@
actionModeShare = testMenu.findItem(R.id.action_menu_share);
actionModeDelete = testMenu.findItem(R.id.action_menu_delete);
actionModeSelectAll = testMenu.findItem(R.id.action_menu_select_all);
+ mActionModeDeselectAll = testMenu.findItem(R.id.action_menu_deselect_all);
actionModeCopyTo = testMenu.findItem(R.id.action_menu_copy_to);
actionModeExtractTo = testMenu.findItem(R.id.action_menu_extract_to);
actionModeMoveTo = testMenu.findItem(R.id.action_menu_move_to);
@@ -162,7 +168,9 @@
selectionDetails = new TestSelectionDetails();
dirDetails = new TestDirectoryDetails();
testSearchManager = new TestSearchViewManager();
- mgr = new MenuManager(testSearchManager, state, dirDetails);
+ mgr = new MenuManager(testSearchManager, state, dirDetails, this::getFilesCount);
+ selectionDetails.size = 1;
+ mFilesCount = 10;
testRootInfo = new RootInfo();
testDocInfo = new DocumentInfo();
@@ -170,6 +178,10 @@
state.allowMultiple = true;
}
+ private int getFilesCount() {
+ return mFilesCount;
+ }
+
@Test
public void testActionMenu() {
mgr.updateActionMenu(testMenu, selectionDetails);
@@ -178,6 +190,7 @@
actionModeShare.assertInvisible();
actionModeRename.assertInvisible();
actionModeSelectAll.assertVisible();
+ mActionModeDeselectAll.assertInvisible();
actionModeViewInOwner.assertInvisible();
actionModeSort.assertVisible();
actionModeSort.assertEnabled();
@@ -221,6 +234,7 @@
mgr.updateActionMenu(testMenu, selectionDetails);
actionModeSelectAll.assertInvisible();
+ mActionModeDeselectAll.assertInvisible();
}
@Test
@@ -229,6 +243,19 @@
mgr.updateActionMenu(testMenu, selectionDetails);
actionModeSelectAll.assertVisible();
+ mActionModeDeselectAll.assertInvisible();
+ }
+
+ @Test
+ public void testActionMenu_CanDeselectAll() {
+ state.allowMultiple = true;
+ selectionDetails.size = 1;
+ mFilesCount = 1;
+
+ mgr.updateActionMenu(testMenu, selectionDetails);
+
+ actionModeSelectAll.assertInvisible();
+ mActionModeDeselectAll.assertVisible();
}
@Test
@@ -311,10 +338,12 @@
dirDetails.canCreateDoc = false;
dirDetails.canCreateDirectory = false;
- mgr.updateContextMenuForContainer(testMenu);
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
dirSelectAll.assertVisible();
dirSelectAll.assertEnabled();
+ mDirDeselectAll.assertInvisible();
+ mDirDeselectAll.assertDisabled();
dirPasteFromClipboard.assertVisible();
dirPasteFromClipboard.assertDisabled();
dirCreateDir.assertVisible();
@@ -326,7 +355,7 @@
dirDetails.hasItemsToPaste = false;
dirDetails.canCreateDoc = true;
- mgr.updateContextMenuForContainer(testMenu);
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
dirSelectAll.assertVisible();
dirSelectAll.assertEnabled();
@@ -341,7 +370,7 @@
dirDetails.hasItemsToPaste = true;
dirDetails.canCreateDoc = false;
- mgr.updateContextMenuForContainer(testMenu);
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
dirSelectAll.assertVisible();
dirSelectAll.assertEnabled();
@@ -356,7 +385,7 @@
dirDetails.hasItemsToPaste = true;
dirDetails.canCreateDoc = true;
- mgr.updateContextMenuForContainer(testMenu);
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
dirSelectAll.assertVisible();
dirSelectAll.assertEnabled();
@@ -370,7 +399,7 @@
public void testContextMenu_EmptyArea_CanCreateDirectory() {
dirDetails.canCreateDirectory = true;
- mgr.updateContextMenuForContainer(testMenu);
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
dirSelectAll.assertVisible();
dirSelectAll.assertEnabled();
@@ -381,6 +410,19 @@
}
@Test
+ public void testContextMenu_EmptyArea_CanDeselectAll() {
+ selectionDetails.size = 1;
+ mFilesCount = 1;
+
+ mgr.updateContextMenuForContainer(testMenu, selectionDetails);
+
+ dirSelectAll.assertInvisible();
+ dirSelectAll.assertDisabled();
+ mDirDeselectAll.assertVisible();
+ mDirDeselectAll.assertEnabled();
+ }
+
+ @Test
public void testContextMenu_OnFile() {
mgr.updateContextMenuForFiles(testMenu, selectionDetails);
// We don't want share in pickers.