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