Commit 4a438287 authored by hirono@chromium.org's avatar hirono@chromium.org

Files.app: Add a test to create new folder.

BUG=345048
TEST=run the new test

Review URL: https://codereview.chromium.org/216513004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260444 0039d316-1c4b-4281-b951-d872f2087c98
parent fb0115f6
...@@ -758,7 +758,13 @@ INSTANTIATE_TEST_CASE_P( ...@@ -758,7 +758,13 @@ INSTANTIATE_TEST_CASE_P(
TestParameter(NOT_IN_GUEST_MODE, "keyboardDeleteDrive"), TestParameter(NOT_IN_GUEST_MODE, "keyboardDeleteDrive"),
TestParameter(IN_GUEST_MODE, "keyboardCopyDownloads"), TestParameter(IN_GUEST_MODE, "keyboardCopyDownloads"),
TestParameter(NOT_IN_GUEST_MODE, "keyboardCopyDownloads"), TestParameter(NOT_IN_GUEST_MODE, "keyboardCopyDownloads"),
TestParameter(NOT_IN_GUEST_MODE, "keyboardCopyDrive"))); TestParameter(NOT_IN_GUEST_MODE, "keyboardCopyDrive"),
TestParameter(IN_GUEST_MODE,
"createNewFolderDownloads"),
TestParameter(NOT_IN_GUEST_MODE,
"createNewFolderDownloads"),
TestParameter(NOT_IN_GUEST_MODE,
"createNewFolderDrive")));
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
DriveSpecific, DriveSpecific,
......
...@@ -2464,13 +2464,13 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; ...@@ -2464,13 +2464,13 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
event.stopPropagation(); event.stopPropagation();
} }
switch (util.getKeyModifiers(event) + event.keyCode) { switch (util.getKeyModifiers(event) + event.keyIdentifier) {
case '27': // Escape case 'U+001B': // Escape
this.cancelRename_(); this.cancelRename_();
event.preventDefault(); event.preventDefault();
break; break;
case '13': // Enter case 'Enter':
this.commitRename_(); this.commitRename_();
event.preventDefault(); event.preventDefault();
break; break;
......
...@@ -127,6 +127,62 @@ function keyboardDelete(path) { ...@@ -127,6 +127,62 @@ function keyboardDelete(path) {
]); ]);
} }
/**
* Adds check of chrome.test to the end of the given promise.
* @param {Promise} promise Promise.
*/
function testPromise(promise) {
promise.then(function() {
return new Promise(checkIfNoErrorsOccured);
}).then(chrome.test.callbackPass(function() {
chrome.test.succeed();
}), function(error) {
chrome.test.fail(error.stack || error);
});
};
/**
* Test for creating new folder.
* @param {string} path Initial path.
* @param {Array.<TestEntryInfo>} initialEntrySet Initial set of entries.
* @return {Promise} Promise to be fulfilled on success.
*/
function createNewFolder(path, initialEntrySet) {
var windowId;
// Open window.
return new Promise(function(callback) {
setupAndWaitUntilReady(null, path, callback);
}).then(function(inWindowId) {
windowId = inWindowId;
// Push Ctrl + E.
return callRemoteTestUtil('fakeKeyDown',
windowId,
// Ctrl + E
['#file-list', 'U+0045', true]);
}).then(function() {
// Wait for rename text field.
return waitForElement(windowId, 'input.rename');
}).then(function() {
// Type new folder name.
return callRemoteTestUtil(
'inputText', windowId, ['input.rename', 'Test Folder Name']);
}).then(function() {
// Push Enter.
return callRemoteTestUtil('fakeKeyDown',
windowId,
['input.rename', 'Enter', false]);
}).then(function() {
return waitForElementLost(windowId, 'input.rename');
}).then(function() {
var expectedEntryRows = TestEntryInfo.getExpectedRows(initialEntrySet);
expectedEntryRows.push(['Test Folder Name', '--', 'Folder', '']);
// Wait for the new folder.
return waitForFiles(windowId,
expectedEntryRows,
{ignoreLastModifiedTime: true});
});
};
testcase.keyboardCopyDownloads = function() { testcase.keyboardCopyDownloads = function() {
keyboardCopy(RootPath.DOWNLOADS); keyboardCopy(RootPath.DOWNLOADS);
}; };
...@@ -142,3 +198,11 @@ testcase.keyboardCopyDrive = function() { ...@@ -142,3 +198,11 @@ testcase.keyboardCopyDrive = function() {
testcase.keyboardDeleteDrive = function() { testcase.keyboardDeleteDrive = function() {
keyboardDelete(RootPath.DRIVE); keyboardDelete(RootPath.DRIVE);
}; };
testcase.createNewFolderDownloads = function() {
testPromise(createNewFolder(RootPath.DOWNLOADS, BASIC_LOCAL_ENTRY_SET));
};
testcase.createNewFolderDrive = function() {
testPromise(createNewFolder(RootPath.DRIVE, BASIC_DRIVE_ENTRY_SET));
};
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