Commit e996d16c authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Update FilesApp UI tests to use MyFiles

* Update tests to use MyFiles
* Update test_util.js to use MyFiles and remove dead code.

Bug: 955920
Change-Id: Ia1c7774a0857a8e1631f8b5b7f86a1cee597f9a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1585823Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654790}
parent 407b153f
......@@ -57,9 +57,9 @@ crostiniMount.testMountCrostiniSuccess = async (done) => {
// Linux Files fake root is shown.
await test.waitForElement(fakeRoot);
// Downloads folder should be shown when crostini goes away.
await test.waitForFiles(
test.TestEntryInfo.getExpectedRows(test.BASIC_LOCAL_ENTRY_SET));
// MyFiles folder should be shown when crostini goes away.
await test.waitForFiles(test.TestEntryInfo.getExpectedRows(
test.BASIC_MY_FILES_ENTRY_SET_WITH_LINUX_FILES));
done();
};
......
......@@ -36,7 +36,7 @@ shareBase.testSharePathsSuccess =
const shareWithDirTree =
'#directory-tree-context-menu [command="#' + share + '"]';
const photos = '#file-list [file-name="photos"]';
const downloadsDirTree = '#directory-tree [volume-type-icon="downloads"]';
const myFilesDirTree = '#directory-tree [root-type-icon="my_files"]';
const oldSharePaths = chrome.fileManagerPrivate.sharePathsWithCrostini;
let sharePathsCalled = false;
let sharePathsPersist;
......@@ -116,10 +116,9 @@ shareBase.testSharePathsSuccess =
assertTrue(test.fakeMouseRightClick(photos), 'right-click photos');
await test.waitForElement(menuShareWith);
// Verify dialog is shown for Downloads root.
// Verify dialog is shown for MyFiles root.
// Check 'Share with <VM>' is shown in menu.
assertTrue(
test.fakeMouseRightClick(downloadsDirTree), 'right-click downloads');
assertTrue(test.fakeMouseRightClick(myFilesDirTree), 'right-click MyFiles');
await test.waitForElement(menuShareWithDirTree);
// Click 'Share with <VM>', verify dialog.
......@@ -167,7 +166,6 @@ shareBase.testSharePathShown = async (vmName, vmNameSelector, done) => {
'[command="#' + share + '"][hidden][disabled="disabled"]';
const menuShareWith = '#file-context-menu:not([hidden]) ' +
'[command="#' + share + '"]:not([hidden]):not([disabled])';
const downloadsDirTree = '#directory-tree [volume-type-icon="downloads"]';
const removableVolumeRoot = '#directory-tree [volume-type-icon="removable"]';
const menuShareWithDirTree = '#directory-tree-context-menu:not([hidden]) ' +
'[command="#' + share + '"]:not([hidden]):not([disabled])';
......@@ -203,9 +201,9 @@ shareBase.testSharePathShown = async (vmName, vmNameSelector, done) => {
assertTrue(test.fakeMouseRightClick(downloads), 'right-click downloads');
await test.waitForElement(menuShareWith);
// Right-click 'Downloads' directory in directory tree.
// Right-click 'MyFiles' in directory tree.
// Check 'Share with <VM>' is shown in menu.
assertTrue(test.fakeMouseRightClick(downloadsDirTree), 'downloads dirtree');
assertTrue(test.fakeMouseRightClick(myFiles), 'MyFiles dirtree');
await test.waitForElement(menuShareWithDirTree);
// Select removable root.
......
......@@ -5,6 +5,8 @@
const crostiniTasks = {};
crostiniTasks.testShareBeforeOpeningDownloadsWithCrostiniApp = async (done) => {
const fakeRoot = '#directory-tree [root-type-icon="crostini"]';
// Save old fmp.getFileTasks and replace with version that returns
// crostini app and chrome Text app.
let oldGetFileTasks = chrome.fileManagerPrivate.getFileTasks;
......@@ -49,8 +51,8 @@ crostiniTasks.testShareBeforeOpeningDownloadsWithCrostiniApp = async (done) => {
// Add '/A', and '/A/hello.txt', refresh, 'A' is shown.
test.addEntries([test.ENTRIES.directoryA, test.ENTRIES.helloInA], [], []);
assertTrue(test.fakeMouseClick('#refresh-button'), 'click refresh');
await test.waitForFiles(
test.TestEntryInfo.getExpectedRows([test.ENTRIES.directoryA]));
await test.waitForFiles(test.TestEntryInfo.getExpectedRows(
[test.ENTRIES.directoryA, test.ENTRIES.linuxFiles]));
// Change to 'A' directory, hello.txt is shown.
assertTrue(test.fakeMouseDoubleClick('[file-name="A"]'));
......@@ -93,11 +95,13 @@ crostiniTasks.testShareBeforeOpeningDownloadsWithCrostiniApp = async (done) => {
chrome.fileManagerPrivate.getFileTasks = oldGetFileTasks;
chrome.fileManagerPrivate.sharePathsWithCrostini = oldSharePaths;
chrome.fileManagerPrivate.executeTask = oldExecuteTask;
chrome.fileManagerPrivate.removeMount('crostini');
await test.waitForElement(fakeRoot);
done();
};
crostiniTasks.testErrorLoadingLinuxPackageInfo = async (done) => {
const linuxFiles = '#directory-tree .tree-item [root-type-icon="crostini"]';
const fakeRoot = '#directory-tree [root-type-icon="crostini"]';
const dialog = '#install-linux-package-dialog';
const detailsFrame = '.install-linux-package-details-frame';
......@@ -123,10 +127,10 @@ crostiniTasks.testErrorLoadingLinuxPackageInfo = async (done) => {
};
await test.setupAndWaitUntilReady([], [], [test.ENTRIES.debPackage]);
await test.waitForElement(linuxFiles);
await test.waitForElement(fakeRoot);
// Select 'Linux files' in directory tree.
assertTrue(test.fakeMouseClick(linuxFiles), 'click Linux files');
assertTrue(test.fakeMouseClick(fakeRoot), 'click Linux files');
await test.waitForFiles(
test.TestEntryInfo.getExpectedRows([test.ENTRIES.debPackage]));
......@@ -158,5 +162,7 @@ crostiniTasks.testErrorLoadingLinuxPackageInfo = async (done) => {
// Restore fmp.getFileTasks, fmp.getLinuxPackageInfo.
chrome.fileManagerPrivate.getFileTasks = oldGetFileTasks;
chrome.fileManagerPrivate.getLinuxPackageInfo = oldGetLinuxPackageInfo;
chrome.fileManagerPrivate.removeMount('crostini');
await test.waitForElement(fakeRoot);
done();
};
......@@ -8,7 +8,7 @@
loadTimeData.data = $GRDP;
// Extend with additional fields not found in grdp files.
Object.setPrototypeOf(loadTimeData.data_, {
loadTimeData.overrideValues({
'CROSTINI_ENABLED': true,
'DRIVE_FS_ENABLED': false,
'GOOGLE_DRIVE_REDEEM_URL': 'http://www.google.com/intl/en/chrome/devices' +
......@@ -16,6 +16,7 @@ Object.setPrototypeOf(loadTimeData.data_, {
'GOOGLE_DRIVE_OVERVIEW_URL':
'https://support.google.com/chromebook/?p=filemanager_drive',
'HIDE_SPACE_INFO': false,
'MY_FILES_VOLUME_ENABLED': true,
'PLUGIN_VM_ENABLED': true,
'UI_LOCALE': 'en_US',
'language': 'en-US',
......
......@@ -127,7 +127,7 @@ test.TestEntryInfo.prototype.getMockFileSystemPopulateRow = function(prefix) {
var content = test.DATA[this.sourceFileName];
var size = content && content.size || 0;
return {
fullPath: prefix + this.nameText + suffix,
fullPath: prefix + this.targetPath + suffix,
metadata: {
size: size,
modificationTime: new Date(Date.parse(this.lastModifiedTime)),
......@@ -188,12 +188,12 @@ test.ENTRIES = {
'Jan 1, 1980, 11:59 PM', 'photos', '--', 'Folder'),
testDocument: new test.TestEntryInfo(
test.EntryType.FILE, '', 'Test Document',
test.EntryType.FILE, '', 'Test Document.gdoc',
'application/vnd.google-apps.document', test.SharedOption.NONE,
'Apr 10, 2013, 4:20 PM', 'Test Document.gdoc', '--', 'Google document'),
testSharedDocument: new test.TestEntryInfo(
test.EntryType.FILE, '', 'Test Shared Document',
test.EntryType.FILE, '', 'Test Shared Document.gdoc',
'application/vnd.google-apps.document', test.SharedOption.SHARED,
'Mar 20, 2013, 10:40 PM', 'Test Shared Document.gdoc', '--',
'Google document'),
......@@ -207,26 +207,6 @@ test.ENTRIES = {
test.EntryType.DIRECTORY, '', 'A', '', test.SharedOption.NONE,
'Jan 1, 2000, 1:00 AM', 'A', '--', 'Folder'),
directoryB: new test.TestEntryInfo(
test.EntryType.DIRECTORY, '', 'A/B', '', test.SharedOption.NONE,
'Jan 1, 2000, 1:00 AM', 'B', '--', 'Folder'),
directoryC: new test.TestEntryInfo(
test.EntryType.DIRECTORY, '', 'A/B/C', '', test.SharedOption.NONE,
'Jan 1, 2000, 1:00 AM', 'C', '--', 'Folder'),
directoryD: new test.TestEntryInfo(
test.EntryType.DIRECTORY, '', 'D', '', test.SharedOption.NONE,
'Jan 1, 2000, 1:00 AM', 'D', '--', 'Folder'),
directoryE: new test.TestEntryInfo(
test.EntryType.DIRECTORY, '', 'D/E', '', test.SharedOption.NONE,
'Jan 1, 2000, 1:00 AM', 'E', '--', 'Folder'),
directoryF: new test.TestEntryInfo(
test.EntryType.DIRECTORY, '', 'D/E/F', '', test.SharedOption.NONE,
'Jan 1, 2000, 1:00 AM', 'F', '--', 'Folder'),
zipArchive: new test.TestEntryInfo(
test.EntryType.FILE, 'archive.zip', 'archive.zip', 'application/x-zip',
test.SharedOption.NONE, 'Jan 1, 2014, 1:00 AM', 'archive.zip',
......@@ -243,24 +223,41 @@ test.ENTRIES = {
'51 bytes', 'Plain text'),
helloInA: new test.TestEntryInfo(
test.EntryType.FILE, 'text.txt', 'hello.txt', 'text/plain',
test.SharedOption.NONE, 'Sep 4, 1998, 12:34 PM', 'A/hello.txt',
'51 bytes', 'Plain text'),
test.EntryType.FILE, 'text.txt', 'A/hello.txt', 'text/plain',
test.SharedOption.NONE, 'Sep 4, 1998, 12:34 PM', 'hello.txt', '51 bytes',
'Plain text'),
downloads: new test.TestEntryInfo(
test.EntryType.DIRECTORY, '', 'Downloads', '', test.SharedOption.NONE,
'Jan 1, 2000, 1:00 AM', 'Downloads', '--', 'Folder'),
linuxFiles: new test.TestEntryInfo(
test.EntryType.DIRECTORY, '', 'Linux files', '', test.SharedOption.NONE,
'...', 'Linux files', '--', 'Folder'),
};
/**
* Basic entry set for the local volume.
* Basic entry set for the MyFiles volume.
* @type {!Array<!test.TestEntryInfo>}
* @const
*/
test.BASIC_LOCAL_ENTRY_SET = [
test.BASIC_MY_FILES_ENTRY_SET = [
test.ENTRIES.downloads,
test.ENTRIES.hello,
test.ENTRIES.world,
test.ENTRIES.desktop,
test.ENTRIES.beautiful,
test.ENTRIES.photos
test.ENTRIES.photos,
];
/**
* MyFiles plus the fake item 'Linux files'.
* @type {!Array<!test.TestEntryInfo>}
* @const
*/
test.BASIC_MY_FILES_ENTRY_SET_WITH_LINUX_FILES =
test.BASIC_MY_FILES_ENTRY_SET.concat([test.ENTRIES.linuxFiles]);
/**
* Basic entry set for the drive volume.
*
......@@ -532,15 +529,15 @@ test.waitForFiles = function(expected, opt_options) {
* Opens a Files app's main window and waits until it is initialized. Fills
* the window with initial files. Should be called for the first window only.
*
* @param {Array<!test.TestEntryInfo>=} opt_downloads Entries for downloads.
* @param {Array<!test.TestEntryInfo>=} opt_myFiles Entries for MyFiles.
* @param {Array<!test.TestEntryInfo>=} opt_drive Entries for drive.
* @param {Array<!test.TestEntryInfo>=} opt_crostini Entries for crostini.
* @return {Promise} Promise to be fulfilled with the result object, which
* contains the file list.
*/
test.setupAndWaitUntilReady =
async function(opt_downloads, opt_drive, opt_crostini) {
const entriesDownloads = opt_downloads || test.BASIC_LOCAL_ENTRY_SET;
async function(opt_myFiles, opt_drive, opt_crostini) {
const entriesMyFiles = opt_myFiles || test.BASIC_MY_FILES_ENTRY_SET;
const entriesDrive = opt_drive || test.BASIC_DRIVE_ENTRY_SET;
const entriesCrostini = opt_crostini || test.BASIC_CROSTINI_ENTRY_SET;
......@@ -556,19 +553,19 @@ test.setupAndWaitUntilReady =
test.inputText = test.util.sync.inputText.bind(null, window);
test.selectFile = test.util.sync.selectFile.bind(null, window);
const downloadsElement = '#directory-tree [volume-type-icon="downloads"]';
const myFilesElement = '#directory-tree [root-type-icon="my_files"]';
await test.loadData();
test.addEntries(entriesDownloads, entriesDrive, entriesCrostini);
const downloadsIcon = await test.waitForElement(downloadsElement);
test.addEntries(entriesMyFiles, entriesDrive, entriesCrostini);
const myFiles = await test.waitForElement(myFilesElement);
// Click Downloads if not already on Downloads, then refresh button.
if (!downloadsIcon.parentElement.hasAttribute('selected')) {
assertTrue(test.fakeMouseClick(downloadsElement), 'click downloads');
// Click MyFiles if not already on MyFiles, then refresh button.
if (!myFiles.parentElement.hasAttribute('selected')) {
assertTrue(test.fakeMouseClick(myFilesElement), 'click MyFiles');
}
assertTrue(test.fakeMouseClick('#refresh-button'), 'click refresh');
return test.waitForFiles(
test.TestEntryInfo.getExpectedRows(entriesDownloads));
const filesShown = entriesMyFiles.concat([test.ENTRIES.linuxFiles]);
return test.waitForFiles(test.TestEntryInfo.getExpectedRows(filesShown));
};
/**
......@@ -578,29 +575,3 @@ test.setupAndWaitUntilReady =
test.done = function(opt_failed) {
window.endTests(!opt_failed);
};
/**
* @return {number} Maximum listitem-? id from #file-list.
*/
test.maxListItemId = function() {
var listItems = document.querySelectorAll('#file-list .table-row');
if (!listItems) {
return 0;
}
return Math.max(...Array.from(listItems).map(e => {
return e.id.replace('listitem-', '');
}));
};
/**
* @return {number} Minium listitem-? id from #file-list.
*/
test.minListItemId = function() {
var listItems = document.querySelectorAll('#file-list .table-row');
if (!listItems) {
return 0;
}
return Math.min(...Array.from(listItems).map(e => {
return e.id.replace('listitem-', '');
}));
};
......@@ -17,8 +17,8 @@ uma.testClickBreadcrumb = async (done) => {
// Click breadcrumb to return to parent dir.
assertTrue(test.fakeMouseClick(
'#location-breadcrumbs .breadcrumb-path:nth-of-type(1)'));
await test.waitForFiles(
test.TestEntryInfo.getExpectedRows(test.BASIC_LOCAL_ENTRY_SET));
await test.waitForFiles(test.TestEntryInfo.getExpectedRows(
test.BASIC_MY_FILES_ENTRY_SET_WITH_LINUX_FILES));
assertArrayEquals(
['FileBrowser.ClickBreadcrumbs'], chrome.metricsPrivate.userActions_);
......
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