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 "nsIGenericFactory.h"
25 #include "nsStringAPI.h"
28 #include "nsIStringEnumerator.h"
30 #include "nsITestRunner.h"
32 /* Project includes */
33 #include "aaSqliteChannelTest.h"
34 #include "aaSqliteLoadEntityTest.h"
35 #include "aaSqliteCreateTable1Test.h"
37 #define AA_SQLITE_TRANSPORT_TEST_MODULE_CID \
38 {0x8ebe8443, 0xe59b, 0x4ffc, {0xa5, 0x40, 0x93, 0xf5, 0x26, 0xee, 0x1d, 0x5b}}
39 #define AA_SQLITE_TRANSPORT_TEST_MODULE_CONTRACT \
40 "@aasii.org/transport/sqlite/unit;1"
42 class aaSqliteTransportTestModule
: public nsITest
,
43 public nsIUTF8StringEnumerator
46 aaSqliteTransportTestModule() :mSubtest(0) {;}
49 NS_DECL_NSIUTF8STRINGENUMERATOR
51 ~aaSqliteTransportTestModule() {;}
55 NS_IMPL_ISUPPORTS2(aaSqliteTransportTestModule
,
57 nsIUTF8StringEnumerator
)
60 aaSqliteTransportTestModule::Test(nsITestRunner
*aTestRunner
)
65 /* nsIUTF8StringEnumerator */
66 static const char* subtests
[] =
68 AA_SQLITE_CREATE_TABLE1_CONTRACT
69 ,"@aasii.org/transport/xml/sqlite;1"
71 #define subtestCount (sizeof(subtests) / sizeof(char*))
74 aaSqliteTransportTestModule::HasMore(PRBool
*aHasMore
)
76 NS_ENSURE_ARG_POINTER(aHasMore
);
77 *aHasMore
= (mSubtest
< subtestCount
);
82 aaSqliteTransportTestModule::GetNext(nsACString
&aContractID
)
84 NS_ENSURE_TRUE(mSubtest
< subtestCount
, NS_ERROR_FAILURE
);
85 aContractID
.Assign(subtests
[mSubtest
++]);
89 /* Module and Factory code */
90 NS_GENERIC_FACTORY_CONSTRUCTOR(aaSqliteTransportTestModule
)
93 aaSqliteLoadEntityTestConstructor(nsISupports
*aOuter
, REFNSIID aIID
,
97 aaSqliteChannelTest
*inst
;
100 NS_ENSURE_TRUE(NULL
== aOuter
, NS_ERROR_NO_AGGREGATION
);
102 inst
= new aaSqliteChannelTest(AA_SQLITE_LOAD_ENTITY_QUERY
,
103 AA_SQLITE_LOAD_ENTITY_RESULT
);
104 NS_ENSURE_TRUE(NULL
!= inst
, NS_ERROR_OUT_OF_MEMORY
);
107 rv
= inst
->QueryInterface(aIID
, aResult
);
114 aaSqliteCreateTable1TestConstructor(nsISupports
*aOuter
, REFNSIID aIID
,
118 aaSqliteChannelTest
*inst
;
121 NS_ENSURE_TRUE(NULL
== aOuter
, NS_ERROR_NO_AGGREGATION
);
123 inst
= new aaSqliteChannelTest(AA_SQLITE_CREATE_TABLE1_QUERY
,
124 AA_SQLITE_CREATE_TABLE1_RESULT
);
125 NS_ENSURE_TRUE(NULL
!= inst
, NS_ERROR_OUT_OF_MEMORY
);
128 rv
= inst
->QueryInterface(aIID
, aResult
);
134 static const nsModuleComponentInfo kComponents
[] =
136 { "Sqlite Transport Module Test Container",
137 AA_SQLITE_TRANSPORT_TEST_MODULE_CID
,
138 AA_SQLITE_TRANSPORT_TEST_MODULE_CONTRACT
,
139 aaSqliteTransportTestModuleConstructor
}
140 ,{"Sqlite Channel Load Entity Test",
141 AA_SQLITE_LOAD_ENTITY_CID
,
142 AA_SQLITE_LOAD_ENTITY_CONTRACT
,
143 aaSqliteLoadEntityTestConstructor
}
144 ,{"Sqlite Channel Create Table Test",
145 AA_SQLITE_CREATE_TABLE1_CID
,
146 AA_SQLITE_CREATE_TABLE1_CONTRACT
,
147 aaSqliteCreateTable1TestConstructor
}
149 NS_IMPL_NSGETMODULE(aaSqliteTransportTest
, kComponents
)