Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8883)

Unified Diff: chrome/test/data/extensions/api_test/file_manager_browsertest/create_new_folder.js

Issue 275493006: Files.app: Fix selection on creating new folder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a test Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/file_manager_browsertest/create_new_folder.js
diff --git a/chrome/test/data/extensions/api_test/file_manager_browsertest/create_new_folder.js b/chrome/test/data/extensions/api_test/file_manager_browsertest/create_new_folder.js
new file mode 100644
index 0000000000000000000000000000000000000000..85dcbe44c4d355623b2f5be46436a16d160baea9
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/file_manager_browsertest/create_new_folder.js
@@ -0,0 +1,131 @@
+// Copyright 2014 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';
+
+/**
+ * Select the first item in the file list.
hirono 2014/05/09 07:29:38 Selects
yoshiki 2014/05/09 13:54:17 Done.
+ * @param {string} windowId ID of the target window.
+ * @return {Promise} Promise to be fulfilled on success.
+ */
+function selectFirstListItem(windowId) {
+ return Promise.resolve().then(function() {
+ // Push Down.
+ return callRemoteTestUtil('fakeKeyDown',
+ windowId,
+ // Down
+ ['#file-list', 'Down', true]);
+ }).then(function() {
+ // Wait until rename completes.
hirono 2014/05/09 07:29:38 The comment is not correct.
yoshiki 2014/05/09 13:54:17 Done.
+ return callRemoteTestUtil(
+ 'queryAllElements',
hirono 2014/05/09 07:29:38 The number of indent is 4.
yoshiki 2014/05/09 13:54:17 Done.
+ windowId,
+ ['div.detail-table > list > li[selected]']);
+ }).then(function(elements) {
+ chrome.test.assertEq(1, elements.length);
hirono 2014/05/09 07:29:38 Can we ensure the selected attribute is added here
yoshiki 2014/05/09 13:54:17 the selected attribute is checked in the query. An
hirono 2014/05/12 02:28:27 I think it can cause a flakiness. If detail-table-
yoshiki 2014/05/13 09:40:57 Done.
+ chrome.test.assertEq('detail-table-1', elements[0].attributes['id']);
+ return Promise.resolve();
+ });
+}
+
+/**
+ * Creates new folder.
+ * @param {string} windowId ID of the target window.
+ * @param {string} path Initial path.
+ * @param {Array.<TestEntryInfo>} initialEntrySet Initial set of entries.
+ * @return {Promise} Promise to be fulfilled on success.
+ */
+function createNewFolder(windowId, path, initialEntrySet) {
+ return Promise.resolve(
+ ).then(function() {
+ // Push Ctrl + E.
+ return callRemoteTestUtil('fakeKeyDown',
+ windowId,
+ // Ctrl + E
+ ['#file-list', 'U+0045', true]);
+ }).then(function() {
+ // Wait for rename text field.
+ return waitForElement(windowId, 'li[renaming] input.rename');
+ }).then(function() {
+ // Wait until rename completes.
hirono 2014/05/09 07:29:38 The comment is incorrect?
yoshiki 2014/05/09 13:54:17 Done.
+ return callRemoteTestUtil(
+ 'queryAllElements',
hirono 2014/05/09 07:29:38 Indent is 4.
yoshiki 2014/05/09 13:54:17 Done.
+ windowId,
+ ['div.detail-table > list > li[selected]']);
hirono 2014/05/09 07:29:38 How about li[selected][renaming]? instead of check
yoshiki 2014/05/09 13:54:17 I'd like to ensure that the number of selected ite
hirono 2014/05/12 02:28:27 SGTM.
+ }).then(function(elements) {
+ chrome.test.assertEq(1, elements.length);
+ chrome.test.assertTrue('renaming' in elements[0].attributes);
+ return Promise.resolve();
hirono 2014/05/09 07:29:38 This is not needed.
yoshiki 2014/05/09 13:54:17 Done.
+ }).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});
+ }).then(function() {
+ // Wait until rename completes.
hirono 2014/05/09 07:29:38 The comment is incorrect?
yoshiki 2014/05/09 13:54:17 Done.
+ return callRemoteTestUtil(
+ 'queryAllElements',
+ windowId,
+ ['div.detail-table > list > li[selected]']);
+ }).then(function(elements) {
+ chrome.test.assertEq(1, elements.length);
+ return Promise.resolve();
hirono 2014/05/09 07:29:38 This is not needed.
yoshiki 2014/05/09 13:54:17 Done.
+ });
+};
+
+testcase.createNewFolderAfterSelectFile = function() {
+ var PATH = RootPath.DOWNLOADS;
+ var windowId = null;
+ new Promise(function(callback) {
+ setupAndWaitUntilReady(null, PATH, callback);
+ }).then(function(inWindowId) {
+ windowId = inWindowId;
+ return selectFirstListItem(windowId);
+ }).then(function() {
+ return createNewFolder(windowId, PATH, BASIC_LOCAL_ENTRY_SET);
+ }).then(
+ checkIfNoErrorsOccured.bind(null, chrome.test.callbackPass()),
hirono 2014/05/09 07:29:38 How about using testPromise? https://code.google.c
yoshiki 2014/05/09 13:54:17 Done.
+ function(error) {
+ chrome.test.fail('Promise rejected: ' + (error.stack || error));
+ });
+};
+
+testcase.createNewFolderDownloads = function() {
+ var PATH = RootPath.DOWNLOADS;
+ new Promise(function(callback) {
+ setupAndWaitUntilReady(null, PATH, callback);
+ }).then(function(windowId) {
+ return createNewFolder(windowId, PATH, BASIC_LOCAL_ENTRY_SET);
+ }).then(
+ checkIfNoErrorsOccured.bind(null, chrome.test.callbackPass()),
+ function(error) {
+ chrome.test.fail('Promise rejected: ' + (error.stack || error));
+ });
+};
+
+testcase.createNewFolderDrive = function() {
+ var PATH = RootPath.DRIVE;
+ new Promise(function(callback) {
+ setupAndWaitUntilReady(null, PATH, callback);
+ }).then(function(windowId) {
+ return createNewFolder(windowId, PATH, BASIC_DRIVE_ENTRY_SET);
+ }).then(
+ checkIfNoErrorsOccured.bind(null, chrome.test.callbackPass()),
+ function(error) {
+ chrome.test.fail('Promise rejected: ' + (error.stack || error));
+ });
+};

Powered by Google App Engine
This is Rietveld 408576698