|
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 #include <stdio.h> |
|
19 #include <string> |
|
20 |
|
21 #include "TestHarness.h" |
|
22 |
|
23 #include "javacommonutils.h" |
|
24 #include "javaoslayer.h" |
|
25 #include "javastorage.h" |
|
26 #include "javastorageexception.h" |
|
27 #include "javastoragenames.h" |
|
28 #include "javasymbianoslayer.h" |
|
29 #include "javauid.h" |
|
30 #include "logger.h" |
|
31 #include "minstalledappsregistry.h" |
|
32 #include "mjavaregistry.h" |
|
33 #include "storagetestutils.h" |
|
34 |
|
35 using namespace std; |
|
36 using namespace java::storage; |
|
37 using namespace java::util; |
|
38 |
|
39 /** |
|
40 * NOTE: Some of MJavaRegistrySuiteEntry interface methods are already tested |
|
41 * at testlegacyregistry.cpp test case. |
|
42 */ |
|
43 TEST_GROUP(TestSuiteEntry) |
|
44 { |
|
45 JavaStorage* js; |
|
46 JavaStorageTestUtils* jtu; |
|
47 |
|
48 TEST_SETUP() |
|
49 { |
|
50 js = JavaStorage::createInstance(); |
|
51 jtu = new JavaStorageTestUtils(); |
|
52 } |
|
53 TEST_TEARDOWN() |
|
54 { |
|
55 try |
|
56 { |
|
57 js->rollbackTransaction(); |
|
58 js->close(); |
|
59 } |
|
60 catch (...) |
|
61 { |
|
62 // No can do |
|
63 } |
|
64 |
|
65 delete js; |
|
66 js = 0; |
|
67 delete jtu; |
|
68 jtu = 0; |
|
69 } |
|
70 }; |
|
71 |
|
72 /** |
|
73 * Test CJavaRegistrySuiteEntry::JadUrlL() method. |
|
74 * 1. Test no JAD URL defined. Only Jar present. Empty URL returned. |
|
75 * 2. Test one len Url. |
|
76 * 3. Test standard Url. |
|
77 */ |
|
78 TEST(TestSuiteEntry, TestJadUrlL) |
|
79 { |
|
80 LOG(EJavaStorage, EInfo, "+TestJadUrlL"); |
|
81 |
|
82 MJavaRegistry* registry = MJavaRegistry::CreateL(); |
|
83 CHECK(registry != NULL); |
|
84 |
|
85 JavaStorageApplicationEntry_t suite1; |
|
86 JavaStorageEntry attr; |
|
87 attr.setEntry(PACKAGE_NAME, L"TestJadUrlL"); |
|
88 suite1.insert(attr); |
|
89 |
|
90 attr.setEntry(JAR_URL, L"http://www.url.to.Jar.com"); |
|
91 suite1.insert(attr); |
|
92 |
|
93 string tableName = APPLICATION_PACKAGE_TABLE; |
|
94 Uid suite1Uid(L"[e1234321]"); |
|
95 attr.setEntry(ID, suite1Uid.toString()); |
|
96 suite1.insert(attr); |
|
97 attr.setEntry(MEDIA_ID, L"-124614446"); |
|
98 suite1.insert(attr); |
|
99 |
|
100 js->open(); |
|
101 js->startTransaction(); |
|
102 CHECK(jtu->populate(*js, tableName, suite1)); |
|
103 |
|
104 JavaStorageApplicationEntry_t midlet1; |
|
105 attr.setEntry(NAME, L"MyMIDlet1"); |
|
106 midlet1.insert(attr); |
|
107 |
|
108 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
109 midlet1.insert(attr); |
|
110 |
|
111 string appTableName = APPLICATION_TABLE; |
|
112 Uid midlet1Uid(L"[e12e1077]"); |
|
113 attr.setEntry(ID, midlet1Uid.toString()); |
|
114 midlet1.insert(attr); |
|
115 |
|
116 CHECK(jtu->populate(*js, appTableName, midlet1)); |
|
117 js->commitTransaction(); |
|
118 |
|
119 TUid suiteUid; |
|
120 uidToTUid(suite1Uid, suiteUid); |
|
121 |
|
122 // 1. No JAD URL defined. Only Jar present. Empty URL returned. |
|
123 MJavaRegistrySuiteEntry* suiteEntry = registry->SuiteEntryL(suiteUid); |
|
124 CHECK(suiteEntry != NULL); |
|
125 CHECK(suiteEntry->JadUrlL().Size() == 0); // Empty if not set. |
|
126 |
|
127 suiteEntry->Release(); |
|
128 |
|
129 // 2. One len Url. |
|
130 JavaStorageApplicationEntry_t updateEntry; |
|
131 attr.setEntry(JAD_URL, L"1"); |
|
132 updateEntry.insert(attr); |
|
133 js->startTransaction(); |
|
134 CHECK(jtu->update(*js, tableName, updateEntry, suite1)); |
|
135 js->commitTransaction(); |
|
136 |
|
137 suiteEntry = registry->SuiteEntryL(suiteUid); |
|
138 CHECK(suiteEntry != NULL); |
|
139 _LIT(KOneLenURL, "1"); |
|
140 CHECK(suiteEntry->JadUrlL().Compare(KOneLenURL) == 0); |
|
141 |
|
142 suiteEntry->Release(); |
|
143 |
|
144 // 3. Standard Url. |
|
145 updateEntry.clear(); |
|
146 |
|
147 attr.setEntry(JAD_URL, L"http://www.gonna.be/standard/URL/index.html"); |
|
148 updateEntry.insert(attr); |
|
149 js->startTransaction(); |
|
150 CHECK(jtu->update(*js, tableName, updateEntry, suite1)); |
|
151 js->commitTransaction(); |
|
152 |
|
153 suiteEntry = registry->SuiteEntryL(suiteUid); |
|
154 CHECK(suiteEntry != NULL); |
|
155 _LIT(KStandardURL, "http://www.gonna.be/standard/URL/index.html"); |
|
156 CHECK(suiteEntry->JadUrlL().Compare(KStandardURL) == 0); |
|
157 |
|
158 suiteEntry->Release(); |
|
159 updateEntry.clear(); |
|
160 |
|
161 // Clean |
|
162 js->startTransaction(); |
|
163 CHECK(jtu->remove(*js, tableName, suite1)); |
|
164 CHECK(jtu->remove(*js, appTableName, midlet1)); |
|
165 js->commitTransaction(); |
|
166 js->close(); |
|
167 |
|
168 registry->Release(); |
|
169 |
|
170 LOG(EJavaStorage, EInfo, "-TestJadUrlL"); |
|
171 } |
|
172 |
|
173 /** |
|
174 * Test CJavaRegistrySuiteEntry::JarUrlL() method. |
|
175 * 1. Test no JAR URL defined leaves KErrNotFound. |
|
176 * 2. Test one len JAR Url. |
|
177 * 3. Test standard JAR Url. |
|
178 */ |
|
179 TEST(TestSuiteEntry, TestJarUrlL) |
|
180 { |
|
181 LOG(EJavaStorage, EInfo, "+TestJarUrlL"); |
|
182 |
|
183 MJavaRegistry* registry = MJavaRegistry::CreateL(); |
|
184 CHECK(registry != NULL); |
|
185 |
|
186 JavaStorageApplicationEntry_t suite1; |
|
187 JavaStorageEntry attr; |
|
188 attr.setEntry(PACKAGE_NAME, L"TestJarUrlL"); |
|
189 suite1.insert(attr); |
|
190 |
|
191 attr.setEntry(JAD_URL, L"http://www.url.to.Jad.com"); |
|
192 suite1.insert(attr); |
|
193 |
|
194 string tableName = APPLICATION_PACKAGE_TABLE; |
|
195 Uid suite1Uid(L"[e1234543]"); |
|
196 attr.setEntry(ID, suite1Uid.toString()); |
|
197 suite1.insert(attr); |
|
198 attr.setEntry(MEDIA_ID, L"-124614446"); |
|
199 suite1.insert(attr); |
|
200 |
|
201 js->open(); |
|
202 js->startTransaction(); |
|
203 CHECK(jtu->populate(*js, tableName, suite1)); |
|
204 |
|
205 JavaStorageApplicationEntry_t midlet1; |
|
206 attr.setEntry(NAME, L"MyMIDlet1"); |
|
207 midlet1.insert(attr); |
|
208 |
|
209 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
210 midlet1.insert(attr); |
|
211 |
|
212 string appTableName = APPLICATION_TABLE; |
|
213 Uid midlet1Uid(L"[e12e0077]"); |
|
214 attr.setEntry(ID, midlet1Uid.toString()); |
|
215 midlet1.insert(attr); |
|
216 |
|
217 CHECK(jtu->populate(*js, appTableName, midlet1)); |
|
218 js->commitTransaction(); |
|
219 |
|
220 TUid suiteUid; |
|
221 uidToTUid(suite1Uid, suiteUid); |
|
222 |
|
223 // 1. No JAD URL defined. Only Jar present. Empty URL returned. |
|
224 MJavaRegistrySuiteEntry* suiteEntry = registry->SuiteEntryL(suiteUid); |
|
225 CHECK(suiteEntry != NULL); |
|
226 TRAPD(err, suiteEntry->JarUrlL()); |
|
227 CHECK(suiteEntry->JarUrlL().Size() == 0); // Empty if not set |
|
228 |
|
229 suiteEntry->Release(); |
|
230 |
|
231 // 2. One len Url. |
|
232 JavaStorageApplicationEntry_t updateEntry; |
|
233 attr.setEntry(JAR_URL, L"1"); |
|
234 updateEntry.insert(attr); |
|
235 js->startTransaction(); |
|
236 CHECK(jtu->update(*js, tableName, updateEntry, suite1)); |
|
237 js->commitTransaction(); |
|
238 |
|
239 suiteEntry = registry->SuiteEntryL(suiteUid); |
|
240 CHECK(suiteEntry != NULL); |
|
241 _LIT(KOneLenURL, "1"); |
|
242 CHECK(suiteEntry->JarUrlL().Compare(KOneLenURL) == 0); |
|
243 |
|
244 suiteEntry->Release(); |
|
245 |
|
246 // 3. Standard Url. |
|
247 updateEntry.clear(); |
|
248 |
|
249 attr.setEntry(JAR_URL, L"http://www.gonna.be/standard/URL/index.html"); |
|
250 updateEntry.insert(attr); |
|
251 js->startTransaction(); |
|
252 CHECK(jtu->update(*js, tableName, updateEntry, suite1)); |
|
253 js->commitTransaction(); |
|
254 |
|
255 suiteEntry = registry->SuiteEntryL(suiteUid); |
|
256 CHECK(suiteEntry != NULL); |
|
257 _LIT(KStandardURL, "http://www.gonna.be/standard/URL/index.html"); |
|
258 CHECK(suiteEntry->JarUrlL().Compare(KStandardURL) == 0); |
|
259 |
|
260 suiteEntry->Release(); |
|
261 updateEntry.clear(); |
|
262 |
|
263 // Clean |
|
264 js->startTransaction(); |
|
265 CHECK(jtu->remove(*js, tableName, suite1)); |
|
266 CHECK(jtu->remove(*js, appTableName, midlet1)); |
|
267 js->commitTransaction(); |
|
268 js->close(); |
|
269 |
|
270 registry->Release(); |
|
271 |
|
272 LOG(EJavaStorage, EInfo, "-TestJarUrlL"); |
|
273 } |
|
274 |
|
275 /** |
|
276 * Test CJavaRegistrySuiteEntry::MIDletUidsL() method. |
|
277 * 1. Test one embedded application. |
|
278 * 2. Test three embedded applications. |
|
279 */ |
|
280 TEST(TestSuiteEntry, TestMIDletUids) |
|
281 { |
|
282 LOG(EJavaStorage, EInfo, "+TestMIDletUidsL"); |
|
283 |
|
284 MJavaRegistry* registry = MJavaRegistry::CreateL(); |
|
285 CHECK(registry != NULL); |
|
286 |
|
287 JavaStorageApplicationEntry_t suite1; |
|
288 JavaStorageEntry attr; |
|
289 attr.setEntry(PACKAGE_NAME, L"TestMIdletUids"); |
|
290 suite1.insert(attr); |
|
291 |
|
292 string tableName = APPLICATION_PACKAGE_TABLE; |
|
293 Uid suite1Uid(L"[e1230043]"); |
|
294 attr.setEntry(ID, suite1Uid.toString()); |
|
295 suite1.insert(attr); |
|
296 attr.setEntry(MEDIA_ID, L"-124614446"); |
|
297 suite1.insert(attr); |
|
298 |
|
299 js->open(); |
|
300 js->startTransaction(); |
|
301 CHECK(jtu->populate(*js, tableName, suite1)); |
|
302 |
|
303 JavaStorageApplicationEntry_t midlet1; |
|
304 attr.setEntry(NAME, L"MyMIDlet1"); |
|
305 midlet1.insert(attr); |
|
306 |
|
307 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
308 midlet1.insert(attr); |
|
309 |
|
310 string appTableName = APPLICATION_TABLE; |
|
311 Uid midlet1Uid(L"[e12a0077]"); |
|
312 attr.setEntry(ID, midlet1Uid.toString()); |
|
313 midlet1.insert(attr); |
|
314 |
|
315 CHECK(jtu->populate(*js, appTableName, midlet1)); |
|
316 js->commitTransaction(); |
|
317 |
|
318 TUid suiteUid; |
|
319 uidToTUid(suite1Uid, suiteUid); |
|
320 |
|
321 // 1. Test one embedded application. |
|
322 MJavaRegistrySuiteEntry* suiteEntry = registry->SuiteEntryL(suiteUid); |
|
323 CHECK(suiteEntry != NULL); |
|
324 RArray<TUid> embeddedUids; |
|
325 suiteEntry->MIDletUidsL(embeddedUids); |
|
326 CHECK(embeddedUids.Count() == 1); |
|
327 |
|
328 TUid midletUid; |
|
329 uidToTUid(midlet1Uid, midletUid); |
|
330 CHECK(embeddedUids[0] == midletUid); |
|
331 |
|
332 embeddedUids.Reset(); |
|
333 suiteEntry->Release(); |
|
334 |
|
335 JavaStorageApplicationEntry_t midlet2; |
|
336 attr.setEntry(NAME, L"MyMIDlet2"); |
|
337 midlet2.insert(attr); |
|
338 |
|
339 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
340 midlet2.insert(attr); |
|
341 |
|
342 Uid midlet2Uid(L"[e12a0007]"); |
|
343 attr.setEntry(ID, midlet2Uid.toString()); |
|
344 midlet2.insert(attr); |
|
345 |
|
346 js->startTransaction(); |
|
347 CHECK(jtu->populate(*js, appTableName, midlet2)); |
|
348 js->commitTransaction(); |
|
349 |
|
350 JavaStorageApplicationEntry_t midlet3; |
|
351 attr.setEntry(NAME, L"MyMIDlet3"); |
|
352 midlet3.insert(attr); |
|
353 |
|
354 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
355 midlet3.insert(attr); |
|
356 |
|
357 Uid midlet3Uid(L"[e12a0117]"); |
|
358 attr.setEntry(ID, midlet3Uid.toString()); |
|
359 midlet3.insert(attr); |
|
360 |
|
361 js->startTransaction(); |
|
362 CHECK(jtu->populate(*js, appTableName, midlet3)); |
|
363 js->commitTransaction(); |
|
364 |
|
365 // 2. Test three embedded applications. |
|
366 suiteEntry = registry->SuiteEntryL(suiteUid); |
|
367 CHECK(suiteEntry != NULL); |
|
368 suiteEntry->MIDletUidsL(embeddedUids); |
|
369 CHECK(embeddedUids.Count() == 3); |
|
370 |
|
371 uidToTUid(midlet1Uid, midletUid); |
|
372 CHECK(embeddedUids.Find(midletUid) >= 0); |
|
373 |
|
374 uidToTUid(midlet2Uid, midletUid); |
|
375 CHECK(embeddedUids.Find(midletUid) >= 0); |
|
376 |
|
377 uidToTUid(midlet3Uid, midletUid); |
|
378 CHECK(embeddedUids.Find(midletUid) >= 0); |
|
379 |
|
380 embeddedUids.Reset(); |
|
381 suiteEntry->Release(); |
|
382 embeddedUids.Close(); |
|
383 |
|
384 // Clean |
|
385 js->startTransaction(); |
|
386 CHECK(jtu->remove(*js, tableName, suite1)); |
|
387 CHECK(jtu->remove(*js, appTableName, midlet1)); |
|
388 CHECK(jtu->remove(*js, appTableName, midlet2)); |
|
389 CHECK(jtu->remove(*js, appTableName, midlet3)); |
|
390 js->commitTransaction(); |
|
391 js->close(); |
|
392 |
|
393 registry->Release(); |
|
394 |
|
395 LOG(EJavaStorage, EInfo, "-TestMIDletUidsL"); |
|
396 } |
|
397 |
|
398 /** |
|
399 * Test CJavaRegistrySuiteEntry::NumberOfMIDletsL() method. |
|
400 * 1. Test one embedded application. |
|
401 * 2. Test three embedded applications. |
|
402 */ |
|
403 TEST(TestSuiteEntry, TestNumberOfMIDletsL) |
|
404 { |
|
405 LOG(EJavaStorage, EInfo, "+TestNumberOfMIDletsL"); |
|
406 |
|
407 MJavaRegistry* registry = MJavaRegistry::CreateL(); |
|
408 CHECK(registry != NULL); |
|
409 |
|
410 JavaStorageApplicationEntry_t suite1; |
|
411 JavaStorageEntry attr; |
|
412 attr.setEntry(PACKAGE_NAME, L"TestNumberOfMIDletsL"); |
|
413 suite1.insert(attr); |
|
414 |
|
415 string tableName = APPLICATION_PACKAGE_TABLE; |
|
416 Uid suite1Uid(L"[e1230043]"); |
|
417 attr.setEntry(ID, suite1Uid.toString()); |
|
418 suite1.insert(attr); |
|
419 attr.setEntry(MEDIA_ID, L"-124614446"); |
|
420 suite1.insert(attr); |
|
421 |
|
422 js->open(); |
|
423 js->startTransaction(); |
|
424 CHECK(jtu->populate(*js, tableName, suite1)); |
|
425 |
|
426 JavaStorageApplicationEntry_t midlet1; |
|
427 attr.setEntry(NAME, L"MyMIDlet1"); |
|
428 midlet1.insert(attr); |
|
429 |
|
430 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
431 midlet1.insert(attr); |
|
432 |
|
433 string appTableName = APPLICATION_TABLE; |
|
434 Uid midlet1Uid(L"[e12a0077]"); |
|
435 attr.setEntry(ID, midlet1Uid.toString()); |
|
436 midlet1.insert(attr); |
|
437 |
|
438 CHECK(jtu->populate(*js, appTableName, midlet1)); |
|
439 js->commitTransaction(); |
|
440 |
|
441 TUid suiteUid; |
|
442 uidToTUid(suite1Uid, suiteUid); |
|
443 |
|
444 // 1. Test one embedded application. |
|
445 MJavaRegistrySuiteEntry* suiteEntry = registry->SuiteEntryL(suiteUid); |
|
446 CHECK(suiteEntry != NULL); |
|
447 CHECK(suiteEntry->NumberOfMIDletsL() == 1); |
|
448 |
|
449 suiteEntry->Release(); |
|
450 |
|
451 JavaStorageApplicationEntry_t midlet2; |
|
452 attr.setEntry(NAME, L"MyMIDlet2"); |
|
453 midlet2.insert(attr); |
|
454 |
|
455 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
456 midlet2.insert(attr); |
|
457 |
|
458 Uid midlet2Uid(L"[e12a0007]"); |
|
459 attr.setEntry(ID, midlet2Uid.toString()); |
|
460 midlet2.insert(attr); |
|
461 |
|
462 js->startTransaction(); |
|
463 CHECK(jtu->populate(*js, appTableName, midlet2)); |
|
464 js->commitTransaction(); |
|
465 |
|
466 JavaStorageApplicationEntry_t midlet3; |
|
467 attr.setEntry(NAME, L"MyMIDlet3"); |
|
468 midlet3.insert(attr); |
|
469 |
|
470 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
471 midlet3.insert(attr); |
|
472 |
|
473 Uid midlet3Uid(L"[e12a0117]"); |
|
474 attr.setEntry(ID, midlet3Uid.toString()); |
|
475 midlet3.insert(attr); |
|
476 |
|
477 js->startTransaction(); |
|
478 CHECK(jtu->populate(*js, appTableName, midlet3)); |
|
479 js->commitTransaction(); |
|
480 |
|
481 // 2. Test three embedded applications. |
|
482 suiteEntry = registry->SuiteEntryL(suiteUid); |
|
483 CHECK(suiteEntry != NULL); |
|
484 CHECK(suiteEntry->NumberOfMIDletsL() == 3); |
|
485 |
|
486 suiteEntry->Release(); |
|
487 |
|
488 // Clean |
|
489 js->startTransaction(); |
|
490 CHECK(jtu->remove(*js, tableName, suite1)); |
|
491 CHECK(jtu->remove(*js, appTableName, midlet1)); |
|
492 CHECK(jtu->remove(*js, appTableName, midlet2)); |
|
493 CHECK(jtu->remove(*js, appTableName, midlet3)); |
|
494 js->commitTransaction(); |
|
495 js->close(); |
|
496 |
|
497 registry->Release(); |
|
498 |
|
499 LOG(EJavaStorage, EInfo, "-TestNumberOfMIDletsL"); |
|
500 } |
|
501 |
|
502 /** |
|
503 * Test CJavaRegistrySuiteEntry::MIDletByUidL() method. |
|
504 * 1. Test TUid::Null() leaves KErrArgument. |
|
505 * 2. Test TUid is not embedded leaves KErrNotFound. |
|
506 * 3. Test TUid is not embedded leaves KErrNotFound when entry contains |
|
507 * embedded application. |
|
508 * 4. Test one embedded application. |
|
509 * 5. Test two embedded applications. |
|
510 */ |
|
511 TEST(TestSuiteEntry, TestMIDletByUidL) |
|
512 { |
|
513 LOG(EJavaStorage, EInfo, "+TestMIDletByUidL"); |
|
514 |
|
515 MJavaRegistry* registry = MJavaRegistry::CreateL(); |
|
516 CHECK(registry != NULL); |
|
517 |
|
518 JavaStorageApplicationEntry_t suite1; |
|
519 JavaStorageEntry attr; |
|
520 attr.setEntry(PACKAGE_NAME, L"TestMIDletByUidL"); |
|
521 suite1.insert(attr); |
|
522 |
|
523 string tableName = APPLICATION_PACKAGE_TABLE; |
|
524 Uid suite1Uid(L"[e1230043]"); |
|
525 attr.setEntry(ID, suite1Uid.toString()); |
|
526 suite1.insert(attr); |
|
527 attr.setEntry(MEDIA_ID, L"-124614446"); |
|
528 suite1.insert(attr); |
|
529 |
|
530 js->open(); |
|
531 js->startTransaction(); |
|
532 CHECK(jtu->populate(*js, tableName, suite1)); |
|
533 |
|
534 JavaStorageApplicationEntry_t midlet1; |
|
535 attr.setEntry(NAME, L"MyMIDlet1"); |
|
536 midlet1.insert(attr); |
|
537 |
|
538 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
539 midlet1.insert(attr); |
|
540 |
|
541 string appTableName = APPLICATION_TABLE; |
|
542 Uid midlet1Uid(L"[e12a0077]"); |
|
543 attr.setEntry(ID, midlet1Uid.toString()); |
|
544 midlet1.insert(attr); |
|
545 |
|
546 CHECK(jtu->populate(*js, appTableName, midlet1)); |
|
547 js->commitTransaction(); |
|
548 |
|
549 TUid suiteUid; |
|
550 uidToTUid(suite1Uid, suiteUid); |
|
551 |
|
552 // 1. Test TUid::Null() leaves KErrArgument. |
|
553 MJavaRegistrySuiteEntry* suiteEntry = registry->SuiteEntryL(suiteUid); |
|
554 CHECK(suiteEntry != NULL); |
|
555 TRAPD(err, suiteEntry->MIDletByUidL(TUid::Null())); |
|
556 CHECK(KErrNotFound == err); |
|
557 |
|
558 // 2. Test TUid is not embedded leaves KErrNotFound. |
|
559 TUid uid = TUid::Uid(3777185127); // e1234567 |
|
560 TRAP(err, suiteEntry->MIDletByUidL(uid)); |
|
561 CHECK(KErrNotFound == err); |
|
562 |
|
563 suiteEntry->Release(); |
|
564 |
|
565 // 3. Test TUid is not embedded leaves KErrNotFound. |
|
566 suiteEntry = registry->SuiteEntryL(suiteUid); |
|
567 CHECK(suiteEntry != NULL); |
|
568 |
|
569 TRAP(err, suiteEntry->MIDletByUidL(uid)); |
|
570 CHECK(KErrNotFound == err); |
|
571 |
|
572 // 4. Test one embedded application. |
|
573 TUid midletUid; |
|
574 uidToTUid(midlet1Uid, midletUid); |
|
575 MJavaRegistryMIDletEntry* midletEntry |
|
576 = suiteEntry->MIDletByUidL(midletUid); |
|
577 CHECK(midletEntry != NULL); |
|
578 CHECK(midletEntry->UidL() == midletUid); |
|
579 |
|
580 midletEntry->Release(); |
|
581 suiteEntry->Release(); |
|
582 |
|
583 JavaStorageApplicationEntry_t midlet2; |
|
584 attr.setEntry(NAME, L"MyMIDlet2"); |
|
585 midlet2.insert(attr); |
|
586 |
|
587 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
588 midlet2.insert(attr); |
|
589 |
|
590 Uid midlet2Uid(L"[e12a0007]"); |
|
591 attr.setEntry(ID, midlet2Uid.toString()); |
|
592 midlet2.insert(attr); |
|
593 |
|
594 js->startTransaction(); |
|
595 CHECK(jtu->populate(*js, appTableName, midlet2)); |
|
596 js->commitTransaction(); |
|
597 |
|
598 // 5. Test two embedded applications. |
|
599 suiteEntry = registry->SuiteEntryL(suiteUid); |
|
600 CHECK(suiteEntry != NULL); |
|
601 uidToTUid(midlet1Uid, midletUid); |
|
602 midletEntry = suiteEntry->MIDletByUidL(midletUid); |
|
603 CHECK(midletEntry != NULL); |
|
604 CHECK(midletEntry->UidL() == midletUid); |
|
605 |
|
606 midletEntry->Release(); |
|
607 |
|
608 uidToTUid(midlet2Uid, midletUid); |
|
609 midletEntry = suiteEntry->MIDletByUidL(midletUid); |
|
610 CHECK(midletEntry != NULL); |
|
611 CHECK(midletEntry->UidL() == midletUid); |
|
612 |
|
613 midletEntry->Release(); |
|
614 suiteEntry->Release(); |
|
615 |
|
616 // Clean |
|
617 js->startTransaction(); |
|
618 CHECK(jtu->remove(*js, tableName, suite1)); |
|
619 CHECK(jtu->remove(*js, appTableName, midlet1)); |
|
620 CHECK(jtu->remove(*js, appTableName, midlet2)); |
|
621 js->commitTransaction(); |
|
622 js->close(); |
|
623 |
|
624 registry->Release(); |
|
625 |
|
626 LOG(EJavaStorage, EInfo, "-TestMIDletByUidL"); |
|
627 } |
|
628 |
|
629 /** |
|
630 * Test CJavaRegistrySuiteEntry::MIDletByNumberL() method. |
|
631 * 1. Test 0 leaves KErrArgument. |
|
632 * 2. Test 2 leaves KErrNotFound after population. |
|
633 * 3. Test one embedded application. |
|
634 * 4. Test two embedded applications. |
|
635 */ |
|
636 TEST(TestSuiteEntry, TestMIDletByNumberL) |
|
637 { |
|
638 LOG(EJavaStorage, EInfo, "+TestMIDletByNumberL"); |
|
639 |
|
640 MJavaRegistry* registry = MJavaRegistry::CreateL(); |
|
641 CHECK(registry != NULL); |
|
642 |
|
643 JavaStorageApplicationEntry_t suite1; |
|
644 JavaStorageEntry attr; |
|
645 attr.setEntry(PACKAGE_NAME, L"TestMIDletByNumberL"); |
|
646 suite1.insert(attr); |
|
647 |
|
648 string tableName = APPLICATION_PACKAGE_TABLE; |
|
649 Uid suite1Uid(L"[e1230022]"); |
|
650 attr.setEntry(ID, suite1Uid.toString()); |
|
651 suite1.insert(attr); |
|
652 attr.setEntry(MEDIA_ID, L"-124614446"); |
|
653 suite1.insert(attr); |
|
654 |
|
655 js->open(); |
|
656 js->startTransaction(); |
|
657 CHECK(jtu->populate(*js, tableName, suite1)); |
|
658 js->commitTransaction(); |
|
659 |
|
660 TUid suiteUid; |
|
661 uidToTUid(suite1Uid, suiteUid); |
|
662 |
|
663 JavaStorageApplicationEntry_t midlet1; |
|
664 attr.setEntry(NAME, L"MyMIDlet1"); |
|
665 midlet1.insert(attr); |
|
666 |
|
667 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
668 midlet1.insert(attr); |
|
669 |
|
670 string appTableName = APPLICATION_TABLE; |
|
671 Uid midlet1Uid(L"[e12a0021]"); |
|
672 attr.setEntry(ID, midlet1Uid.toString()); |
|
673 midlet1.insert(attr); |
|
674 |
|
675 js->startTransaction(); |
|
676 CHECK(jtu->populate(*js, appTableName, midlet1)); |
|
677 js->commitTransaction(); |
|
678 |
|
679 // 1. Test 0 leaves KErrArgument. |
|
680 MJavaRegistrySuiteEntry* suiteEntry = registry->SuiteEntryL(suiteUid); |
|
681 CHECK(suiteEntry != NULL); |
|
682 TRAPD(err, suiteEntry->MIDletByNumberL(0)); |
|
683 // CHECK(KErrArgument == err); |
|
684 CHECK(KErrNotFound == err); |
|
685 |
|
686 suiteEntry->Release(); |
|
687 |
|
688 // 2. Test 2 leaves KErrNotFound after population. |
|
689 suiteEntry = registry->SuiteEntryL(suiteUid); |
|
690 CHECK(suiteEntry != NULL); |
|
691 TRAP(err, suiteEntry->MIDletByNumberL(2)); |
|
692 CHECK(KErrNotFound == err); |
|
693 |
|
694 // 3. Test one embedded application. |
|
695 TUid midletUid; |
|
696 uidToTUid(midlet1Uid, midletUid); |
|
697 MJavaRegistryMIDletEntry* midletEntry |
|
698 = suiteEntry->MIDletByNumberL(1); |
|
699 CHECK(midletEntry != NULL); |
|
700 CHECK(midletEntry->UidL() == midletUid); |
|
701 |
|
702 midletEntry->Release(); |
|
703 suiteEntry->Release(); |
|
704 |
|
705 JavaStorageApplicationEntry_t midlet2; |
|
706 attr.setEntry(NAME, L"MyMIDlet2"); |
|
707 midlet2.insert(attr); |
|
708 |
|
709 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
710 midlet2.insert(attr); |
|
711 |
|
712 Uid midlet2Uid(L"[e12a0012]"); |
|
713 attr.setEntry(ID, midlet2Uid.toString()); |
|
714 midlet2.insert(attr); |
|
715 |
|
716 js->startTransaction(); |
|
717 CHECK(jtu->populate(*js, appTableName, midlet2)); |
|
718 js->commitTransaction(); |
|
719 |
|
720 // 4. Test two embedded applications. |
|
721 suiteEntry = registry->SuiteEntryL(suiteUid); |
|
722 CHECK(suiteEntry != NULL); |
|
723 |
|
724 // Order is not quaranteed! |
|
725 uidToTUid(midlet1Uid, midletUid); |
|
726 midletEntry = suiteEntry->MIDletByNumberL(1); |
|
727 CHECK(midletEntry != NULL); |
|
728 CHECK(midletEntry->UidL() == midletUid); |
|
729 |
|
730 midletEntry->Release(); |
|
731 |
|
732 uidToTUid(midlet2Uid, midletUid); |
|
733 midletEntry = suiteEntry->MIDletByNumberL(2); |
|
734 CHECK(midletEntry != NULL); |
|
735 CHECK(midletEntry->UidL() == midletUid); |
|
736 |
|
737 midletEntry->Release(); |
|
738 suiteEntry->Release(); |
|
739 |
|
740 // Clean |
|
741 js->startTransaction(); |
|
742 CHECK(jtu->remove(*js, tableName, suite1)); |
|
743 CHECK(jtu->remove(*js, appTableName, midlet1)); |
|
744 CHECK(jtu->remove(*js, appTableName, midlet2)); |
|
745 js->commitTransaction(); |
|
746 js->close(); |
|
747 |
|
748 registry->Release(); |
|
749 |
|
750 LOG(EJavaStorage, EInfo, "-TestMIDletByNumberL"); |
|
751 } |
|
752 |
|
753 /** |
|
754 * Test CJavaRegistrySuiteEntry::InstalledAppsEntryL() method. |
|
755 * 1. Test InstalledAppsEntry is valid object. |
|
756 */ |
|
757 TEST(TestSuiteEntry, TestInstalledAppsEntryL) |
|
758 { |
|
759 LOG(EJavaStorage, EInfo, "+TestInstalledAppsEntryL"); |
|
760 |
|
761 MJavaRegistry* registry = MJavaRegistry::CreateL(); |
|
762 CHECK(registry != NULL); |
|
763 CleanupReleasePushL(*registry); |
|
764 |
|
765 JavaStorageApplicationEntry_t suite1; |
|
766 JavaStorageEntry attr; |
|
767 attr.setEntry(PACKAGE_NAME, L"TestMIDletByNumberL"); |
|
768 suite1.insert(attr); |
|
769 |
|
770 string tableName = APPLICATION_PACKAGE_TABLE; |
|
771 Uid suite1Uid(L"[e123abcd]"); |
|
772 attr.setEntry(ID, suite1Uid.toString()); |
|
773 suite1.insert(attr); |
|
774 attr.setEntry(MEDIA_ID, L"-124614446"); |
|
775 suite1.insert(attr); |
|
776 |
|
777 js->open(); |
|
778 js->startTransaction(); |
|
779 CHECK(jtu->populate(*js, tableName, suite1)); |
|
780 |
|
781 JavaStorageApplicationEntry_t midlet1; |
|
782 attr.setEntry(NAME, L"MyMIDlet1"); |
|
783 midlet1.insert(attr); |
|
784 |
|
785 attr.setEntry(PACKAGE_ID, suite1Uid.toString()); |
|
786 midlet1.insert(attr); |
|
787 |
|
788 string appTableName = APPLICATION_TABLE; |
|
789 Uid midlet1Uid(L"[ea0000a1]"); |
|
790 attr.setEntry(ID, midlet1Uid.toString()); |
|
791 midlet1.insert(attr); |
|
792 |
|
793 CHECK(jtu->populate(*js, appTableName, midlet1)); |
|
794 js->commitTransaction(); |
|
795 |
|
796 TUid suiteUid; |
|
797 uidToTUid(suite1Uid, suiteUid); |
|
798 |
|
799 // 1. Test 0 leaves KErrArgument. |
|
800 MJavaRegistrySuiteEntry* suiteEntry = registry->SuiteEntryL(suiteUid); |
|
801 CHECK(suiteEntry != NULL); |
|
802 CleanupReleasePushL(*suiteEntry); |
|
803 |
|
804 const MInstalledAppsRegistryEntry& appsRegEntry = |
|
805 suiteEntry->InstalledAppsEntryL(); |
|
806 CHECK(appsRegEntry.UidL() == suiteUid); |
|
807 |
|
808 CleanupStack::PopAndDestroy(suiteEntry); |
|
809 |
|
810 // Clean |
|
811 js->startTransaction(); |
|
812 CHECK(jtu->remove(*js, tableName, suite1)); |
|
813 CHECK(jtu->remove(*js, appTableName, midlet1)); |
|
814 js->commitTransaction(); |
|
815 js->close(); |
|
816 |
|
817 CleanupStack::PopAndDestroy(registry); |
|
818 LOG(EJavaStorage, EInfo, "-TestInstalledAppsEntryL"); |
|
819 } |