Commit a1228976 authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Don't switch to the default display root if the current entry is fake.

If a FakeItem is the current entry and a volume is mounted or unmounted,
Files app switches to the default display root since the FakeItem
doesn't have a VolumeInfo. Omit switching if the current root is not a
native entry.

Bug: 900870
Change-Id: I943959112135ceb5752207f87e6810a4ec60ae0f
Reviewed-on: https://chromium-review.googlesource.com/c/1312148
Commit-Queue: Sam McNally <sammc@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605221}
parent 14776798
...@@ -212,6 +212,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P( ...@@ -212,6 +212,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
TestCase("fileDisplayWithoutVolumesThenMountDrive").EnableDriveFs(), TestCase("fileDisplayWithoutVolumesThenMountDrive").EnableDriveFs(),
TestCase("fileDisplayWithoutDrive"), TestCase("fileDisplayWithoutDrive"),
TestCase("fileDisplayWithoutDriveThenDisable"), TestCase("fileDisplayWithoutDriveThenDisable"),
TestCase("fileDisplayMountWithFakeItemSelected"),
TestCase("fileSearchCaseInsensitive"), TestCase("fileSearchCaseInsensitive"),
TestCase("fileSearchNotFound"))); TestCase("fileSearchNotFound")));
......
...@@ -1203,13 +1203,28 @@ DirectoryModel.prototype.onVolumeInfoListUpdated_ = function(event) { ...@@ -1203,13 +1203,28 @@ DirectoryModel.prototype.onVolumeInfoListUpdated_ = function(event) {
// root. If current directory path is empty, stop the fallback // root. If current directory path is empty, stop the fallback
// since the current directory is initializing now. // since the current directory is initializing now.
const entry = this.getCurrentDirEntry(); const entry = this.getCurrentDirEntry();
if (entry && !this.volumeManager_.getVolumeInfo(entry)) { if (entry && util.isNativeEntry(entry) &&
!this.volumeManager_.getVolumeInfo(entry)) {
this.volumeManager_.getDefaultDisplayRoot((displayRoot) => { this.volumeManager_.getDefaultDisplayRoot((displayRoot) => {
if (displayRoot) if (displayRoot)
this.changeDirectoryEntry(displayRoot); this.changeDirectoryEntry(displayRoot);
}); });
} }
// If a volume within My files is mounted, rescan the contents.
// TODO(crbug.com/901690): Remove this special case.
if (this.getCurrentRootType() === VolumeManagerCommon.RootType.MY_FILES) {
for (let newVolume of event.added) {
if (newVolume.volumeType === VolumeManagerCommon.VolumeType.DOWNLOADS ||
newVolume.volumeType ===
VolumeManagerCommon.VolumeType.ANDROID_FILES ||
newVolume.volumeType === VolumeManagerCommon.VolumeType.CROSTINI) {
this.rescan(false);
break;
}
}
}
// If the current directory is the Drive placeholder and the real Drive is // If the current directory is the Drive placeholder and the real Drive is
// mounted, switch to it. // mounted, switch to it.
if (this.getCurrentRootType() === if (this.getCurrentRootType() ===
......
...@@ -504,14 +504,18 @@ testcase.fileDisplayWithoutVolumesThenMountDownloads = function() { ...@@ -504,14 +504,18 @@ testcase.fileDisplayWithoutVolumesThenMountDownloads = function() {
function() { function() {
sendTestMessage({name: 'mountDownloads'}).then(this.next); sendTestMessage({name: 'mountDownloads'}).then(this.next);
}, },
// Add an entry to Downloads. // Downloads should appear in My files in the directory tree.
function() { function() {
addEntries(['local'], [ENTRIES.newlyAdded], this.next); remoteCall.waitForElement(appId, '[volume-type-for-testing="downloads"]')
.then(this.next);
}, },
// Because Downloads is the default volume it will be automatically
// selected, so let's wait for its entry to appear.
function() { function() {
remoteCall.waitForFiles(appId, [ENTRIES.newlyAdded.getExpectedRow()]) const downloadsRow = ['Downloads', '--', 'Folder'];
const crostiniRow = ['Linux files', '--', 'Folder'];
remoteCall
.waitForFiles(
appId, [downloadsRow, crostiniRow],
{ignoreFileSize: true, ignoreLastModifiedTime: true})
.then(this.next); .then(this.next);
}, },
function() { function() {
...@@ -560,8 +564,7 @@ testcase.fileDisplayWithoutVolumesThenMountDrive = function() { ...@@ -560,8 +564,7 @@ testcase.fileDisplayWithoutVolumesThenMountDrive = function() {
// Navigate to the Drive FakeItem. // Navigate to the Drive FakeItem.
function() { function() {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['span[root-type-icon=\'drive\']'], 'fakeMouseClick', appId, ['[root-type-icon=\'drive\']'], this.next);
this.next);
}, },
// The fake Google Drive should be empty. // The fake Google Drive should be empty.
function() { function() {
...@@ -630,8 +633,7 @@ testcase.fileDisplayWithoutDrive = function() { ...@@ -630,8 +633,7 @@ testcase.fileDisplayWithoutDrive = function() {
// Navigate to Drive. // Navigate to Drive.
function() { function() {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['span[root-type-icon=\'drive\']'], 'fakeMouseClick', appId, ['[root-type-icon=\'drive\']'], this.next);
this.next);
}, },
function() { function() {
remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/Google Drive') remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/Google Drive')
...@@ -705,8 +707,7 @@ testcase.fileDisplayWithoutDriveThenDisable = function() { ...@@ -705,8 +707,7 @@ testcase.fileDisplayWithoutDriveThenDisable = function() {
// Navigate to Drive. // Navigate to Drive.
function() { function() {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['span[root-type-icon=\'drive\']'], 'fakeMouseClick', appId, ['[root-type-icon=\'drive\']'], this.next);
this.next);
}, },
// The fake Google Drive should be empty. // The fake Google Drive should be empty.
function() { function() {
...@@ -734,7 +735,7 @@ testcase.fileDisplayWithoutDriveThenDisable = function() { ...@@ -734,7 +735,7 @@ testcase.fileDisplayWithoutDriveThenDisable = function() {
}, },
// Wait for the fake drive to reappear. // Wait for the fake drive to reappear.
function() { function() {
remoteCall.waitForElement(appId, ['span[root-type-icon=\'drive\']']) remoteCall.waitForElement(appId, ['[root-type-icon=\'drive\']'])
.then(this.next); .then(this.next);
}, },
function() { function() {
...@@ -742,3 +743,55 @@ testcase.fileDisplayWithoutDriveThenDisable = function() { ...@@ -742,3 +743,55 @@ testcase.fileDisplayWithoutDriveThenDisable = function() {
}, },
]); ]);
}; };
/**
* Tests Files app resisting the urge to switch to Downloads when mounts change.
* re-enabling Drive.
*/
testcase.fileDisplayMountWithFakeItemSelected = function() {
let appId = null;
StepsRunner.run([
// Open Files app on Drive with the given test files.
function() {
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.newlyAdded], []);
},
// Ensure Downloads has loaded.
function(result) {
appId = result.windowId;
remoteCall.waitForFiles(appId, [ENTRIES.newlyAdded.getExpectedRow()])
.then(this.next);
},
// Navigate to My files.
function() {
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['[root-type-icon=\'my_files\']'],
this.next);
},
// Wait for the navigation to complete.
function() {
remoteCall.waitUntilCurrentDirectoryIsChanged(appId, '/My files')
.then(this.next);
},
// Mount a USB drive.
function() {
sendTestMessage({name: 'mountFakeUsbEmpty'}).then(this.next);
},
// Wait for the mount to appear.
function() {
remoteCall
.waitForElement(
appId, ['#directory-tree [volume-type-icon="removable"]'])
.then(this.next);
},
function() {
remoteCall.callRemoteTestUtil('getBreadcrumbPath', appId, [])
.then(this.next);
},
function(path) {
chrome.test.assertEq('/My files', path);
checkIfNoErrorsOccured(this.next);
},
]);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment