Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Unified Diff: ui/file_manager/file_manager/foreground/js/ui/directory_tree_unittest.js

Issue 2897973002: Hide Team Drives when user don't have membership of any Team Drive. (Closed)
Patch Set: revise comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/ui/directory_tree.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/ui/directory_tree_unittest.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/directory_tree_unittest.js b/ui/file_manager/file_manager/foreground/js/ui/directory_tree_unittest.js
index 097e7cacc55003b95c1b4dc64d191674da012f4f..ad14f68bb21b663f8fc2fc5357c8c3987bdcfef2 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/directory_tree_unittest.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/directory_tree_unittest.js
@@ -155,6 +155,9 @@ function testCreateDirectoryTreeWithTeamDrive(callback) {
window
.webkitResolveLocalFileSystemURLEntries['filesystem:drive/team_drives'] =
new MockDirectoryEntry(driveFileSystem, '/team_drives');
+ window.webkitResolveLocalFileSystemURLEntries
+ ['filesystem:drive/team_drives/a'] =
+ new MockDirectoryEntry(driveFileSystem, '/team_drives/a');
DirectoryTree.decorate(
directoryTree, directoryModel, volumeManager, null, fileOperationManager,
@@ -187,6 +190,67 @@ function testCreateDirectoryTreeWithTeamDrive(callback) {
}
/**
+ * Test case for creating tree with empty Team Drives.
+ * Team Drives subtree should be hidden when the user don't have access to any
+ * Team Drive.
+ *
+ * @param {!function(boolean)} callback A callback function which is called with
+ * test result.
+ */
+function testCreateDirectoryTreeWithEmptyTeamDrive(callback) {
+ mockCommandLinePrivate.addSwitch('team-drives');
+
+ // Create elements.
+ var parentElement = document.createElement('div');
+ var directoryTree = document.createElement('div');
+ directoryTree.metadataModel = {
+ notifyEntriesChanged: function() {},
+ get: function(entries, labels) {
+ // Mock a non-shared directory
+ return Promise.resolve([{shared: false}]);
+ }
+ };
+ parentElement.appendChild(directoryTree);
+
+ // Create mocks.
+ var directoryModel = new MockDirectoryModel();
+ var volumeManager = new MockVolumeManagerWrapper();
+ var fileOperationManager = {addEventListener: function(name, callback) {}};
+
+ // Set entry which is returned by
+ // window.webkitResolveLocalFileSystemURLResults.
+ var driveFileSystem = volumeManager.volumeInfoList.item(0).fileSystem;
+ window.webkitResolveLocalFileSystemURLEntries['filesystem:drive/root'] =
+ new MockDirectoryEntry(driveFileSystem, '/root');
+ window
+ .webkitResolveLocalFileSystemURLEntries['filesystem:drive/team_drives'] =
+ new MockDirectoryEntry(driveFileSystem, '/team_drives');
+ // No directories exist under Team Drives
+
+ DirectoryTree.decorate(
+ directoryTree, directoryModel, volumeManager, null, fileOperationManager,
+ true);
+ directoryTree.dataModel = new MockNavigationListModel(volumeManager);
+ directoryTree.redraw(true);
+
+ var driveItem = directoryTree.items[0];
+
+ reportPromise(
+ waitUntil(function() {
+ // Root entries under Drive volume is generated except Team Drives.
+ // See testCreateDirectoryTreeWithTeamDrive for detail.
+ return driveItem.items.length == 4;
+ }).then(function() {
+ for (var i = 0; i < driveItem.items.length; i++) {
+ assertFalse(
+ driveItem.items[i].label == str('DRIVE_TEAM_DRIVES_LABEL'),
+ 'Team Drives node should not be shown');
+ }
+ }),
+ callback);
+}
+
+/**
* Test case for updateSubElementsFromList.
*
* Mounts/unmounts removable and archive volumes, and checks these volumes come
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/ui/directory_tree.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698