|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 |
|
23 #include "T_StartAppStep.h" |
|
24 #include "tstapp.h" |
|
25 #include "TRApaLsSessionStartAppTest.h" |
|
26 #include <apacmdln.h> |
|
27 |
|
28 _LIT(KCompleted, "Completed."); |
|
29 _LIT8(KLitPlainText,"text/plain"); |
|
30 |
|
31 const TInt KTUnProtectedAppTestPassed = 1234; |
|
32 |
|
33 class RIpcApparcFuzzTest : public RSessionBase |
|
34 { |
|
35 public: |
|
36 RIpcApparcFuzzTest(CTestStep& aTestFuzz);// Constructor |
|
37 ~RIpcApparcFuzzTest();//Destructor |
|
38 void RunFuzzTestL(); |
|
39 private: |
|
40 CTestStep& iTestFuzz; |
|
41 }; |
|
42 |
|
43 RIpcApparcFuzzTest::RIpcApparcFuzzTest(CTestStep& aTestFuzz):iTestFuzz(aTestFuzz) |
|
44 { |
|
45 } |
|
46 |
|
47 RIpcApparcFuzzTest::~RIpcApparcFuzzTest() |
|
48 { |
|
49 Close(); |
|
50 } |
|
51 /** |
|
52 @SYMTestCaseID APPFWK-APPARC-0086 |
|
53 |
|
54 @SYMDEF DEF116002 IpcFuzz Test on CApaAppListServSession::GetExecutableNameGivenDataTypeL and AppForDataTypeL |
|
55 |
|
56 @SYMTestPriority Medium |
|
57 |
|
58 @SYMTestStatus Implemented |
|
59 |
|
60 @SYMTestActions Create AppListServer server session and pass the HBufC descriptor to the |
|
61 apparc server APIs GetExecutableNameGivenDataTypeL() and AppForDataTypeL(). |
|
62 |
|
63 @SYMTestExpectedResults Test should return KErrArgument if client passes other than TDataType. |
|
64 */ |
|
65 |
|
66 void RIpcApparcFuzzTest::RunFuzzTestL() |
|
67 { |
|
68 iTestFuzz.INFO_PRINTF1(_L("Testing appserv APIs GetExecutableNameGivenDataTypeL and AppForDataTypeL ")); |
|
69 TInt ret; |
|
70 TVersion version(1,1,1); |
|
71 ret = CreateSession(_L("!AppListServer"),version,4); |
|
72 iTestFuzz.TEST(ret ==KErrNone); |
|
73 HBufC* buf = HBufC::NewLC(268); |
|
74 TPtr ptr = buf->Des(); |
|
75 TIpcArgs args; |
|
76 args.Set(0, &ptr); |
|
77 ret = SendReceive(14, args); // Send bad args to CApaAppListServSession::AppForDataTypeL using enum value of EAppListServAppForDataType |
|
78 iTestFuzz.TEST(ret ==KErrArgument); |
|
79 iTestFuzz.INFO_PRINTF1(_L("Testing CApaAppListServSession::AppForDataTypeL() is completed ")); |
|
80 args.Set(2, &ptr); |
|
81 ret = SendReceive(21, args);// Send bad args to CApaAppListServSession::GetExecutableNameGivenDataTypeL using enum value EAppListServGetExecutableNameGivenDocument |
|
82 iTestFuzz.TEST(ret ==KErrArgument); |
|
83 iTestFuzz.INFO_PRINTF1(_L("Tesing CApaAppListServSession::GetExecutableNameGivenDataTypeL() is completed ")); |
|
84 iTestFuzz.INFO_PRINTF2(_L("Test successfully returns KErrArgument %d"),ret); |
|
85 CleanupStack::PopAndDestroy(buf); |
|
86 } |
|
87 |
|
88 /** |
|
89 Constructor |
|
90 */ |
|
91 CT_StartAppTestStep::CT_StartAppTestStep() |
|
92 { |
|
93 // Call base class method to set up the human readable name for logging*/ |
|
94 SetTestStepName(KT_StartAppStep); |
|
95 } |
|
96 |
|
97 /** |
|
98 Destructor |
|
99 */ |
|
100 CT_StartAppTestStep::~CT_StartAppTestStep() |
|
101 { |
|
102 iApaLsSession.Close(); |
|
103 } |
|
104 |
|
105 /** |
|
106 @return - TVerdict code |
|
107 Override of base class virtual |
|
108 */ |
|
109 TVerdict CT_StartAppTestStep::doTestStepPreambleL() |
|
110 { |
|
111 SetTestStepResult(EPass); |
|
112 TInt error = iApaLsSession.Connect(); |
|
113 TEST(error==KErrNone); |
|
114 return TestStepResult(); |
|
115 } |
|
116 |
|
117 /** |
|
118 @return - TVerdict code |
|
119 Override of base class virtual |
|
120 */ |
|
121 TVerdict CT_StartAppTestStep::doTestStepPostambleL() |
|
122 { |
|
123 return TestStepResult(); |
|
124 } |
|
125 |
|
126 |
|
127 TVerdict CT_StartAppTestStep::doTestStepL() |
|
128 { |
|
129 INFO_PRINTF1(_L("Testing Apparc...T_StartApp Test Cases Running...")); |
|
130 TRAPD(ret,RunTestCasesL()); |
|
131 TEST(ret==KErrNone); |
|
132 |
|
133 TRAP(ret,TestIpcFuzzL()); |
|
134 TEST(ret==KErrNone); |
|
135 |
|
136 INFO_PRINTF1(_L("...T_StartApp Test Cases Completed.")); |
|
137 return TestStepResult(); |
|
138 } |
|
139 |
|
140 void CT_StartAppTestStep::RunTestCasesL() |
|
141 { |
|
142 HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp8L(), NO_CLEANUP); |
|
143 HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp1L(), NO_CLEANUP); |
|
144 HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp2L(), iApaLsSession.FlushRecognitionCache() ); |
|
145 HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp3L(), iApaLsSession.FlushRecognitionCache() ); |
|
146 HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp4L(), NO_CLEANUP); |
|
147 HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp5L(), NO_CLEANUP); |
|
148 HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp6L(), NO_CLEANUP); |
|
149 HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp7L(), NO_CLEANUP); |
|
150 HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestStartApp9L(), NO_CLEANUP); |
|
151 // The following two APIs InsertDataMappingL() & DeleteDataMappingL(), update the type store on the server side. |
|
152 // This update takes place on the server side while the test case is still running, which causes the heap check to fail. |
|
153 // To avoid the heap check on the server side, DONT_CHECK macro is used. |
|
154 |
|
155 HEAP_TEST_LS_SESSION(iApaLsSession, 0, DONT_CHECK, TestInsertDataTypeL(), NO_CLEANUP); |
|
156 HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, TestAppForDataTypeL(), NO_CLEANUP); |
|
157 HEAP_TEST_LS_SESSION(iApaLsSession, 0, DONT_CHECK, TestDeleteDataTypeL(), NO_CLEANUP); |
|
158 } |
|
159 |
|
160 /** |
|
161 @SYMTestCaseID T-Serv2Step-StartAppTests1L |
|
162 |
|
163 @SYMPREQ |
|
164 |
|
165 @SYMTestCaseDesc Test Launching of an application. |
|
166 |
|
167 @SYMTestPriority High |
|
168 |
|
169 @SYMTestStatus Implemented |
|
170 |
|
171 @SYMTestActions Prepare command line information to start an application using |
|
172 CApaCommandLine Apis.Call RApaLsSession::StartApp() to start an |
|
173 application defined by the command line information.\n |
|
174 Test the launching of application for following scenarios:\n |
|
175 (1) When Application specified by command line exists.\n |
|
176 (2) When Application specified by command line does not exist.\n |
|
177 API Calls:\n |
|
178 RApaLsSession::StartApp(const CApaCommandLine& aCommandLine)\n |
|
179 |
|
180 @SYMTestExpectedResults The test observes that StartApp() returns KErrNone and |
|
181 starts the app in the first scenario. In the second case KErrNotFound is |
|
182 returned. |
|
183 |
|
184 */ |
|
185 void CT_StartAppTestStep::TestStartApp1L() |
|
186 { |
|
187 INFO_PRINTF1(_L("Test RApaLsSession::StartApp using CApaCommandLine.....")); |
|
188 CApaCommandLine* cmdLn=CApaCommandLine::NewLC(); |
|
189 TFileName filename; |
|
190 _LIT(KLitExePath,"\\sys\\bin\\texe.exe"); |
|
191 TFullName exePath(KLitExePath); |
|
192 filename = SearchAndReturnCompleteFileName(exePath); |
|
193 |
|
194 _LIT8(KLitDogfish,"dogfish"); |
|
195 _LIT(KLitWibble,"wibble"); |
|
196 cmdLn->SetExecutableNameL(filename); |
|
197 cmdLn->SetTailEndL(KLitDogfish); |
|
198 TThreadId startAppThreadID; |
|
199 TInt ret = iApaLsSession.StartApp(*cmdLn,startAppThreadID); // explicit |
|
200 TEST(ret==KErrNone); |
|
201 |
|
202 //we need to close the started thread, if appropiate |
|
203 if (ret==KErrNone) |
|
204 { |
|
205 RThread thread; |
|
206 User::LeaveIfError(thread.Open(startAppThreadID)); |
|
207 CleanupClosePushL(thread); |
|
208 |
|
209 RProcess process; |
|
210 User::LeaveIfError(thread.Process(process)); |
|
211 CleanupClosePushL(process); |
|
212 |
|
213 process.Kill(0); |
|
214 |
|
215 CleanupStack::PopAndDestroy(&process); |
|
216 CleanupStack::PopAndDestroy(&thread); |
|
217 } |
|
218 |
|
219 // start a non-existant app |
|
220 cmdLn->SetExecutableNameL(KLitWibble); |
|
221 |
|
222 ret = iApaLsSession.StartApp(*cmdLn); |
|
223 TEST(ret==KErrNotFound); |
|
224 |
|
225 CleanupStack::PopAndDestroy(cmdLn); // cmdLn |
|
226 INFO_PRINTF1(KCompleted); |
|
227 } |
|
228 |
|
229 /** |
|
230 @SYMTestCaseID T-RApaLsSessionTestStep-TestStartApp2L |
|
231 |
|
232 @SYMPREQ |
|
233 |
|
234 @SYMTestCaseDesc. |
|
235 |
|
236 @SYMTestPriority High |
|
237 |
|
238 @SYMTestStatus Implemented |
|
239 |
|
240 @SYMTestActions \n |
|
241 API Calls:\n |
|
242 \n |
|
243 |
|
244 @SYMTestExpectedResults . |
|
245 |
|
246 */ |
|
247 void CT_StartAppTestStep::TestStartApp2L() |
|
248 { |
|
249 INFO_PRINTF1(_L("Test RApaLsSession::AppForDocument using filename and app uid....")); |
|
250 TUid testUid={0x10004c4f}; |
|
251 iStartAppTestsUid.iUid=0; |
|
252 TDataType data; |
|
253 _LIT(KLitDocPath,"\\system\\data\\TRApaLsSessionStartAppTest.tst"); |
|
254 iStartAppTestsFilename = SearchAndReturnCompleteFileName(KLitDocPath); |
|
255 TInt ret=iApaLsSession.AppForDocument(iStartAppTestsFilename,iStartAppTestsUid,data); |
|
256 TEST(ret==KErrNone); |
|
257 TEST(iStartAppTestsUid==testUid); |
|
258 INFO_PRINTF1(KCompleted); |
|
259 } |
|
260 |
|
261 /** |
|
262 @SYMTestCaseID T-RApaLsSessionTestStep-TestStartApp3L |
|
263 |
|
264 @SYMPREQ |
|
265 |
|
266 @SYMTestCaseDesc |
|
267 |
|
268 @SYMTestPriority High |
|
269 |
|
270 @SYMTestStatus Implemented |
|
271 |
|
272 @SYMTestActions \n |
|
273 API Calls:\n |
|
274 \n |
|
275 |
|
276 @SYMTestExpectedResults |
|
277 |
|
278 */ |
|
279 void CT_StartAppTestStep::TestStartApp3L() |
|
280 { |
|
281 INFO_PRINTF1(_L("Test RApaLsSession::StartDocument.....start the app from the recognized doc given.")); |
|
282 |
|
283 TThreadId startAppThreadID; |
|
284 TPtrC startAppTestsDoc(KLitTRApaLsSessionStartAppTest); |
|
285 TInt ret=iApaLsSession.StartDocument(startAppTestsDoc,startAppThreadID); |
|
286 TEST(ret==KErrNone); |
|
287 |
|
288 //we need to close the started thread, if appropiate |
|
289 if (ret==KErrNone) |
|
290 { |
|
291 RThread thread; |
|
292 User::LeaveIfError(thread.Open(startAppThreadID)); |
|
293 CleanupClosePushL(thread); |
|
294 |
|
295 RProcess process; |
|
296 User::LeaveIfError(thread.Process(process)); |
|
297 CleanupClosePushL(process); |
|
298 |
|
299 process.Kill(0); |
|
300 |
|
301 CleanupStack::PopAndDestroy(&process); |
|
302 CleanupStack::PopAndDestroy(&thread); |
|
303 } |
|
304 |
|
305 INFO_PRINTF1(KCompleted); |
|
306 } |
|
307 |
|
308 /** |
|
309 @SYMTestCaseID T-RApaLsSessionTestStep-TestStartApp4L |
|
310 |
|
311 @SYMPREQ |
|
312 |
|
313 @SYMTestCaseDesc |
|
314 |
|
315 @SYMTestPriority High |
|
316 |
|
317 @SYMTestStatus Implemented |
|
318 |
|
319 @SYMTestActions \n |
|
320 API Calls:\n |
|
321 \n |
|
322 |
|
323 @SYMTestExpectedResults |
|
324 |
|
325 */ |
|
326 void CT_StartAppTestStep::TestStartApp4L() |
|
327 { |
|
328 INFO_PRINTF1(_L("Test RApaLsSession::StartDocument....known data type")); |
|
329 TThreadId startAppThreadID; |
|
330 TInt ret=iApaLsSession.StartDocument(iStartAppTestsFilename, TDataType(KLitMimeType_TRApaLsSessionStartAppTest),startAppThreadID); |
|
331 TEST(ret==KErrNone); |
|
332 |
|
333 //we need to close the started thread, if appropiate |
|
334 if (ret==KErrNone) |
|
335 { |
|
336 RThread thread; |
|
337 User::LeaveIfError(thread.Open(startAppThreadID)); |
|
338 CleanupClosePushL(thread); |
|
339 |
|
340 RProcess process; |
|
341 User::LeaveIfError(thread.Process(process)); |
|
342 CleanupClosePushL(process); |
|
343 |
|
344 process.Kill(0); |
|
345 |
|
346 CleanupStack::PopAndDestroy(&process); |
|
347 CleanupStack::PopAndDestroy(&thread); |
|
348 } |
|
349 |
|
350 INFO_PRINTF1(KCompleted); |
|
351 } |
|
352 |
|
353 /** |
|
354 @SYMTestCaseID T_RApaLsSessionTestStep_TestStartApp5L |
|
355 |
|
356 @SYMPREQ |
|
357 |
|
358 @SYMTestCaseDesc |
|
359 |
|
360 @SYMTestPriority High |
|
361 |
|
362 @SYMTestStatus Implemented |
|
363 |
|
364 @SYMTestActions \n |
|
365 API Calls:\n |
|
366 \n |
|
367 |
|
368 @SYMTestExpectedResults |
|
369 |
|
370 */ |
|
371 void CT_StartAppTestStep::TestStartApp5L() |
|
372 { |
|
373 INFO_PRINTF1(_L("Test RApaLsSession::StartDocument....unknown data type")); |
|
374 |
|
375 TThreadId startAppThreadID; |
|
376 TInt ret=iApaLsSession.StartDocument(iStartAppTestsFilename, TDataType(_L8("text/plain/no thanks")),startAppThreadID); |
|
377 TEST(ret==KErrNotFound); |
|
378 INFO_PRINTF1(KCompleted); |
|
379 } |
|
380 |
|
381 /** |
|
382 @SYMTestCaseID T_RApaLsSessionTestStep_TestStartApp6L |
|
383 |
|
384 @SYMPREQ |
|
385 |
|
386 @SYMTestCaseDesc |
|
387 |
|
388 @SYMTestPriority High |
|
389 |
|
390 @SYMTestStatus Implemented |
|
391 |
|
392 @SYMTestActions \n |
|
393 API Calls:\n |
|
394 \n |
|
395 |
|
396 @SYMTestExpectedResults |
|
397 |
|
398 */ |
|
399 void CT_StartAppTestStep::TestStartApp6L() |
|
400 { |
|
401 INFO_PRINTF1(_L("Test RApaLsSession::StartDocument....known App Uid")); |
|
402 |
|
403 TThreadId startAppThreadID; |
|
404 TInt ret=iApaLsSession.StartDocument(iStartAppTestsFilename,iStartAppTestsUid,startAppThreadID); |
|
405 TEST(ret==KErrNone); |
|
406 |
|
407 //we need to close the started thread, if appropiate |
|
408 if (ret==KErrNone) |
|
409 { |
|
410 RThread thread; |
|
411 User::LeaveIfError(thread.Open(startAppThreadID)); |
|
412 CleanupClosePushL(thread); |
|
413 |
|
414 RProcess process; |
|
415 User::LeaveIfError(thread.Process(process)); |
|
416 CleanupClosePushL(process); |
|
417 |
|
418 process.Kill(0); |
|
419 |
|
420 CleanupStack::PopAndDestroy(&process); |
|
421 CleanupStack::PopAndDestroy(&thread); |
|
422 } |
|
423 |
|
424 INFO_PRINTF1(KCompleted); |
|
425 } |
|
426 |
|
427 /** |
|
428 @SYMTestCaseID T_RApaLsSessionTestStep_TestStartApp7L |
|
429 |
|
430 @SYMPREQ |
|
431 |
|
432 @SYMTestCaseDesc Test mapping of a MIME type to an application. |
|
433 |
|
434 @SYMTestPriority High |
|
435 |
|
436 @SYMTestStatus Implemented |
|
437 |
|
438 @SYMTestActions \n |
|
439 API Calls:\n |
|
440 \n |
|
441 |
|
442 @SYMTestExpectedResults Checks mapping of a MIME type to an application. |
|
443 |
|
444 */ |
|
445 void CT_StartAppTestStep::TestStartApp7L() |
|
446 { |
|
447 INFO_PRINTF1(_L("Test RApaLsSession::StartDocument....non existent file.")); |
|
448 |
|
449 TThreadId startAppThreadID; |
|
450 iStartAppTestsFilename = SearchAndReturnCompleteFileName(_L("\\system\\data\\not_here_thanks.foo")); |
|
451 TInt ret=iApaLsSession.StartDocument(iStartAppTestsFilename, startAppThreadID); |
|
452 TEST(ret==KErrNotFound); |
|
453 INFO_PRINTF1(KCompleted); |
|
454 } |
|
455 |
|
456 /** |
|
457 @SYMTestCaseID APPFWK-APPARC-0071 |
|
458 |
|
459 @SYMDEF PDEF100072 -- CApaWindowGroupName::SetAppUid() and FindByAppUid panic |
|
460 |
|
461 @SYMTestCaseDesc Test Launching of an application with unprotected application UID |
|
462 |
|
463 @SYMTestPriority High |
|
464 |
|
465 @SYMTestStatus Implemented |
|
466 |
|
467 @SYMTestActions Prepare command line information to start an application using |
|
468 CApaCommandLine Apis.Call RApaLsSession::StartApp() to start an |
|
469 application defined by the command line information.\n |
|
470 Test the launching of application for following scenario:\n |
|
471 When Application specified by command line has unprotected application UID(negative uid).\n |
|
472 API Calls:\n |
|
473 RApaLsSession::StartApp(const CApaCommandLine &aCommandLine, TThreadId &aThreadId);\n |
|
474 |
|
475 @SYMTestExpectedResults The test checks whether the thread has terminated with the exit reason KTUnProtectedAppTestPassed |
|
476 */ |
|
477 void CT_StartAppTestStep::TestStartApp8L() |
|
478 { |
|
479 INFO_PRINTF1(_L("Checking launching of an application which has unprotected UID")); |
|
480 CApaCommandLine* cmdLine=CApaCommandLine::NewLC(); |
|
481 TFileName filename; |
|
482 _LIT(KAppFileName, "z:\\sys\\bin\\UnProctectedUidApp.exe"); |
|
483 TFullName exePath(KAppFileName); |
|
484 filename = SearchAndReturnCompleteFileName(exePath); |
|
485 cmdLine->SetExecutableNameL(filename); |
|
486 |
|
487 TThreadId appThreadId(0U); |
|
488 TInt ret = iApaLsSession.StartApp(*cmdLine, appThreadId); |
|
489 TEST(ret == KErrNone); |
|
490 User::LeaveIfError(ret); |
|
491 CleanupStack::PopAndDestroy(cmdLine); // cmdLine |
|
492 |
|
493 RThread appThread; |
|
494 User::LeaveIfError(appThread.Open(appThreadId)); |
|
495 |
|
496 TRequestStatus logonRequestStatus; |
|
497 appThread.Logon(logonRequestStatus); |
|
498 |
|
499 // wait for UnProctectedUidApp.exe to terminate |
|
500 INFO_PRINTF1(_L("Waiting for application to terminate...")); |
|
501 User::WaitForRequest(logonRequestStatus); |
|
502 |
|
503 const TExitType exitType = appThread.ExitType(); |
|
504 const TInt exitReason = appThread.ExitReason(); |
|
505 TExitCategoryName categoryName = appThread.ExitCategory(); |
|
506 appThread.Close(); |
|
507 |
|
508 TBuf<50> msg; |
|
509 if (exitType == EExitPanic) |
|
510 { |
|
511 _LIT(KAppPanicInfo, "Application panic: %S %d"); |
|
512 msg.Format(KAppPanicInfo, &categoryName, exitReason); |
|
513 } |
|
514 else |
|
515 { |
|
516 _LIT(KAppExitInfo, "Application exited with code %d"); |
|
517 msg.Format(KAppExitInfo, exitReason); |
|
518 } |
|
519 INFO_PRINTF1(msg); |
|
520 |
|
521 TEST(logonRequestStatus == KTUnProtectedAppTestPassed); |
|
522 TEST(exitType == EExitKill); |
|
523 TEST(exitReason == KTUnProtectedAppTestPassed); |
|
524 INFO_PRINTF1(KCompleted); |
|
525 } |
|
526 /** |
|
527 @SYMTestCaseID APPFWK-APPARC-0076 |
|
528 |
|
529 @SYMDEF INC104463 |
|
530 |
|
531 @SYMTestCaseDesc Testing StartApp API by forcing memory leak. |
|
532 |
|
533 @SYMTestPriority High |
|
534 |
|
535 @SYMTestStatus Implemented |
|
536 |
|
537 @SYMTestActions Apparc should kill the child process if a leave occurs in StartApp API. |
|
538 API Calls:\n |
|
539 RApaLsSession::StartApp \n |
|
540 |
|
541 @SYMTestExpectedResults Test should complete without any panic. |
|
542 |
|
543 */ |
|
544 |
|
545 void CT_StartAppTestStep::TestStartApp9L() |
|
546 { |
|
547 INFO_PRINTF1(_L("Test to check the StartApp API with forced memory failures...")); |
|
548 CApaCommandLine* cmdLn=CApaCommandLine::NewLC(); |
|
549 TFileName filename; |
|
550 TThreadId threadId(0); |
|
551 TInt fail; |
|
552 _LIT(KLitExePath,"\\sys\\bin\\texe.exe"); |
|
553 TFullName exePath(KLitExePath); |
|
554 filename = SearchAndReturnCompleteFileName(exePath); |
|
555 cmdLn->SetExecutableNameL(filename); |
|
556 TInt ret = KErrNoMemory; |
|
557 //Without the fix for the Incident INC104463, the OOM test causes panic |
|
558 //KERN-EXEC 56. |
|
559 for(fail=1; ret == KErrNoMemory; fail++) |
|
560 { |
|
561 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
562 __UHEAP_MARK; |
|
563 ret = iApaLsSession.StartApp(*cmdLn, threadId); |
|
564 __UHEAP_MARKEND; |
|
565 __UHEAP_RESET; |
|
566 TEST((ret==KErrNoMemory || ret==KErrNone)); |
|
567 if(ret == KErrNone) |
|
568 { |
|
569 TEST(threadId.Id() != 0); |
|
570 } |
|
571 } |
|
572 INFO_PRINTF3(_L("Iteration count is %d and the value of return is %d "),fail-1 ,ret); |
|
573 CleanupStack::PopAndDestroy(cmdLn); |
|
574 INFO_PRINTF1(KCompleted); |
|
575 } |
|
576 |
|
577 |
|
578 |
|
579 /** |
|
580 @SYMTestCaseID CT_RApaLsSessionTestStep_TestInsertDataTypeL |
|
581 |
|
582 @SYMPREQ Data caging |
|
583 |
|
584 @SYMTestCaseDesc |
|
585 |
|
586 @SYMTestPriority High |
|
587 |
|
588 @SYMTestStatus Implemented |
|
589 |
|
590 @SYMTestActions |
|
591 API Calls:\n |
|
592 RApaLsSession::InsertDataMapping \n |
|
593 RApaLsSession::InsertDataMappingIfHigher \n |
|
594 @SYMTestExpectedResults |
|
595 * |
|
596 */ |
|
597 void CT_StartAppTestStep::TestInsertDataTypeL() |
|
598 { |
|
599 INFO_PRINTF1(_L("Test RApaLsSession::InsertDataMapping....Check data type mapping addition")); |
|
600 const TDataTypePriority KPriLow = 1; |
|
601 const TDataTypePriority KPriHigh = 2; |
|
602 TBool added=EFalse; |
|
603 |
|
604 TInt err=iApaLsSession.InsertDataMapping(TDataType(KLitPlainText), KPriLow, KUidTestApp); |
|
605 INFO_PRINTF2(_L("returned, %d"), err); |
|
606 TSecurityInfo info; |
|
607 info.Set(RProcess()); |
|
608 |
|
609 info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone) : TEST(err==KErrPermissionDenied); |
|
610 |
|
611 TRequestStatus status; |
|
612 |
|
613 //Register for notification when data type mappings are restored from the data store ini file |
|
614 iApaLsSession.NotifyOnDataMappingChange(status); |
|
615 |
|
616 err=iApaLsSession.InsertDataMappingIfHigher(TDataType(KLitPlainText), KPriHigh, KUidTestApp, added); |
|
617 INFO_PRINTF2(_L("returned, %d"), err); |
|
618 info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone && added) : TEST(err==KErrPermissionDenied); |
|
619 |
|
620 if (err==KErrNone) |
|
621 { |
|
622 // Waits till the data type mappings are restored from the data store ini file |
|
623 User::WaitForRequest(status); |
|
624 TEST(status.Int()==KErrNone); |
|
625 } |
|
626 else |
|
627 { |
|
628 iApaLsSession.CancelNotifyOnDataMappingChange(); |
|
629 TEST(status.Int()==KErrCancel); |
|
630 } |
|
631 INFO_PRINTF1(_L("Test RApaLsSession::InsertDataMapping....Check data type mapping addition....Done")); |
|
632 } |
|
633 |
|
634 /** |
|
635 @SYMTestCaseID T_RApaLsSessionTestStep_TestAppForDataTypeL |
|
636 |
|
637 @SYMPREQ |
|
638 |
|
639 @SYMTestCaseDesc . |
|
640 |
|
641 @SYMTestPriority High |
|
642 |
|
643 @SYMTestStatus Implemented |
|
644 |
|
645 @SYMTestActions \n |
|
646 API Calls:\n |
|
647 |
|
648 @SYMTestExpectedResults |
|
649 |
|
650 */ |
|
651 void CT_StartAppTestStep::TestAppForDataTypeL() |
|
652 { |
|
653 INFO_PRINTF1(_L("Test RApaLsSession::AppForDataType....Check an app binding")); |
|
654 _LIT8(KLitPlainText,"text/plain"); |
|
655 TUid testUid={KTestAppUidValue}; |
|
656 |
|
657 TInt ret=iApaLsSession.AppForDataType(TDataType(KLitPlainText),iStartAppTestsUid); |
|
658 TEST(ret==KErrNone); |
|
659 TEST(iStartAppTestsUid==testUid); |
|
660 INFO_PRINTF1(KCompleted); |
|
661 } |
|
662 |
|
663 /** |
|
664 @SYMTestCaseID CT_RApaLsSessionTestStep::TestDeleteDataTypeL |
|
665 |
|
666 @SYMPREQ Data caging |
|
667 |
|
668 @SYMTestCaseDesc |
|
669 |
|
670 @SYMTestPriority High |
|
671 |
|
672 @SYMTestStatus Implemented |
|
673 |
|
674 @SYMTestActions |
|
675 API Calls:\n |
|
676 RApaLsSession::DeleteDataMapping \n |
|
677 @SYMTestExpectedResults |
|
678 |
|
679 */ |
|
680 |
|
681 void CT_StartAppTestStep::TestDeleteDataTypeL() |
|
682 { |
|
683 INFO_PRINTF1(_L("Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion")); |
|
684 |
|
685 TRequestStatus status; |
|
686 |
|
687 //Register for notification when data type mappings are restored from the data store ini file |
|
688 iApaLsSession.NotifyOnDataMappingChange(status); |
|
689 |
|
690 TInt err=iApaLsSession.DeleteDataMapping(TDataType(KLitPlainText)); |
|
691 INFO_PRINTF2(_L("returned, %d"), err); |
|
692 TSecurityInfo info; |
|
693 info.Set(RProcess()); |
|
694 |
|
695 info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone) : TEST(err==KErrPermissionDenied); |
|
696 |
|
697 if (err==KErrNone) |
|
698 { |
|
699 // Waits till the data type mappings are restored from the data store ini file |
|
700 User::WaitForRequest(status); |
|
701 TEST(status.Int()==KErrNone); |
|
702 } |
|
703 else |
|
704 { |
|
705 iApaLsSession.CancelNotifyOnDataMappingChange(); |
|
706 TEST(status.Int()==KErrCancel); |
|
707 } |
|
708 INFO_PRINTF1(_L("Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion....Done")); |
|
709 } |
|
710 |
|
711 TFileName CT_StartAppTestStep::SearchAndReturnCompleteFileName(const TDesC& aFileName) |
|
712 { |
|
713 RFs fs; |
|
714 TInt ret = fs.Connect(); |
|
715 TEST(ret==KErrNone); |
|
716 |
|
717 TParsePtrC parse(aFileName); |
|
718 TFindFile findFile(fs); |
|
719 ret = findFile.FindByDir(parse.NameAndExt(), parse.Path()); |
|
720 if (ret!=KErrNone) |
|
721 { |
|
722 TBuf<64> buffer; |
|
723 buffer.Format(_L("Error while finding the file, %d"), ret); |
|
724 } |
|
725 fs.Close(); |
|
726 return findFile.File(); |
|
727 } |
|
728 |
|
729 void CT_StartAppTestStep::TestIpcFuzzL() |
|
730 { |
|
731 INFO_PRINTF1(_L("Test IpcFuzz DEF116002 Started")); |
|
732 RIpcApparcFuzzTest testIpc(*this); |
|
733 CleanupClosePushL(testIpc); |
|
734 TRAPD(err,testIpc.RunFuzzTestL()); |
|
735 TEST(err==KErrNone); |
|
736 CleanupStack::PopAndDestroy(&testIpc); |
|
737 INFO_PRINTF1(_L("Test IpcFuzz DEF116002 Completed")); |
|
738 } |
|
739 |