Commit b55e2595 authored by Alex Lau's avatar Alex Lau Committed by Commit Bot

Cleanup Files app gear menu integration tests.

Add missing assertions after callRemoteTestUtil invocations.

LOG(FATAL) instead of assertion when trying to add entries to a
non-existant Android Files test volume. Also remove unnecessary
AndroidFilesTestVolume.Initialize() call.

Bug: 877371
Change-Id: I925ad37a056e411eb3a5bd833cad59a5ce11fae3
Reviewed-on: https://chromium-review.googlesource.com/1218664Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Alex Lau <alexlau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590232}
parent 9a4538ad
...@@ -501,8 +501,6 @@ class AndroidFilesTestVolume : public LocalTestVolume { ...@@ -501,8 +501,6 @@ class AndroidFilesTestVolume : public LocalTestVolume {
AndroidFilesTestVolume() : LocalTestVolume("AndroidFiles") {} AndroidFilesTestVolume() : LocalTestVolume("AndroidFiles") {}
~AndroidFilesTestVolume() override = default; ~AndroidFilesTestVolume() override = default;
bool Initialize(Profile* profile) { return CreateRootDirectory(profile); }
bool Mount(Profile* profile) override { bool Mount(Profile* profile) override {
return CreateRootDirectory(profile) && return CreateRootDirectory(profile) &&
VolumeManager::Get(profile)->RegisterAndroidFilesDirectoryForTesting( VolumeManager::Get(profile)->RegisterAndroidFilesDirectoryForTesting(
...@@ -1269,9 +1267,11 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name, ...@@ -1269,9 +1267,11 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name,
} }
break; break;
case AddEntriesMessage::ANDROID_FILES_VOLUME: case AddEntriesMessage::ANDROID_FILES_VOLUME:
CHECK(android_files_volume_); if (android_files_volume_) {
ASSERT_TRUE(android_files_volume_->Initialize(profile()));
android_files_volume_->CreateEntry(*message.entries[i]); android_files_volume_->CreateEntry(*message.entries[i]);
} else {
LOG(FATAL) << "Add entry: but no Android files volume.";
}
break; break;
} }
} }
......
...@@ -129,7 +129,7 @@ std::string GetDownloadsMountPointName(Profile* profile) { ...@@ -129,7 +129,7 @@ std::string GetDownloadsMountPointName(Profile* profile) {
return net::EscapeQueryParamValue(kDownloadsFolderName + id, false); return net::EscapeQueryParamValue(kDownloadsFolderName + id, false);
} }
std::string GetAndroidFilesMountPointName() { const std::string GetAndroidFilesMountPointName() {
return kAndroidFilesMountPointName; return kAndroidFilesMountPointName;
} }
......
...@@ -47,7 +47,7 @@ bool MigratePathFromOldFormat(Profile* profile, ...@@ -47,7 +47,7 @@ bool MigratePathFromOldFormat(Profile* profile,
std::string GetDownloadsMountPointName(Profile* profile); std::string GetDownloadsMountPointName(Profile* profile);
// The canonical mount point name for ARC "Play files" folder. // The canonical mount point name for ARC "Play files" folder.
std::string GetAndroidFilesMountPointName(); const std::string GetAndroidFilesMountPointName();
// The canonical mount point name for crostini "Linux files" folder. // The canonical mount point name for crostini "Linux files" folder.
std::string GetCrostiniMountPointName(Profile* profile); std::string GetCrostiniMountPointName(Profile* profile);
......
...@@ -951,10 +951,11 @@ void VolumeManager::OnArcPlayStoreEnabledChanged(bool enabled) { ...@@ -951,10 +951,11 @@ void VolumeManager::OnArcPlayStoreEnabledChanged(bool enabled) {
Volume::CreateForMediaView(arc::kVideosRootDocumentId)); Volume::CreateForMediaView(arc::kVideosRootDocumentId));
DoMountEvent(chromeos::MOUNT_ERROR_NONE, DoMountEvent(chromeos::MOUNT_ERROR_NONE,
Volume::CreateForMediaView(arc::kAudioRootDocumentId)); Volume::CreateForMediaView(arc::kAudioRootDocumentId));
if (IsShowAndroidFilesEnabled()) if (IsShowAndroidFilesEnabled()) {
DoMountEvent(chromeos::MOUNT_ERROR_NONE, DoMountEvent(chromeos::MOUNT_ERROR_NONE,
Volume::CreateForAndroidFiles( Volume::CreateForAndroidFiles(
base::FilePath(util::kAndroidFilesPath))); base::FilePath(util::kAndroidFilesPath)));
}
} else { } else {
DoUnmountEvent(chromeos::MOUNT_ERROR_NONE, DoUnmountEvent(chromeos::MOUNT_ERROR_NONE,
*Volume::CreateForMediaView(arc::kImagesRootDocumentId)); *Volume::CreateForMediaView(arc::kImagesRootDocumentId));
......
...@@ -301,12 +301,13 @@ testcase.toogleGoogleDocsDrive = function() { ...@@ -301,12 +301,13 @@ testcase.toogleGoogleDocsDrive = function() {
remoteCall.waitForElement(appId, remoteCall.waitForElement(appId,
'#gear-menu-drive-hosted-settings:not([disabled])').then(this.next); '#gear-menu-drive-hosted-settings:not([disabled])').then(this.next);
}, },
function(results) { function(result) {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-menu-drive-hosted-settings'], 'fakeMouseClick', appId, ['#gear-menu-drive-hosted-settings'],
this.next); this.next);
}, },
function(result) { function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows( remoteCall.waitForFiles(appId, TestEntryInfo.getExpectedRows(
BASIC_DRIVE_ENTRY_SET), {ignoreFileSize: true, BASIC_DRIVE_ENTRY_SET), {ignoreFileSize: true,
ignoreLastModifiedTime: true}).then(this.next); ignoreLastModifiedTime: true}).then(this.next);
...@@ -369,7 +370,8 @@ testcase.showToggleHiddenAndroidFoldersGearMenuItemsInMyFiles = function() { ...@@ -369,7 +370,8 @@ testcase.showToggleHiddenAndroidFoldersGearMenuItemsInMyFiles = function() {
'fakeMouseClick', appId, ['#file-list'], this.next); 'fakeMouseClick', appId, ['#file-list'], this.next);
}, },
// Wait for the gear menu to hide. // Wait for the gear menu to hide.
function() { function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next); remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next);
}, },
// Navigate to Recent. // Navigate to Recent.
...@@ -379,7 +381,8 @@ testcase.showToggleHiddenAndroidFoldersGearMenuItemsInMyFiles = function() { ...@@ -379,7 +381,8 @@ testcase.showToggleHiddenAndroidFoldersGearMenuItemsInMyFiles = function() {
this.next); this.next);
}, },
// Click the gear menu button. // Click the gear menu button.
function() { function(result) {
chrome.test.assertTrue(result);
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#gear-button'], this.next); 'fakeMouseClick', appId, ['#gear-button'], this.next);
}, },
...@@ -493,7 +496,8 @@ testcase.showPasteIntoCurrentFolder = function() { ...@@ -493,7 +496,8 @@ testcase.showPasteIntoCurrentFolder = function() {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#file-list'], this.next); 'fakeMouseClick', appId, ['#file-list'], this.next);
}, },
function() { function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next); remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next);
}, },
...@@ -509,7 +513,8 @@ testcase.showPasteIntoCurrentFolder = function() { ...@@ -509,7 +513,8 @@ testcase.showPasteIntoCurrentFolder = function() {
}, },
// Wait for menu to appear. // Wait for menu to appear.
// The command is still shown. // The command is still shown.
function() { function(result) {
chrome.test.assertTrue(result);
remoteCall remoteCall
.waitForElement( .waitForElement(
appId, appId,
...@@ -522,7 +527,8 @@ testcase.showPasteIntoCurrentFolder = function() { ...@@ -522,7 +527,8 @@ testcase.showPasteIntoCurrentFolder = function() {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#file-list'], this.next); 'fakeMouseClick', appId, ['#file-list'], this.next);
}, },
function() { function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next); remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next);
}, },
...@@ -532,7 +538,8 @@ testcase.showPasteIntoCurrentFolder = function() { ...@@ -532,7 +538,8 @@ testcase.showPasteIntoCurrentFolder = function() {
'selectFile', appId, [ENTRIES.hello.nameText], this.next); 'selectFile', appId, [ENTRIES.hello.nameText], this.next);
}, },
// Ctrl-C to copy the selected file // Ctrl-C to copy the selected file
function() { function(result) {
chrome.test.assertTrue(result);
remoteCall remoteCall
.fakeKeyDown(appId, '#file-list', 'c', 'U+0043', true, false, false) .fakeKeyDown(appId, '#file-list', 'c', 'U+0043', true, false, false)
.then(this.next); .then(this.next);
...@@ -542,7 +549,8 @@ testcase.showPasteIntoCurrentFolder = function() { ...@@ -542,7 +549,8 @@ testcase.showPasteIntoCurrentFolder = function() {
'fakeMouseClick', appId, ['#gear-button'], this.next); 'fakeMouseClick', appId, ['#gear-button'], this.next);
}, },
// The command appears enabled. // The command appears enabled.
function() { function(result) {
chrome.test.assertTrue(result);
remoteCall remoteCall
.waitForElement( .waitForElement(
appId, appId,
...@@ -555,7 +563,8 @@ testcase.showPasteIntoCurrentFolder = function() { ...@@ -555,7 +563,8 @@ testcase.showPasteIntoCurrentFolder = function() {
remoteCall.callRemoteTestUtil( remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['#file-list'], this.next); 'fakeMouseClick', appId, ['#file-list'], this.next);
}, },
function() { function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next); remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next);
}, },
function() { function() {
...@@ -589,7 +598,8 @@ testcase.showSelectAllInCurrentFolder = function() { ...@@ -589,7 +598,8 @@ testcase.showSelectAllInCurrentFolder = function() {
'fakeMouseClick', appId, ['#gear-button'], this.next); 'fakeMouseClick', appId, ['#gear-button'], this.next);
}, },
// Wait for the gear menu to appear. // Wait for the gear menu to appear.
function() { function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu:not([hidden])') remoteCall.waitForElement(appId, '#gear-menu:not([hidden])')
.then(this.next); .then(this.next);
}, },
...@@ -609,7 +619,8 @@ testcase.showSelectAllInCurrentFolder = function() { ...@@ -609,7 +619,8 @@ testcase.showSelectAllInCurrentFolder = function() {
'fakeMouseClick', appId, ['#file-list'], this.next); 'fakeMouseClick', appId, ['#file-list'], this.next);
}, },
// Wait for the gear menu to hide. // Wait for the gear menu to hide.
function() { function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next); remoteCall.waitForElement(appId, '#gear-menu[hidden]').then(this.next);
}, },
// Add a new file to Downloads. // Add a new file to Downloads.
...@@ -644,7 +655,8 @@ testcase.showSelectAllInCurrentFolder = function() { ...@@ -644,7 +655,8 @@ testcase.showSelectAllInCurrentFolder = function() {
'fakeMouseClick', appId, ['#gear-menu-select-all'], this.next); 'fakeMouseClick', appId, ['#gear-menu-select-all'], this.next);
}, },
// Check: the file-list should be selected. // Check: the file-list should be selected.
function() { function(result) {
chrome.test.assertTrue(result);
remoteCall.waitForElement(appId, '#file-list li[selected]') remoteCall.waitForElement(appId, '#file-list li[selected]')
.then(this.next); .then(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