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: */
4 * Copyright (C) 2008 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 "nsStringAPI.h"
25 #include "nsIGenericFactory.h"
27 /* Unfrozen interfaces */
28 #include "nsIStringEnumerator.h"
30 /* Project includes */
31 #include "nsTestUtils.h"
32 #include "nsITestRunner.h"
35 #include "aaAccountTest.h"
36 #include "aaBug133Test.h"
37 #include "aaCurrencyTest.h"
38 #include "aaTaxRulesTest.h"
40 #define AA_ACCOUNT_TEST_MODULE_CID \
41 {0x0eaf81ee, 0xa6bf, 0x4757, {0x8a, 0xa3, 0x5f, 0xbd, 0xc8, 0x7d, 0x0e, 0x3c}}
42 #define AA_ACCOUNT_TEST_MODULE_CONTRACT "@aasii.org/storage/unit-account;1"
44 class aaAccountTestModule
: public nsITest
,
45 public nsIUTF8StringEnumerator
48 aaAccountTestModule() :mSubtest(0) {;}
51 NS_DECL_NSIUTF8STRINGENUMERATOR
53 virtual ~aaAccountTestModule() {;}
57 NS_IMPL_ISUPPORTS2(aaAccountTestModule
,
59 nsIUTF8StringEnumerator
)
63 aaAccountTestModule::Test(nsITestRunner
*aTestRunner
)
68 /* nsIUTF8StringEnumerator */
69 static const char* subtests
[] =
71 "@aasii.org/storage/unit-account-core;1"
72 ,"@aasii.org/storage/unit-bug133;1"
73 ,"@aasii.org/storage/unit-account-currency;1"
74 ,"@aasii.org/storage/unit-tax-rules;1"
76 #define subtestCount (sizeof(subtests) / sizeof(char*))
79 aaAccountTestModule::HasMore(PRBool
*aHasMore
)
81 NS_ENSURE_ARG_POINTER(aHasMore
);
82 *aHasMore
= (mSubtest
< subtestCount
);
87 aaAccountTestModule::GetNext(nsACString
&aContractID
)
89 NS_ENSURE_TRUE(mSubtest
< subtestCount
, NS_ERROR_FAILURE
);
90 aContractID
.Assign( subtests
[mSubtest
++] );
94 /* Boilerplate - factory & module */
95 NS_GENERIC_FACTORY_CONSTRUCTOR(aaAccountTestModule
)
96 NS_GENERIC_FACTORY_CONSTRUCTOR(aaAccountTest
)
97 NS_GENERIC_FACTORY_CONSTRUCTOR(aaBug133Test
)
98 NS_GENERIC_FACTORY_CONSTRUCTOR(aaCurrencyTest
)
99 NS_GENERIC_FACTORY_CONSTRUCTOR(aaTaxRulesTest
)
101 static const nsModuleComponentInfo kComponents
[] =
104 "Account Module Test Container",
105 AA_ACCOUNT_TEST_MODULE_CID
,
106 AA_ACCOUNT_TEST_MODULE_CONTRACT
,
107 aaAccountTestModuleConstructor
110 "Account Core Unit Test",
112 AA_ACCOUNT_TEST_CONTRACT
,
113 aaAccountTestConstructor
118 AA_BUG133_TEST_CONTRACT
,
119 aaBug133TestConstructor
122 "Multiple Currency Unit Test",
123 AA_CURRENCY_TEST_CID
,
124 AA_CURRENCY_TEST_CONTRACT
,
125 aaCurrencyTestConstructor
128 "Tax Rules Unit Test",
129 AA_TAX_RULES_TEST_CID
,
130 AA_TAX_RULES_TEST_CONTRACT
,
131 aaTaxRulesTestConstructor
134 NS_IMPL_NSGETMODULE(aaAccountTest
, kComponents
)