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

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

Issue 132453007: Migrate fullPaths to URLs in appState. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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/test_cases.js
diff --git a/chrome/test/data/extensions/api_test/file_manager_browsertest/test_cases.js b/chrome/test/data/extensions/api_test/file_manager_browsertest/test_cases.js
index 870aa0c6bb61885468cb462bb7d7816079e24f2e..1ba30837caaa84496a1958318e0d750238000b0f 100644
--- a/chrome/test/data/extensions/api_test/file_manager_browsertest/test_cases.js
+++ b/chrome/test/data/extensions/api_test/file_manager_browsertest/test_cases.js
@@ -219,37 +219,70 @@ var SHARED_WITH_ME_ENTRY_SET = [
];
/**
- * Opens a Files.app's main window and waits until it is initialized.
+ * Opens a Files.app's main window.
+ *
+ * TODO(mtomasz): Pass a volumeId or an enum value instead of full paths.
+ *
+ * @param {Object} appState App state to be passed with on opening Files.app.
+ * Can be null.
+ * @param {?string} initialRoot Root path to be used as a default current
+ * directory during initialization. Can be null, for no default path.
+ * @param {function(string)} Callback with the app id.
+ */
+function openNewWindow(appState, initialRoot, callback) {
+ var appId;
+
+ // TODO(mtomasz): Migrate from full paths to a pair of a volumeId and a
+ // relative path. To compose the URL communicate via messages with
+ // file_manager_browser_test.cc.
+ var processedAppState = appState || {};
+ if (initialRoot) {
+ processedAppState.currentDirectoryURL =
+ 'filesystem:chrome-extension://' + FILE_MANAGER_EXTENSIONS_ID +
+ '/external' + initialRoot;
+ }
+
+ callRemoteTestUtil('openMainWindow', null, [processedAppState], callback);
+}
+
+/**
+ * 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.
*
* TODO(hirono): Add parameters to specify the entry set to be prepared.
+ * TODO(mtomasz): Pass a volumeId or an enum value instead of full paths.
*
* @param {Object} appState App state to be passed with on opening Files.app.
+ * Can be null.
+ * @param {?string} initialRoot Root path to be used as a default current
+ * directory during initialization. Can be null, for no default path.
* @param {function(string, Array.<Array.<string>>)} Callback with the app id
* and with the file list.
*/
-function setupAndWaitUntilReady(appState, callback) {
+function setupAndWaitUntilReady(appState, initialRoot, callback) {
var appId;
- var steps = [
+
+ StepsRunner.run([
function() {
- callRemoteTestUtil('openMainWindow', null, [appState], steps.shift());
+ openNewWindow(appState, initialRoot, this.next);
},
function(inAppId) {
appId = inAppId;
- addEntries(['local'], BASIC_LOCAL_ENTRY_SET, steps.shift());
+ addEntries(['local'], BASIC_LOCAL_ENTRY_SET, this.next);
},
function(success) {
chrome.test.assertTrue(success);
- addEntries(['drive'], BASIC_DRIVE_ENTRY_SET, steps.shift());
+ addEntries(['drive'], BASIC_DRIVE_ENTRY_SET, this.next);
},
function(success) {
chrome.test.assertTrue(success);
- callRemoteTestUtil('waitForFileListChange', appId, [0], steps.shift());
+ callRemoteTestUtil('waitForFileListChange', appId, [0], this.next);
},
function(fileList) {
callback(appId, fileList);
+ this.next();
}
- ];
- steps.shift()();
+ ]);
}
/**
@@ -263,8 +296,6 @@ function checkIfNoErrorsOccured(callback) {
});
}
-
-
/**
* Returns the name of the given file list entry.
* @param {Array.<string>} file An entry in a file list.
@@ -320,8 +351,7 @@ testcase.intermediate.fileDisplay = function(path) {
StepsRunner.run([
function() {
- var appState = {currentDirectoryPath: path};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, path, this.next);
},
// Notify that the list has been verified and a new file can be added
// in file_manager_browsertest.cc.
@@ -356,8 +386,7 @@ testcase.intermediate.galleryOpen = function(path) {
var appId;
StepsRunner.run([
function() {
- var appState = {currentDirectoryPath: path};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, path, this.next);
},
// Resize the window to desired dimensions to avoid flakyness.
function(inAppId) {
@@ -415,8 +444,7 @@ testcase.intermediate.audioOpen = function(path) {
var audioAppId;
StepsRunner.run([
function() {
- var appState = {currentDirectoryPath: path};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, path, this.next);
},
// Select the song.
function(inAppId) {
@@ -478,8 +506,7 @@ testcase.intermediate.videoOpen = function(path) {
var videoAppId;
StepsRunner.run([
function() {
- var appState = {currentDirectoryPath: path};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, path, this.next);
},
function(inAppId) {
appId = inAppId;
@@ -539,8 +566,7 @@ testcase.intermediate.keyboardCopy = function(path, callback) {
StepsRunner.run([
// Set up File Manager.
function() {
- var appState = {currentDirectoryPath: path};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, path, this.next);
},
// Copy the file.
function(inAppId, inFileListBefore) {
@@ -585,8 +611,7 @@ testcase.intermediate.keyboardDelete = function(path) {
StepsRunner.run([
// Set up File Manager.
function() {
- var appState = {currentDirectoryPath: path};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, path, this.next);
},
// Delete the file.
function(inAppId, inFileListBefore) {
@@ -692,8 +717,7 @@ testcase.openSidebarRecent = function() {
var appId;
StepsRunner.run([
function() {
- var appState = {currentDirectoryPath: '/drive/root'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/drive/root', this.next);
},
// Click the icon of the Recent volume.
function(inAppId) {
@@ -730,8 +754,7 @@ testcase.openSidebarOffline = function() {
var appId;
StepsRunner.run([
function() {
- var appState = {currentDirectoryPath: '/drive/root/'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/drive/root', this.next);
},
// Click the icon of the Offline volume.
function(inAppId) {
@@ -767,8 +790,7 @@ testcase.openSidebarSharedWithMe = function() {
var appId;
StepsRunner.run([
function() {
- var appState = {currentDirectoryPath: '/drive/root/'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/drive/root', this.next);
},
// Click the icon of the Shared With Me volume.
function(inAppId) {
@@ -809,8 +831,7 @@ testcase.autocomplete = function() {
StepsRunner.run([
function() {
- var appState = {currentDirectoryPath: '/drive/root'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/drive/root', this.next);
},
// Perform an auto complete test and wait until the list changes.
// TODO(mtomasz): Move the operation from test_util.js to tests_cases.js.
@@ -851,8 +872,7 @@ testcase.intermediate.copyBetweenVolumes = function(targetFile,
StepsRunner.run([
// Set up File Manager.
function() {
- var appState = {currentDirectoryPath: '/Downloads'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/Downloads', this.next);
},
// Select the source volume.
function(inAppId) {
@@ -949,8 +969,7 @@ testcase.intermediate.share = function(path) {
StepsRunner.run([
// Set up File Manager.
function() {
- var appState = {currentDirectoryPath: '/drive/root/'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/drive/root', this.next);
},
// Select the source file.
function(inAppId) {
@@ -1021,14 +1040,14 @@ testcase.intermediate.share = function(path) {
/**
* Test utility for traverse tests.
+ * @param {string} path Root path to be traversed.
*/
-testcase.intermediate.traverseDirectories = function(root) {
+testcase.intermediate.traverseDirectories = function(path) {
var appId;
StepsRunner.run([
- // Set up File Manager.
+ // Set up File Manager. Do not add initial files.
function() {
- var appState = {currentDirectoryPath: root};
- callRemoteTestUtil('openMainWindow', null, [appState], this.next);
+ openNewWindow(null, path, this.next);
},
// Check the initial view.
function(inAppId) {
@@ -1185,18 +1204,16 @@ testcase.executeDefaultTaskOnDownloads = function(root) {
/**
* Tests executing the default task when there is only one task.
+ * @param {boolean} drive Whether to test Drive or Downloads.
*/
testcase.intermediate.executeDefaultTask = function(drive) {
- var root = drive ? '/drive/root' : '/Downloads';
+ var path = drive ? '/drive/root' : '/Downloads';
var taskId = drive ? 'dummytaskid|drive|open-with' : 'dummytaskid|open-with'
var appId;
StepsRunner.run([
// Set up File Manager.
function() {
- var appState = {
- currentDirectoryPath: root
- };
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, path, this.next);
},
// Override tasks list with a dummy task.
function(inAppId, inFileListBefore) {
@@ -1264,13 +1281,12 @@ testcase.suggestAppDialog = function() {
var data = JSON.parse(json);
var appState = {
- currentDirectoryPath: '/drive/root',
suggestAppsDialogState: {
overrideCwsContainerUrlForTest: data.url,
overrideCwsContainerOriginForTest: data.origin
}
};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(appState, '/drive/root', this.next);
},
function(inAppId, inFileListBefore) {
appId = inAppId;
@@ -1378,8 +1394,7 @@ testcase.hideSearchBox = function() {
StepsRunner.run([
// Set up File Manager.
function() {
- var appState = {currentDirectoryPath: '/Downloads'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/Downloads', this.next);
},
// Resize the window.
function(inAppId, inFileListBefore) {
@@ -1419,8 +1434,7 @@ testcase.restoreSortColumn = function() {
StepsRunner.run([
// Set up File Manager.
function() {
- var appState = {currentDirectoryPath: '/Downloads'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/Downloads', this.next);
},
// Sort by name.
function(inAppId) {
@@ -1460,8 +1474,7 @@ testcase.restoreSortColumn = function() {
},
// Open another window, where the sorted column should be restored.
function() {
- var appState = {currentDirectoryPath: '/Downloads'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/Downloads', this.next);
},
// Check the sorted style of the header.
function(inAppId) {
@@ -1493,8 +1506,7 @@ testcase.restoreCurrentView = function() {
StepsRunner.run([
// Set up File Manager.
function() {
- var appState = {currentDirectoryPath: '/Downloads'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/Downloads', this.next);
},
// Check the initial view.
function(inAppId) {
@@ -1528,8 +1540,7 @@ testcase.restoreCurrentView = function() {
},
// Open another window, where the current view is restored.
function() {
- var appState = {currentDirectoryPath: '/Downloads'};
- callRemoteTestUtil('openMainWindow', null, [appState], this.next);
+ openNewWindow(null, '/Downloads', this.next);
},
// Check the current view.
function(inAppId) {
@@ -1554,8 +1565,7 @@ testcase.traverseNavigationList = function() {
StepsRunner.run([
// Set up File Manager.
function() {
- var appState = {currentDirectoryPath: '/drive/root'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/drive/root', this.next);
},
// Wait until Google Drive is selected.
function(inAppId) {
@@ -1650,8 +1660,7 @@ testcase.restoreGeometry = function() {
StepsRunner.run([
// Set up File Manager.
function() {
- var appState = {currentDirectoryPath: '/Downloads'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/Downloads', this.next);
},
// Resize the window to minimal dimensions.
function(inAppId) {
@@ -1680,8 +1689,7 @@ testcase.restoreGeometry = function() {
},
// Open another window, where the current view is restored.
function() {
- var appState = {currentDirectoryPath: '/Downloads'};
- setupAndWaitUntilReady(appState, this.next);
+ openNewWindow(null, '/Downloads', this.next);
},
// Check the next window's size.
function(inAppId) {
@@ -1718,8 +1726,7 @@ testcase.searchBoxFocus = function() {
StepsRunner.run([
// Set up File Manager.
function() {
- var appState = {currentDirectoryPath: '/drive/root'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/drive/root', this.next);
},
// Check that the file list has the focus on launch.
function(inAppId) {
@@ -1768,8 +1775,7 @@ testcase.thumbnailsDownloads = function() {
var appId;
StepsRunner.run([
function() {
- var appState = {currentDirectoryPath: '/Downloads'};
- setupAndWaitUntilReady(appState, this.next);
+ setupAndWaitUntilReady(null, '/Downloads', this.next);
},
// Select the image.
function(inAppId) {

Powered by Google App Engine
This is Rietveld 408576698