|
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 * |
|
16 */ |
|
17 /* |
|
18 * castoragetestadd.cpp |
|
19 * |
|
20 * Created on: 2009-08-05 |
|
21 * Author: michal.czerwiec |
|
22 */ |
|
23 |
|
24 |
|
25 #include "castoragetest.h" |
|
26 #include "castoragefactory.h" |
|
27 #include "castorage.h" |
|
28 #include "cainnerentry.h" |
|
29 #include "casqlquery.h" |
|
30 #include "casqlitestorage.h" |
|
31 #include "castoragetestsqlcommands.h" |
|
32 #include "caarraycleanup.inl" |
|
33 #include <QMap> |
|
34 #include <QString> |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 void CCAStorageTest::testAdd() |
|
43 { |
|
44 __UHEAP_MARK; |
|
45 TInt entryId(0); |
|
46 |
|
47 TRAPD(err, |
|
48 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
49 innerEntry->SetTextL(KTestName); |
|
50 innerEntry->SetEntryTypeNameL(KTypeName); |
|
51 innerEntry->SetFlags(flag); |
|
52 innerEntry->SetRole(CCaInnerQuery::Group); |
|
53 mStorage->AddL(innerEntry); |
|
54 entryId = innerEntry->GetId(); |
|
55 |
|
56 CleanupStack::PopAndDestroy(innerEntry); |
|
57 ); |
|
58 |
|
59 QCOMPARE(err, KErrNone); |
|
60 QVERIFY(entryId > 0); |
|
61 |
|
62 __UHEAP_MARKEND; |
|
63 |
|
64 } |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CCAStorageTest::testAddEmptyIcon() |
|
70 { |
|
71 TInt entryId(0); |
|
72 __UHEAP_MARK; |
|
73 TRAPD(err, |
|
74 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
75 innerEntry->SetTextL(KTestName); |
|
76 innerEntry->SetEntryTypeNameL(KTypeName); |
|
77 innerEntry->SetFlags(flag); |
|
78 innerEntry->SetRole(CCaInnerQuery::Group); |
|
79 innerEntry->SetIconDataL(KNullDesC, KNullDesC, KNullDesC); |
|
80 mStorage->AddL(innerEntry); |
|
81 entryId = innerEntry->GetId(); |
|
82 CleanupStack::PopAndDestroy(innerEntry); |
|
83 ); |
|
84 QCOMPARE(err, KErrNone); |
|
85 QVERIFY(entryId > 0); |
|
86 |
|
87 __UHEAP_MARKEND; |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 void CCAStorageTest::testAddWithIcon() |
|
93 { |
|
94 __UHEAP_MARK; |
|
95 TInt entryId(0); |
|
96 TInt iconId(0); |
|
97 TRAPD(err, |
|
98 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
99 innerEntry->SetTextL(KTestName); |
|
100 innerEntry->SetEntryTypeNameL(KTypeName); |
|
101 innerEntry->SetFlags(flag); |
|
102 innerEntry->SetRole(CCaInnerQuery::Group); |
|
103 innerEntry->SetIconDataL(_L("qtg_large_applications_user"), KNullDesC, KNullDesC); |
|
104 mStorage->AddL(innerEntry); |
|
105 |
|
106 entryId = innerEntry->GetId(); |
|
107 iconId = innerEntry->GetIconId(); |
|
108 |
|
109 CleanupStack::PopAndDestroy(innerEntry); |
|
110 ); |
|
111 |
|
112 QCOMPARE(err, KErrNone); |
|
113 |
|
114 QVERIFY(entryId > 0); |
|
115 QVERIFY(iconId > 0); |
|
116 |
|
117 |
|
118 __UHEAP_MARKEND; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 void CCAStorageTest::testAddWithExistingIcon() |
|
124 { |
|
125 __UHEAP_MARK; |
|
126 TInt entryId1(0); |
|
127 TInt iconId1(0); |
|
128 TInt entryId2(0); |
|
129 TInt iconId2(0); |
|
130 TInt countIconsAfterFirstAdd (0); |
|
131 TInt countIconsAfterSecondAdd (0); |
|
132 |
|
133 TRAPD(err, |
|
134 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
135 innerEntry->SetTextL(KTestName); |
|
136 innerEntry->SetEntryTypeNameL(KTypeName); |
|
137 innerEntry->SetFlags(flag); |
|
138 innerEntry->SetRole(CCaInnerQuery::Group); |
|
139 innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321")); |
|
140 mStorage->AddL(innerEntry); |
|
141 |
|
142 CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
143 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
144 query->PrepareL(); |
|
145 query->ExecuteL(countIconsAfterFirstAdd); |
|
146 CleanupStack::PopAndDestroy(query); |
|
147 |
|
148 // Add second entry with the some icon |
|
149 CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC(); |
|
150 innerEntry2->SetTextL(KTestName2); |
|
151 innerEntry2->SetEntryTypeNameL(KTypeName); |
|
152 innerEntry2->SetFlags(flag); |
|
153 innerEntry2->SetRole(CCaInnerQuery::Group); |
|
154 innerEntry2->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321")); |
|
155 mStorage->AddL(innerEntry2); |
|
156 |
|
157 query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
158 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
159 query->PrepareL(); |
|
160 query->ExecuteL(countIconsAfterSecondAdd); |
|
161 CleanupStack::PopAndDestroy(query); |
|
162 |
|
163 entryId1 = innerEntry->GetId(); |
|
164 iconId1 = innerEntry->GetIconId(); |
|
165 |
|
166 entryId2 = innerEntry2->GetId(); |
|
167 iconId2 = innerEntry2->GetIconId(); |
|
168 |
|
169 CleanupStack::PopAndDestroy(innerEntry2); |
|
170 CleanupStack::PopAndDestroy(innerEntry); |
|
171 ); |
|
172 |
|
173 QCOMPARE(err, KErrNone); |
|
174 |
|
175 // No new icon created; Icon which is the same should be shared by newly added entries |
|
176 QCOMPARE(countIconsAfterFirstAdd, countIconsAfterSecondAdd); |
|
177 |
|
178 QVERIFY(entryId1 > 0); |
|
179 QVERIFY(iconId1 > 0); |
|
180 QVERIFY(entryId2 > 0); |
|
181 QVERIFY(iconId2 > 0); |
|
182 QVERIFY(!(entryId1 == entryId2)); |
|
183 QCOMPARE(iconId1, iconId2); |
|
184 |
|
185 __UHEAP_MARKEND; |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 void CCAStorageTest::testAddWithExistingIconOnlyFileName() |
|
191 { |
|
192 __UHEAP_MARK; |
|
193 TInt entryId1(0); |
|
194 TInt iconId1(0); |
|
195 TInt entryId2(0); |
|
196 TInt iconId2(0); |
|
197 TInt countIconsAfterFirstAdd (0); |
|
198 TInt countIconsAfterSecondAdd (0); |
|
199 |
|
200 TRAPD(err, |
|
201 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
202 innerEntry->SetTextL(KTestName); |
|
203 innerEntry->SetEntryTypeNameL(KTypeName); |
|
204 innerEntry->SetFlags(flag); |
|
205 innerEntry->SetRole(CCaInnerQuery::Group); |
|
206 innerEntry->SetIconDataL(_L("qtg_large_applications_user"), KNullDesC, KNullDesC); |
|
207 mStorage->AddL(innerEntry); |
|
208 |
|
209 CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
210 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
211 query->PrepareL(); |
|
212 query->ExecuteL(countIconsAfterFirstAdd); |
|
213 CleanupStack::PopAndDestroy(query); |
|
214 |
|
215 // Add second entry with the some icon |
|
216 CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC(); |
|
217 innerEntry2->SetTextL(KTestName2); |
|
218 innerEntry2->SetEntryTypeNameL(KTypeName); |
|
219 innerEntry2->SetFlags(flag); |
|
220 innerEntry2->SetRole(CCaInnerQuery::Group); |
|
221 innerEntry2->SetIconDataL(_L("qtg_large_applications_user"), KNullDesC, KNullDesC); |
|
222 mStorage->AddL(innerEntry2); |
|
223 |
|
224 query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
225 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
226 query->PrepareL(); |
|
227 query->ExecuteL(countIconsAfterSecondAdd); |
|
228 CleanupStack::PopAndDestroy(query); |
|
229 |
|
230 entryId1 = innerEntry->GetId(); |
|
231 iconId1 = innerEntry->GetIconId(); |
|
232 |
|
233 entryId2 = innerEntry2->GetId(); |
|
234 iconId2 = innerEntry2->GetIconId(); |
|
235 |
|
236 CleanupStack::PopAndDestroy(innerEntry2); |
|
237 CleanupStack::PopAndDestroy(innerEntry); |
|
238 |
|
239 ); |
|
240 |
|
241 QCOMPARE(err, KErrNone); |
|
242 |
|
243 // No new icon created; Icon which is the same should be shared by newly added entries |
|
244 QCOMPARE(countIconsAfterFirstAdd, countIconsAfterSecondAdd); |
|
245 |
|
246 |
|
247 QVERIFY(entryId1 > 0); |
|
248 QVERIFY(iconId1 > 0); |
|
249 QVERIFY(entryId2 > 0); |
|
250 QVERIFY(iconId2 > 0); |
|
251 QVERIFY(!(entryId1 == entryId2)); |
|
252 QCOMPARE(iconId1, iconId2); |
|
253 |
|
254 |
|
255 __UHEAP_MARKEND; |
|
256 } |
|
257 |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 void CCAStorageTest::testAddWithPartlyMatchingIcon() |
|
261 { |
|
262 __UHEAP_MARK; |
|
263 TInt entryId1(0); |
|
264 TInt iconId1(0); |
|
265 TInt entryId2(0); |
|
266 TInt iconId2(0); |
|
267 TInt countIconsAfterFirstAdd (0); |
|
268 TInt countIconsAfterSecondAdd (0); |
|
269 |
|
270 TRAPD(err, |
|
271 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
272 innerEntry->SetTextL(KTestName); |
|
273 innerEntry->SetEntryTypeNameL(KTypeName); |
|
274 innerEntry->SetFlags(flag); |
|
275 innerEntry->SetRole(CCaInnerQuery::Group); |
|
276 innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321")); |
|
277 mStorage->AddL(innerEntry); |
|
278 |
|
279 CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
280 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
281 query->PrepareL(); |
|
282 query->ExecuteL(countIconsAfterFirstAdd); |
|
283 CleanupStack::PopAndDestroy(query); |
|
284 |
|
285 // Add second entry with the some icon |
|
286 CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC(); |
|
287 innerEntry2->SetTextL(KTestName2); |
|
288 innerEntry2->SetEntryTypeNameL(KTypeName); |
|
289 innerEntry2->SetFlags(flag); |
|
290 innerEntry2->SetRole(CCaInnerQuery::Group); |
|
291 innerEntry2->SetIconDataL(_L("filename"), _L("skinId2"), _L("111111111")); |
|
292 mStorage->AddL(innerEntry2); |
|
293 |
|
294 query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
295 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
296 query->PrepareL(); |
|
297 query->ExecuteL(countIconsAfterSecondAdd); |
|
298 CleanupStack::PopAndDestroy(query); |
|
299 |
|
300 entryId1 = innerEntry->GetId(); |
|
301 iconId1 = innerEntry->GetIconId(); |
|
302 |
|
303 entryId2 = innerEntry2->GetId(); |
|
304 iconId2 = innerEntry2->GetIconId(); |
|
305 |
|
306 CleanupStack::PopAndDestroy(innerEntry2); |
|
307 CleanupStack::PopAndDestroy(innerEntry); |
|
308 ); |
|
309 |
|
310 QCOMPARE(err, KErrNone); |
|
311 |
|
312 // New icon should be added |
|
313 QCOMPARE(countIconsAfterSecondAdd - countIconsAfterFirstAdd, 1); |
|
314 |
|
315 QVERIFY(entryId1 > 0); |
|
316 QVERIFY(iconId1 > 0); |
|
317 QVERIFY(entryId2 > 0); |
|
318 QVERIFY(iconId2 > 0); |
|
319 QVERIFY(!(entryId1 == entryId2)); |
|
320 QVERIFY(!(iconId1 == iconId2)); |
|
321 |
|
322 __UHEAP_MARKEND; |
|
323 } |
|
324 |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // |
|
328 void CCAStorageTest::testAddWithPartlyMatchingIconNotAllParams() |
|
329 { |
|
330 __UHEAP_MARK; |
|
331 TInt entryId1(0); |
|
332 TInt iconId1(0); |
|
333 TInt entryId2(0); |
|
334 TInt iconId2(0); |
|
335 TInt countIconsAfterFirstAdd (0); |
|
336 TInt countIconsAfterSecondAdd (0); |
|
337 |
|
338 TRAPD(err, |
|
339 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
340 innerEntry->SetTextL(KTestName); |
|
341 innerEntry->SetEntryTypeNameL(KTypeName); |
|
342 innerEntry->SetFlags(flag); |
|
343 innerEntry->SetRole(CCaInnerQuery::Group); |
|
344 innerEntry->SetIconDataL(_L("filename"), _L("skinId"), KNullDesC); |
|
345 mStorage->AddL(innerEntry); |
|
346 |
|
347 CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
348 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
349 query->PrepareL(); |
|
350 query->ExecuteL(countIconsAfterFirstAdd); |
|
351 CleanupStack::PopAndDestroy(query); |
|
352 |
|
353 // Add second entry with the some icon |
|
354 CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC(); |
|
355 innerEntry2->SetTextL(KTestName2); |
|
356 innerEntry2->SetEntryTypeNameL(KTypeName); |
|
357 innerEntry2->SetFlags(flag); |
|
358 innerEntry2->SetRole(CCaInnerQuery::Group); |
|
359 innerEntry2->SetIconDataL(KNullDesC, _L("skinId"), KNullDesC); |
|
360 mStorage->AddL(innerEntry2); |
|
361 |
|
362 query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
363 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
364 query->PrepareL(); |
|
365 query->ExecuteL(countIconsAfterSecondAdd); |
|
366 CleanupStack::PopAndDestroy(query); |
|
367 |
|
368 entryId1 = innerEntry->GetId(); |
|
369 iconId1 = innerEntry->GetIconId(); |
|
370 |
|
371 entryId2 = innerEntry2->GetId(); |
|
372 iconId2 = innerEntry2->GetIconId(); |
|
373 |
|
374 CleanupStack::PopAndDestroy(innerEntry2); |
|
375 CleanupStack::PopAndDestroy(innerEntry); |
|
376 ); |
|
377 |
|
378 QCOMPARE(err, KErrNone); |
|
379 |
|
380 // New icon should be added |
|
381 QCOMPARE(countIconsAfterSecondAdd - countIconsAfterFirstAdd, 1); |
|
382 |
|
383 QVERIFY(entryId1 > 0); |
|
384 QVERIFY(iconId1 > 0); |
|
385 QVERIFY(entryId2 > 0); |
|
386 QVERIFY(iconId2 > 0); |
|
387 QVERIFY(!(entryId1 == entryId2)); |
|
388 QVERIFY(!(iconId1 == iconId2)); |
|
389 |
|
390 __UHEAP_MARKEND; |
|
391 } |
|
392 |
|
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // |
|
396 void CCAStorageTest::testAddWithNotCompleteIcon() |
|
397 { |
|
398 TInt entryId(0); |
|
399 TInt iconId(0); |
|
400 __UHEAP_MARK; |
|
401 TRAPD(err, |
|
402 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
403 innerEntry->SetTextL(KTestName); |
|
404 innerEntry->SetEntryTypeNameL(KTypeName); |
|
405 innerEntry->SetFlags(flag); |
|
406 innerEntry->SetRole(CCaInnerQuery::Group); |
|
407 innerEntry->SetIconDataL(_L("fake"), KNullDesC, KNullDesC); |
|
408 mStorage->AddL(innerEntry); |
|
409 |
|
410 entryId = innerEntry->GetId(); |
|
411 iconId = innerEntry->GetIconId(); |
|
412 |
|
413 CleanupStack::PopAndDestroy(innerEntry); |
|
414 ); |
|
415 |
|
416 QCOMPARE(err, KErrNone); |
|
417 QVERIFY(entryId > 0); |
|
418 QVERIFY(iconId > 0); |
|
419 |
|
420 __UHEAP_MARKEND; |
|
421 } |
|
422 |
|
423 // --------------------------------------------------------------------------- |
|
424 // |
|
425 void CCAStorageTest::testAddUpdateIcon() |
|
426 { |
|
427 TInt entryId(0); |
|
428 TInt iconId(0); |
|
429 TInt updatedEntryId(0); |
|
430 TInt updatedIconId(0); |
|
431 TInt countIconsAfterAdd (0); |
|
432 TInt countIconsAfterUpdate (0); |
|
433 |
|
434 RBuf updatedIconFileName; |
|
435 RBuf updatedIconSkinId; |
|
436 RBuf updatedIconAppId; |
|
437 TInt updatedIconIdFormIcon(0); |
|
438 |
|
439 __UHEAP_MARK; |
|
440 updatedIconFileName.CreateL( KMaxFileName ); |
|
441 updatedIconSkinId.CreateL( KMaxFileName ); |
|
442 updatedIconAppId.CreateL( KMaxUidName ); |
|
443 |
|
444 TRAPD(err, |
|
445 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
446 innerEntry->SetTextL(KTestName); |
|
447 innerEntry->SetEntryTypeNameL(KTypeName); |
|
448 innerEntry->SetFlags(flag); |
|
449 innerEntry->SetRole(CCaInnerQuery::Group); |
|
450 innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321")); |
|
451 mStorage->AddL(innerEntry); |
|
452 |
|
453 // Check db after add with icon |
|
454 CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
455 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
456 query->PrepareL(); |
|
457 query->ExecuteL(countIconsAfterAdd); |
|
458 CleanupStack::PopAndDestroy(query); |
|
459 |
|
460 entryId = innerEntry->GetId(); |
|
461 iconId = innerEntry->GetIconId(); |
|
462 |
|
463 innerEntry->SetTextL(KTestNameUpdate); |
|
464 innerEntry->SetFlags(flagUpdate); |
|
465 innerEntry->SetIconDataL( _L("filename2"), _L("skinId2"), _L("537001519")); |
|
466 mStorage->AddL(innerEntry); |
|
467 |
|
468 // Check db after update with icon |
|
469 query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
470 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
471 query->PrepareL(); |
|
472 query->ExecuteL(countIconsAfterUpdate); |
|
473 CleanupStack::PopAndDestroy(query); |
|
474 |
|
475 updatedEntryId = innerEntry->GetId(); |
|
476 updatedIconId = innerEntry->GetIconId(); |
|
477 |
|
478 updatedIconFileName = innerEntry->Icon()->FileName(); |
|
479 updatedIconSkinId= innerEntry->Icon()->SkinId(); |
|
480 updatedIconAppId = innerEntry->Icon()->ApplicationId(); |
|
481 updatedIconIdFormIcon = innerEntry->Icon()->Id(); |
|
482 |
|
483 |
|
484 |
|
485 CleanupStack::PopAndDestroy(innerEntry); |
|
486 ); |
|
487 QCOMPARE(err, KErrNone); |
|
488 QVERIFY(entryId > 0); |
|
489 QVERIFY(iconId > 0); |
|
490 QCOMPARE(updatedEntryId, entryId); |
|
491 QCOMPARE(updatedIconId, iconId); |
|
492 QCOMPARE(updatedIconIdFormIcon, updatedIconId); |
|
493 QVERIFY(!updatedIconFileName.Compare(_L("filename2"))); |
|
494 QVERIFY(!updatedIconSkinId.Compare(_L("skinId2"))); |
|
495 QVERIFY(!updatedIconAppId.Compare(_L("537001519"))); |
|
496 |
|
497 // No new icon should be added to DB |
|
498 QCOMPARE(countIconsAfterAdd, countIconsAfterUpdate); |
|
499 |
|
500 |
|
501 updatedIconFileName.Close(); |
|
502 updatedIconSkinId.Close(); |
|
503 updatedIconAppId.Close(); |
|
504 __UHEAP_MARKEND; |
|
505 } |
|
506 |
|
507 // --------------------------------------------------------------------------- |
|
508 // |
|
509 void CCAStorageTest::testAddUpdateIconOnlyFewParams() |
|
510 { |
|
511 TInt entryId(0); |
|
512 TInt iconId(0); |
|
513 TInt updatedEntryId(0); |
|
514 TInt updatedIconId(0); |
|
515 TInt countIconsAfterAdd (0); |
|
516 TInt countIconsAfterUpdate (0); |
|
517 |
|
518 |
|
519 RBuf updatedIconFileName; |
|
520 RBuf updatedIconSkinId; |
|
521 RBuf updatedIconAppId; |
|
522 TInt updatedIconIdFormIcon(0); |
|
523 |
|
524 __UHEAP_MARK; |
|
525 updatedIconFileName.CreateL( KMaxFileName ); |
|
526 updatedIconSkinId.CreateL( KMaxFileName ); |
|
527 updatedIconAppId.CreateL( KMaxUidName ); |
|
528 |
|
529 TRAPD(err, |
|
530 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
531 innerEntry->SetTextL(KTestName); |
|
532 innerEntry->SetEntryTypeNameL(KTypeName); |
|
533 innerEntry->SetFlags(flag); |
|
534 innerEntry->SetRole(CCaInnerQuery::Group); |
|
535 innerEntry->SetIconDataL(_L("filename"), KNullDesC, _L("268458321")); |
|
536 mStorage->AddL(innerEntry); |
|
537 |
|
538 // Check db after add with icon |
|
539 CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
540 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
541 query->PrepareL(); |
|
542 query->ExecuteL(countIconsAfterAdd); |
|
543 CleanupStack::PopAndDestroy(query); |
|
544 |
|
545 |
|
546 entryId = innerEntry->GetId(); |
|
547 iconId = innerEntry->GetIconId(); |
|
548 |
|
549 innerEntry->SetTextL(KTestNameUpdate); |
|
550 innerEntry->SetFlags(flagUpdate); |
|
551 innerEntry->SetIconDataL( _L("filename2"), KNullDesC, _L("537001519")); |
|
552 mStorage->AddL(innerEntry); |
|
553 |
|
554 // Check db after update with icon |
|
555 query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
556 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
557 query->PrepareL(); |
|
558 query->ExecuteL(countIconsAfterUpdate); |
|
559 CleanupStack::PopAndDestroy(query); |
|
560 |
|
561 |
|
562 updatedEntryId = innerEntry->GetId(); |
|
563 updatedIconId = innerEntry->GetIconId(); |
|
564 |
|
565 updatedIconFileName = innerEntry->Icon()->FileName(); |
|
566 updatedIconSkinId= innerEntry->Icon()->SkinId(); |
|
567 updatedIconAppId = innerEntry->Icon()->ApplicationId(); |
|
568 updatedIconIdFormIcon = innerEntry->Icon()->Id(); |
|
569 |
|
570 |
|
571 |
|
572 CleanupStack::PopAndDestroy(innerEntry); |
|
573 ); |
|
574 QCOMPARE(err, KErrNone); |
|
575 QVERIFY(entryId > 0); |
|
576 QVERIFY(iconId > 0); |
|
577 QCOMPARE(updatedEntryId, entryId); |
|
578 QCOMPARE(updatedIconId, iconId); |
|
579 QCOMPARE(updatedIconIdFormIcon, updatedIconId); |
|
580 QVERIFY(!updatedIconFileName.Compare(_L("filename2"))); |
|
581 QVERIFY(!updatedIconSkinId.Compare(KNullDesC)); |
|
582 QVERIFY(!updatedIconAppId.Compare(_L("537001519"))); |
|
583 // No new icon should be added to DB |
|
584 QCOMPARE(countIconsAfterAdd, countIconsAfterUpdate); |
|
585 |
|
586 updatedIconFileName.Close(); |
|
587 updatedIconSkinId.Close(); |
|
588 updatedIconAppId.Close(); |
|
589 __UHEAP_MARKEND; |
|
590 } |
|
591 |
|
592 |
|
593 |
|
594 // --------------------------------------------------------------------------- |
|
595 // |
|
596 void CCAStorageTest::testAddUpdateWithEmptyIcon() |
|
597 { |
|
598 TInt countIconsAfterAdd(0); |
|
599 TInt countIconsAfterUpdateWithEmptyIcon(0); |
|
600 TInt entryId(0); |
|
601 TInt iconId(0); |
|
602 __UHEAP_MARK; |
|
603 TRAPD(err, |
|
604 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
605 innerEntry->SetTextL(KTestName); |
|
606 innerEntry->SetEntryTypeNameL(KTypeName); |
|
607 innerEntry->SetFlags(flag); |
|
608 innerEntry->SetRole(CCaInnerQuery::Group); |
|
609 innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321")); |
|
610 // Add entry with icon - not null icon |
|
611 mStorage->AddL(innerEntry); |
|
612 |
|
613 // Check db after add with icon |
|
614 CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
615 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
616 query->PrepareL(); |
|
617 |
|
618 query->ExecuteL(countIconsAfterAdd); |
|
619 |
|
620 |
|
621 CleanupStack::PopAndDestroy(query); |
|
622 |
|
623 entryId = innerEntry->GetId(); |
|
624 iconId = innerEntry->GetIconId(); |
|
625 |
|
626 //CCaInnerEntry::TIconAttributes attr; |
|
627 innerEntry->SetTextL(KTestNameUpdate); |
|
628 innerEntry->SetFlags(flagUpdate); |
|
629 //innerEntry->SetIconId( 0 ); |
|
630 innerEntry->SetIconDataL(KNullDesC, KNullDesC, KNullDesC); |
|
631 //attr = innerEntry->GetIcon(); |
|
632 // Update entry with empty icon |
|
633 mStorage->AddL(innerEntry); |
|
634 |
|
635 // Check db after update with empty icon |
|
636 query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
637 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
638 query->PrepareL(); |
|
639 query->ExecuteL(countIconsAfterUpdateWithEmptyIcon); |
|
640 |
|
641 CleanupStack::PopAndDestroy(query); |
|
642 CleanupStack::PopAndDestroy(innerEntry); |
|
643 ); |
|
644 |
|
645 QCOMPARE(err, KErrNone); |
|
646 |
|
647 QVERIFY(entryId > 0); |
|
648 QVERIFY(iconId > 0); |
|
649 // icon should be removed from db because we set params to NULL |
|
650 QCOMPARE(countIconsAfterAdd - countIconsAfterUpdateWithEmptyIcon, 1); |
|
651 |
|
652 __UHEAP_MARKEND; |
|
653 } |
|
654 |
|
655 // --------------------------------------------------------------------------- |
|
656 // |
|
657 void CCAStorageTest::testAddUpdateWithEmptyIconAdvanced() |
|
658 { |
|
659 TInt countIconsAfterAdd(0); |
|
660 TInt countIconsAfterUpdateWithEmptyIcon(0); |
|
661 TInt entryId(0); |
|
662 TInt iconId(0); |
|
663 __UHEAP_MARK; |
|
664 TRAPD(err, |
|
665 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
666 innerEntry->SetTextL(KTestName); |
|
667 innerEntry->SetEntryTypeNameL(KTypeName); |
|
668 innerEntry->SetFlags(flag); |
|
669 innerEntry->SetRole(CCaInnerQuery::Group); |
|
670 innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321")); |
|
671 // Add entry with icon - not null icon |
|
672 mStorage->AddL(innerEntry); |
|
673 |
|
674 CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC(); |
|
675 innerEntry2->SetTextL(KTestName2); |
|
676 innerEntry2->SetEntryTypeNameL(KTypeName); |
|
677 innerEntry2->SetFlags(flag); |
|
678 innerEntry2->SetRole(CCaInnerQuery::Group); |
|
679 innerEntry2->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321")); |
|
680 |
|
681 // Add second entry with the some icon - not null icon |
|
682 mStorage->AddL(innerEntry2); |
|
683 |
|
684 CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
685 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
686 query->PrepareL(); |
|
687 |
|
688 query->ExecuteL(countIconsAfterAdd); |
|
689 CleanupStack::PopAndDestroy(query); |
|
690 |
|
691 entryId = innerEntry->GetId(); |
|
692 |
|
693 iconId = innerEntry->GetIconId(); |
|
694 |
|
695 innerEntry->SetTextL(KTestNameUpdate); |
|
696 innerEntry->SetFlags(flagUpdate); |
|
697 //innerEntry->SetIconId( 0 ); |
|
698 innerEntry->SetIconDataL(KNullDesC, KNullDesC, KNullDesC); |
|
699 // Update entry with empty icon |
|
700 mStorage->AddL(innerEntry); |
|
701 |
|
702 |
|
703 // Check db after update with empty icon |
|
704 |
|
705 query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
706 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
707 query->PrepareL(); |
|
708 query->ExecuteL(countIconsAfterUpdateWithEmptyIcon); |
|
709 CleanupStack::PopAndDestroy(query); |
|
710 CleanupStack::PopAndDestroy(innerEntry2); |
|
711 CleanupStack::PopAndDestroy(innerEntry); |
|
712 ); |
|
713 QCOMPARE(err, KErrNone); |
|
714 |
|
715 QVERIFY(entryId > 0); |
|
716 QVERIFY(iconId > 0); |
|
717 |
|
718 // icon shouldn't be removed from db because it is use by other entry |
|
719 QCOMPARE(countIconsAfterUpdateWithEmptyIcon, countIconsAfterAdd); |
|
720 |
|
721 __UHEAP_MARKEND; |
|
722 } |
|
723 |
|
724 |
|
725 // --------------------------------------------------------------------------- |
|
726 // |
|
727 void CCAStorageTest::testAddUpdateWithExistingIcon() |
|
728 { |
|
729 TInt countIconsAfterAdd(0); |
|
730 TInt countIconsAfterUpdateWithEmptyIcon(0); |
|
731 TInt entryId(0); |
|
732 TInt iconId(0); |
|
733 __UHEAP_MARK; |
|
734 TRAPD(err, |
|
735 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
736 innerEntry->SetTextL(KTestName); |
|
737 innerEntry->SetEntryTypeNameL(KTypeName); |
|
738 innerEntry->SetFlags(flag); |
|
739 innerEntry->SetRole(CCaInnerQuery::Group); |
|
740 innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("158321")); |
|
741 // Add entry with icon - not null icon |
|
742 mStorage->AddL(innerEntry); |
|
743 |
|
744 CCaInnerEntry *innerEntry2 = CCaInnerEntry::NewLC(); |
|
745 innerEntry2->SetTextL(KTestName2); |
|
746 innerEntry2->SetEntryTypeNameL(KTypeName); |
|
747 innerEntry2->SetFlags(flag); |
|
748 innerEntry2->SetRole(CCaInnerQuery::Group); |
|
749 innerEntry2->SetIconDataL(_L("filename2"), _L("skinId2"), KNullDesC); |
|
750 |
|
751 // Add second entry with the some icon - not null icon |
|
752 mStorage->AddL(innerEntry2); |
|
753 |
|
754 CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
755 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
756 query->PrepareL(); |
|
757 |
|
758 query->ExecuteL(countIconsAfterAdd); |
|
759 CleanupStack::PopAndDestroy(query); |
|
760 |
|
761 entryId = innerEntry->GetId(); |
|
762 |
|
763 iconId = innerEntry->GetIconId(); |
|
764 |
|
765 innerEntry->SetTextL(KTestNameUpdate); |
|
766 innerEntry->SetFlags(flagUpdate); |
|
767 //innerEntry->SetIconId( 0 ); |
|
768 innerEntry->SetIconDataL(_L("filename2"), _L("skinId2"), KNullDesC); |
|
769 // Update entry with empty icon |
|
770 mStorage->AddL(innerEntry); |
|
771 |
|
772 |
|
773 // Check db after update with empty icon |
|
774 |
|
775 query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
776 query->SetQueryL(KSQLGetIdCountFromIconTable); |
|
777 query->PrepareL(); |
|
778 query->ExecuteL(countIconsAfterUpdateWithEmptyIcon); |
|
779 CleanupStack::PopAndDestroy(query); |
|
780 CleanupStack::PopAndDestroy(innerEntry2); |
|
781 CleanupStack::PopAndDestroy(innerEntry); |
|
782 ); |
|
783 QCOMPARE(err, KErrNone); |
|
784 |
|
785 QVERIFY(entryId > 0); |
|
786 QVERIFY(iconId > 0); |
|
787 |
|
788 // icon shouldn't be removed from db because it is use by other entry |
|
789 QCOMPARE(countIconsAfterUpdateWithEmptyIcon, countIconsAfterAdd); |
|
790 |
|
791 __UHEAP_MARKEND; |
|
792 } |
|
793 |
|
794 |
|
795 |
|
796 // --------------------------------------------------------------------------- |
|
797 // |
|
798 void CCAStorageTest::testAddAttributes() |
|
799 { |
|
800 TInt err(KErrGeneral); |
|
801 __UHEAP_MARK; |
|
802 TRAP(err, |
|
803 CCaInnerEntry *innerEntry = CCaInnerEntry::NewL(); |
|
804 RPointerArray<CCaInnerEntry> innerEntryArray; |
|
805 CleanupResetAndDestroyPushL(innerEntryArray); |
|
806 innerEntryArray.AppendL(innerEntry); |
|
807 |
|
808 innerEntry->SetTextL(KTestName); |
|
809 innerEntry->SetEntryTypeNameL(KTypeName); |
|
810 innerEntry->SetFlags(flag); |
|
811 innerEntry->SetRole(CCaInnerQuery::Group); |
|
812 innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321")); |
|
813 |
|
814 innerEntry->AddAttributeL(KAttrName_1, KAttrValue_1); |
|
815 innerEntry->AddAttributeL(KAttrName_2, KAttrValue_2); |
|
816 innerEntry->AddAttributeL(KAttrName_3, KAttrValue_3); |
|
817 |
|
818 mStorage->AddL(innerEntry); |
|
819 // check status |
|
820 CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
821 query->SetQueryL(KSQLCheckAttribute); |
|
822 query->SetTableType(CCaSqlQuery::EAttributeTable); |
|
823 query->PrepareL(); |
|
824 query->BindEntryIdL(innerEntry->GetId()); |
|
825 RPointerArray<CCaInnerEntry> entryArray; |
|
826 CleanupResetAndDestroyPushL(entryArray); |
|
827 TInt count = query->ExecuteL(entryArray, CCaSqlQuery::EAttribute); |
|
828 query->CloseStatement(); |
|
829 CleanupStack::PopAndDestroy(&entryArray); |
|
830 |
|
831 if (innerEntry->GetId() > 0) |
|
832 if (innerEntry->GetIconId() > 0) |
|
833 if (innerEntry->GetAttributes().Count() == count) { |
|
834 err = KErrNone; |
|
835 } else |
|
836 err = KErrArgument; |
|
837 else |
|
838 err = KErrNotFound; |
|
839 else |
|
840 err = KErrNotFound; |
|
841 |
|
842 if (!err) { |
|
843 query->SetQueryL(KSQLGetAttribute); |
|
844 query->SetTableType(CCaSqlQuery::EAttributeTable); |
|
845 query->PrepareL(); |
|
846 query->BindValuesForAddAttributeL(innerEntry, NULL); |
|
847 query->ExecuteL(innerEntryArray, CCaSqlQuery::EAttribute); |
|
848 query->CloseStatement(); |
|
849 RCaEntryAttrArray attributes = innerEntry->GetAttributes(); |
|
850 |
|
851 if (!( |
|
852 (attributes[0])->Name().Compare(KAttrName_1) |
|
853 && (attributes[0])->Value().Compare(KAttrValue_1) |
|
854 && (attributes[1])->Name().Compare(KAttrName_2) |
|
855 && (attributes[1])->Value().Compare(KAttrValue_2) |
|
856 && (attributes[2])->Name().Compare(KAttrName_3) |
|
857 && (attributes[2])->Value().Compare(KAttrValue_3) |
|
858 )) |
|
859 err = KErrNone; |
|
860 else |
|
861 err = KErrNotSupported; |
|
862 } |
|
863 |
|
864 CleanupStack::PopAndDestroy(query); |
|
865 CleanupStack::PopAndDestroy(&innerEntryArray); |
|
866 ); |
|
867 |
|
868 __UHEAP_MARKEND; |
|
869 QCOMPARE(err, KErrNone); |
|
870 } |
|
871 // --------------------------------------------------------------------------- |
|
872 // |
|
873 void CCAStorageTest::testUpdateAttributes() |
|
874 { |
|
875 TInt err(KErrGeneral); |
|
876 __UHEAP_MARK; |
|
877 // TRAP(err, |
|
878 CCaInnerEntry *innerEntry = CCaInnerEntry::NewL(); |
|
879 RPointerArray<CCaInnerEntry> innerEntryArray; |
|
880 CleanupResetAndDestroyPushL(innerEntryArray); |
|
881 innerEntryArray.AppendL(innerEntry); |
|
882 |
|
883 innerEntry->SetTextL(KTestName); |
|
884 innerEntry->SetEntryTypeNameL(KTypeName); |
|
885 innerEntry->SetFlags(flag); |
|
886 innerEntry->SetRole(CCaInnerQuery::Group); |
|
887 innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321")); |
|
888 |
|
889 innerEntry->AddAttributeL(KAttrName_1, KAttrValue_1); |
|
890 innerEntry->AddAttributeL(KAttrName_2, KAttrValue_2); |
|
891 innerEntry->AddAttributeL(KAttrName_3, KAttrValue_3); |
|
892 |
|
893 mStorage->AddL(innerEntry); |
|
894 // check status |
|
895 CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
896 query->SetQueryL(KSQLCheckAttribute); |
|
897 query->SetTableType(CCaSqlQuery::EAttributeTable); |
|
898 query->PrepareL(); |
|
899 query->BindEntryIdL(innerEntry->GetId()); |
|
900 RPointerArray<CCaInnerEntry> entryArray; |
|
901 CleanupResetAndDestroyPushL(entryArray); |
|
902 TInt count = query->ExecuteL(entryArray, CCaSqlQuery::EAttribute); |
|
903 query->CloseStatement(); |
|
904 CleanupStack::PopAndDestroy(&entryArray); |
|
905 |
|
906 if (innerEntry->GetId() > 0) |
|
907 if (innerEntry->GetIconId() > 0) |
|
908 if (innerEntry->GetAttributes().Count() == count) { |
|
909 err = KErrNone; |
|
910 } else |
|
911 err = KErrArgument; |
|
912 else |
|
913 err = KErrNotFound; |
|
914 else |
|
915 err = KErrNotFound; |
|
916 |
|
917 if (!err) { |
|
918 innerEntry->AddAttributeL(KAttrName_2, KAttrName_1); |
|
919 mStorage->AddL(innerEntry); |
|
920 // check status |
|
921 query->SetQueryL(KSQLCheckAttribute); |
|
922 query->SetTableType(CCaSqlQuery::EAttributeTable); |
|
923 query->PrepareL(); |
|
924 query->BindEntryIdL(innerEntry->GetId()); |
|
925 RPointerArray<CCaInnerEntry> entryArray; |
|
926 CleanupResetAndDestroyPushL(entryArray); |
|
927 TInt count = query->ExecuteL(entryArray, CCaSqlQuery::EAttribute); |
|
928 query->CloseStatement(); |
|
929 CleanupStack::PopAndDestroy(&entryArray); |
|
930 |
|
931 RCaEntryAttrArray attributes = innerEntry->GetAttributes(); |
|
932 if (innerEntry->GetAttributes().Count() == count) { |
|
933 if (!( |
|
934 (attributes[0])->Name().Compare(KAttrName_1) |
|
935 && (attributes[0])->Value().Compare(KAttrValue_1) |
|
936 && (attributes[1])->Name().Compare(KAttrName_2) |
|
937 && (attributes[1])->Value().Compare(KAttrValue_1) |
|
938 && (attributes[2])->Name().Compare(KAttrName_3) |
|
939 && (attributes[2])->Value().Compare(KAttrValue_3) |
|
940 )) { |
|
941 innerEntry->RemoveAttributeL(KAttrName_1); |
|
942 innerEntry->RemoveAttributeL(KAttrName_2); |
|
943 innerEntry->RemoveAttributeL(KAttrName_3); |
|
944 query->SetQueryL(KSQLGetAttribute); |
|
945 query->SetTableType(CCaSqlQuery::EAttributeTable); |
|
946 query->PrepareL(); |
|
947 query->BindValuesForAddAttributeL(innerEntry, NULL); |
|
948 query->ExecuteL(innerEntryArray, CCaSqlQuery::EAttribute); |
|
949 query->CloseStatement(); |
|
950 |
|
951 RCaEntryAttrArray newAttributes = innerEntry->GetAttributes(); |
|
952 if (!( |
|
953 (newAttributes[0])->Name().Compare(KAttrName_1) |
|
954 && (newAttributes[0])->Value().Compare(KAttrValue_1) |
|
955 && (newAttributes[1])->Name().Compare(KAttrName_2) |
|
956 && (newAttributes[1])->Value().Compare(KAttrValue_1) |
|
957 && (newAttributes[2])->Name().Compare(KAttrName_3) |
|
958 && (newAttributes[2])->Value().Compare(KAttrValue_3) |
|
959 )) |
|
960 err = KErrNone; |
|
961 else |
|
962 err = KErrNotSupported; |
|
963 } else { |
|
964 err = KErrNotReady; |
|
965 } |
|
966 } else |
|
967 err = KErrNotReady; |
|
968 } |
|
969 |
|
970 CleanupStack::PopAndDestroy(query); |
|
971 CleanupStack::PopAndDestroy(&innerEntryArray); |
|
972 // ); |
|
973 __UHEAP_MARKEND; |
|
974 QCOMPARE(err, KErrNone); |
|
975 } |
|
976 // --------------------------------------------------------------------------- |
|
977 // |
|
978 void CCAStorageTest::testDeleteAttributes() |
|
979 { |
|
980 TInt entryId(0); |
|
981 TInt iconId(0); |
|
982 TInt attributesACount(0); |
|
983 TInt queryAResultCount(0); |
|
984 TInt attributesBCount(0); |
|
985 TInt queryBResultCount(0); |
|
986 __UHEAP_MARK; |
|
987 TRAPD(err, |
|
988 // A query section starts |
|
989 CCaInnerEntry *innerEntry = CCaInnerEntry::NewLC(); |
|
990 innerEntry->SetTextL(KTestName); |
|
991 innerEntry->SetEntryTypeNameL(KTypeName); |
|
992 innerEntry->SetFlags(flag); |
|
993 innerEntry->SetRole(CCaInnerQuery::Group); |
|
994 innerEntry->SetIconDataL(_L("filename"), _L("skinId"), _L("268458321")); |
|
995 |
|
996 innerEntry->AddAttributeL(KAttrName_1, KAttrValue_1); |
|
997 innerEntry->AddAttributeL(KAttrName_2, KAttrValue_2); |
|
998 innerEntry->AddAttributeL(KAttrName_3, KAttrValue_3); |
|
999 |
|
1000 mStorage->AddL(innerEntry); |
|
1001 // check status |
|
1002 CCaSqlQuery *query = CCaSqlQuery::NewLC(((CCaSqLiteStorage *)mStorage)->iSqlDb); |
|
1003 query->SetQueryL(KSQLCheckAttribute); |
|
1004 query->SetTableType(CCaSqlQuery::EAttributeTable); |
|
1005 query->PrepareL(); |
|
1006 query->BindEntryIdL(innerEntry->GetId()); |
|
1007 RPointerArray<CCaInnerEntry> entryArray; |
|
1008 CleanupResetAndDestroyPushL(entryArray); |
|
1009 queryAResultCount = query->ExecuteL(entryArray, CCaSqlQuery::EAttribute); |
|
1010 query->CloseStatement(); |
|
1011 CleanupStack::PopAndDestroy(&entryArray); |
|
1012 |
|
1013 if (!err) { |
|
1014 entryId = innerEntry->GetId(); |
|
1015 iconId = innerEntry->GetIconId(); |
|
1016 attributesACount = innerEntry->GetAttributes().Count(); |
|
1017 |
|
1018 // B query section starts |
|
1019 |
|
1020 innerEntry->RemoveAttributeL(KAttrName_1); |
|
1021 innerEntry->RemoveAttributeL(KAttrName_2); |
|
1022 innerEntry->RemoveAttributeL(KAttrName_3); |
|
1023 mStorage->AddL(innerEntry); |
|
1024 // check status |
|
1025 query->SetQueryL(KSQLCheckAttribute); |
|
1026 query->SetTableType(CCaSqlQuery::EAttributeTable); |
|
1027 query->PrepareL(); |
|
1028 query->BindEntryIdL(innerEntry->GetId()); |
|
1029 RPointerArray<CCaInnerEntry> entryArray; |
|
1030 CleanupResetAndDestroyPushL(entryArray); |
|
1031 queryBResultCount= query->ExecuteL(entryArray, CCaSqlQuery::EAttribute); |
|
1032 query->CloseStatement(); |
|
1033 CleanupStack::PopAndDestroy(&entryArray); |
|
1034 attributesBCount = innerEntry->GetAttributes().Count(); |
|
1035 } |
|
1036 CleanupStack::PopAndDestroy(query); |
|
1037 CleanupStack::PopAndDestroy(innerEntry); |
|
1038 ); |
|
1039 __UHEAP_MARKEND; |
|
1040 |
|
1041 QVERIFY(entryId > 0); |
|
1042 QVERIFY(iconId > 0); |
|
1043 QCOMPARE(queryAResultCount, attributesACount); |
|
1044 QCOMPARE(queryBResultCount, 0); |
|
1045 QCOMPARE(queryBResultCount, attributesBCount); |
|
1046 } |
|
1047 // end of file |