From b3a3147281c7e88894e7a43ebab87e9855504de4 Mon Sep 17 00:00:00 2001 From: Sergey Yanovich Date: Tue, 25 Mar 2008 15:09:29 +0200 Subject: [PATCH] [accounts] Add a test container (bug 141) --- app/test/aaMainTest.cpp | 1 - storage/account/test/Makefile.in | 2 + storage/account/test/aaAccountTest.cpp | 84 +------------------ storage/account/test/aaAccountTest.h | 91 ++++++++++++++++++++ .../account/test/aaAccountTestModule.cpp | 98 +++++++++++++--------- 5 files changed, 155 insertions(+), 121 deletions(-) create mode 100644 storage/account/test/aaAccountTest.h copy app/test/aaMainTest.cpp => storage/account/test/aaAccountTestModule.cpp (50%) diff --git a/app/test/aaMainTest.cpp b/app/test/aaMainTest.cpp index a2c761a..ee95d95 100644 --- a/app/test/aaMainTest.cpp +++ b/app/test/aaMainTest.cpp @@ -68,7 +68,6 @@ static const char* subtests[] = ,"@aasii.org/base/unit;1" ,"@aasii.org/storage/unit;1" ,"@aasii.org/storage/unit-account;1" - ,"@aasii.org/storage/unit-bug133;1" ,"@aasii.org/report/unit;1" ,"@aasii.org/view/unit;1" ,"@aasii.org/abstract/test/vc-base;1" diff --git a/storage/account/test/Makefile.in b/storage/account/test/Makefile.in index 7e83c7b..b828700 100644 --- a/storage/account/test/Makefile.in +++ b/storage/account/test/Makefile.in @@ -20,6 +20,7 @@ # # Contributor(s): # Brian Ryner +# Sergey Yanovich # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -58,6 +59,7 @@ REQUIRES = \ $(NULL) CPPSRCS = \ + aaAccountTestModule.cpp \ aaAccountTest.cpp \ aaBug133Test.cpp \ $(NULL) diff --git a/storage/account/test/aaAccountTest.cpp b/storage/account/test/aaAccountTest.cpp index 0c547b6..c7a1345 100644 --- a/storage/account/test/aaAccountTest.cpp +++ b/storage/account/test/aaAccountTest.cpp @@ -1,7 +1,7 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */ /* - * Copyright (C) 2007 Sergey Yanovich + * Copyright (C) 2007,2008 Sergey Yanovich * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -59,66 +59,7 @@ #include "aaTestConsts.h" #include "aaAccountTestUtils.h" -#include "aaBug133Test.h" - -#define AA_ACCOUNT_TEST_CID \ -{0x9f3b3e19, 0x2f06, 0x4a75, {0xbc, 0xb8, 0xd7, 0xd3, 0x5c, 0xaf, 0x9d, 0x36}} -#define AA_ACCOUNT_TEST_CONTRACT_ID "@aasii.org/storage/unit-account;1" - -class aaAccountTest: public nsITest -{ -public: - aaAccountTest() {;} - virtual ~aaAccountTest() {;} - NS_DECL_ISUPPORTS - NS_DECL_NSITEST -private: - class RAII - { - public: - RAII(aaAccountTest *t); - ~RAII(); - - PRBool status; - private: - aaAccountTest* test; - void cleanQuotes(); - }; - - //friend class RAII; - nsCOMPtr mSession; - nsCOMPtr mFlows; - nsCOMPtr mResources; - nsCOMPtr mEntities; - nsCOMPtr mPendingFact; - - double mRubs; - double mEuros; - double mProfit; - - nsresult load(); - void free(); - - nsresult testEmptyBalance(nsITestRunner *aTestRunner); - nsresult testPendingFacts(nsITestRunner *aTestRunner); - nsresult testQuote(nsITestRunner *aTestRunner); - nsresult testBalanceRow(nsITestRunner *aTestRunner); - nsresult testTransaction(nsITestRunner *aTestRunner); - nsresult testUpdateTransaction(nsITestRunner *aTestRunner); - nsresult testReplaceTransaction(nsITestRunner *aTestRunner); - nsresult testFlowBalance(nsITestRunner *aTestRunner); - nsresult testStateFilter(nsITestRunner *aTestRunner); - nsresult testCreditTransaction(nsITestRunner *aTestRunner); - nsresult testDeleteTransaction(nsITestRunner *aTestRunner); - nsresult testFlowChart(nsITestRunner *aTestRunner); - nsresult testIncomeRow(nsITestRunner *aTestRunner); - nsresult testLoadIncome(nsITestRunner *aTestRunner); - nsresult testStopTransaction(nsITestRunner *aTestRunner); - nsresult testLossTransaction(nsITestRunner *aTestRunner); - nsresult testSplitTransaction(nsITestRunner *aTestRunner); - nsresult testGainTransaction(nsITestRunner *aTestRunner); - nsresult testDirectGainsLosses(nsITestRunner *aTestRunner); -}; +#include "aaAccountTest.h" /* nsITest */ NS_IMETHODIMP @@ -154,27 +95,6 @@ aaAccountTest::Test(nsITestRunner *aTestRunner) NS_IMPL_ISUPPORTS1(aaAccountTest, nsITest) -/* Boilerplate - factory & module */ -NS_GENERIC_FACTORY_CONSTRUCTOR(aaAccountTest) -NS_GENERIC_FACTORY_CONSTRUCTOR(aaBug133Test) - -static const nsModuleComponentInfo kComponents[] = -{ - { - "Account Submodule Unit Test", - AA_ACCOUNT_TEST_CID, - AA_ACCOUNT_TEST_CONTRACT_ID, - aaAccountTestConstructor - } - ,{ - "Bug133 Submodule Unit Test", - AA_BUG133_TEST_CID, - AA_BUG133_TEST_CONTRACT_ID, - aaBug133TestConstructor - } -}; -NS_IMPL_NSGETMODULE(aaaccountt, kComponents) - /* Helpers */ PRBool testFact(nsITestRunner *cxxUnitTestRunner, aaIFact *node, PRInt64 fromFlowId, diff --git a/storage/account/test/aaAccountTest.h b/storage/account/test/aaAccountTest.h new file mode 100644 index 0000000..00b556f --- /dev/null +++ b/storage/account/test/aaAccountTest.h @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */ +/* + * Copyright (C) 2008 Sergey Yanovich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef AAACCOUNTTEST_H +#define AAACCOUNTTEST_H + +#define AA_ACCOUNT_TEST_CID \ +{0x9f3b3e19, 0x2f06, 0x4a75, {0xbc, 0xb8, 0xd7, 0xd3, 0x5c, 0xaf, 0x9d, 0x36}} +#define AA_ACCOUNT_TEST_CONTRACT_ID "@aasii.org/storage/unit-account-core;1" + +#include "nsCOMPtr.h" + +#include "aaISession.h" +#include "aaILoadQuery.h" +#include "aaIFact.h" +#include "nsITestRunner.h" + +class aaAccountTest: public nsITest +{ +public: + aaAccountTest() {;} + virtual ~aaAccountTest() {;} + NS_DECL_ISUPPORTS + NS_DECL_NSITEST +private: + class RAII + { + public: + RAII(aaAccountTest *t); + ~RAII(); + + PRBool status; + private: + aaAccountTest* test; + void cleanQuotes(); + }; + + //friend class RAII; + nsCOMPtr mSession; + nsCOMPtr mFlows; + nsCOMPtr mResources; + nsCOMPtr mEntities; + nsCOMPtr mPendingFact; + + double mRubs; + double mEuros; + double mProfit; + + nsresult load(); + void free(); + + nsresult testEmptyBalance(nsITestRunner *aTestRunner); + nsresult testPendingFacts(nsITestRunner *aTestRunner); + nsresult testQuote(nsITestRunner *aTestRunner); + nsresult testBalanceRow(nsITestRunner *aTestRunner); + nsresult testTransaction(nsITestRunner *aTestRunner); + nsresult testUpdateTransaction(nsITestRunner *aTestRunner); + nsresult testReplaceTransaction(nsITestRunner *aTestRunner); + nsresult testFlowBalance(nsITestRunner *aTestRunner); + nsresult testStateFilter(nsITestRunner *aTestRunner); + nsresult testCreditTransaction(nsITestRunner *aTestRunner); + nsresult testDeleteTransaction(nsITestRunner *aTestRunner); + nsresult testFlowChart(nsITestRunner *aTestRunner); + nsresult testIncomeRow(nsITestRunner *aTestRunner); + nsresult testLoadIncome(nsITestRunner *aTestRunner); + nsresult testStopTransaction(nsITestRunner *aTestRunner); + nsresult testLossTransaction(nsITestRunner *aTestRunner); + nsresult testSplitTransaction(nsITestRunner *aTestRunner); + nsresult testGainTransaction(nsITestRunner *aTestRunner); + nsresult testDirectGainsLosses(nsITestRunner *aTestRunner); +}; + +#endif /* AAACCOUNTTEST_H */ diff --git a/app/test/aaMainTest.cpp b/storage/account/test/aaAccountTestModule.cpp similarity index 50% copy from app/test/aaMainTest.cpp copy to storage/account/test/aaAccountTestModule.cpp index a2c761a..878f81b 100644 --- a/app/test/aaMainTest.cpp +++ b/storage/account/test/aaAccountTestModule.cpp @@ -1,7 +1,7 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */ /* - * Copyright (C) 2007 Sergey Yanovich + * Copyright (C) 2008 Sergey Yanovich * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -33,62 +33,49 @@ #include "nsITestRunner.h" #include "nsITest.h" -#define MODULE_TEST_CID \ -{0xfefc6b55, 0xe3a9, 0x4c5f, {0x87, 0x01, 0x8f, 0xcc, 0xa9, 0x6c, 0xdc, 0xfa}} -#define MODULE_TEST_CONTRACT_ID "@aasii.org/abstract/test" +#include "aaAccountTest.h" +#include "aaBug133Test.h" +/*#include "aaCurrencyTest.h"*/ -class aaAbstractTest: public nsITest, - public nsIUTF8StringEnumerator +#define AA_ACCOUNT_TEST_MODULE_CID \ +{0x0eaf81ee, 0xa6bf, 0x4757, {0x8a, 0xa3, 0x5f, 0xbd, 0xc8, 0x7d, 0x0e, 0x3c}} +#define AA_ACCOUNT_TEST_MODULE_CONTRACT_ID "@aasii.org/storage/unit-account;1" + +class aaAccountTestModule: public nsITest, + public nsIUTF8StringEnumerator { public: - aaAbstractTest() :mSubtest(0) {} + aaAccountTestModule() :mSubtest(0) {;} NS_DECL_ISUPPORTS NS_DECL_NSITEST NS_DECL_NSIUTF8STRINGENUMERATOR private: - virtual ~aaAbstractTest() {} + virtual ~aaAccountTestModule() {;} PRUint32 mSubtest; }; -NS_GENERIC_FACTORY_CONSTRUCTOR(aaAbstractTest) +NS_IMPL_ISUPPORTS2(aaAccountTestModule, + nsITest, + nsIUTF8StringEnumerator) -static const nsModuleComponentInfo components[] = +/* nsITest */ +NS_IMETHODIMP +aaAccountTestModule::Test(nsITestRunner *aTestRunner) { - { "Abstract Accounting Test", - MODULE_TEST_CID, - MODULE_TEST_CONTRACT_ID, - aaAbstractTestConstructor - } -}; -NS_IMPL_NSGETMODULE(aaMainTest, components) + return NS_OK; +} +/* nsIUTF8StringEnumerator */ static const char* subtests[] = { - "@aasii.org/xpunit/unit;1" - ,"@aasii.org/base/unit;1" - ,"@aasii.org/storage/unit;1" - ,"@aasii.org/storage/unit-account;1" + "@aasii.org/storage/unit-account-core;1" ,"@aasii.org/storage/unit-bug133;1" - ,"@aasii.org/report/unit;1" - ,"@aasii.org/view/unit;1" - ,"@aasii.org/abstract/test/vc-base;1" - ,"@aasii.org/abstract/test/vc-accounts;1" + /*,"@aasii.org/storage/unit-account-currency;1"*/ }; #define subtestCount (sizeof(subtests) / sizeof(char*)) -NS_IMPL_ISUPPORTS2(aaAbstractTest, - nsITest, - nsIUTF8StringEnumerator) - NS_IMETHODIMP -aaAbstractTest::Test(nsITestRunner *aTestRunner) -{ - NS_TEST_BEGIN(aTestRunner); - return NS_OK; -} - -NS_IMETHODIMP -aaAbstractTest::HasMore(PRBool *aHasMore) +aaAccountTestModule::HasMore(PRBool *aHasMore) { NS_ENSURE_ARG_POINTER(aHasMore); *aHasMore = (mSubtest < subtestCount); @@ -96,9 +83,44 @@ aaAbstractTest::HasMore(PRBool *aHasMore) } NS_IMETHODIMP -aaAbstractTest::GetNext(nsACString &aContractID) +aaAccountTestModule::GetNext(nsACString &aContractID) { NS_ENSURE_TRUE(mSubtest < subtestCount, NS_ERROR_FAILURE); aContractID.Assign( subtests[mSubtest++] ); return NS_OK; } + +/* Boilerplate - factory & module */ +NS_GENERIC_FACTORY_CONSTRUCTOR(aaAccountTestModule) +NS_GENERIC_FACTORY_CONSTRUCTOR(aaAccountTest) +NS_GENERIC_FACTORY_CONSTRUCTOR(aaBug133Test) +/*NS_GENERIC_FACTORY_CONSTRUCTOR(aaCurrencyTest)*/ + +static const nsModuleComponentInfo kComponents[] = +{ + { + "Account Module Test Container", + AA_ACCOUNT_TEST_MODULE_CID, + AA_ACCOUNT_TEST_MODULE_CONTRACT_ID, + aaAccountTestModuleConstructor + } + ,{ + "Account Core Unit Test", + AA_ACCOUNT_TEST_CID, + AA_ACCOUNT_TEST_CONTRACT_ID, + aaAccountTestConstructor + } + ,{ + "Bug133 Unit Test", + AA_BUG133_TEST_CID, + AA_BUG133_TEST_CONTRACT_ID, + aaBug133TestConstructor + } + /*,{ + "Multiple Currency Unit Test", + AA_CURRENCY_TEST_CID, + AA_CURRENCY_TEST_CONTRACT_ID, + aaCurrencyTestConstructor + }*/ +}; +NS_IMPL_NSGETMODULE(aaAccountTest, kComponents) -- 2.11.4.GIT