summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordhaddock <dhaddock@chromium.org>2015-06-01 18:16:56 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-02 01:18:21 +0000
commitfd5c957e3f9d2f5c6446e5b5d77e61502321a24e (patch)
treef4d3bd9c158354da1d4df387010d324107263f1e
parent4a61908bc2846ffddc84b861b57816f5b19942b3 (diff)
downloadchromium_src-fd5c957e3f9d2f5c6446e5b5d77e61502321a24e.zip
chromium_src-fd5c957e3f9d2f5c6446e5b5d77e61502321a24e.tar.gz
chromium_src-fd5c957e3f9d2f5c6446e5b5d77e61502321a24e.tar.bz2
Adding directory tree update check to browser_tests for Files app
I plan to add checks to see that the directory tree in the LHS of Files app is updated when we create/delete/share a folder. BUG=None TEST=browser_tests -gtest_filter=*CreateNewFolder/FileManagerBrowserTest* Review URL: https://codereview.chromium.org/1157663005 Cr-Commit-Position: refs/heads/master@{#332298}
-rw-r--r--ui/file_manager/integration_tests/file_manager/create_new_folder.js70
1 files changed, 68 insertions, 2 deletions
diff --git a/ui/file_manager/integration_tests/file_manager/create_new_folder.js b/ui/file_manager/integration_tests/file_manager/create_new_folder.js
index bb83170..d39c6cf 100644
--- a/ui/file_manager/integration_tests/file_manager/create_new_folder.js
+++ b/ui/file_manager/integration_tests/file_manager/create_new_folder.js
@@ -5,6 +5,20 @@
'use strict';
/**
+ * Constants for interacting with the directory tree on the LHS of Files.
+ * When we are not in guest mode, we fill Google Drive with the basic entry set
+ * which causes an extra tree-item to be added.
+ */
+var TREEITEM_DRIVE = '#directory-tree > div:nth-child(1) '
+var TREEITEM_DOWNLOADS = '#directory-tree > div:nth-child(2) '
+var EXPAND_ICON = '> .tree-row > .expand-icon';
+var EXPANDED_SUBTREE = '> .tree-children[expanded]';
+var NEWFOLDER = '#tree-item-autogen-id-9';
+var TESTFOLDER = '#tree-item-autogen-id-10';
+var NEWFOLDER_GUEST = '#tree-item-autogen-id-8';
+var TESTFOLDER_GUEST = '#tree-item-autogen-id-9';
+
+/**
* Selects the first item in the file list.
* @param {string} windowId ID of the target window.
* @return {Promise} Promise to be fulfilled on success.
@@ -65,6 +79,12 @@ function createNewFolder(windowId, path, initialEntrySet) {
chrome.test.assertEq(1, elements.length);
chrome.test.assertTrue('renaming' in elements[0].attributes);
}).then(function() {
+ // Check directory tree for new folder.
+ if (chrome.extension.inIncognitoContext)
+ return remoteCall.waitForElement(windowId, NEWFOLDER_GUEST);
+ else
+ return remoteCall.waitForElement(windowId, NEWFOLDER);
+ }).then(function() {
// Type new folder name.
return remoteCall.callRemoteTestUtil(
'inputText', windowId, ['input.rename', 'Test Folder Name']);
@@ -78,6 +98,18 @@ function createNewFolder(windowId, path, initialEntrySet) {
// Wait until rename completes.
return remoteCall.waitForElementLost(windowId, 'input.rename');
}).then(function() {
+ // Once it is renamed, the original 'New Folder' item is removed.
+ if (chrome.extension.inIncognitoContext)
+ return remoteCall.waitForElementLost(windowId, NEWFOLDER_GUEST);
+ else
+ return remoteCall.waitForElementLost(windowId, NEWFOLDER);
+ }).then(function() {
+ // A newer entry is then added for the renamed folder.
+ if (chrome.extension.inIncognitoContext)
+ return remoteCall.waitForElement(windowId, TESTFOLDER_GUEST);
+ else
+ return remoteCall.waitForElement(windowId, TESTFOLDER);
+ }).then(function() {
var expectedEntryRows = TestEntryInfo.getExpectedRows(initialEntrySet);
expectedEntryRows.push(['Test Folder Name', '--', 'Folder', '']);
// Wait for the new folder.
@@ -109,6 +141,24 @@ function createNewFolder(windowId, path, initialEntrySet) {
});
};
+/**
+ * This is used to expand the tree item for Downloads or Drive.
+ * @param {string} windowId The Files app window.
+ * @param {string} selector The Downloads or Drive tree item selector.
+ * @return {Promise} Promise fulfilled on success.
+ */
+function expandRoot(windowId, selector) {
+ return remoteCall.waitForElement(
+ windowId, selector + EXPAND_ICON).then(function() {
+ return remoteCall.callRemoteTestUtil(
+ 'fakeMouseClick', windowId, [selector + EXPAND_ICON]);
+ }).then(function(result) {
+ chrome.test.assertTrue(result);
+ return remoteCall.waitForElement(windowId,
+ selector + EXPANDED_SUBTREE);
+ });
+}
+
testcase.createNewFolderAfterSelectFile = function() {
var PATH = RootPath.DOWNLOADS;
var windowId = null;
@@ -118,6 +168,10 @@ testcase.createNewFolderAfterSelectFile = function() {
windowId = inWindowId;
return selectFirstListItem(windowId);
}).then(function() {
+ return expandRoot(windowId, TREEITEM_DOWNLOADS);
+ }).then(function() {
+ return remoteCall.waitForElement(windowId, '#detail-table')
+ }).then(function() {
return createNewFolder(windowId, PATH, BASIC_LOCAL_ENTRY_SET);
});
@@ -126,9 +180,15 @@ testcase.createNewFolderAfterSelectFile = function() {
testcase.createNewFolderDownloads = function() {
var PATH = RootPath.DOWNLOADS;
+ var windowId = null;
var promise = new Promise(function(callback) {
setupAndWaitUntilReady(null, PATH, callback);
- }).then(function(windowId) {
+ }).then(function(inWindowId) {
+ windowId = inWindowId
+ return expandRoot(windowId, TREEITEM_DOWNLOADS);
+ }).then(function() {
+ return remoteCall.waitForElement(windowId, '#detail-table')
+ }).then(function() {
return createNewFolder(windowId, PATH, BASIC_LOCAL_ENTRY_SET);
});
@@ -137,9 +197,15 @@ testcase.createNewFolderDownloads = function() {
testcase.createNewFolderDrive = function() {
var PATH = RootPath.DRIVE;
+ var windowId = null;
var promise = new Promise(function(callback) {
setupAndWaitUntilReady(null, PATH, callback);
- }).then(function(windowId) {
+ }).then(function(inWindowId) {
+ windowId = inWindowId
+ return expandRoot(windowId, TREEITEM_DRIVE);
+ }).then(function() {
+ return remoteCall.waitForElement(windowId, '#detail-table')
+ }).then(function() {
return createNewFolder(windowId, PATH, BASIC_DRIVE_ENTRY_SET);
});