Commit 62b8f725 authored by Jeremie Boulic's avatar Jeremie Boulic Committed by Commit Bot

Update manifest to allow launching app on directories

Update file_manager manifest to be able to accept path parameters when
trying to launch the files app on specific directories.

Bug: 1028038
Change-Id: I48b4084699edeb2ba39456e2ac1b14a60ee0ea9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1936437Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Jeremie Boulic <jboulic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719516}
parent aebc15cc
...@@ -80,6 +80,11 @@ struct TestCase { ...@@ -80,6 +80,11 @@ struct TestCase {
return *this; return *this;
} }
TestCase& DontObserveFileTasks() {
observe_file_tasks = false;
return *this;
}
// Show the startup browser. Some tests invoke the file picker dialog during // Show the startup browser. Some tests invoke the file picker dialog during
// the test. Requesting a file picker from a background page is forbidden by // the test. Requesting a file picker from a background page is forbidden by
// the apps platform, and it's a bug that these tests do so. // the apps platform, and it's a bug that these tests do so.
...@@ -128,6 +133,7 @@ struct TestCase { ...@@ -128,6 +133,7 @@ struct TestCase {
bool files_ng = false; bool files_ng = false;
bool enable_native_smb = true; bool enable_native_smb = true;
bool mount_no_volumes = false; bool mount_no_volumes = false;
bool observe_file_tasks = true;
}; };
// ZipCase: FilesAppBrowserTest with zip/unzip support. // ZipCase: FilesAppBrowserTest with zip/unzip support.
...@@ -193,6 +199,10 @@ class FilesAppBrowserTest : public FileManagerBrowserTestBase, ...@@ -193,6 +199,10 @@ class FilesAppBrowserTest : public FileManagerBrowserTestBase,
return GetParam().mount_no_volumes; return GetParam().mount_no_volumes;
} }
bool GetStartWithFileTasksObserver() const override {
return GetParam().observe_file_tasks;
}
private: private:
DISALLOW_COPY_AND_ASSIGN(FilesAppBrowserTest); DISALLOW_COPY_AND_ASSIGN(FilesAppBrowserTest);
}; };
...@@ -239,6 +249,7 @@ WRAPPED_INSTANTIATE_TEST_SUITE_P( ...@@ -239,6 +249,7 @@ 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("fileDisplayDrive").TabletMode(), TestCase("fileDisplayDrive").TabletMode(),
TestCase("fileDisplayDrive"), TestCase("fileDisplayDrive"),
TestCase("fileDisplayDriveOffline").Offline(), TestCase("fileDisplayDriveOffline").Offline(),
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "chrome/browser/chromeos/file_manager/volume_manager.h" #include "chrome/browser/chromeos/file_manager/volume_manager.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/notifications/notification_display_service_tester.h" #include "chrome/browser/notifications/notification_display_service_tester.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h"
#include "chrome/browser/sync_file_system/sync_file_system_service_factory.h" #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h"
#include "chrome/browser/ui/app_list/search/chrome_search_result.h" #include "chrome/browser/ui/app_list/search/chrome_search_result.h"
...@@ -1464,9 +1465,11 @@ void FileManagerBrowserTestBase::SetUpOnMainThread() { ...@@ -1464,9 +1465,11 @@ void FileManagerBrowserTestBase::SetUpOnMainThread() {
} }
if (!IsIncognitoModeTest()) { if (!IsIncognitoModeTest()) {
file_tasks_observer_ = if (GetStartWithFileTasksObserver()) {
std::make_unique<testing::StrictMock<MockFileTasksObserver>>( file_tasks_observer_ =
profile()); std::make_unique<testing::StrictMock<MockFileTasksObserver>>(
profile());
}
} else { } else {
EXPECT_FALSE(file_tasks::FileTasksNotifier::GetForProfile(profile())); EXPECT_FALSE(file_tasks::FileTasksNotifier::GetForProfile(profile()));
} }
...@@ -1540,6 +1543,10 @@ bool FileManagerBrowserTestBase::GetStartWithNoVolumesMounted() const { ...@@ -1540,6 +1543,10 @@ bool FileManagerBrowserTestBase::GetStartWithNoVolumesMounted() const {
return false; return false;
} }
bool FileManagerBrowserTestBase::GetStartWithFileTasksObserver() const {
return true;
}
void FileManagerBrowserTestBase::StartTest() { void FileManagerBrowserTestBase::StartTest() {
LOG(INFO) << "FileManagerBrowserTest::StartTest " << GetFullTestCaseName(); LOG(INFO) << "FileManagerBrowserTest::StartTest " << GetFullTestCaseName();
static const base::FilePath test_extension_dir = static const base::FilePath test_extension_dir =
...@@ -1615,6 +1622,15 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name, ...@@ -1615,6 +1622,15 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name,
return; return;
} }
if (name == "launchAppOnDownloads") {
const base::FilePath downloads_path =
file_manager::util::GetDownloadsFolderForProfile(profile());
platform_util::OpenItem(profile(), downloads_path,
platform_util::OPEN_FOLDER,
platform_util::OpenOperationCallback());
return;
}
if (name == "zipArchiverLoaded") { if (name == "zipArchiverLoaded") {
if (IsZipTest()) { if (IsZipTest()) {
LOG(INFO) << "Preloading zip archiver NaCl module"; LOG(INFO) << "Preloading zip archiver NaCl module";
......
...@@ -69,6 +69,7 @@ class FileManagerBrowserTestBase : public extensions::ExtensionApiTest { ...@@ -69,6 +69,7 @@ class FileManagerBrowserTestBase : public extensions::ExtensionApiTest {
virtual bool GetEnableFilesNg() const; virtual bool GetEnableFilesNg() const;
virtual bool GetEnableNativeSmb() const; virtual bool GetEnableNativeSmb() const;
virtual bool GetStartWithNoVolumesMounted() const; virtual bool GetStartWithNoVolumesMounted() const;
virtual bool GetStartWithFileTasksObserver() const;
// Launches the test extension from GetTestExtensionManifestName() and uses // Launches the test extension from GetTestExtensionManifestName() and uses
// it to drive the testing the actual FileManager component extension under // it to drive the testing the actual FileManager component extension under
......
...@@ -134,7 +134,8 @@ ...@@ -134,7 +134,8 @@
"extensions": ["*"] "extensions": ["*"]
}, },
"open": { "open": {
"extensions": ["*"] "extensions": ["*"],
"include_directories": true
} }
}, },
// Required to import scripts in a web worker. Note, that in Apps v2, it is // Required to import scripts in a web worker. Note, that in Apps v2, it is
......
...@@ -35,6 +35,26 @@ testcase.fileDisplayDownloads = () => { ...@@ -35,6 +35,26 @@ testcase.fileDisplayDownloads = () => {
return fileDisplay(RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET); return fileDisplay(RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET);
}; };
/**
* Tests opening the files app navigating to the Downloads folder. Uses
* platform_util::OpenItem, a call to an API distinct from the one commonly used
* in other tests for the same operation.
*/
testcase.fileDisplayLaunchOnDownloads = async () => {
// Open Files app on the Downloads directory.
await sendTestMessage({name: 'launchAppOnDownloads'});
// Wait for app window to open.
const appId = await remoteCall.waitForWindow('files#');
// Check: the Downloads folder should be selected.
await remoteCall.waitForElement(appId, 'li[file-name="Downloads"][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 files display in Google Drive. * Tests files display in Google Drive.
*/ */
......
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