transport: construct channel from file uri
[abstract.git] / xpunit / nsTestModule.cpp
blob46c599ac45ca7dabfb700cd3eeb9243666710892
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */
3 /*
4 * Copyright (C) 2007 Sergey Yanovich <ynvich@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include "xpcom-config.h"
24 #include "nsXPCOM.h"
25 #include "nsMemory.h"
26 #include "nsIGenericFactory.h"
27 #include "nsIServiceManager.h"
28 #include "nsICategoryManager.h"
29 #include "nsComponentManagerUtils.h"
30 #include "nsIWebProgressListener.h"
31 #include "nsWeakReference.h"
33 /* Unfrozen interfaces */
34 #include "nsIConsoleListener.h"
35 #include "nsITimer.h"
36 #include "nsICommandLineHandler.h"
37 #include "nsDeque.h"
39 /* Project includes */
40 #include "nsITestRunner.h"
41 #include "nsITestResult.h"
42 #include "nsITest.h"
43 #include "nsTestUtils.h"
44 #include "nsTestRunner.h"
45 #include "nsTestResult.h"
47 #define NS_TESTRUNNER_CLH "m-aatest"
49 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsTestRunner,
50 nsTestRunner::GetTestRunner)
51 NS_GENERIC_FACTORY_CONSTRUCTOR(nsTestResult)
53 static NS_METHOD ModuleRegistration(nsIComponentManager *aCompMgr,
54 nsIFile *aPath, const char *registryLocation, const char *componentType,
55 const nsModuleComponentInfo *info)
57 nsresult rv;
59 nsCOMPtr<nsIServiceManager> servman;
60 servman = do_QueryInterface((nsISupports*)aCompMgr, &rv);
61 NS_ENSURE_SUCCESS(rv,rv);
63 nsCOMPtr<nsICategoryManager> catman;
64 rv = servman->GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,
65 NS_GET_IID(nsICategoryManager), getter_AddRefs(catman));
66 NS_ENSURE_SUCCESS(rv,rv);
68 char* previous = nsnull;
69 rv = catman->AddCategoryEntry("command-line-handler",
70 NS_TESTRUNNER_CLH, NS_TESTRUNNER_CONTRACT, PR_TRUE, PR_TRUE,
71 &previous);
72 if (previous)
73 nsMemory::Free(previous);
74 return rv;
77 static NS_METHOD ModuleUnregistration(nsIComponentManager *aCompMgr,
78 nsIFile *aPath, const char *registryLocation,
79 const nsModuleComponentInfo *info)
81 nsresult rv;
83 nsCOMPtr<nsIServiceManager> servman;
84 servman = do_QueryInterface((nsISupports*)aCompMgr, &rv);
85 NS_ENSURE_SUCCESS(rv,rv);
87 nsCOMPtr<nsICategoryManager> catman;
88 rv = servman->GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,
89 NS_GET_IID(nsICategoryManager), getter_AddRefs(catman));
90 NS_ENSURE_SUCCESS(rv,rv);
92 rv = catman->DeleteCategoryEntry("command-line-handler",
93 NS_TESTRUNNER_CLH, PR_TRUE);
94 return rv;
97 static const nsModuleComponentInfo components[] =
99 { "XPUnit Test Runner",
100 NS_TESTRUNNER_CID,
101 NS_TESTRUNNER_CONTRACT,
102 nsTestRunnerConstructor,
103 ModuleRegistration,
104 ModuleUnregistration },
105 { "XPUnit Test Result",
106 NS_TESTRESULT_CID,
107 NS_TESTRESULT_CONTRACT,
108 nsTestResultConstructor }
110 NS_IMPL_NSGETMODULE(nsTest, components)