|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include <QtTest/QtTest> |
|
43 #include <QObject> |
|
44 #include <qdebug.h> |
|
45 #include <qtcontacts.h> |
|
46 |
|
47 #ifdef SYMBIANSIM_BACKEND_USE_ETEL_TESTSERVER |
|
48 #include <etelmm_etel_test_server.h> |
|
49 #else |
|
50 #include <etelmm.h> |
|
51 #endif |
|
52 #include <mmtsy_names.h> |
|
53 #include "ut_cntsimutility.h" |
|
54 #include "cntsimutility.h" |
|
55 |
|
56 bool TestCntSimUtility::returnErrorInStub_1 = false; |
|
57 bool TestCntSimUtility::returnErrorInStub_2 = false; |
|
58 |
|
59 |
|
60 TestCntSimUtility::TestCntSimUtility() : |
|
61 m_SimStore(0) |
|
62 { |
|
63 |
|
64 } |
|
65 |
|
66 TestCntSimUtility::~TestCntSimUtility() |
|
67 { |
|
68 |
|
69 } |
|
70 |
|
71 void TestCntSimUtility::initTestCase() |
|
72 { |
|
73 |
|
74 int error = KErrNone; |
|
75 |
|
76 // remove all contacts |
|
77 } |
|
78 |
|
79 void TestCntSimUtility::cleanupTestCase() |
|
80 { |
|
81 |
|
82 delete m_SimStore; |
|
83 m_SimStore = 0; |
|
84 } |
|
85 |
|
86 void TestCntSimUtility::TestStoreCreation() |
|
87 { |
|
88 |
|
89 } |
|
90 |
|
91 void TestCntSimUtility::TestGetSimInfo() |
|
92 { |
|
93 // ok case |
|
94 TestCntSimUtility::returnErrorInStub_1 = false; |
|
95 int error = KErrNotSupported; |
|
96 m_SimStore = new CntSimUtility(CntSimUtility::AdnStore, error); |
|
97 error = KErrNotSupported; |
|
98 CntSimUtility::SimInfo simInformation_adn = m_SimStore->getSimInfo(error); |
|
99 QVERIFY(KErrNone == error); |
|
100 outputSimInfo(simInformation_adn); |
|
101 |
|
102 // error case |
|
103 TestCntSimUtility::returnErrorInStub_1 = true; |
|
104 simInformation_adn = m_SimStore->getSimInfo(error); |
|
105 QVERIFY(KErrNone == KErrGeneral); |
|
106 |
|
107 |
|
108 } |
|
109 void TestCntSimUtility::outputSimInfo(CntSimUtility::SimInfo &results) |
|
110 { |
|
111 return; |
|
112 qDebug()<< "SIMUTILITY:Totalentries = "<< results.totalEntries; |
|
113 qDebug()<< "SIMUTILITY:usedEntries = "<< results.usedEntries ; |
|
114 qDebug()<< "SIMUTILITY:maxNumLength = "<< results.maxNumLength; |
|
115 qDebug()<< "SIMUTILITY:maxTextLength = "<< results.maxTextLength; |
|
116 qDebug()<< "SIMUTILITY:maxSecondNames = "<< results.maxSecondNames; |
|
117 qDebug()<< "SIMUTILITY:maxTextLengthSecondName = "<< results.maxTextLengthSecondName ; |
|
118 qDebug()<< "SIMUTILITY:maxAdditionalNumbers = "<< results.maxAdditionalNumbers ; |
|
119 qDebug()<< "SIMUTILITY:maxNumLengthAdditionalNumber = "<< results.maxNumLengthAdditionalNumber; |
|
120 qDebug()<< "SIMUTILITY:maxTextLengthAdditionalNumber = "<< results.maxTextLengthAdditionalNumber; |
|
121 qDebug()<< "SIMUTILITY:maxGroupNames = "<< results.maxGroupNames ; |
|
122 qDebug()<< "SIMUTILITY:maxTextLengthGroupName = "<<results.maxTextLengthGroupName ; |
|
123 qDebug()<< "SIMUTILITY:maxEmailAddr = "<<results.maxEmailAddr ; |
|
124 qDebug()<< "SIMUTILITY:maxTextLengthEmailAddr = "<<results.maxTextLengthEmailAddr; |
|
125 |
|
126 |
|
127 |
|
128 } |
|
129 |
|
130 void TestCntSimUtility::TestGetAvailableStores() |
|
131 { |
|
132 TestCntSimUtility::returnErrorInStub_1 = false; |
|
133 int error1 = KErrNotSupported; |
|
134 CntSimUtility::AvailableStores avalStores1 = m_SimStore->getAvailableStores(error1); |
|
135 |
|
136 |
|
137 TestCntSimUtility::returnErrorInStub_1 = true; |
|
138 int error2 = KErrNotSupported; |
|
139 CntSimUtility::AvailableStores avalStores2 = m_SimStore->getAvailableStores(error2); |
|
140 |
|
141 QVERIFY(error1 == KErrNone); |
|
142 QVERIFY(true == avalStores1.AdnStorePresent); |
|
143 QVERIFY(false == avalStores1.SdnStorePresent); |
|
144 QVERIFY(true == avalStores1.FdnStorePresent); |
|
145 QVERIFY(false == avalStores1.OnStorePresent); |
|
146 QVERIFY(avalStores1.SimPresent == true); |
|
147 |
|
148 QVERIFY(error2 == KErrNone); |
|
149 QVERIFY(false == avalStores2.AdnStorePresent); |
|
150 QVERIFY(false == avalStores2.SdnStorePresent); |
|
151 QVERIFY(false == avalStores2.FdnStorePresent); |
|
152 QVERIFY(false == avalStores2.OnStorePresent); |
|
153 QVERIFY(false == avalStores2.SimPresent); |
|
154 |
|
155 } |
|
156 void TestCntSimUtility::TestVerifyPin2Code() |
|
157 { |
|
158 TestCntSimUtility::returnErrorInStub_1 = false; |
|
159 bool ret = m_SimStore->verifyPin2Code(); |
|
160 QVERIFY(true == ret); |
|
161 |
|
162 } |
|
163 void TestCntSimUtility::TestIsFdnActive() |
|
164 { |
|
165 TestCntSimUtility::returnErrorInStub_1 = false; |
|
166 bool isFdnActive = m_SimStore->isFdnActive(); |
|
167 QVERIFY(isFdnActive == true); |
|
168 |
|
169 //check error case |
|
170 TestCntSimUtility::returnErrorInStub_1 = true; |
|
171 isFdnActive = m_SimStore->isFdnActive(); |
|
172 QVERIFY(isFdnActive == false); |
|
173 |
|
174 } |
|
175 void TestCntSimUtility::TestSetFdnStatus() |
|
176 { |
|
177 TestCntSimUtility::returnErrorInStub_1 = false; |
|
178 bool fdnActive = m_SimStore->isFdnActive(); |
|
179 int err = m_SimStore->setFdnStatus(true); |
|
180 QVERIFY(err == KErrNone); |
|
181 //error case |
|
182 TestCntSimUtility::returnErrorInStub_1 = true; |
|
183 err = m_SimStore->setFdnStatus(true); |
|
184 QVERIFY(err == KErrGeneral); |
|
185 |
|
186 } |
|
187 void TestCntSimUtility::TestGetLastImportTime() |
|
188 { |
|
189 TestCntSimUtility::returnErrorInStub_1 = false; |
|
190 int error1 = KErrNotSupported; |
|
191 QDateTime datetime1 = m_SimStore->getLastImportTime(error1); |
|
192 |
|
193 TestCntSimUtility::returnErrorInStub_1 = true; |
|
194 int error2 = KErrNotSupported; |
|
195 QDateTime datetime = m_SimStore->getLastImportTime(error2); |
|
196 |
|
197 QVERIFY(KErrNone == error1); |
|
198 |
|
199 QVERIFY(KErrAccessDenied == error2); |
|
200 |
|
201 |
|
202 |
|
203 } |
|
204 |
|
205 void TestCntSimUtility::TestSetLastImportTime() |
|
206 { |
|
207 |
|
208 TestCntSimUtility::returnErrorInStub_1 = false; |
|
209 int error1 = KErrNotSupported; |
|
210 m_SimStore->setLastImportTime(error1); |
|
211 TestCntSimUtility::returnErrorInStub_1 = false; |
|
212 int error2 = KErrNotSupported; |
|
213 m_SimStore->setLastImportTime(error2); |
|
214 |
|
215 |
|
216 QVERIFY(KErrNone == error1); |
|
217 QVERIFY(KErrAccessDenied == error2); |
|
218 |
|
219 } |
|
220 |
|
221 |
|
222 void TestCntSimUtility::TestStartGetSimInfo() |
|
223 { |
|
224 connect(m_SimStore, SIGNAL(simInfoReady(CntSimUtility::SimInfo& simInfo, int error)), this, SLOT(simInfoReady(CntSimUtility::SimInfo& simInfo, int error))); |
|
225 bool ret = m_SimStore->startGetSimInfo(); |
|
226 QVERIFY(true == ret); |
|
227 } |
|
228 |
|
229 void TestCntSimUtility::TestStartGetAvailableStores() |
|
230 { |
|
231 connect(m_SimStore, SIGNAL(availableStoresReady(CntSimUtility::AvailableStores& availableStores, int error)), this, SLOT(availableStoresReady(CntSimUtility::AvailableStores& availableStores, int error))); |
|
232 bool ret = m_SimStore->startGetAvailableStores(); |
|
233 QVERIFY(true == ret); |
|
234 } |
|
235 |
|
236 void TestCntSimUtility::TestNotifyAdnCacheStatus() |
|
237 { |
|
238 connect(m_SimStore, SIGNAL(adnCacheStatusReady(CntSimUtility::CacheStatus&, int)), this, SLOT(getSimInfoAndUpdateUI(CntSimUtility::CacheStatus&, int))); |
|
239 bool ret = m_SimStore->notifyAdnCacheStatus(); |
|
240 QVERIFY(true == ret); |
|
241 } |
|
242 |
|
243 |
|
244 void TestCntSimUtility::adnCacheStatusReady(CntSimUtility::CacheStatus& cacheStatus, int error) |
|
245 { |
|
246 |
|
247 QVERIFY(cacheStatus == RMmCustomAPI::ECacheReady); |
|
248 QVERIFY(KErrNone == error); |
|
249 |
|
250 } |
|
251 |
|
252 void TestCntSimUtility::simInfoReady(CntSimUtility::SimInfo& simInfo, int error) |
|
253 { |
|
254 QVERIFY(KErrNone == error); |
|
255 |
|
256 } |
|
257 |
|
258 void TestCntSimUtility::availableStoresReady(CntSimUtility::AvailableStores& availableStores, int error) |
|
259 { |
|
260 QVERIFY(KErrNone == error); |
|
261 |
|
262 } |
|
263 |