зеркало из https://github.com/mozilla/gecko-dev.git
bug 1259753 - fix some C++ unittests to use ScopedXPCOM to init XPCOM. r=ms2ger
MozReview-Commit-ID: B6xdlB9Di0y --HG-- extra : rebase_source : 182d29d677c77ae6780260f5fc9b0792bdd98f84 extra : amend_source : 1e4fa2453d6773bd1e63f52b7aa3bf61e61600ff
This commit is contained in:
Родитель
4639af5cdb
Коммит
815dd278b6
|
@ -4,6 +4,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "TestCommon.h"
|
||||
#include "TestHarness.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICookieService.h"
|
||||
#include "nsICookieManager.h"
|
||||
|
@ -186,18 +187,6 @@ InitPrefs(nsIPrefBranch *aPrefBranch)
|
|||
aPrefBranch->SetIntPref(kCookiesMaxPerHost, 50);
|
||||
}
|
||||
|
||||
class ScopedXPCOM
|
||||
{
|
||||
public:
|
||||
ScopedXPCOM() : rv(NS_InitXPCOM2(nullptr, nullptr, nullptr)) { }
|
||||
~ScopedXPCOM()
|
||||
{
|
||||
if (NS_SUCCEEDED(rv))
|
||||
NS_ShutdownXPCOM(nullptr);
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
};
|
||||
|
||||
int
|
||||
main(int32_t argc, char *argv[])
|
||||
|
@ -207,9 +196,7 @@ main(int32_t argc, char *argv[])
|
|||
|
||||
bool allTestsPassed = true;
|
||||
|
||||
ScopedXPCOM xpcom;
|
||||
if (NS_FAILED(xpcom.rv))
|
||||
return -1;
|
||||
ScopedXPCOM xpcom("TestCookie");
|
||||
|
||||
{
|
||||
nsresult rv0;
|
||||
|
|
|
@ -7,12 +7,13 @@
|
|||
#include "nsIPrefService.h"
|
||||
#include "nsIX509CertDB.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "TestHarness.h"
|
||||
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
ScopedXPCOM xpcom("TestCertDB");
|
||||
{
|
||||
NS_InitXPCOM2(nullptr, nullptr, nullptr);
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (!prefs) {
|
||||
return -1;
|
||||
|
@ -29,6 +30,5 @@ main(int argc, char* argv[])
|
|||
}
|
||||
} // this scopes the nsCOMPtrs
|
||||
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
|
||||
NS_ShutdownXPCOM(nullptr);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsIFile.h"
|
||||
#include "TestHarness.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -1194,8 +1195,7 @@ int main(int argc, char **argv) {
|
|||
if (argc > 1)
|
||||
count = atoi(argv[1]);
|
||||
|
||||
if (NS_FAILED(NS_InitXPCOM2(nullptr, nullptr, nullptr)))
|
||||
return -1;
|
||||
ScopedXPCOM xpcom("TestTArray");
|
||||
|
||||
bool success = true;
|
||||
while (count--) {
|
||||
|
@ -1206,7 +1206,6 @@ int main(int argc, char **argv) {
|
|||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ShutdownXPCOM(nullptr);
|
||||
|
||||
return success ? 0 : -1;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче