Bug 917217 - Rename getUserDownloadsDirectory and getTemporaryDownloadsDirectory. r=paolo

This commit is contained in:
Raymond Lee 2013-09-24 09:48:02 +08:00
parent ad0d891c02
commit ff3cbd678e
4 changed files with 17 additions and 17 deletions

View File

@ -313,7 +313,7 @@ this.DownloadIntegration = {
* @return {Promise}
* @resolves The nsIFile of downloads directory.
*/
getUserDownloadsDirectory: function DI_getUserDownloadsDirectory() {
getPreferredDownloadsDirectory: function DI_getPreferredDownloadsDirectory() {
return Task.spawn(function() {
let directory = null;
let prefValue = 1;
@ -356,7 +356,7 @@ this.DownloadIntegration = {
return Task.spawn(function() {
let directory = null;
#ifdef XP_MACOSX
directory = yield this.getUserDownloadsDirectory();
directory = yield this.getPreferredDownloadsDirectory();
#elifdef ANDROID
directory = yield this.getSystemDownloadsDirectory();
#else

View File

@ -273,8 +273,8 @@ this.Downloads = {
* @return {Promise}
* @resolves The nsIFile of downloads directory.
*/
getUserDownloadsDirectory: function D_getUserDownloadsDirectory() {
return DownloadIntegration.getUserDownloadsDirectory();
getPreferredDownloadsDirectory: function D_getPreferredDownloadsDirectory() {
return DownloadIntegration.getPreferredDownloadsDirectory();
},
/**

View File

@ -116,10 +116,10 @@ add_task(function test_getSystemDownloadsDirectory()
});
/**
* Tests that the getUserDownloadsDirectory returns a valid nsFile
* Tests that the getPreferredDownloadsDirectory returns a valid nsFile
* download directory object.
*/
add_task(function test_getUserDownloadsDirectory()
add_task(function test_getPreferredDownloadsDirectory()
{
let folderListPrefName = "browser.download.folderList";
let dirPrefName = "browser.download.dir";
@ -132,20 +132,20 @@ add_task(function test_getUserDownloadsDirectory()
// Should return the system downloads directory.
Services.prefs.setIntPref(folderListPrefName, 1);
let systemDir = yield DownloadIntegration.getSystemDownloadsDirectory();
let downloadDir = yield DownloadIntegration.getUserDownloadsDirectory();
let downloadDir = yield DownloadIntegration.getPreferredDownloadsDirectory();
do_check_true(downloadDir instanceof Ci.nsIFile);
do_check_eq(downloadDir.path, systemDir.path);
// Should return the desktop directory.
Services.prefs.setIntPref(folderListPrefName, 0);
downloadDir = yield DownloadIntegration.getUserDownloadsDirectory();
downloadDir = yield DownloadIntegration.getPreferredDownloadsDirectory();
do_check_true(downloadDir instanceof Ci.nsIFile);
do_check_eq(downloadDir.path, Services.dirsvc.get("Desk", Ci.nsIFile).path);
// Should return the system downloads directory because the dir preference
// is not set.
Services.prefs.setIntPref(folderListPrefName, 2);
let downloadDir = yield DownloadIntegration.getUserDownloadsDirectory();
let downloadDir = yield DownloadIntegration.getPreferredDownloadsDirectory();
do_check_true(downloadDir instanceof Ci.nsIFile);
do_check_eq(downloadDir.path, systemDir.path);
@ -154,7 +154,7 @@ add_task(function test_getUserDownloadsDirectory()
let tempDir = Services.dirsvc.get("TmpD", Ci.nsIFile);
tempDir.append(time);
Services.prefs.setComplexValue("browser.download.dir", Ci.nsIFile, tempDir);
downloadDir = yield DownloadIntegration.getUserDownloadsDirectory();
downloadDir = yield DownloadIntegration.getPreferredDownloadsDirectory();
do_check_true(downloadDir instanceof Ci.nsIFile);
do_check_eq(downloadDir.path, tempDir.path);
do_check_true(yield OS.File.exists(downloadDir.path));
@ -166,13 +166,13 @@ add_task(function test_getUserDownloadsDirectory()
tempDir.append("dir_not_exist");
tempDir.append(time);
Services.prefs.setComplexValue("browser.download.dir", Ci.nsIFile, tempDir);
downloadDir = yield DownloadIntegration.getUserDownloadsDirectory();
downloadDir = yield DownloadIntegration.getPreferredDownloadsDirectory();
do_check_eq(downloadDir.path, systemDir.path);
// Should return the system downloads directory because the folderList
// preference is invalid
Services.prefs.setIntPref(folderListPrefName, 999);
let downloadDir = yield DownloadIntegration.getUserDownloadsDirectory();
let downloadDir = yield DownloadIntegration.getPreferredDownloadsDirectory();
do_check_eq(downloadDir.path, systemDir.path);
cleanup();
@ -188,8 +188,8 @@ add_task(function test_getTemporaryDownloadsDirectory()
do_check_true(downloadDir instanceof Ci.nsIFile);
if ("nsILocalFileMac" in Ci) {
let userDownloadDir = yield DownloadIntegration.getUserDownloadsDirectory();
do_check_eq(downloadDir.path, userDownloadDir.path);
let preferredDownloadDir = yield DownloadIntegration.getPreferredDownloadsDirectory();
do_check_eq(downloadDir.path, preferredDownloadDir.path);
} else {
let tempDir = Services.dirsvc.get("TmpD", Ci.nsIFile);
do_check_eq(downloadDir.path, tempDir.path);

View File

@ -146,12 +146,12 @@ add_task(function test_getSystemDownloadsDirectory()
});
/**
* Tests that the getUserDownloadsDirectory returns a valid nsFile
* Tests that the getPreferredDownloadsDirectory returns a valid nsFile
* download directory object.
*/
add_task(function test_getUserDownloadsDirectory()
add_task(function test_getPreferredDownloadsDirectory()
{
let downloadDir = yield Downloads.getUserDownloadsDirectory();
let downloadDir = yield Downloads.getPreferredDownloadsDirectory();
do_check_true(downloadDir instanceof Ci.nsIFile);
});