Commit 106115a3 authored by Jeremie Boulic's avatar Jeremie Boulic Committed by Commit Bot

Improve tests for launching files app on specific folders

browser_tests --gtest_filter="*fileDisplayLaunchOnLocalFolder"
browser_tests --gtest_filter="*fileDisplayLaunchOnDrive"

Bug: 1028907, 1028038
Test: 
Change-Id: I72e5e91a8bfc093807ccdaa4f7a29a38c73b2f57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1940320
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719871}
parent e48ff40b
...@@ -249,7 +249,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P( ...@@ -249,7 +249,8 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P(
TestCase("fileDisplayDownloads"), TestCase("fileDisplayDownloads"),
TestCase("fileDisplayDownloads").InGuestMode(), TestCase("fileDisplayDownloads").InGuestMode(),
TestCase("fileDisplayDownloads").TabletMode(), TestCase("fileDisplayDownloads").TabletMode(),
TestCase("fileDisplayLaunchOnDownloads").DontObserveFileTasks(), TestCase("fileDisplayLaunchOnLocalFolder").DontObserveFileTasks(),
TestCase("fileDisplayLaunchOnDrive").DontObserveFileTasks(),
TestCase("fileDisplayDrive").TabletMode(), TestCase("fileDisplayDrive").TabletMode(),
TestCase("fileDisplayDrive"), TestCase("fileDisplayDrive"),
TestCase("fileDisplayDriveOffline").Offline(), TestCase("fileDisplayDriveOffline").Offline(),
......
...@@ -642,6 +642,22 @@ struct GetUserActionCountMessage { ...@@ -642,6 +642,22 @@ struct GetUserActionCountMessage {
std::string user_action_name; std::string user_action_name;
}; };
struct GetLocalPathMessage {
static bool ConvertJSONValue(const base::DictionaryValue& value,
GetLocalPathMessage* message) {
base::JSONValueConverter<GetLocalPathMessage> converter;
return converter.Convert(value, message);
}
static void RegisterJSONConverter(
base::JSONValueConverter<GetLocalPathMessage>* converter) {
converter->RegisterStringField("localPath",
&GetLocalPathMessage::local_path);
}
std::string local_path;
};
} // anonymous namespace } // anonymous namespace
class FileManagerBrowserTestBase::MockFileTasksObserver class FileManagerBrowserTestBase::MockFileTasksObserver
...@@ -1622,12 +1638,30 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name, ...@@ -1622,12 +1638,30 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name,
return; return;
} }
if (name == "launchAppOnDownloads") { if (name == "launchAppOnLocalFolder") {
const base::FilePath downloads_path = GetLocalPathMessage message;
file_manager::util::GetDownloadsFolderForProfile(profile()); ASSERT_TRUE(GetLocalPathMessage::ConvertJSONValue(value, &message));
platform_util::OpenItem(profile(), downloads_path,
platform_util::OPEN_FOLDER, base::FilePath folder_path =
file_manager::util::GetMyFilesFolderForProfile(profile());
folder_path = folder_path.AppendASCII(message.local_path);
platform_util::OpenItem(profile(), folder_path, platform_util::OPEN_FOLDER,
platform_util::OpenOperationCallback()); platform_util::OpenOperationCallback());
return;
}
if (name == "launchAppOnDrive") {
auto* integration_service =
drive::DriveIntegrationServiceFactory::FindForProfile(profile());
ASSERT_TRUE(integration_service && integration_service->is_enabled());
base::FilePath mount_path =
integration_service->GetMountPointPath().AppendASCII("root");
platform_util::OpenItem(profile(), mount_path, platform_util::OPEN_FOLDER,
platform_util::OpenOperationCallback());
return; return;
} }
......
...@@ -36,19 +36,45 @@ testcase.fileDisplayDownloads = () => { ...@@ -36,19 +36,45 @@ testcase.fileDisplayDownloads = () => {
}; };
/** /**
* Tests opening the files app navigating to the Downloads folder. Uses * Tests opening the files app navigating to a local folder. Uses
* platform_util::OpenItem, a call to an API distinct from the one commonly used * platform_util::OpenItem, a call to an API distinct from the one commonly used
* in other tests for the same operation. * in other tests for the same operation.
*/ */
testcase.fileDisplayLaunchOnDownloads = async () => { testcase.fileDisplayLaunchOnLocalFolder = async () => {
// Add a file to Downloads.
await addEntries(['local'], [ENTRIES.photos]);
// Open Files app on the Downloads directory. // Open Files app on the Downloads directory.
await sendTestMessage({name: 'launchAppOnDownloads'}); await sendTestMessage(
{name: 'launchAppOnLocalFolder', localPath: 'Downloads/photos'});
// Wait for app window to open.
const appId = await remoteCall.waitForWindow('files#');
// Check: the Downloads/photos folder should be selected.
await remoteCall.waitForElement(
appId, '#file-list [file-name="photos"][selected]');
// The API used to launch the Files app does not set the IN_TEST flag to true:
// error when attempting to retrieve Web Store access token.
return IGNORE_APP_ERRORS;
};
/**
* Tests opening the files app navigating to the My Drive folder. Uses
* platform_util::OpenItem, a call to an API distinct from the one commonly used
* in other tests for the same operation.
*/
testcase.fileDisplayLaunchOnDrive = async () => {
// Open Files app on the Drive directory.
await sendTestMessage({name: 'launchAppOnDrive'});
// Wait for app window to open. // Wait for app window to open.
const appId = await remoteCall.waitForWindow('files#'); const appId = await remoteCall.waitForWindow('files#');
// Check: the Downloads folder should be selected. // Check: the app should be open on My Drive.
await remoteCall.waitForElement(appId, 'li[file-name="Downloads"][selected]'); await remoteCall.waitForElement(
appId, '#directory-tree .tree-item[selected] [volume-type-icon="drive"]');
// The API used to launch the Files app does not set the IN_TEST flag to true: // The API used to launch the Files app does not set the IN_TEST flag to true:
// error when attempting to retrieve Web Store access token. // error when attempting to retrieve Web Store access token.
......
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