33
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0""
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* test the functions in cppluginconfigreader class
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "ut_cppluginconfigreader.h"
|
|
19 |
#include <QtTest/QtTest>
|
|
20 |
#include <cppluginconfigreader.h>
|
|
21 |
#include <cpbasepath.h>
|
|
22 |
#include <qdir.h>
|
|
23 |
|
|
24 |
/*!
|
|
25 |
class name: cppluginconfigreader
|
|
26 |
class's description:
|
|
27 |
type of test case: unit test
|
|
28 |
test cases' number totally: \n
|
|
29 |
*/
|
|
30 |
|
|
31 |
/*!
|
|
32 |
Description of test data \n
|
|
33 |
*/
|
|
34 |
void TestCppluginConfigReader::initTestCase()
|
|
35 |
{
|
|
36 |
// initialize public test data here
|
|
37 |
}
|
|
38 |
|
|
39 |
void TestCppluginConfigReader::testConstructor()
|
|
40 |
{
|
|
41 |
CpPluginConfigReader * pReader = new CpPluginConfigReader(CP_PLUGIN_CONFIG_PATH + QDir::separator() + "mainview.cpcfg");
|
|
42 |
QVERIFY(pReader!=0);
|
|
43 |
delete pReader;
|
|
44 |
}
|
|
45 |
|
|
46 |
/*!
|
|
47 |
Test Case Description: \n
|
|
48 |
1. Function Name: \n
|
|
49 |
QList<CpPluginConfig> readCpPluginConfigs();\n
|
|
50 |
2. Case Descrition: \n
|
|
51 |
Verify that the valid config file can be read correctly. \n
|
|
52 |
3. Input Parameters:\n
|
|
53 |
<1> valid configfiles: pluginfortest.cpcfg \n
|
|
54 |
4. Expected result: \n
|
|
55 |
<1> return the correct plugin number \n
|
|
56 |
*/
|
|
57 |
void TestCppluginConfigReader::testReadValidConfigFile()
|
|
58 |
{
|
|
59 |
CpPluginConfigReader * pReader = new CpPluginConfigReader(CP_PLUGIN_CONFIG_PATH + QDir::separator() + "pluginfortest.cpcfg");
|
|
60 |
QVERIFY(pReader!=0);
|
|
61 |
mCorrectConfig = pReader->readCpPluginConfigs();
|
|
62 |
QVERIFY(mCorrectConfig.count() == 4 );
|
|
63 |
delete pReader;
|
|
64 |
pReader = 0;
|
|
65 |
}
|
|
66 |
/*!
|
|
67 |
Test Case Description: \n
|
|
68 |
1. Function Name: \n
|
|
69 |
QList<CpPluginConfig> readCpPluginConfigs(); \n
|
|
70 |
2. Case Descrition: \n
|
|
71 |
Verify the empty config file path can be dealed without any crash. \n
|
|
72 |
3. Input Parameters: \n
|
|
73 |
<1> empty config plugin path \n
|
|
74 |
<2> config plugin path = null \n
|
|
75 |
4. Expected result: \n
|
|
76 |
<1> no crash \n
|
|
77 |
<2> no crash \n
|
|
78 |
*/
|
|
79 |
void TestCppluginConfigReader::testReadEmptyConfigFilePath()
|
|
80 |
{
|
|
81 |
CpPluginConfigReader * pReader = new CpPluginConfigReader("");
|
|
82 |
QVERIFY(pReader!=0);
|
|
83 |
mCorrectConfig = pReader->readCpPluginConfigs();
|
|
84 |
QVERIFY(mCorrectConfig.count() == 0 );
|
|
85 |
delete pReader;
|
|
86 |
pReader = 0;
|
|
87 |
pReader = new CpPluginConfigReader(0);
|
|
88 |
QVERIFY(pReader!=0);
|
|
89 |
mCorrectConfig = pReader->readCpPluginConfigs();
|
|
90 |
QVERIFY(mCorrectConfig.count() == 0 );
|
|
91 |
delete pReader;
|
|
92 |
pReader = 0;
|
|
93 |
}
|
|
94 |
/*!
|
|
95 |
Test Case Description: \n
|
|
96 |
1. Function Name: \n
|
|
97 |
QList<CpPluginConfig> readCpPluginConfigs(); \n
|
|
98 |
2. Case Descrition: \n
|
|
99 |
Verify that the empty config file could be read. \n
|
|
100 |
3. Input Parameters: \n
|
|
101 |
<1> empty config file "emptypluginfortest.cpcfg" \n
|
|
102 |
4. Expected result: \n
|
|
103 |
<1> no crash \n
|
|
104 |
*/
|
|
105 |
void TestCppluginConfigReader::testReadEmptyConfigFile()
|
|
106 |
{
|
|
107 |
CpPluginConfigReader * pReader = new CpPluginConfigReader(CP_PLUGIN_CONFIG_PATH + QDir::separator() + "emptypluginfortest.cpcfg");
|
|
108 |
QVERIFY(pReader!=0);
|
|
109 |
mCorrectConfig = pReader->readCpPluginConfigs();
|
|
110 |
QVERIFY(mCorrectConfig.count() == 0 );
|
|
111 |
delete pReader;
|
|
112 |
pReader = 0;
|
|
113 |
}
|
|
114 |
/*!
|
|
115 |
Test Case Description: \n
|
|
116 |
1. Function Name: \n
|
|
117 |
void readCpPluginConfigs(QXmlStreamReader &xmlReader,QList<CpPluginConfig> &cpPluginConfigList) \n
|
|
118 |
2. Case Descrition: \n
|
|
119 |
Verify that the function can work without crash when reading the plugin files with wrong tag. \n
|
|
120 |
3. Input Parameters: \n
|
|
121 |
<1> config file with wrong child plugin tag: "pluginfilewithwrongchildtag.cpcfg" \n
|
|
122 |
4. Expected result: \n
|
|
123 |
<1> no crash \n
|
|
124 |
*/
|
|
125 |
void TestCppluginConfigReader::testReaderWithWrongChildPluginTag()
|
|
126 |
{
|
|
127 |
CpPluginConfigReader * pReader = new CpPluginConfigReader(CP_PLUGIN_CONFIG_PATH + QDir::separator() + "pluginfilewithwrongchildtag.cpcfg");
|
|
128 |
QVERIFY(pReader!=0);
|
|
129 |
mCorrectConfig = pReader->readCpPluginConfigs();
|
|
130 |
QVERIFY( mCorrectConfig.count() == 0 );
|
|
131 |
delete pReader;
|
|
132 |
pReader = 0;
|
|
133 |
}
|
|
134 |
/*!
|
|
135 |
Test Case Description: \n
|
|
136 |
1. Function Name: \n
|
|
137 |
void readChildPluginsElement(QXmlStreamReader &xmlReader,QList<CpPluginConfig> &cpPluginConfigList) \n
|
|
138 |
2. Case Descrition: \n
|
|
139 |
Verify that the function can work without crash when reading the plugin files with empty child plugin element. \n
|
|
140 |
3. Input Parameters: \n
|
|
141 |
<1> config file with empty child plugin element: "pluginfilewithemptychildelement.cpcfg" \n
|
|
142 |
4. Expected result: \n
|
|
143 |
<1> no crash \n
|
|
144 |
*/
|
|
145 |
void TestCppluginConfigReader::testReaderWithEmptyChildElement()
|
|
146 |
{
|
|
147 |
CpPluginConfigReader * pReader = new CpPluginConfigReader(CP_PLUGIN_CONFIG_PATH + QDir::separator() + "pluginfilewithemptychildelement.cpcfg");
|
|
148 |
QVERIFY(pReader!=0);
|
|
149 |
mCorrectConfig = pReader->readCpPluginConfigs();
|
|
150 |
QVERIFY( mCorrectConfig.count() == 0 );
|
|
151 |
delete pReader;
|
|
152 |
pReader = 0;
|
|
153 |
}
|
|
154 |
/*!
|
|
155 |
Test Case Description: \n
|
|
156 |
1. Function Name: \n
|
|
157 |
void readChildPluginsElement(QXmlStreamReader &xmlReader,QList<CpPluginConfig> &cpPluginConfigList) \n
|
|
158 |
2. Case Descrition: \n
|
|
159 |
Verify that the function can work without crash when reading plugin files with wrong tags. \n
|
|
160 |
3. Input Parameters: \n
|
|
161 |
<1> config file with wrong plugin tag: "pluginfilewithwrongplugintag.cpcfg" \n
|
|
162 |
4. Expected result: \n
|
|
163 |
<1> no crash \n
|
|
164 |
*/
|
|
165 |
void TestCppluginConfigReader::testReaderWithWrongPluginTag()
|
|
166 |
{
|
|
167 |
CpPluginConfigReader * pReader = new CpPluginConfigReader(CP_PLUGIN_CONFIG_PATH + QDir::separator() + "pluginfilewithwrongplugintag.cpcfg");
|
|
168 |
QVERIFY(pReader!=0);
|
|
169 |
mCorrectConfig = pReader->readCpPluginConfigs();
|
|
170 |
QVERIFY( mCorrectConfig.count() == 0 );
|
|
171 |
delete pReader;
|
|
172 |
pReader = 0;
|
|
173 |
}
|
|
174 |
/*!
|
|
175 |
Test Case Description: \n
|
|
176 |
1. Function Name: \n
|
|
177 |
void readPluginElement(QXmlStreamReader &xmlReader,QList<CpPluginConfig> &cpPluginConfigList); \n
|
|
178 |
2. Case Descrition: \n
|
|
179 |
Verify that the function can work without crash when reading the plugin files having no attrs. \n
|
|
180 |
3. Input Parameters: \n
|
|
181 |
<1> plugin element has no plugin attrs: "pluginfilewithoutattrs.cpcfg" \n
|
|
182 |
<2> plugin element has wrong plugin attrs. \n
|
|
183 |
4. Expected result: \n
|
|
184 |
<1> no crash \n
|
|
185 |
<2> no crash \n
|
|
186 |
*/
|
|
187 |
void TestCppluginConfigReader::testReaderWithoutAttrs()
|
|
188 |
{
|
|
189 |
CpPluginConfigReader * pReader = new CpPluginConfigReader(CP_PLUGIN_CONFIG_PATH + QDir::separator() + "pluginfilewithoutattrs.cpcfg");
|
|
190 |
QVERIFY(pReader!=0);
|
|
191 |
mCorrectConfig = pReader->readCpPluginConfigs();
|
|
192 |
QVERIFY( mCorrectConfig.count() == 1 );
|
|
193 |
delete pReader;
|
|
194 |
pReader = 0;
|
|
195 |
}
|
|
196 |
/*!
|
|
197 |
Test Case Description: \n
|
|
198 |
1. Function Name: \n
|
|
199 |
void readDescElement(QXmlStreamReader &xmlReader,CpPluginConfig &cpPluginConfig) \n
|
|
200 |
2. Case Descrition: \n
|
|
201 |
Verify that the function can work without crash when reading the plugin files with wrong tag. \n
|
|
202 |
3. Input Parameters: \n
|
|
203 |
<1> plugin element has no desc tag: "pluginfilewithwrongdesctag.cpcfg" \n
|
|
204 |
<2> plugin element has wrong desc tag \n
|
|
205 |
4. Expected result: \n
|
|
206 |
<1> no crash \n
|
|
207 |
<2> no crash \n
|
|
208 |
*/
|
|
209 |
void TestCppluginConfigReader::testReaderWithWrongDescTag()
|
|
210 |
{
|
|
211 |
CpPluginConfigReader * pReader = new CpPluginConfigReader(CP_PLUGIN_CONFIG_PATH + QDir::separator() + "pluginfilewithwrongdesctag.cpcfg");
|
|
212 |
QVERIFY(pReader!=0);
|
|
213 |
mCorrectConfig = pReader->readCpPluginConfigs();
|
|
214 |
delete pReader;
|
|
215 |
pReader = 0;
|
|
216 |
}
|
|
217 |
/*!
|
|
218 |
Descrition of what you will do in this function
|
|
219 |
*/
|
|
220 |
void TestCppluginConfigReader::cleanupTestCase()
|
|
221 |
{
|
|
222 |
// release all test data
|
|
223 |
QCoreApplication::processEvents();
|
|
224 |
}
|
|
225 |
|
|
226 |
QTEST_APPLESS_MAIN(TestCppluginConfigReader)
|