зеркало из https://github.com/mozilla/pjs.git
Follow up to bug 437556 change the unit test to work properly cross-platform. p=Josh Geenen <joshgeenen+bugzilla@gmail.com>,r=me
This commit is contained in:
Родитель
800d47dacc
Коммит
62705418f3
|
@ -0,0 +1,37 @@
|
|||
/**
|
||||
* Returns an import interface based on the name of the module and a string
|
||||
* to search for. Throws an error if it cannot find the module.
|
||||
*
|
||||
* @param moduleName The name of the module, such as "addressbook"
|
||||
* @param searchStr The string to search the module names for, such as ".csv"
|
||||
* to find the import module for comma-separated value files
|
||||
* @return An nsIImportGeneric import interface.
|
||||
*/
|
||||
function getImportInterface(moduleName, searchStr)
|
||||
{
|
||||
do_check_true(moduleName && moduleName.length > 0);
|
||||
do_check_true(searchStr && searchStr.length > 0);
|
||||
|
||||
var importService = Cc["@mozilla.org/import/import-service;1"]
|
||||
.getService(Ci.nsIImportService);
|
||||
var module;
|
||||
var count = importService.GetModuleCount(moduleName);
|
||||
|
||||
// Iterate through each import module until the one being searched for is found
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
// Check if the current module fits the search string gets the interface
|
||||
if (importService.GetModuleName(moduleName, i).indexOf(searchStr) != -1)
|
||||
{
|
||||
module = importService.GetModule(moduleName, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the module was found. If not, return false
|
||||
if (!module)
|
||||
return null;
|
||||
|
||||
return module.GetImportInterface(moduleName)
|
||||
.QueryInterface(Ci.nsIImportGeneric);
|
||||
}
|
|
@ -1,2 +1,4 @@
|
|||
// Import the main scripts that mailnews tests need to set up and tear down
|
||||
// Set up the profile directory for verifying the success of imports
|
||||
do_import_script("mailnews/test/resources/mailDirService.js");
|
||||
// Import the script with basic import functions
|
||||
do_import_script("mailnews/import/test/resources/import_helper.js");
|
||||
|
|
|
@ -4,17 +4,16 @@
|
|||
*/
|
||||
function run_test()
|
||||
{
|
||||
var file = do_get_file('mailnews/import/test/resources/basic_addressbook.csv');
|
||||
var importService = Cc["@mozilla.org/import/import-service;1"]
|
||||
.getService(Ci.nsIImportService);
|
||||
var module = importService.GetModule("addressbook", 0);
|
||||
var abInterface = module.GetImportInterface("addressbook")
|
||||
.QueryInterface(Ci.nsIImportGeneric);
|
||||
|
||||
var file = do_get_file("mailnews/import/test/resources/basic_addressbook.csv");
|
||||
var errorStr = Cc["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Ci.nsISupportsString);
|
||||
// get the text Address Book import interface and make sure it succeeded
|
||||
var abInterface = getImportInterface("addressbook", ".csv");
|
||||
do_check_neq(abInterface, null);
|
||||
abInterface.SetData("addressLocation", file);
|
||||
do_check_true(abInterface.WantsProgress());
|
||||
|
||||
//do_check_true(abInterface.WantsProgress());
|
||||
|
||||
// BeginImport should return false if the field map isn't set
|
||||
//do_check_false(abInterface.BeginImport(null, null, false));
|
||||
// BeginImport should return false and log an error if the fieldMap isn't set
|
||||
do_check_false(abInterface.BeginImport(null, errorStr, false));
|
||||
do_check_neq(errorStr, null);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче