Bug 541235 - mailnews xpcshell tests fail when running as packaged tests. r=Standard8
authorRobert Kaiser <kairo@kairo.at>
Thu, 25 Feb 2010 08:29:00 -0500
changeset 5894 f33643d4a469ac7c17f46ac8a48a78e7eedadd43
parent 5893 f27e030e9a1469a86ead6d7e7da12bee105ca72c
child 5895 b999fdbf21074a31160fe2af5af9c2cd24f3e972
push idunknown
push userunknown
push dateunknown
reviewersStandard8
bugs541235
Bug 541235 - mailnews xpcshell tests fail when running as packaged tests. r=Standard8
mailnews/imap/test/unit/test_bug460636.js
mailnews/test/resources/mailDirService.js
--- a/mailnews/imap/test/unit/test_bug460636.js
+++ b/mailnews/imap/test/unit/test_bug460636.js
@@ -38,20 +38,19 @@ function run_test()
   var msgfileuri = Cc["@mozilla.org/network/io-service;1"]
                      .getService(Ci.nsIIOService)
                      .newFileURI(gMsgFile).QueryInterface(Ci.nsIFileURL);
 
   inbox.addMessage(new imapMessage(msgfileuri.spec, inbox.uidnext++, []));
 
   /*
    * Save the message to a local file. IMapMD corresponds to
-   * mozilla/_test/mailtest/ImapMail in the build directory
-   * (where fakeserver puts the IMAP mailbox files). If we pass
-   * the test, we'll remove the file afterwards (cf. UrlListener),
-   * otherwise it's kept in IMapMD.
+   * <profile_dir>/mailtest/ImapMail (where fakeserver puts the IMAP mailbox
+   * files). If we pass the test, we'll remove the file afterwards
+   * (cf. UrlListener), otherwise it's kept in IMapMD.
    */
   gSavedMsgFile = Cc["@mozilla.org/file/directory_service;1"]
                   .getService(Ci.nsIProperties)
                   .get("IMapMD", Ci.nsILocalFile);
   gSavedMsgFile.append(gFileName + ".eml");
 
   do_test_pending();
   do_timeout(10000, function(){
--- a/mailnews/test/resources/mailDirService.js
+++ b/mailnews/test/resources/mailDirService.js
@@ -1,17 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /*
  * Sets up the directory service provider to create the "mailtest" sub
  * directory under the process directory and use that as the profile
  * directory for the mailnews tests to locate files during unit tests.
  *
- * For xpcshell tests, the "profile" directory will be:
- * <objdir>/dist/bin/mailtest/  (on Windows and Linux)
- * <objdir>/dist/Thunderbird{Debug}.app/Contents/MacOS/mailtest/  (on Mac OS X)
+ * For xpcshell tests, the "profile" directory will be <profile_dir>/mailtest/
  */
 
 // Make sure we execute this file exactly once
 var gMailDirService_js__;
 if (!gMailDirService_js__) {
 gMailDirService_js__ = true;
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
@@ -36,35 +34,22 @@ function initializeDirServer() {
      */
     makeDirectoryService : function () {
       // Register our own provider for the profile directory.
       // It will simply return the current directory.
       const provider = {
         getFile : function(prop, persistent) {
           persistent.value = true;
           if (prop == NS_APP_USER_PROFILE_50_DIR) {
-            var processDir = dirSvc.get("CurProcD", Ci.nsIFile);
-
-            // Process dir is normally <objdir>/dist/bin, _tests is
-            // <objdir>/_tests, so go up 2 directories
-            processDir = processDir.parent;
-            processDir = processDir.parent;
-
-            // Then into the _tests directory
-            processDir.append("_tests");
-
-            // We need to normalize on a directory we'll always know about it
-            // because otherwise Linux doesn't work properly. Therefore do it
-            // here before we add mailtest.
-            processDir.normalize();
+            var profileDir = do_get_profile();
 
             // Then this is the directory we want
-            processDir.append("mailtest");
+            profileDir.append("mailtest");
 
-            return processDir;
+            return profileDir;
           }
           if (prop == "resource:app") {
             // app should return the same as gre...
             return dirSvc.get("GreD", Ci.nsIFile);
           }
           if (prop == "TmpD") {
             throw Components.results.NS_ERROR_FAILURE;
           }