Commit 58b088b1 authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Add tests for the Recents virtual folder in the file manager.

Bug: 854481
Change-Id: I090cd08474d41793b7a03b7d363d523b8a06c432
Reviewed-on: https://chromium-review.googlesource.com/1238034
Commit-Queue: Sam McNally <sammc@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593096}
parent b1879b77
......@@ -607,6 +607,18 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
FilesAppBrowserTest,
::testing::Values(TestCase("launcherOpenSearchResult")));
WRAPPED_INSTANTIATE_TEST_CASE_P(
Recents, /* recents.js */
FilesAppBrowserTest,
::testing::Values(
TestCase("recentsDownloads"),
TestCase("recentsDrive"),
TestCase("recentsDrive").EnableDriveFs(),
TestCase("recentsDownloadsAndDrive"),
TestCase("recentsDownloadsAndDrive").EnableDriveFs(),
TestCase("recentsDownloadsAndDriveWithOverlap"),
TestCase("recentsDownloadsAndDriveWithOverlap").EnableDriveFs()));
// Structure to describe an account info.
struct TestAccountInfo {
const char* const gaia_id;
......
......@@ -97,7 +97,6 @@ class FakeDriveFs::SearchQuery : public mojom::SearchQuery {
query_(base::ToLowerASCII(
params.title.value_or(params.text_content.value_or("")))),
weak_ptr_factory_(this) {
CHECK(!query_.empty());
}
private:
......@@ -122,11 +121,19 @@ class FakeDriveFs::SearchQuery : public mojom::SearchQuery {
std::vector<drivefs::mojom::QueryItemPtr> results;
base::FileEnumerator walker(mount_path, true, base::FileEnumerator::FILES);
for (auto file = walker.Next(); !file.empty(); file = walker.Next()) {
if (base::ToLowerASCII(file.BaseName().value()).find(query) !=
if (query.empty() ||
base::ToLowerASCII(file.BaseName().value()).find(query) !=
std::string::npos) {
auto item = drivefs::mojom::QueryItem::New();
item->path = base::FilePath("/");
CHECK(mount_path.AppendRelativePath(file, &item->path));
std::vector<std::string> components;
item->path.GetComponents(&components);
// During tests, metadata for the other drive sync implementation can
// end up in |mount_path| so filter it out.
if (components.size() < 2u || components[1] == "meta") {
continue;
}
results.push_back(std::move(item));
}
}
......@@ -243,6 +250,7 @@ void FakeDriveFs::GetMetadata(const base::FilePath& path,
auto metadata = drivefs::mojom::FileMetadata::New();
metadata->size = info.size;
metadata->modification_time = info.last_modified;
metadata->last_viewed_by_me_time = info.last_modified;
const auto& stored_metadata = metadata_[path];
metadata->pinned = stored_metadata.pinned;
......
......@@ -205,13 +205,8 @@ var BASIC_FAKE_ENTRY_SET = [
* @const
*/
var RECENT_ENTRY_SET = [
ENTRIES.hello,
ENTRIES.world,
ENTRIES.desktop,
ENTRIES.beautiful,
ENTRIES.unsupported,
ENTRIES.testDocument,
ENTRIES.testSharedDocument
];
/**
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
function generateVerifyRecentsSteps(expectedRecents = RECENT_ENTRY_SET) {
let appId;
return [
// Navigate to Recents.
function(results) {
appId = results.windowId;
remoteCall.callRemoteTestUtil(
'fakeMouseClick', appId, ['span[root-type-icon=\'recent\']'],
this.next);
},
// Verify Recents contains the expected files - those with an mtime in the
// future.
function(result) {
chrome.test.assertTrue(result);
const files = TestEntryInfo.getExpectedRows(expectedRecents);
remoteCall.waitForFiles(appId, files).then(this.next);
},
function() {
checkIfNoErrorsOccured(this.next);
}
];
}
testcase.recentsDownloads = function() {
StepsRunner.run([
// Populate downloads.
function() {
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, BASIC_LOCAL_ENTRY_SET, []);
},
].concat(generateVerifyRecentsSteps()));
};
testcase.recentsDrive = function() {
StepsRunner.run([
// Populate drive.
function() {
setupAndWaitUntilReady(
null, RootPath.DRIVE, this.next, [], BASIC_DRIVE_ENTRY_SET);
},
].concat(generateVerifyRecentsSteps()));
};
testcase.recentsDownloadsAndDrive = function() {
StepsRunner.run([
// Populate both downloads and drive with disjoint sets of files.
function() {
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next,
[ENTRIES.beautiful, ENTRIES.hello, ENTRIES.photos],
[ENTRIES.desktop, ENTRIES.world, ENTRIES.testDocument]);
},
].concat(generateVerifyRecentsSteps()));
};
testcase.recentsDownloadsAndDriveWithOverlap = function() {
StepsRunner.run([
// Populate both downloads and drive with overlapping sets of files.
function() {
setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next);
},
].concat(generateVerifyRecentsSteps(RECENT_ENTRY_SET
.concat(RECENT_ENTRY_SET))));
};
......@@ -36,6 +36,7 @@
"file_manager/open_video_files.js",
"file_manager/providers.js",
"file_manager/quick_view.js",
"file_manager/recents.js",
"file_manager/restore_geometry.js",
"file_manager/restore_prefs.js",
"file_manager/share_and_manage_dialog.js",
......
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