Commit 5b778247 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Files app Fix some tests with flag MyFilesVolume enabled

Fix metadataDownloads, MigratePinnedFiles and DriveFS RecoverDirtyFiles.

Change |EnsureDownloadsFolderExists| to make sure that /Downloads folder
has been added to internal map, this fixes tests running with PRE_ which
creates the folder in the file system, but when the test run the entry
doesn't exist in the internal map.

Bug: 873539
Change-Id: I429ab76179f0e386df1d94842d2bfb9994d2100b
Reviewed-on: https://chromium-review.googlesource.com/c/1354800Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612081}
parent d095ec40
...@@ -822,6 +822,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P( ...@@ -822,6 +822,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
FilesAppBrowserTest, FilesAppBrowserTest,
::testing::Values( ::testing::Values(
TestCase("metadataDownloads"), TestCase("metadataDownloads"),
TestCase("metadataDownloads").EnableMyFilesVolume(),
TestCase("metadataDrive").DisableDriveFs(), TestCase("metadataDrive").DisableDriveFs(),
TestCase("metadataDrive").EnableDriveFs(), TestCase("metadataDrive").EnableDriveFs(),
TestCase("metadataDrive").EnableDriveFs().EnableMyFilesVolume(), TestCase("metadataDrive").EnableDriveFs().EnableMyFilesVolume(),
...@@ -1004,6 +1005,12 @@ class DriveFsFilesAppBrowserTest : public FileManagerBrowserTestBase { ...@@ -1004,6 +1005,12 @@ class DriveFsFilesAppBrowserTest : public FileManagerBrowserTestBase {
return profile()->GetPath().Append("drive/v1"); return profile()->GetPath().Append("drive/v1");
} }
bool GetEnableMyFilesVolume() const override {
return base::StringPiece(
::testing::UnitTest::GetInstance()->current_test_info()->name())
.ends_with("MyFiles");
}
private: private:
std::string test_case_name_; std::string test_case_name_;
...@@ -1023,6 +1030,20 @@ IN_PROC_BROWSER_TEST_F(DriveFsFilesAppBrowserTest, MigratePinnedFiles) { ...@@ -1023,6 +1030,20 @@ IN_PROC_BROWSER_TEST_F(DriveFsFilesAppBrowserTest, MigratePinnedFiles) {
EXPECT_TRUE(base::IsDirectoryEmpty(GetDriveDataDirectory())); EXPECT_TRUE(base::IsDirectoryEmpty(GetDriveDataDirectory()));
} }
IN_PROC_BROWSER_TEST_F(DriveFsFilesAppBrowserTest,
PRE_MigratePinnedFilesMyFiles) {
set_test_case_name("PRE_driveMigratePinnedFile");
StartTest();
}
IN_PROC_BROWSER_TEST_F(DriveFsFilesAppBrowserTest, MigratePinnedFilesMyFiles) {
set_test_case_name("driveMigratePinnedFile");
StartTest();
base::ScopedAllowBlockingForTesting allow_io;
EXPECT_TRUE(base::IsDirectoryEmpty(GetDriveDataDirectory()));
}
IN_PROC_BROWSER_TEST_F(DriveFsFilesAppBrowserTest, PRE_RecoverDirtyFiles) { IN_PROC_BROWSER_TEST_F(DriveFsFilesAppBrowserTest, PRE_RecoverDirtyFiles) {
set_test_case_name("PRE_driveRecoverDirtyFiles"); set_test_case_name("PRE_driveRecoverDirtyFiles");
StartTest(); StartTest();
...@@ -1043,6 +1064,27 @@ IN_PROC_BROWSER_TEST_F(DriveFsFilesAppBrowserTest, RecoverDirtyFiles) { ...@@ -1043,6 +1064,27 @@ IN_PROC_BROWSER_TEST_F(DriveFsFilesAppBrowserTest, RecoverDirtyFiles) {
EXPECT_TRUE(base::IsDirectoryEmpty(GetDriveDataDirectory())); EXPECT_TRUE(base::IsDirectoryEmpty(GetDriveDataDirectory()));
} }
IN_PROC_BROWSER_TEST_F(DriveFsFilesAppBrowserTest,
PRE_RecoverDirtyFilesMyFiles) {
set_test_case_name("PRE_driveRecoverDirtyFiles");
StartTest();
{
base::ScopedAllowBlockingForTesting allow_io;
// Create a non-dirty file in the cache.
base::WriteFile(GetDriveDataDirectory().Append("files/foo"), "data", 4);
}
}
IN_PROC_BROWSER_TEST_F(DriveFsFilesAppBrowserTest, RecoverDirtyFilesMyFiles) {
set_test_case_name("driveRecoverDirtyFiles");
StartTest();
base::ScopedAllowBlockingForTesting allow_io;
EXPECT_TRUE(base::IsDirectoryEmpty(GetDriveDataDirectory()));
}
IN_PROC_BROWSER_TEST_F(DriveFsFilesAppBrowserTest, LaunchWithoutOldDriveData) { IN_PROC_BROWSER_TEST_F(DriveFsFilesAppBrowserTest, LaunchWithoutOldDriveData) {
base::ScopedAllowBlockingForTesting allow_io; base::ScopedAllowBlockingForTesting allow_io;
......
...@@ -519,6 +519,13 @@ class LocalTestVolume : public TestVolume { ...@@ -519,6 +519,13 @@ class LocalTestVolume : public TestVolume {
CreateEntryImpl(entry, root_path().AppendASCII(entry.target_path)); CreateEntryImpl(entry, root_path().AppendASCII(entry.target_path));
} }
void InsertEntryOnMap(const AddEntriesMessage::TestEntryInfo& entry,
const base::FilePath& target_path) {
const auto it = entries_.find(target_path);
if (it == entries_.end())
entries_.insert(std::make_pair(target_path, entry));
}
void CreateEntryImpl(const AddEntriesMessage::TestEntryInfo& entry, void CreateEntryImpl(const AddEntriesMessage::TestEntryInfo& entry,
const base::FilePath& target_path) { const base::FilePath& target_path) {
entries_.insert(std::make_pair(target_path, entry)); entries_.insert(std::make_pair(target_path, entry));
...@@ -589,11 +596,14 @@ class DownloadsTestVolume : public LocalTestVolume { ...@@ -589,11 +596,14 @@ class DownloadsTestVolume : public LocalTestVolume {
// When MyFiles is the volume create the Downloads folder under it. // When MyFiles is the volume create the Downloads folder under it.
auto downloads_folder = root_path().Append("Downloads"); auto downloads_folder = root_path().Append("Downloads");
if (!base::PathExists(downloads_folder)) { auto downloads_entry = AddEntriesMessage::TestEntryInfo(
CreateEntryImpl(AddEntriesMessage::TestEntryInfo( AddEntriesMessage::DIRECTORY, "", "Downloads");
AddEntriesMessage::DIRECTORY, "", "Downloads"), if (!base::PathExists(downloads_folder))
downloads_folder); CreateEntryImpl(downloads_entry, downloads_folder);
}
// Make sure that Downloads exists in the local entries_ map, in case the
// folder in the FS has been created by a PRE_ routine.
InsertEntryOnMap(downloads_entry, downloads_folder);
} }
// Forces the content to be created inside MyFiles/Downloads when MyFiles is // Forces the content to be created inside MyFiles/Downloads when MyFiles is
// the Volume, so tests are compatible with volume being MyFiles or Downloads. // the Volume, so tests are compatible with volume being MyFiles or Downloads.
......
...@@ -656,7 +656,9 @@ testcase.driveRecoverDirtyFiles = function() { ...@@ -656,7 +656,9 @@ testcase.driveRecoverDirtyFiles = function() {
function() { function() {
return remoteCall return remoteCall
.navigateWithDirectoryTree( .navigateWithDirectoryTree(
appId, '/Recovered files from Google Drive', 'My files/Downloads') appId,
RootPath.DOWNLOADS_PATH + '/Recovered files from Google Drive',
'My files/Downloads')
.then(this.next); .then(this.next);
}, },
// Ensure it contains never-sync.txt and never-sync (1).txt. // Ensure it contains never-sync.txt and never-sync (1).txt.
......
...@@ -177,7 +177,8 @@ testcase.metadataDownloads = function() { ...@@ -177,7 +177,8 @@ testcase.metadataDownloads = function() {
appId = result.windowId; appId = result.windowId;
remoteCall remoteCall
.navigateWithDirectoryTree( .navigateWithDirectoryTree(
appId, '/photos1/folder1', 'My files/Downloads') appId, RootPath.DOWNLOADS_PATH + '/photos1/folder1',
'My files/Downloads')
.then(this.next); .then(this.next);
}, },
// Fetch the metadata stats. // Fetch the metadata stats.
......
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