localisation/apparchitecture/tef/T_CmdlnStep.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 // Test CApaCommandLine Apis\n
       
    15 // Test CApaCommandLine API by setting launching information and
       
    16 // checking setter and getter function.\n
       
    17 // 
       
    18 //
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file
       
    24  @internalComponent - Internal Symbian test code
       
    25 */
       
    26 
       
    27 #include "T_CmdlnStep.h"
       
    28 #include "testableapalssession.h"
       
    29 
       
    30  /**
       
    31    @SYMTestCaseID T-CmdlnStep-testSecureCmdLinesL
       
    32   
       
    33    @SYMPREQ 280 - File Handle Support
       
    34   
       
    35    @SYMTestCaseDesc Tests CApaCommandLine Apis. 
       
    36    
       
    37    @SYMTestPriority High 
       
    38   
       
    39    @SYMTestStatus Implemented
       
    40   
       
    41    
       
    42    @SYMTestActions .
       
    43    Observe the operation that is executed on each command.\n
       
    44    Test the following accessor functions:\n
       
    45    CApaCommandLine::ExecutableName()\n
       
    46    CApaCommandLine::Command()\n
       
    47    CApaCommandLine::DocumentName()\n
       
    48    CApaCommandLine::TailEnd()\n
       
    49    CApaCommandLine::ServerId()\n
       
    50    CApaCommandLine::SessionHandle()\n
       
    51    CApaCommandLine::SubSessionHandle()\n
       
    52    Check whether each of these getter functions return the individual components.\n\n
       
    53    Test the following setter functions:\n
       
    54    CApaCommandLine::SetExecutableNameL()\n
       
    55    CApaCommandLine::SetCommandL()\n
       
    56    CApaCommandLine::SetDocumentNameL()\n
       
    57    CApaCommandLine::SetTailEndL()\n
       
    58    CApaCommandLine::SetServerId()\n
       
    59    CApaCommandLine::SetSessionHandle()\n
       
    60    CApaCommandLine::SetSubSessionHandle()\n
       
    61    Use the setter functions to set the individual components. Use the
       
    62    getter methods to verify values set to the individual components.\n
       
    63    API Calls:\n	
       
    64    CApaCommandLine::NewL(const RMessagePtr2& aMessage)\n 
       
    65    CApaCommandLine::ExecutableName() const\n
       
    66    CApaCommandLine::Command() const\n
       
    67    CApaCommandLine::DocumentName() const\n
       
    68    CApaCommandLine::TailEnd() const\n
       
    69    CApaCommandLine::TailEnd() const\n
       
    70    CApaCommandLine::ServerId() const\n
       
    71    CApaCommandLine::SessionHandle() const\n
       
    72    CApaCommandLine::SubSessionHandle() const\n
       
    73    CApaCommandLine::EnviromentSlotsReaderL()\n
       
    74    CApaCommandLine::SetExecutableNameL(const TDesC& aAppName)\n
       
    75    CApaCommandLine::SetCommandL(TApaCommand aCommand)\n
       
    76    CApaCommandLine::SetDocumentNameL(const TDesC& aDocName)\n
       
    77    CApaCommandLine::SetTailEndL(const TDesC8& aTailEnd)\n
       
    78    CApaCommandLine::SetServerId(TInt aServerId)\n
       
    79    CApaCommandLine::SetSessionHandle(TInt aSessionHandle)\n
       
    80    CApaCommandLine::SetSubSessionHandle(TInt aSubSessionHandle)\n
       
    81    CApaCommandLine::SetProcessEnvironmentL(RProcess& aProcess) const\n
       
    82   
       
    83    
       
    84   
       
    85    @SYMTestExpectedResults Tests checks results against desired results.
       
    86     
       
    87  */
       
    88  void CT_CmdlnStep::testSecureCmdLinesL()
       
    89  	{
       
    90  	RTestableApaLsSession ls;
       
    91  	TEST(KErrNone == ls.Connect());
       
    92  	CleanupClosePushL(ls);
       
    93  	
       
    94  	testPositiveInputsL();
       
    95 	testInitializationL();
       
    96 	testBoundaryConditionsL();
       
    97 	//DONT_CHECK since type store is updated
       
    98     HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, testRecAppLaunchL(ls), NO_CLEANUP);
       
    99     
       
   100     CleanupStack::PopAndDestroy(&ls);
       
   101  	}
       
   102 
       
   103 /**
       
   104    Auxiliary function for TestCaseID T-CmdlnStep-testSecureCmdLinesL
       
   105   
       
   106   
       
   107    @SYMPREQ 280 - File Handle Support
       
   108   
       
   109     Call the Set APIs below with valid inputs
       
   110     CApaCommandLine::SetExecutableNameL(appName);
       
   111     CApaCommandLine::SetDocumentNameL(docName);
       
   112     CApaCommandLine::SetTailEndL(tailEnd);
       
   113     CApaCommandLine::SetFileByHandleL(aFile);
       
   114     CApaCommandLine::SetCommandL(command);
       
   115     
       
   116     Compares the values set by the above APIs with those obtained by the GET APIs mentioned below
       
   117     CApaCommandLine::ExecutableName());
       
   118     CApaCommandLine::DocumentName());
       
   119     CApaCommandLine::TailEnd());
       
   120     CApaCommandLine::GetFileByHandleL();
       
   121     CApaCommandLine::Command());
       
   122 	
       
   123   
       
   124  */
       
   125 void CT_CmdlnStep::testPositiveInputsL()
       
   126 	{
       
   127 	TPtrC appName;
       
   128 	TPtrC docName;
       
   129 	TApaCommand command = EApaCommandRun;
       
   130 	TPtrC8  tailEnd;
       
   131 	TEntry dirEntry;
       
   132 	RFs fSession;
       
   133 	RFile file;
       
   134 	
       
   135 	INFO_PRINTF1(_L("Tests the Set and Get command line APIs  for valid inputs"));	
       
   136 	CApaCommandLine* cmdLine=CApaCommandLine::NewLC(); // start with an empty command line
       
   137 	
       
   138 	appName.Set(KTAppName);
       
   139 	docName.Set(KTDocName);
       
   140 	tailEnd.Set(KTTailEnd);
       
   141 	
       
   142 	User::LeaveIfError(fSession.Connect());
       
   143 	//User::LeaveIfError(fSession.ShareProtected());	
       
   144 	INFO_PRINTF1(_L("Check for the existence of C:\\System\\Data Directory"));	
       
   145 	TInt ret = fSession.Entry(KTempDir,dirEntry);	
       
   146 	if(ret==KErrNotFound)
       
   147 	{
       
   148 		INFO_PRINTF1(_L("Create C:\\System\\Data Directory if not existing already"));
       
   149 		fSession.MkDir(KTempDir); /* Create Data Directory as it does not exist  */				
       
   150 	}	
       
   151 	User::LeaveIfError(file.Replace(fSession, KTDocName, EFileStreamText|EFileShareAny));
       
   152 	User::LeaveIfError(file.Write(KTWriteData));//write some test data
       
   153 	
       
   154 	INFO_PRINTF1(_L("The Set command line APIs  are invoked with valid arguments"));	
       
   155 	// Set the member variables using the Set functions
       
   156 	
       
   157 	TRAP(ret,
       
   158 		{ 
       
   159 		cmdLine->SetExecutableNameL(appName);
       
   160 		cmdLine->SetDocumentNameL(docName);
       
   161 		cmdLine->SetTailEndL(tailEnd);
       
   162 		cmdLine->SetFileByHandleL(file);
       
   163 		cmdLine->SetCommandL(command);
       
   164 		} )
       
   165 		
       
   166 	TEST(KErrNone==ret);
       
   167 	
       
   168 	if(KErrNone==ret)
       
   169 		{
       
   170 		INFO_PRINTF1(_L("The Get command line APIs  are invoked and their return values are verified"));	
       
   171 		//Test the values returned by the Get Functions
       
   172 		TEST(appName==cmdLine->ExecutableName());
       
   173 		TEST(docName==cmdLine->DocumentName());
       
   174 		TEST(tailEnd==cmdLine->TailEnd());	
       
   175 	
       
   176 		RFile tempFile;
       
   177 		TBuf8<10> readData;
       
   178 		TRAP(ret,cmdLine->GetFileByHandleL(tempFile));
       
   179 		TEST(KErrNone==ret);
       
   180 		if(KErrNone==ret)
       
   181 			{
       
   182 			tempFile.Read(0,readData);//file still open so rewind file pointer
       
   183 			TEST(readData==KTWriteData);
       
   184 			}
       
   185 		}
       
   186 	
       
   187 	file.Close();
       
   188 	fSession.Close();	
       
   189 	//fSession.Delete(KTDocName);
       
   190 	CleanupStack::PopAndDestroy(cmdLine); 
       
   191 
       
   192 	}
       
   193 
       
   194 
       
   195 /**
       
   196     Auxiliary function for TestCaseID T-CmdlnStep-testSecureCmdLinesL
       
   197   
       
   198     @SYMPREQ 280 - File Handle Support
       
   199   
       
   200     Tests the initial values of the member variables 
       
   201   
       
   202     Following are the SET APIs tested 
       
   203     CApaCommandLine::SetExecutableNameL(appName);
       
   204     CApaCommandLine::SetDocumentNameL(docName);
       
   205     CApaCommandLine::SetTailEndL(tailEnd);
       
   206     CApaCommandLine::SetSessionHandle(TInt aSessionHandle);
       
   207     CApaCommandLine::SetSubSessionHandle(TInt aSubSessionHandle);
       
   208     CApaCommandLine::SetServerIdL(TInt serverId);
       
   209     CApaCommandLine::SetCommandL(command);
       
   210     
       
   211     Compares the values set with those obtained by the GET APIs
       
   212     CApaCommandLine::ExecutableName();
       
   213     CApaCommandLine::DocumentName();
       
   214     CApaCommandLine::TailEnd();
       
   215     CApaCommandLine::ServerId();
       
   216     CApaCommandLine::SessionHandle();
       
   217     CApaCommandLine::SubSessionHandle();
       
   218     CApaCommandLine::Command();
       
   219   
       
   220     Following Scenarios are tested
       
   221    
       
   222     1. Do not set the values and check the values returned by the GET APIs
       
   223     2. Set Application Name and check all the values returned by the GET APIs
       
   224     3. Set AppName,DocName  and check all the values returned by the GET APIs
       
   225     4. Set AppName,DocName,Tailend  and check all the values returned by the GET APIs
       
   226     5. Set AppName,DocName,Tailend,Serverid and check all the values returned by the GET APIs  
       
   227     6. Set AppName,DocName,Tailend,Serverid,sessionId and check all the values returned by the GET APIs  
       
   228     7. Set AppName,DocName,Tailend,Serverid,sessionId and subsessionId and check all the values returned by the GET APIs  
       
   229  */
       
   230 
       
   231 void CT_CmdlnStep::testInitializationL()
       
   232 	{
       
   233 	
       
   234 	TPtrC appName(KNullDesC);
       
   235 	TPtrC docName(KNullDesC);
       
   236 	TApaCommand cmdType = EApaCommandRun;//CApaCommandLine's initial value
       
   237 	TPtrC8  tailEnd(KNullDesC8);
       
   238 	RFs fSession;
       
   239 	RFile file;
       
   240 	TEntry dirEntry;
       
   241 		
       
   242 	CApaCommandLine* cmdLine=CApaCommandLine::NewLC(); // start with an empty command line
       
   243 
       
   244 	for(TInt index = 0; index < TEST_SET_APIS-1; index++)
       
   245     	{
       
   246     	switch(index)
       
   247     		{
       
   248     		case TEST_INITIALIZATION:
       
   249     			INFO_PRINTF1(_L("Tests the initial values of the member data"));
       
   250     			break;
       
   251     		case TEST_APP:
       
   252     			INFO_PRINTF1(_L("Setting Application Name to \"app name\"."));
       
   253 				appName.Set(KTAppName);
       
   254 				cmdLine->SetExecutableNameL(appName);
       
   255     			break;
       
   256     		case TEST_DOC:
       
   257     			INFO_PRINTF1(_L("Setting document name to \"doc name\"."));
       
   258 				docName.Set(KTDocName);
       
   259 				cmdLine->SetDocumentNameL(docName);
       
   260     			break;
       
   261     		case TEST_TAILEND:
       
   262     			INFO_PRINTF1(_L("Setting tail end to \"tail end \"."));
       
   263 				tailEnd.Set(KTTailEnd);
       
   264 				cmdLine->SetTailEndL(tailEnd);
       
   265     			break;
       
   266     		case TEST_COMMAND:
       
   267     			INFO_PRINTF1(_L("Setting tail end to \"command type \"."));
       
   268     			cmdType=EApaCommandOpen;//any update to the command value 
       
   269     			cmdLine->SetCommandL(cmdType);
       
   270     			break;
       
   271     		case TEST_FILE_HANDLE:
       
   272     			{
       
   273     			INFO_PRINTF1(_L("Setting file handle name to \"handle name\"."));
       
   274     			User::LeaveIfError(fSession.Connect());
       
   275 				User::LeaveIfError(fSession.ShareProtected());	
       
   276 				INFO_PRINTF1(_L("Check for the existence of C:\\System\\Data Directory"));	
       
   277 				TInt ret = fSession.Entry(KTempDir,dirEntry);	
       
   278 				if(ret==KErrNotFound)
       
   279 					{
       
   280 					INFO_PRINTF1(_L("Create C:\\System\\Data Directory if not existing already"));	
       
   281 					}	
       
   282 				User::LeaveIfError(file.Replace(fSession, KTDocName, EFileStreamText|EFileShareAny));
       
   283     			TRAP(ret,cmdLine->SetFileByHandleL(file));
       
   284     			TEST(KErrNone==ret);
       
   285     			break;
       
   286     			}
       
   287     		default:
       
   288     			break;
       
   289     		}
       
   290     		
       
   291     		INFO_PRINTF1(_L("The Get command line APIs  are invoked and their return values are verified"));	
       
   292     
       
   293     		//Test the values returned by the Get Functions
       
   294     		TEST(appName==cmdLine->ExecutableName());
       
   295 			TEST(docName==cmdLine->DocumentName());
       
   296 			TEST(tailEnd==cmdLine->TailEnd());
       
   297 			TEST(cmdType==cmdLine->Command());
       
   298 			
       
   299 			RFile testFile;
       
   300 			TRAPD(ret,cmdLine->GetFileByHandleL(testFile));
       
   301 			TEST(KErrNone==ret);
       
   302 			if(KErrNone==ret)
       
   303 				{	//this test relies on TEST_FILE_HANDLE being the last case in the case statement 
       
   304 					if(index==TEST_FILE_HANDLE)
       
   305 						{//not equal when initialised
       
   306 						TEST(file.SubSessionHandle()!=testFile.SubSessionHandle());	
       
   307 						}
       
   308 						else
       
   309 						{//equal when uninitialised
       
   310 						TEST(file.SubSessionHandle()==testFile.SubSessionHandle());
       
   311 						}
       
   312 				}			
       
   313        	}
       
   314     	
       
   315     file.Close();
       
   316 	fSession.Close();	
       
   317 	//fSession.Delete(KTDocName);
       
   318     CleanupStack::PopAndDestroy(cmdLine); 
       
   319     
       
   320     }
       
   321 
       
   322 /**
       
   323     Auxiliary function for TestCaseID T-CmdlnStep-testSecureCmdLinesL
       
   324   
       
   325     @SYMPREQ 280 - File Handle Support
       
   326   
       
   327     Tests CApaCommandLine Apis. 
       
   328    
       
   329     Tests the Boundary values of the member variables like Null descriptors and zero for integer member variables
       
   330     Also test negative values for the integer member variables
       
   331     
       
   332     CApaCommandLine::SetExecutableNameL(appName);
       
   333     CApaCommandLine::SetDocumentNameL(docName);
       
   334     CApaCommandLine::SetTailEndL(tailEnd);
       
   335     CApaCommandLine::SetCommandL(command);
       
   336     
       
   337     Compares the values set with those obtained by the GET APIs
       
   338     CApaCommandLine::ExecutableName());
       
   339     CApaCommandLine::DocumentName());
       
   340     CApaCommandLine::TailEnd());
       
   341     CApaCommandLine::Command());
       
   342   
       
   343     Following Scenarios are tested
       
   344    
       
   345     1. Set AppName,DocName and Tailend to Null descriptors and check the values returned by the corresponding
       
   346        GET APIs
       
   347  */
       
   348 
       
   349 void CT_CmdlnStep::testBoundaryConditionsL()
       
   350 	{
       
   351 		
       
   352 	TPtrC appName(KNullDesC);
       
   353 	TPtrC docName(KNullDesC);
       
   354 	TPtrC8 tailEnd;
       
   355 	
       
   356 	CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); // start with an empty command line
       
   357 	
       
   358 	INFO_PRINTF1(_L("TEST APIS WITH BOUNDARY CONDITIONS\n"));
       
   359 	
       
   360 	//Set the member variables 
       
   361 	cmdLine->SetExecutableNameL(appName);
       
   362 	cmdLine->SetDocumentNameL(docName);
       
   363 	tailEnd.Set(KTNullTail);
       
   364 	cmdLine->SetTailEndL(tailEnd);
       
   365 				
       
   366 	// Check the values returned by the Get Functions		
       
   367 	TEST(appName==cmdLine->ExecutableName());
       
   368 	TEST(docName==cmdLine->DocumentName());
       
   369 	TEST(tailEnd==cmdLine->TailEnd());
       
   370 	
       
   371 	CleanupStack::PopAndDestroy(cmdLine); 
       
   372     
       
   373     }
       
   374 
       
   375 /**
       
   376    Auxiliary function for TestCaseID T-CmdlnStep-testSecureCmdLinesL
       
   377   
       
   378    @SYMPREQ 280 - File Handle Support
       
   379   
       
   380    Tests CApaCommandLine Apis. 
       
   381   
       
   382    The functions tests positive and negative test scenarios for API 
       
   383    TInt RApaLsSession::StartDocument(const TDesC& aFileName, RFs& aFSession, RFile& aFile, TThreadId& aThreadId) 
       
   384     
       
   385    The test case opens a document "temp.test" with datatype "test/plain" which is recognized by TESTREC.
       
   386    T_EnvSlots.exe is application mapped to the this data type using InsertDataMappingL function.
       
   387    When the file is opened using StartDocument the application is launched which verifies the environment slots 
       
   388    of the launched application to those set.
       
   389    
       
   390    
       
   391  */
       
   392  
       
   393 void CT_CmdlnStep::testRecAppLaunchL(RApaLsSession& aLs)
       
   394 	{
       
   395 
       
   396 	TThreadId startAppThreadID;
       
   397 	RFs fSession;
       
   398 	RFile file;
       
   399 	TDataType dataType(KTDataType);
       
   400 	TEntry dirEntry;
       
   401 		
       
   402 	User::LeaveIfError(fSession.Connect());
       
   403 	User::LeaveIfError(fSession.ShareProtected());
       
   404 	
       
   405 	INFO_PRINTF1(_L("Check for the existence of C:\\System\\Data Directory"));	
       
   406 	TInt ret = fSession.Entry(KTempDir,dirEntry);
       
   407 	
       
   408 	if(ret==KErrNotFound)
       
   409 	{
       
   410 		INFO_PRINTF1(_L("Create C:\\System\\Data Directory if not existing already"));	
       
   411 	}
       
   412 	
       
   413 	User::LeaveIfError(file.Replace(fSession, KTDocName, EFileStreamText|EFileShareAny));
       
   414 	User::LeaveIfError(file.Write(KTWriteData));
       
   415 		
       
   416 	//Create A Global mutex to control the access to the logfile
       
   417 	
       
   418 	RMutex fileAccess;
       
   419 	fileAccess.CreateGlobal(KTLogFileAccess);
       
   420 	
       
   421 	INFO_PRINTF1(_L("Start Valid Document of Data type : test"));
       
   422 	
       
   423 	TUid uid;
       
   424 	uid.iUid = (0x102032AB);
       
   425 	ret = aLs.InsertDataMapping(dataType, KDataTypePriorityHigh, uid);
       
   426 	TEST(ret==KErrNone);
       
   427 	if(ret == KErrNone)
       
   428 		{
       
   429 		INFO_PRINTF1(_L("InsertDataMapping API call successful"));
       
   430 		}
       
   431 	else 
       
   432 		{
       
   433 		INFO_PRINTF1(_L("InsertDataMapping API call failed"));
       
   434 		}
       
   435 	
       
   436 	ret = aLs.StartDocument(file,startAppThreadID);
       
   437 	TEST(ret==KErrNone);
       
   438 	if(ret == KErrNone)
       
   439 		{
       
   440 		INFO_PRINTF1(_L("Start Document API call successful"));
       
   441 		}
       
   442 	else 
       
   443 		{
       
   444 		INFO_PRINTF1(_L("Start Document API call failed"));
       
   445 		}
       
   446 		
       
   447 	// Make the process sleep in order to launch T_EnvSlots
       
   448 	User::After(KOneSecond);
       
   449 	
       
   450 	// Wait for the Mutex for log file access
       
   451 	fileAccess.Wait();
       
   452 	TBufC<KMaxFilePath> filePath(KEnvFilePath);
       
   453 	RFile logFile;
       
   454 	
       
   455 	INFO_PRINTF1(_L("File Access Mutex obtained"));
       
   456 	
       
   457 	//Open the logfile in the readmode	
       
   458 	User::LeaveIfError(logFile.Open(fSession,filePath,EFileRead));
       
   459 	
       
   460 	INFO_PRINTF1(_L("Env Log File Open successful"));
       
   461 				
       
   462 	TBuf8<8> expected(KTPass);
       
   463 	TBuf8<8> obtained;
       
   464 	TBuf8<8> failReason;		
       
   465 	
       
   466 	// Read from the logfile
       
   467 	User::LeaveIfError(logFile.Read(obtained));
       
   468 	
       
   469 	INFO_PRINTF1(_L("Env Log File Read successful"));
       
   470 		
       
   471 	TEST(expected==obtained);
       
   472 	
       
   473 	if(expected == obtained)
       
   474 	{
       
   475 		INFO_PRINTF1(_L("Environment slots verification Passed"));
       
   476 	}
       
   477 	else {
       
   478 		// Read up to the end of the file to log all the failures
       
   479 		do
       
   480 		{
       
   481 			// Read the environment slot whose verification failed 
       
   482 			logFile.Read(failReason);
       
   483 			
       
   484 			if(failReason == KTApp)
       
   485 			{
       
   486 				INFO_PRINTF1(_L("Environment slot verification failed for Application Name"));
       
   487 			}
       
   488 			else if(failReason == KTDoc)
       
   489 			{
       
   490 				INFO_PRINTF1(_L("Environment slot verification failed for Document Name"));
       
   491 			}
       
   492 			else if(failReason == KTServer)
       
   493 			{
       
   494 				INFO_PRINTF1(_L("Environment slot verification failed for Server Id"));
       
   495 			}
       
   496 			else if(failReason == KTCommand)
       
   497 			{
       
   498 				INFO_PRINTF1(_L("Environment slot verification failed for Command"));
       
   499 			}
       
   500 			
       
   501 			// Skip the "TestFail" text
       
   502 			logFile.Read(failReason);
       
   503 			
       
   504 			//Exit the loop if end of the file 
       
   505 			if(failReason.Length() == 0)
       
   506 				break;
       
   507 			
       
   508 		} while(ETrue);
       
   509 	}
       
   510 	
       
   511 	ret = aLs.DeleteDataMapping(dataType);
       
   512 	TEST(ret==KErrNone);
       
   513 	if(ret == KErrNone)
       
   514 		{
       
   515 		INFO_PRINTF1(_L("DeleteDataMapping API call successful"));
       
   516 		}
       
   517 	else 
       
   518 		{
       
   519 		INFO_PRINTF1(_L("DeleteDataMapping API call failed"));
       
   520 		}
       
   521 		
       
   522 	ret = aLs.StartDocument(file,startAppThreadID);
       
   523 	TEST(ret==KErrNotFound);
       
   524 	if(ret == KErrNotFound)
       
   525 		{
       
   526 		INFO_PRINTF1(_L("Start Document API call with expected failure successful"));
       
   527 		}
       
   528 	else 
       
   529 		{
       
   530 		INFO_PRINTF1(_L("Start Document API call with expected failure failed"));
       
   531 		}
       
   532 	
       
   533 	logFile.Close();
       
   534 		
       
   535 	// Test on Invalid Document Name, Invalid File Session and Invalid File Args removed
       
   536 	// This test was invalid & panics
       
   537 		
       
   538 	file.Close();
       
   539 	fSession.Close();	
       
   540 	//fSession.Delete(KTDocName);
       
   541 	fileAccess.Close();
       
   542 		
       
   543 	}
       
   544 
       
   545 /**
       
   546    @SYMTestCaseID CT-CmdlnStep-testCmdLinesAPIsL()
       
   547   
       
   548    @SYMPREQ
       
   549 
       
   550    @SYMTestCaseDesc Command line APIs to be properly tested 
       
   551  
       
   552    @SYMTestActions CApaCommandLine::NewLC() is called to create a commandline object;CApaCommandLineSetFileByHandleL() is called to set the file session and file handle; RProcess::Create is called to create a new process to launch the exe;
       
   553    CApaCommandLine::SetProcessEnvironmentL is called to initialise the parameters of the child process; CApaCommandLine::GetCommandLineFromProcessEnvironment is
       
   554    called by the child process to get the commandline object created by the parent process; In order to be able to read the file, CApaCommandLine::GetFileByHandleL is called by the child process
       
   555    to get the file handle created by the parent process. 
       
   556    
       
   557    API Calls:static CApaCommandLine* NewLC();
       
   558  			 void SetProcessEnvironmentL(RProcess& aProcess) const;
       
   559  			 static TInt GetCommandLineFromProcessEnvironment(CApaCommandLine*& aCommandLine);
       
   560  			 void SetFileByHandleL(const RFile& aFile);
       
   561 			 void GetFileByHandleL(RFile& aFile) const;
       
   562    
       
   563    @SYMTestExpectedResults Returns an integer value (99) if no exception occurs else return system wide errors.
       
   564     
       
   565  */	
       
   566 void CT_CmdlnStep::testCmdLinesAPIsL()
       
   567 	{
       
   568 	INFO_PRINTF1(_L("Start test testCmdLinesAPIsL ..."));
       
   569 	RFs fs;
       
   570 	RFile file;	
       
   571 	RProcess process; 
       
   572 	TInt ret(0);
       
   573 	_LIT(KFileName, "z:\\system\\data\\one_byte.txt"); //the file to be read by the process
       
   574 	_LIT(KExeName, "TCmdLineExe"); //exe that is created for this test case
       
   575 	TRequestStatus status;
       
   576    
       
   577 	ret = fs.Connect();
       
   578 	TEST(ret==KErrNone);	
       
   579 	CleanupClosePushL(fs);
       
   580 	ret = fs.ShareProtected();		
       
   581 	TEST(ret==KErrNone);	
       
   582 	ret = file.Open(fs, KFileName, EFileRead|EFileShareAny); //open for read
       
   583 	TEST(ret==KErrNone);
       
   584 	CleanupClosePushL(file);
       
   585 	if(ret == KErrNone)		
       
   586 		{
       
   587 		CApaCommandLine* cmdLine=CApaCommandLine::NewLC();
       
   588 		ret = process.Create(KExeName, KNullDesC);
       
   589 		CleanupClosePushL(process);
       
   590 		TEST(ret==KErrNone);
       
   591 		if(ret==KErrNone)
       
   592 			{
       
   593 			TRAP(ret,cmdLine->SetFileByHandleL(file));
       
   594 			TEST(ret==KErrNone);
       
   595 			if(ret==KErrNone)
       
   596 				{
       
   597 				TRAP(ret,cmdLine->SetProcessEnvironmentL(process));	
       
   598 				TEST(ret==KErrNone);
       
   599 				if(ret==KErrNone)
       
   600 					{
       
   601 					status = KRequestPending;
       
   602 					process.Logon(status);
       
   603 					process.Resume();
       
   604 					User::WaitForRequest(status); 	
       
   605 					}
       
   606 				TEST(status.Int()==KFileHandleTestPassed);
       
   607 				}
       
   608 			}	
       
   609 		
       
   610 		CleanupStack::PopAndDestroy(&process);
       
   611 		CleanupStack::PopAndDestroy(cmdLine);
       
   612 		}
       
   613 	CleanupStack::PopAndDestroy(2);
       
   614 	TEST(ret==KErrNone);	
       
   615 	}
       
   616 
       
   617 
       
   618 	
       
   619 CT_CmdlnStep::~CT_CmdlnStep()
       
   620 /**
       
   621    Destructor
       
   622  */
       
   623 	{
       
   624 	}
       
   625 
       
   626 CT_CmdlnStep::CT_CmdlnStep()
       
   627 /**
       
   628    Constructor
       
   629  */
       
   630 	{
       
   631 	// Call base class method to set up the human readable name for logging
       
   632 	SetTestStepName(KT_CmdlnStep);
       
   633 	}
       
   634 
       
   635 TVerdict CT_CmdlnStep::doTestStepPreambleL()
       
   636 /**
       
   637    @return - TVerdict code
       
   638    Override of base class virtual
       
   639  */
       
   640 	{
       
   641 	SetTestStepResult(EPass);
       
   642 	return TestStepResult();
       
   643 	}
       
   644 
       
   645 TVerdict CT_CmdlnStep::doTestStepPostambleL()
       
   646 /**
       
   647    @return - TVerdict code
       
   648    Override of base class virtual
       
   649  */
       
   650 	{
       
   651 	return TestStepResult();
       
   652 	}
       
   653 
       
   654 
       
   655 // need to also test CApaCommandLine - SetServerNotRequiredL/SetServerRequiredL/ServerRequired
       
   656 
       
   657 TVerdict CT_CmdlnStep::doTestStepL()
       
   658 /**
       
   659    @return - TVerdict code
       
   660    Override of base class virtual
       
   661  */
       
   662 {
       
   663 	INFO_PRINTF1(_L("Test setting full command lines"));
       
   664 
       
   665 	// run the testcode (inside an alloc heaven harness)
       
   666 
       
   667 	__UHEAP_MARK;
       
   668 	TRAPD(ret,testSecureCmdLinesL());
       
   669 	TEST(ret==KErrNone);
       
   670 
       
   671 	TRAP(ret,testCmdLinesAPIsL());
       
   672 	TEST(ret==KErrNone);
       
   673 	__UHEAP_MARKEND;
       
   674 
       
   675 	INFO_PRINTF1(_L("Test completed!"));
       
   676 	return TestStepResult();
       
   677 }