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