storage: move rule tests
[abstract.git] / storage / base / test / aaStorageTestModule.cpp
blob22f38a030ca918fbdefd9c80426ccee3d74aa917
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,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 "nsEmbedString.h"
26 #include "nsIGenericFactory.h"
28 /* Unfrozen API */
29 #include "nsIStringEnumerator.h"
30 #include "nsTestUtils.h"
31 #include "nsITest.h"
32 #include "nsITestRunner.h"
34 /* Project includes */
35 #include "aaStorageTest.h"
37 #define AA_STORAGE_TEST_MODULE_CID \
38 {0x96705450, 0x908f, 0x496d, {0xa9, 0xf5, 0x3d, 0x67, 0xfa, 0xa4, 0x55, 0x6d}}
39 #define AA_STORAGE_TEST_MODULE_CONTRACT_ID "@aasii.org/storage/unit;1"
41 class aaStorageTestModule: public nsITest,
42 public nsIUTF8StringEnumerator
44 public:
45 aaStorageTestModule():mSubtest(0) {;}
46 NS_DECL_ISUPPORTS
47 NS_DECL_NSITEST
48 NS_DECL_NSIUTF8STRINGENUMERATOR
49 private:
50 virtual ~aaStorageTestModule() {;}
51 PRUint32 mSubtest;
54 NS_IMPL_ISUPPORTS2(aaStorageTestModule,
55 nsITest,
56 nsIUTF8StringEnumerator)
58 /* nsITest */
59 NS_IMETHODIMP
60 aaStorageTestModule::Test(nsITestRunner *aTestRunner)
62 return NS_OK;
65 /* nsIUTF8StringEnumerator */
66 static const char* subtests[] =
68 "@aasii.org/storage/unit-core;1"
70 #define subtestCount (sizeof(subtests) / sizeof(char*))
72 NS_IMETHODIMP
73 aaStorageTestModule::HasMore(PRBool *aHasMore)
75 NS_ENSURE_ARG_POINTER(aHasMore);
76 *aHasMore = (mSubtest < subtestCount);
77 return NS_OK;
80 NS_IMETHODIMP
81 aaStorageTestModule::GetNext(nsACString &aContractID)
83 NS_ENSURE_TRUE(mSubtest < subtestCount, NS_ERROR_FAILURE);
84 aContractID.Assign( subtests[mSubtest++] );
85 return NS_OK;
88 NS_GENERIC_FACTORY_CONSTRUCTOR(aaStorageTestModule)
89 NS_GENERIC_FACTORY_CONSTRUCTOR(aaStorageTest)
91 static const nsModuleComponentInfo kComponents[] =
94 "Storage Module Test Container",
95 AA_STORAGE_TEST_MODULE_CID,
96 AA_STORAGE_TEST_MODULE_CONTRACT_ID,
97 aaStorageTestModuleConstructor
100 "Storage Core Unit Test",
101 AA_STORAGE_TEST_CID,
102 AA_STORAGE_TEST_CONTRACT_ID,
103 aaStorageTestConstructor
106 NS_IMPL_NSGETMODULE(aabase, kComponents)