Commit cdcf5765 authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

Don't show the read only label when the "Linux files" fake root is open

Bug: 1027041
Change-Id: Ibb15074dcedc65e3275123b7bb7241c3f323a6e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1935308Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarRyo Hashimoto <hashimoto@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718987}
parent bb3aabe3
......@@ -267,7 +267,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("fileDisplayDownloadsWithBlockedFileTaskRunner"),
TestCase("fileDisplayCheckSelectWithFakeItemSelected"),
TestCase("fileDisplayCheckReadOnlyIconOnFakeDirectory"),
TestCase("fileDisplayCheckNoReadOnlyIconOnDownloads")));
TestCase("fileDisplayCheckNoReadOnlyIconOnDownloads"),
TestCase("fileDisplayCheckNoReadOnlyIconOnLinuxFiles")));
WRAPPED_INSTANTIATE_TEST_SUITE_P(
OpenVideoFiles, /* open_video_files.js */
......
......@@ -2193,6 +2193,15 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name,
return;
}
if (name == "blockMounts") {
chromeos::DBusThreadManager* dbus_thread_manager =
chromeos::DBusThreadManager::Get();
static_cast<chromeos::FakeCrosDisksClient*>(
dbus_thread_manager->GetCrosDisksClient())
->BlockMount();
return;
}
FAIL() << "Unknown test message: " << name;
}
......
......@@ -76,6 +76,10 @@ void FakeCrosDisksClient::Mount(const std::string& source_path,
MountAccessMode access_mode,
RemountOption remount,
VoidDBusMethodCallback callback) {
if (block_mount_) {
return;
}
// This fake implementation assumes mounted path is device when source_format
// is empty, or an archive otherwise.
MountType type =
......
......@@ -150,6 +150,10 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) FakeCrosDisksClient
return get_device_properties_success_count_;
}
// Prevent subsequent Mount() calls from taking any action or responding via
// its callback.
void BlockMount() { block_mount_ = true; }
private:
// Continuation of Mount().
void DidMount(const std::string& source_path,
......@@ -176,6 +180,7 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) FakeCrosDisksClient
std::vector<CustomMountPointCallback> custom_mount_point_callbacks_;
const DiskInfo* next_get_device_properties_disk_info_ = nullptr;
int get_device_properties_success_count_ = 0;
bool block_mount_ = false;
base::WeakPtrFactory<FakeCrosDisksClient> weak_ptr_factory_{this};
......
......@@ -172,7 +172,16 @@ class ToolbarController {
const currentDirectory = this.directoryModel_.getCurrentDirEntry();
const locationInfo = currentDirectory &&
this.volumeManager_.getLocationInfo(currentDirectory);
this.readOnlyIndicator_.hidden = !(locationInfo && locationInfo.isReadOnly);
// Normally, isReadOnly can be used to show the label. This property
// is always true for fake volumes (eg. Google Drive root). However, "Linux
// files" is a fake volume on first access until the VM is loaded and the
// mount point is initialised. The volume is technically read-only since the
// temportary fake volume can (and should) not be written to. However,
// showing the read only label is not appropriate since the volume will
// become read-write once all loading has completed.
this.readOnlyIndicator_.hidden =
!(locationInfo && locationInfo.isReadOnly &&
locationInfo.rootType !== VolumeManagerCommon.RootType.CROSTINI);
}
/** @private */
......
......@@ -801,3 +801,29 @@ testcase.fileDisplayCheckNoReadOnlyIconOnDownloads = async () => {
// Make sure read-only indicator on toolbar is NOT visible.
await remoteCall.waitForElement(appId, '#read-only-indicator[hidden]');
};
/**
* Tests to make sure read-only indicator is NOT visible when the current
* directory is the "Linux files" fake root.
*/
testcase.fileDisplayCheckNoReadOnlyIconOnLinuxFiles = async () => {
const fakeRoot = '#directory-tree [root-type-icon="crostini"]';
// Block mounts from progressing. This should cause the file manager to always
// show the loading bar for linux files.
await sendTestMessage({name: 'blockMounts'});
// Open files app on Downloads.
const appId =
await setupAndWaitUntilReady(RootPath.DOWNLOADS, [ENTRIES.hello], []);
// Linux files fake root is shown.
await remoteCall.waitForElement(appId, fakeRoot);
// Click on Linux files.
await remoteCall.callRemoteTestUtil('fakeMouseClick', appId, [fakeRoot]);
await remoteCall.waitForElement(appId, 'paper-progress:not([hidden])');
// Make sure read-only indicator on toolbar is NOT visible.
await remoteCall.waitForElement(appId, '#read-only-indicator[hidden]');
};
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