diff options
10 files changed, 160 insertions, 166 deletions
diff --git a/chrome/browser/chromeos/file_manager/url_util.cc b/chrome/browser/chromeos/file_manager/url_util.cc index b670c96..d1a41b5 100644 --- a/chrome/browser/chromeos/file_manager/url_util.cc +++ b/chrome/browser/chromeos/file_manager/url_util.cc @@ -67,18 +67,18 @@ GURL GetFileManagerMainPageUrl() { GURL GetFileManagerMainPageUrlWithParams( ui::SelectFileDialog::Type type, const base::string16& title, - const base::FilePath& current_directory_virtual_path, - const base::FilePath& selection_virtual_path, + const GURL& current_directory_url, + const GURL& selection_url, + const std::string& target_name, const ui::SelectFileDialog::FileTypeInfo* file_types, int file_type_index, const base::FilePath::StringType& default_extension) { base::DictionaryValue arg_value; arg_value.SetString("type", GetDialogTypeAsString(type)); arg_value.SetString("title", title); - arg_value.SetString( - "currentDirectoryPath", current_directory_virtual_path.value()); - arg_value.SetString("selectionPath", selection_virtual_path.value()); - arg_value.SetString("targetName", selection_virtual_path.BaseName().value()); + arg_value.SetString("currentDirectoryURL", current_directory_url.spec()); + arg_value.SetString("selectionURL", selection_url.spec()); + arg_value.SetString("targetName", target_name); arg_value.SetString("defaultExtension", default_extension); if (file_types) { diff --git a/chrome/browser/chromeos/file_manager/url_util.h b/chrome/browser/chromeos/file_manager/url_util.h index c1ab561..785183b 100644 --- a/chrome/browser/chromeos/file_manager/url_util.h +++ b/chrome/browser/chromeos/file_manager/url_util.h @@ -13,10 +13,6 @@ #include "ui/shell_dialogs/select_file_dialog.h" #include "url/gurl.h" -namespace base { -class FilePath; -} - namespace file_manager { namespace util { @@ -32,8 +28,9 @@ GURL GetFileManagerMainPageUrl(); GURL GetFileManagerMainPageUrlWithParams( ui::SelectFileDialog::Type type, const base::string16& title, - const base::FilePath& current_directory_virtual_path, - const base::FilePath& selection_virtual_path, + const GURL& current_directory_url, + const GURL& selection_url, + const std::string& target_name, const ui::SelectFileDialog::FileTypeInfo* file_types, int file_type_index, const base::FilePath::StringType& default_extension); diff --git a/chrome/browser/chromeos/file_manager/url_util_unittest.cc b/chrome/browser/chromeos/file_manager/url_util_unittest.cc index cd24c18..20ad4ee 100644 --- a/chrome/browser/chromeos/file_manager/url_util_unittest.cc +++ b/chrome/browser/chromeos/file_manager/url_util_unittest.cc @@ -43,8 +43,9 @@ TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrlWithParams_NoFileTypes) { const GURL url = GetFileManagerMainPageUrlWithParams( ui::SelectFileDialog::SELECT_OPEN_FILE, base::UTF8ToUTF16("some title"), - base::FilePath::FromUTF8Unsafe("/Downloads"), - base::FilePath::FromUTF8Unsafe("/Downloads/foo.txt"), + GURL("filesystem:chrome-extension://abc/Downloads/"), + GURL("filesystem:chrome-extension://abc/Downloads/foo.txt"), + "foo.txt", NULL, // No file types 0, // Hence no file type index. FILE_PATH_LITERAL("txt")); @@ -56,9 +57,11 @@ TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrlWithParams_NoFileTypes) { EXPECT_TRUE(url.query().find("%20") != std::string::npos); // The escaped query is hard to read. Pretty print the escaped JSON. EXPECT_EQ("{\n" - " \"currentDirectoryPath\": \"/Downloads\",\n" + " \"currentDirectoryURL\": " + "\"filesystem:chrome-extension://abc/Downloads/\",\n" " \"defaultExtension\": \"txt\",\n" - " \"selectionPath\": \"/Downloads/foo.txt\",\n" + " \"selectionURL\": " + "\"filesystem:chrome-extension://abc/Downloads/foo.txt\",\n" " \"shouldReturnLocalPath\": true,\n" " \"targetName\": \"foo.txt\",\n" " \"title\": \"some title\",\n" @@ -88,8 +91,9 @@ TEST(FileManagerUrlUtilTest, const GURL url = GetFileManagerMainPageUrlWithParams( ui::SelectFileDialog::SELECT_OPEN_FILE, base::UTF8ToUTF16("some title"), - base::FilePath::FromUTF8Unsafe("/Downloads"), - base::FilePath::FromUTF8Unsafe("/Downloads/foo.txt"), + GURL("filesystem:chrome-extension://abc/Downloads/"), + GURL("filesystem:chrome-extension://abc/Downloads/foo.txt"), + "foo.txt", &file_types, 1, // The file type index is 1-based. FILE_PATH_LITERAL("txt")); @@ -101,10 +105,12 @@ TEST(FileManagerUrlUtilTest, EXPECT_TRUE(url.query().find("%20") != std::string::npos); // The escaped query is hard to read. Pretty print the escaped JSON. EXPECT_EQ("{\n" - " \"currentDirectoryPath\": \"/Downloads\",\n" + " \"currentDirectoryURL\": " + "\"filesystem:chrome-extension://abc/Downloads/\",\n" " \"defaultExtension\": \"txt\",\n" " \"includeAllFiles\": false,\n" - " \"selectionPath\": \"/Downloads/foo.txt\",\n" + " \"selectionURL\": " + "\"filesystem:chrome-extension://abc/Downloads/foo.txt\",\n" " \"shouldReturnLocalPath\": false,\n" " \"targetName\": \"foo.txt\",\n" " \"title\": \"some title\",\n" diff --git a/chrome/browser/resources/file_manager/background/js/background.js b/chrome/browser/resources/file_manager/background/js/background.js index 9783bad..0bad7770 100644 --- a/chrome/browser/resources/file_manager/background/js/background.js +++ b/chrome/browser/resources/file_manager/background/js/background.js @@ -518,7 +518,7 @@ function launchFileManager(opt_appState, opt_id, opt_type, opt_callback) { // Wait until all windows are created. background.queue.run(function(onTaskCompleted) { - // Check if there is already a window with the same path. If so, then + // Check if there is already a window with the same URL. If so, then // reuse it instead of opening a new one. if (type == LaunchType.FOCUS_SAME_OR_CREATE || type == LaunchType.FOCUS_ANY_OR_CREATE) { @@ -532,15 +532,15 @@ function launchFileManager(opt_appState, opt_id, opt_type, opt_callback) { continue; // Different current directories. - if (opt_appState.currentDirectoryPath !== - contentWindow.appState.currentDirectoryPath) { + if (opt_appState.currentDirectoryURL !== + contentWindow.appState.currentDirectoryURL) { continue; } - // Selection path specified, and it is different. - if (opt_appState.selectionPath && - opt_appState.selectionPath !== - contentWindow.appState.selectionPath) { + // Selection URL specified, and it is different. + if (opt_appState.selectionURL && + opt_appState.selectionURL !== + contentWindow.appState.selectionURL) { continue; } @@ -669,9 +669,9 @@ Background.prototype.onExecute_ = function(action, details) { }, // It is not allowed to call getParent() here, since there may be // no permissions to access it at this stage. Therefore we are passing - // the selectionPath only, and the currentDirectory will be resolved + // the selectionURL only, and the currentDirectory will be resolved // later. - selectionPath: details.entries[0].fullPath + selectionURL: details.entries[0].toURL() }; // For mounted devices just focus any Files.app window. The mounted // volume will appear on the navigation list. @@ -798,15 +798,15 @@ Background.prototype.onRestarted_ = function() { */ Background.prototype.onContextMenuClicked_ = function(info) { if (info.menuItemId == 'new-window') { - // Find the focused window (if any) and use it's current path for the - // new window. If not found, then launch with the default path. + // Find the focused window (if any) and use it's current url for the + // new window. If not found, then launch with the default url. for (var key in background.appWindows) { try { if (background.appWindows[key].contentWindow.isFocused()) { var appState = { - // Do not clone the selection path, only the current directory. - currentDirectoryPath: background.appWindows[key].contentWindow. - appState.currentDirectoryPath + // Do not clone the selection url, only the current directory. + currentDirectoryURL: background.appWindows[key].contentWindow. + appState.currentDirectoryURL }; launchFileManager(appState); return; @@ -817,7 +817,7 @@ Background.prototype.onContextMenuClicked_ = function(info) { } } - // Launch with the default path. + // Launch with the default URL. launchFileManager(); } }; diff --git a/chrome/browser/resources/file_manager/common/js/util.js b/chrome/browser/resources/file_manager/common/js/util.js index 8494abc..2fa30ec 100644 --- a/chrome/browser/resources/file_manager/common/js/util.js +++ b/chrome/browser/resources/file_manager/common/js/util.js @@ -684,23 +684,22 @@ util.createChild = function(parent, opt_className, opt_tag) { /** * Updates the app state. - * TODO(mtomasz): Migrate to URLs. * - * @param {string} currentDirectoryPath Currently opened path. If null the path - * is left unchanged. - * @param {string} selectionPath Currently selected path. If null the path is -* left unchanged. + * @param {string} currentDirectoryURL Currently opened directory as an URL. + * If null the value is left unchanged. + * @param {string} selectionURL Currently selected entry as an URL. If null the + * value is left unchanged. * @param {string|Object=} opt_param Additional parameters, to be stored. If * null, then left unchanged. */ -util.updateAppState = function(currentDirectoryPath, selectionPath, opt_param) { +util.updateAppState = function(currentDirectoryURL, selectionURL, opt_param) { window.appState = window.appState || {}; if (opt_param !== undefined && opt_param !== null) window.appState.params = opt_param; - if (currentDirectoryPath !== null) - window.appState.currentDirectoryPath = currentDirectoryPath; - if (selectionPath !== null) - window.appState.selectionPath = selectionPath; + if (currentDirectoryURL !== null) + window.appState.currentDirectoryURL = currentDirectoryURL; + if (selectionURL !== null) + window.appState.selectionURL = selectionURL; util.saveAppState(); }; diff --git a/chrome/browser/resources/file_manager/foreground/js/file_manager.js b/chrome/browser/resources/file_manager/foreground/js/file_manager.js index e39955e..ec287d3 100644 --- a/chrome/browser/resources/file_manager/foreground/js/file_manager.js +++ b/chrome/browser/resources/file_manager/foreground/js/file_manager.js @@ -578,16 +578,16 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; // TODO(mtomasz): Unify window.appState with location.search format. if (window.appState) { this.params_ = window.appState.params || {}; - this.initCurrentDirectoryPath_ = window.appState.currentDirectoryPath; - this.initSelectionPath_ = window.appState.selectionPath; + this.initCurrentDirectoryURL_ = window.appState.currentDirectoryURL; + this.initSelectionPath_ = window.appState.selectionURL; this.initTargetName_ = window.appState.targetName; } else { // Used by the select dialog only. this.params_ = location.search ? JSON.parse(decodeURIComponent(location.search.substr(1))) : {}; - this.initCurrentDirectoryPath_ = this.params_.currentDirectoryPath; - this.initSelectionPath_ = this.params_.selectionPath; + this.initCurrentDirectoryURL_ = this.params_.currentDirectoryURL; + this.initSelectionURL_ = this.params_.selectionURL; this.initTargetName_ = this.params_.targetName; } @@ -1407,16 +1407,16 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; var nextCurrentDirEntry; var selectionEntry; - // Resolve the selectionPath to selectionEntry or to currentDirectoryEntry + // Resolve the selectionURL to selectionEntry or to currentDirectoryEntry // in case of being a display root. queue.run(function(callback) { - // TODO(mtomasz): Migrate to URLs, and stop calling resolveAbsolutePath. - if (!this.initSelectionPath_) { + // TODO(mtomasz): Migrate to URLs, and stop calling resolveAbsoluteURL. + if (!this.initSelectionURL_) { callback(); return; } - this.volumeManager_.resolveAbsolutePath( - this.initSelectionPath_, + webkitResolveLocalFileSystemURL( + this.initSelectionURL_, function(inEntry) { var locationInfo = this.volumeManager_.getLocationInfo(inEntry); // If the selection is root, then use it as a current directory @@ -1429,16 +1429,15 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; callback(); }.bind(this), callback); }.bind(this)); - // Resolve the currentDirectoryPath to currentDirectoryEntry (if not done + // Resolve the currentDirectoryURL to currentDirectoryEntry (if not done // by the previous step). queue.run(function(callback) { - if (nextCurrentDirEntry || !this.initCurrentDirectoryPath_) { + if (nextCurrentDirEntry || !this.initCurrentDirectoryURL_) { callback(); return; } - // TODO(mtomasz): Migrate to URLs, and stop calling resolveAbsolutePath. - this.volumeManager_.resolveAbsolutePath( - this.initCurrentDirectoryPath_, + webkitResolveLocalFileSystemURL( + this.initCurrentDirectoryURL_, function(inEntry) { nextCurrentDirEntry = inEntry; callback(); @@ -1541,7 +1540,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; } if (this.dialogType === DialogType.FULL_PAGE) { - // In the FULL_PAGE mode if the restored path points to a file we might + // In the FULL_PAGE mode if the restored URL points to a file we might // have to invoke a task after selecting it. if (this.params_.action === 'select') return; @@ -1574,7 +1573,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; var listener = function() { if (!util.isSameEntry(this.directoryModel_.getCurrentDirEntry(), directoryEntry)) { - // Opened on a different path. Probably fallbacked. Therefore, + // Opened on a different URL. Probably fallbacked. Therefore, // do not invoke a task. return; } @@ -2300,12 +2299,11 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; this.selectionHandler_.onFileSelectionChanged(); this.ui_.searchBox.clear(); - // TODO(mtomasz): Use Entry.toURL() instead of fullPath. // TODO(mtomasz): Consider remembering the selection. util.updateAppState( this.getCurrentDirectoryEntry() ? - this.getCurrentDirectoryEntry().fullPath : '', - '' /* selectionPath */, + this.getCurrentDirectoryEntry().toURL() : '', + '' /* selectionURL */, '' /* opt_param */); if (this.commandHandler) diff --git a/chrome/browser/resources/file_manager/foreground/js/file_manager_commands.js b/chrome/browser/resources/file_manager/foreground/js/file_manager_commands.js index eaa37f4..932bb62 100644 --- a/chrome/browser/resources/file_manager/foreground/js/file_manager_commands.js +++ b/chrome/browser/resources/file_manager/foreground/js/file_manager_commands.js @@ -462,10 +462,9 @@ CommandHandler.COMMANDS_['new-folder'] = { */ CommandHandler.COMMANDS_['new-window'] = { execute: function(event, fileManager) { - // TODO(mtomasz): Use Entry.toURL() instead of fullPath. fileManager.backgroundPage.launchFileManager({ - currentDirectoryPath: fileManager.getCurrentDirectoryEntry() && - fileManager.getCurrentDirectoryEntry().fullPath + currentDirectoryURL: fileManager.getCurrentDirectoryEntry() && + fileManager.getCurrentDirectoryEntry().toURL() }); }, canExecute: function(event, fileManager) { diff --git a/chrome/browser/resources/file_manager/foreground/js/photo/gallery.js b/chrome/browser/resources/file_manager/foreground/js/photo/gallery.js index 8b3ae3f..1cc7918 100644 --- a/chrome/browser/resources/file_manager/foreground/js/photo/gallery.js +++ b/chrome/browser/resources/file_manager/foreground/js/photo/gallery.js @@ -499,7 +499,7 @@ Gallery.prototype.delete_ = function() { // TODO(hirono): Use fileOperationManager. var entry = itemsToRemove.pop().getEntry(); entry.remove(deleteNext, function() { - util.flog('Error deleting: ' + entry.fullPath, deleteNext); + util.flog('Error deleting: ' + entry.name, deleteNext); }); } @@ -637,22 +637,18 @@ Gallery.prototype.onKeyDown_ = function(event) { * @private */ Gallery.prototype.updateSelectionAndState_ = function() { - var path; var displayName = ''; - // TODO(mtomasz): Migrate fullPath to toURL(). var selectedItems = this.getSelectedItems(); if (selectedItems.length === 1) { var item = selectedItems[0]; var entry = item.getEntry(); - path = entry.fullPath; window.top.document.title = entry.name; displayName = ImageUtil.getDisplayNameFromName(entry.name); } else if (selectedItems.length > 1 && this.context_.curDirEntry) { // If the Gallery was opened on search results the search query will not be // recorded in the app state and the relaunch will just open the gallery // in the curDirEntry directory. - path = this.context_.curDirEntry.fullPath; window.top.document.title = this.context_.curDirEntry.name; displayName = this.displayStringFunction_('GALLERY_ITEMS_SELECTED', @@ -661,7 +657,7 @@ Gallery.prototype.updateSelectionAndState_ = function() { window.top.util.updateAppState( null, // Keep the current directory. - path, // Update the selection. + entry.toURL(), // Update the selection. {gallery: (this.currentMode_ === this.mosaicMode_ ? 'mosaic' : 'slide')}); // We can't rename files in readonly directory. @@ -671,7 +667,6 @@ Gallery.prototype.updateSelectionAndState_ = function() { this.filenameEdit_.value = displayName; - // Resolve real filesystem path of the current file. if (this.selectionModel_.selectedIndexes.length) { var selectedIndex = this.selectionModel_.selectedIndex; var selectedItem = diff --git a/chrome/browser/ui/views/select_file_dialog_extension.cc b/chrome/browser/ui/views/select_file_dialog_extension.cc index 6a28051..ce6e83e 100644 --- a/chrome/browser/ui/views/select_file_dialog_extension.cc +++ b/chrome/browser/ui/views/select_file_dialog_extension.cc @@ -333,52 +333,45 @@ void SelectFileDialogExtension::SelectFileImpl( base::FilePath fallback_path = profile_->last_selected_directory().empty() ? download_default_path : profile_->last_selected_directory(); - // Convert the above absolute paths to virtual paths. - // TODO(mtomasz): Use URLs instead of paths. - base::FilePath selection_virtual_path; - if (!file_manager::util::ConvertAbsoluteFilePathToRelativeFileSystemPath( + // Convert the above absolute paths to file system URLs. + GURL selection_url; + if (!file_manager::util::ConvertAbsoluteFilePathToFileSystemUrl( profile_, - file_manager::kFileManagerAppId, selection_path, - &selection_virtual_path)) { + file_manager::kFileManagerAppId, + &selection_url)) { // Due to the current design, an invalid temporal cache file path may passed // as |default_path| (crbug.com/178013 #9-#11). In such a case, we use the // last selected directory as a workaround. Real fix is tracked at // crbug.com/110119. - if (!file_manager::util::ConvertAbsoluteFilePathToRelativeFileSystemPath( + if (!file_manager::util::ConvertAbsoluteFilePathToFileSystemUrl( profile_, - file_manager::kFileManagerAppId, fallback_path.Append(default_path.BaseName()), - &selection_virtual_path)) { - LOG(ERROR) << "Unable to resolve the selection path."; + file_manager::kFileManagerAppId, + &selection_url)) { + LOG(ERROR) << "Unable to resolve the selection URL."; return; } } - // TODO(mtomasz): Adding a leading separator works, because this code is - // executed on Chrome OS only. This trick will be removed, once migration to - // URLs is finished. - selection_virtual_path = base::FilePath("/").Append(selection_virtual_path); - base::FilePath current_directory_virtual_path; + GURL current_directory_url; base::FilePath current_directory_path = selection_path.DirName(); - if (!file_manager::util::ConvertAbsoluteFilePathToRelativeFileSystemPath( + if (!file_manager::util::ConvertAbsoluteFilePathToFileSystemUrl( profile_, - file_manager::kFileManagerAppId, current_directory_path, - ¤t_directory_virtual_path)) { + file_manager::kFileManagerAppId, + ¤t_directory_url)) { // Fallback if necessary, see the comment above. - if (!file_manager::util::ConvertAbsoluteFilePathToRelativeFileSystemPath( + if (!file_manager::util::ConvertAbsoluteFilePathToFileSystemUrl( profile_, - file_manager::kFileManagerAppId, fallback_path, - ¤t_directory_virtual_path)) { - LOG(ERROR) << "Unable to resolve the current directory path: " + file_manager::kFileManagerAppId, + ¤t_directory_url)) { + LOG(ERROR) << "Unable to resolve the current directory URL for: " << fallback_path.value(); return; } } - current_directory_virtual_path = base::FilePath("/").Append( - current_directory_virtual_path); has_multiple_file_type_choices_ = !file_types || (file_types->extensions.size() > 1); @@ -387,8 +380,9 @@ void SelectFileDialogExtension::SelectFileImpl( file_manager::util::GetFileManagerMainPageUrlWithParams( type, title, - current_directory_virtual_path, - selection_virtual_path, + current_directory_url, + selection_url, + default_path.BaseName().value(), file_types, file_type_index, default_extension); 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 baaa622..fa4653d 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 @@ -227,37 +227,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()(); + ]); } /** @@ -271,8 +304,6 @@ function checkIfNoErrorsOccured(callback) { }); } - - /** * Returns the name of the given file list entry. * @param {Array.<string>} file An entry in a file list. @@ -328,8 +359,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. @@ -364,8 +394,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) { @@ -423,8 +452,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) { @@ -486,8 +514,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; @@ -547,8 +574,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) { @@ -593,8 +619,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) { @@ -700,8 +725,7 @@ testcase.openSidebarRecent = function() { var appId; StepsRunner.run([ function() { - var appState = {currentDirectoryPath: RootPath.DRIVE}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); }, // Click the icon of the Recent volume. function(inAppId) { @@ -738,8 +762,7 @@ testcase.openSidebarOffline = function() { var appId; StepsRunner.run([ function() { - var appState = {currentDirectoryPath: RootPath.DRIVE}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); }, // Click the icon of the Offline volume. function(inAppId) { @@ -775,8 +798,7 @@ testcase.openSidebarSharedWithMe = function() { var appId; StepsRunner.run([ function() { - var appState = {currentDirectoryPath: RootPath.DRIVE}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); }, // Click the icon of the Shared With Me volume. function(inAppId) { @@ -817,8 +839,7 @@ testcase.autocomplete = function() { StepsRunner.run([ function() { - var appState = {currentDirectoryPath: RootPath.DRIVE}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DRIVE, 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. @@ -859,8 +880,7 @@ testcase.intermediate.copyBetweenVolumes = function(targetFile, StepsRunner.run([ // Set up File Manager. function() { - var appState = {currentDirectoryPath: RootPath.DOWNLOADS}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next); }, // Select the source volume. function(inAppId) { @@ -957,8 +977,7 @@ testcase.intermediate.share = function(path) { StepsRunner.run([ // Set up File Manager. function() { - var appState = {currentDirectoryPath: RootPath.DRIVE}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); }, // Select the source file. function(inAppId) { @@ -1029,14 +1048,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) { @@ -1193,18 +1212,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 ? RootPath.DRIVE : RootPath.DOWNLOADS; + var path = drive ? RootPath.DRIVE : RootPath.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) { @@ -1272,13 +1289,12 @@ testcase.suggestAppDialog = function() { var data = JSON.parse(json); var appState = { - currentDirectoryPath: RootPath.DRIVE, suggestAppsDialogState: { overrideCwsContainerUrlForTest: data.url, overrideCwsContainerOriginForTest: data.origin } }; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(appState, RootPath.DRIVE, this.next); }, function(inAppId, inFileListBefore) { appId = inAppId; @@ -1386,8 +1402,7 @@ testcase.hideSearchBox = function() { StepsRunner.run([ // Set up File Manager. function() { - var appState = {currentDirectoryPath: RootPath.DOWNLOADS}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next); }, // Resize the window. function(inAppId, inFileListBefore) { @@ -1427,8 +1442,7 @@ testcase.restoreSortColumn = function() { StepsRunner.run([ // Set up File Manager. function() { - var appState = {currentDirectoryPath: RootPath.DOWNLOADS}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next); }, // Sort by name. function(inAppId) { @@ -1468,8 +1482,7 @@ testcase.restoreSortColumn = function() { }, // Open another window, where the sorted column should be restored. function() { - var appState = {currentDirectoryPath: RootPath.DOWNLOADS}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next); }, // Check the sorted style of the header. function(inAppId) { @@ -1501,8 +1514,7 @@ testcase.restoreCurrentView = function() { StepsRunner.run([ // Set up File Manager. function() { - var appState = {currentDirectoryPath: RootPath.DOWNLOADS}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next); }, // Check the initial view. function(inAppId) { @@ -1536,8 +1548,7 @@ testcase.restoreCurrentView = function() { }, // Open another window, where the current view is restored. function() { - var appState = {currentDirectoryPath: RootPath.DOWNLOADS}; - callRemoteTestUtil('openMainWindow', null, [appState], this.next); + openNewWindow(null, RootPath.DOWNLOADS, this.next); }, // Check the current view. function(inAppId) { @@ -1562,8 +1573,7 @@ testcase.traverseNavigationList = function() { StepsRunner.run([ // Set up File Manager. function() { - var appState = {currentDirectoryPath: RootPath.DRIVE}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); }, // Wait until Google Drive is selected. function(inAppId) { @@ -1658,8 +1668,7 @@ testcase.restoreGeometry = function() { StepsRunner.run([ // Set up File Manager. function() { - var appState = {currentDirectoryPath: RootPath.DOWNLOADS}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next); }, // Resize the window to minimal dimensions. function(inAppId) { @@ -1688,8 +1697,7 @@ testcase.restoreGeometry = function() { }, // Open another window, where the current view is restored. function() { - var appState = {currentDirectoryPath: RootPath.DOWNLOADS}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next); }, // Check the next window's size. function(inAppId) { @@ -1726,8 +1734,7 @@ testcase.searchBoxFocus = function() { StepsRunner.run([ // Set up File Manager. function() { - var appState = {currentDirectoryPath: RootPath.DRIVE}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); }, // Check that the file list has the focus on launch. function(inAppId) { @@ -1776,8 +1783,7 @@ testcase.thumbnailsDownloads = function() { var appId; StepsRunner.run([ function() { - var appState = {currentDirectoryPath: RootPath.DOWNLOADS}; - setupAndWaitUntilReady(appState, this.next); + setupAndWaitUntilReady(null, RootPath.DOWNLOADS, this.next); }, // Select the image. function(inAppId) { |