appfw/apparchitecture/tef/tssaac/SysStartApparcTestCases.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     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 // REQ3889 is essentially a change to the boot sequence and not a change to the functionality of apparc,
       
    15 // i.e. once the system has finished startup the functional behaviour should not have changed, which will
       
    16 // be proved with execution of the existing App-Framework test suite.
       
    17 // The test cases implemented below are executed during the Critical Static phase of startup to prove the
       
    18 // restricted functionality during this phase is correct. All calls to the API will panic except the call
       
    19 // to RApaLsSession::StartApp which has been modified not to panic.
       
    20 // Note that some of the tests cases used in this test are later executed during the normal
       
    21 // phone operation phase (non-critical phase) by other tests (see T_StartAppStep.cpp, T_RapaLsSession.cpp, ...)
       
    22 // As nearly all these test cases panic at the first client-server call and so execution of these test cases
       
    23 // will never reach the end of the function.
       
    24 // 
       
    25 // sysstartapparctestcases.cpp
       
    26 //
       
    27 
       
    28 /**
       
    29  @file sysstartapparctestcases.cpp
       
    30  @test
       
    31  @internalComponent - Internal Symbian test code
       
    32 */
       
    33 
       
    34 #include <apacmdln.h>
       
    35 #include <s32file.h>
       
    36 
       
    37 #include "appfwk_test_appui.h"
       
    38 #include "T_SysStartApparcStep.h"
       
    39 #include "SysStartApparcTestCases.h"
       
    40 #include "TRApaLsSessionStartAppTest.h"
       
    41 #include "TRApaLsSessionTestUids.h"
       
    42 #include "tstapp.h"
       
    43 #include "tssaac.h"
       
    44 
       
    45 _LIT(KNonExistingFile, "z:\\system\\data\\not_here_thanks.foo");
       
    46 _LIT(KLitExePath, "\\sys\\bin\\texe.exe");
       
    47 
       
    48 
       
    49 /**
       
    50    Constructor
       
    51  */
       
    52 CSysStartApparcTestCase::CSysStartApparcTestCase()
       
    53 	{
       
    54 	}
       
    55 
       
    56 /**
       
    57    Destructor
       
    58  */
       
    59 CSysStartApparcTestCase::~CSysStartApparcTestCase()
       
    60 	{
       
    61 	iApaLsSession.Close();
       
    62 	}
       
    63 
       
    64 /**
       
    65 Connect to the Apparc server and call RunTestCasesL() inside a
       
    66 trap harness. Panic if an error is returned
       
    67 */
       
    68 void CSysStartApparcTestCase::doTestCasesL()
       
    69 	{
       
    70 	RDebug::Print(_L("CSysStartApparcTestCase: Test Cases Running..."));
       
    71 
       
    72 	TInt error = iApaLsSession.Connect();
       
    73 	if(error!=KErrNone)
       
    74 		{
       
    75 		RDebug::Print(_L("CSysStartApparcTestCase: Error connecting to RApaLsSession (err=%d)"), error);
       
    76 		}
       
    77 
       
    78 	TRAP(error,RunTestCasesL())
       
    79 	if(error!=KErrNone)
       
    80 		{
       
    81 		RDebug::Print(_L("CSysStartApparcTestCase: Error running test cases (err=%d)"), error);
       
    82 		}
       
    83 
       
    84 	RDebug::Print(_L("CSysStartApparcTestCase: Test Cases Completed!"));
       
    85 	}
       
    86 
       
    87 /**
       
    88 Call each test case inside a trap harness and panic if an error is returned.
       
    89 The Panic will be raised in doTestCasesL() function.
       
    90 The Use __UHEAP macros to test for memory leaks.
       
    91 Reads in the test case number from file TestCaseConfig.txt
       
    92 Each test case is assigned a unique number in the batch file sysstart_apparc_run.bat
       
    93 */
       
    94 void CSysStartApparcTestCase::RunTestCasesL()
       
    95 	{
       
    96 	__UHEAP_MARK;
       
    97 
       
    98 	TInt aTestCase=ReadConfigFileL();
       
    99 
       
   100 	switch(aTestCase)
       
   101 		{
       
   102 		case 1:
       
   103 			TestStartApp1L();
       
   104 			WriteResultFileL(); //Called if the test case does not panic
       
   105 			break;
       
   106 
       
   107 		case 2:
       
   108 			TestStartApp2L();
       
   109 			break;
       
   110 
       
   111 		case 3:
       
   112 			TestStartApp3L();
       
   113 			break;
       
   114 
       
   115 		case 4:
       
   116 			TestStartApp4L();
       
   117 			break;
       
   118 
       
   119 		case 5:
       
   120 			TestStartApp5L();
       
   121 			break;
       
   122 
       
   123 		case 6:
       
   124 			TestStartApp6L();
       
   125 			break;
       
   126 
       
   127 		case 7:
       
   128 			TestGetAllApps();
       
   129 			break;
       
   130 
       
   131 		case 8:
       
   132 			TestInsertDataTypeL();
       
   133 			break;
       
   134 
       
   135 		case 9:
       
   136 			TestAppForDataTypeL();
       
   137 			break;
       
   138 
       
   139 		case 10:
       
   140 			TestDeleteDataTypeL();
       
   141 			break;
       
   142 
       
   143 		case 11:
       
   144 			TestServiceDiscovery();
       
   145 			break;
       
   146 
       
   147 		case 12:
       
   148 			TestGetAppInfo();
       
   149 			break;
       
   150 
       
   151 		case 13:
       
   152 			TestAppCount();
       
   153 			break;
       
   154 
       
   155 		case 14:
       
   156 			TestCreateDoc();
       
   157 			break;
       
   158 
       
   159 		case 29:
       
   160 		case 0:
       
   161 		default:
       
   162 			RDebug::Print(_L("CSysStartApparcTestCase: Unknown Test Case Specified"));
       
   163 			break;
       
   164 		}
       
   165 
       
   166 	__UHEAP_MARKEND;
       
   167 	}
       
   168 
       
   169 
       
   170 /**
       
   171    @SYMTestCaseID          APPFWK-APPARC-I-0001
       
   172 
       
   173    @SYMPREQ                PREQ967
       
   174 
       
   175    @SYMREQ                 REQ3889
       
   176 
       
   177    @SYMTestCaseDesc        Test Launching of an application using command line information.
       
   178                            Test is run during SSA Critical Static phase,
       
   179 
       
   180    @SYMTestPriority        High
       
   181 
       
   182    @SYMTestStatus          Implemented
       
   183 
       
   184    @SYMTestActions         Call RApaLsSession::StartApp() to start an application defined by the command
       
   185    						   line information. Test the launching of application for following scenarios:
       
   186                            (1) When Application specified by command line exists.
       
   187                            (2) When Application specified by command line does not exist.
       
   188                            API Calls:\n
       
   189 						   RApaLsSession::StartApp(const CApaCommandLine& aCommandLine)
       
   190 
       
   191    @SYMTestExpectedResults (1) StartApp() returns KErrNone
       
   192                            (2) StartApp() returns KErrNotFound
       
   193 */
       
   194 void CSysStartApparcTestCase::TestStartApp1L()
       
   195 	{
       
   196 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::StartApp using CApaCommandLine....."));
       
   197 
       
   198 	// Set filename location
       
   199 	TPtrC apparcTestFilename(KLitExePath);
       
   200 
       
   201 	// (1) start application texe.exe from the commandline
       
   202 	CApaCommandLine* cmdLn=CApaCommandLine::NewLC();
       
   203 	cmdLn->SetExecutableNameL(apparcTestFilename);
       
   204 	_LIT8(KLitDogfish,"dogfish");
       
   205 	cmdLn->SetTailEndL(KLitDogfish);
       
   206 	iStartApp1LRes1 = iApaLsSession.StartApp(*cmdLn); // explicit
       
   207 
       
   208 	if(iStartApp1LRes1 == KErrNone)
       
   209 		{
       
   210 		RDebug::Print(_L("CSysStartApparcTestCase: TestStartApp1L Launch of Command line app successful"));
       
   211 		}
       
   212 
       
   213 	// (2) start a non-existant app
       
   214 	_LIT(KLitWibble,"wibble");
       
   215 	cmdLn->SetExecutableNameL(KLitWibble);
       
   216 	iStartApp1LRes2 = iApaLsSession.StartApp(*cmdLn);
       
   217 	if(iStartApp1LRes2 == KErrNotFound)
       
   218 		{
       
   219 		RDebug::Print(_L("CSysStartApparcTestCase: TestStartApp1L Launch of non-existant app returns KErrNotFound"));
       
   220 		}
       
   221 
       
   222 	CleanupStack::PopAndDestroy(cmdLn); // cmdLn
       
   223 	}
       
   224 
       
   225 /**
       
   226    @SYMTestCaseID          APPFWK-APPARC-0002
       
   227 
       
   228    @SYMPREQ                PREQ967
       
   229 
       
   230    @SYMREQ                 REQ3889
       
   231 
       
   232    @SYMTestCaseDesc        Get the MIME type of the data in the specified document and return the UID of an
       
   233    						   application that can handle this type.
       
   234 
       
   235    @SYMTestPriority        High
       
   236 
       
   237    @SYMTestStatus          Implemented
       
   238 
       
   239    @SYMTestActions         Call RApaLsSession::AppForDocument() to return the UID of an application that can
       
   240    						   read/display the specified file. The Apparc server is not ready in CS phase, so the
       
   241    						   call has to fail.
       
   242                            API Calls:\n
       
   243 						   RApaLsSession::AppForDocument(const TDesC& aFileName, TUid& aAppUid, TDataType& aDataType) const
       
   244 
       
   245    @SYMTestExpectedResults AppForDocument() causes Main Panic KERN-EXEC 0
       
   246 */
       
   247 void CSysStartApparcTestCase::TestStartApp2L()
       
   248 	{
       
   249 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::AppForDocument using filename and app uid...."));
       
   250 
       
   251 	TUid retUid = KNullUid;
       
   252 
       
   253 	TDataType data;
       
   254 
       
   255 	// Set filename location
       
   256 	TPtrC apparcTestFilename(KLitTRApaLsSessionStartAppTest);
       
   257 
       
   258 	// Main Panic KERN-EXEC 0
       
   259 	iApaLsSession.AppForDocument(apparcTestFilename, retUid, data);
       
   260 
       
   261 	}
       
   262 
       
   263 /**
       
   264    @SYMTestCaseID          APPFWK-APPARC-0003
       
   265 
       
   266    @SYMPREQ                PREQ967
       
   267 
       
   268    @SYMREQ                 REQ3889
       
   269 
       
   270    @SYMTestCaseDesc        Finds and launches an application to match the specified document.
       
   271 
       
   272    @SYMTestPriority        High
       
   273 
       
   274    @SYMTestStatus          Implemented
       
   275 
       
   276    @SYMTestActions         Call RApaLsSession::StartDocument() with a document name
       
   277                            API Calls:\n
       
   278 						   RApaLsSession::StartDocument(const TDesC& aFileName, TThreadId& aThreadId, TLaunchType aLaunchType)
       
   279 
       
   280    @SYMTestExpectedResults StartDocument() causes Main Panic KERN-EXEC 0
       
   281 */
       
   282 void CSysStartApparcTestCase::TestStartApp3L()
       
   283 	{
       
   284 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::StartDocument....start the app from the recognized doc given."));
       
   285 
       
   286 	// Set filename location
       
   287 	TPtrC apparcTestFilename(KLitTRApaLsSessionStartAppTest);
       
   288 
       
   289 	//Call to tested function - for info, startAppThreadID is assigned to the app thread id
       
   290   	TThreadId startAppThreadID;
       
   291 
       
   292 	//Main Panic KERN-EXEC 0
       
   293 	iApaLsSession.StartDocument(apparcTestFilename, startAppThreadID);
       
   294 	}
       
   295 
       
   296 
       
   297 /**
       
   298    @SYMTestCaseID          APPFWK-APPARC-0004
       
   299 
       
   300    @SYMPREQ                PREQ967
       
   301 
       
   302    @SYMREQ                 REQ3889
       
   303 
       
   304    @SYMTestCaseDesc        Launches an application to suit the specified document by means of a specified MIME type
       
   305 
       
   306    @SYMTestPriority        High
       
   307 
       
   308    @SYMTestStatus          Implemented
       
   309 
       
   310    @SYMTestActions         Call RApaLsSession::StartDocument() with filename and MIME type.
       
   311                            API Calls:\n
       
   312 						   RApaLsSession::StartDocument(const TDesC& aFileName, const TDataType& aDataType, TThreadId& aThreadId, TLaunchType aLaunchType)
       
   313 
       
   314    @SYMTestExpectedResults StartDocument() causes Main Panic KERN-EXEC 0
       
   315 */
       
   316 void CSysStartApparcTestCase::TestStartApp4L()
       
   317 	{
       
   318 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::StartDocument....known data type"));
       
   319 
       
   320 	// Set filename location
       
   321 	TPtrC apparcTestFilename(KLitTRApaLsSessionStartAppTest);
       
   322 
       
   323 	// KErrNotFound as a return value
       
   324 	TThreadId startAppThreadID;
       
   325 
       
   326 	//Main Panic KERN-EXEC 0
       
   327 	iApaLsSession.StartDocument(apparcTestFilename, TDataType(KLitMimeType_TRApaLsSessionStartAppTest), startAppThreadID);
       
   328 	}
       
   329 
       
   330 
       
   331 /**
       
   332    @SYMTestCaseID          APPFWK-APPARC-0005
       
   333 
       
   334    @SYMPREQ                PREQ967
       
   335 
       
   336    @SYMREQ                 REQ3889
       
   337 
       
   338    @SYMTestCaseDesc        Attempt to launch an application by means of an unknown MIME type
       
   339 
       
   340    @SYMTestPriority        High
       
   341 
       
   342    @SYMTestStatus          Implemented
       
   343 
       
   344    @SYMTestActions         Call RApaLsSession::StartDocument() with filename and unknown MIME type.
       
   345                            API Calls:\n
       
   346 						   RApaLsSession::StartDocument(const TDesC& aFileName, const TDataType& aDataType, TThreadId& aThreadId, TLaunchType aLaunchType)
       
   347 
       
   348    @SYMTestExpectedResults StartDocument() causes Main Panic KERN-EXEC 0
       
   349 */
       
   350 void CSysStartApparcTestCase::TestStartApp5L()
       
   351 	{
       
   352 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::StartDocument....unknown data type"));
       
   353 
       
   354 	// Set filename location
       
   355 	TPtrC apparcTestFilename(KLitTRApaLsSessionStartAppTest);
       
   356 
       
   357 	// KErrNotFound as a return value
       
   358 	TThreadId startAppThreadID;
       
   359 
       
   360 	//Main Panic KERN-EXEC 0
       
   361 	iApaLsSession.StartDocument(apparcTestFilename, TDataType(_L8("text/plain/no thanks")), startAppThreadID);
       
   362 	}
       
   363 
       
   364 /**
       
   365    @SYMTestCaseID          APPFWK-APPARC-0006
       
   366 
       
   367    @SYMPREQ                PREQ967
       
   368 
       
   369    @SYMREQ                 REQ3889
       
   370 
       
   371    @SYMTestCaseDesc        Attempt to launch an application by specifying a non-existent file
       
   372 
       
   373    @SYMTestPriority        High
       
   374 
       
   375    @SYMTestStatus          Implemented
       
   376 
       
   377    @SYMTestActions         Call RApaLsSession::StartDocument() with a non-existent file
       
   378                            API Calls:\n
       
   379 						   RApaLsSession::StartDocument(const TDesC& aFileName, TThreadId& aThreadId, TLaunchType aLaunchType)
       
   380 
       
   381    @SYMTestExpectedResults StartDocument() causes Main Panic KERN-EXEC 0
       
   382 */
       
   383 void CSysStartApparcTestCase::TestStartApp6L()
       
   384 	{
       
   385 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::StartDocument....non existent file."));
       
   386 
       
   387 	// Set filename location
       
   388 	TPtrC apparcTestFilename(KNonExistingFile);
       
   389 
       
   390 	// KErrNotFound as a return value
       
   391 	TThreadId startAppThreadID;
       
   392 
       
   393 	//Main Panic KERN-EXEC 0
       
   394 	iApaLsSession.StartDocument(apparcTestFilename, startAppThreadID);
       
   395 	}
       
   396 
       
   397 /**
       
   398    @SYMTestCaseID          APPFWK-APPARC-0007
       
   399 
       
   400    @SYMPREQ                PREQ967
       
   401 
       
   402    @SYMREQ                 REQ3889
       
   403 
       
   404    @SYMTestCaseDesc        Test the functionality of GetAllApps
       
   405 
       
   406    @SYMTestPriority        High
       
   407 
       
   408    @SYMTestStatus          Implemented
       
   409 
       
   410    @SYMTestActions         Call RApaLsSession::GetAllApps()
       
   411 
       
   412    @SYMTestExpectedResults GetAllApps() causes Main Panic KERN-EXEC 0
       
   413 
       
   414 */
       
   415 void CSysStartApparcTestCase::TestGetAllApps()
       
   416 	{
       
   417 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::GetAllApps....check list of apps"));
       
   418 
       
   419 	// Main Panic KERN-EXEC 0
       
   420 	iApaLsSession.GetAllApps();
       
   421 
       
   422 	}
       
   423 
       
   424 /**
       
   425    @SYMTestCaseID          APPFWK-APPARC-0008
       
   426 
       
   427    @SYMPREQ                PREQ967
       
   428 
       
   429    @SYMREQ                 REQ3889
       
   430 
       
   431    @SYMTestCaseDesc        Tests InsertDataMapping() which links a datatype to the UID of an associated application
       
   432    						   for launching assigns adds a low priority.
       
   433                            Tests InsertDataMappingIfHigher() which remaps the datatype to the specified UID if the
       
   434                            specified priority is higher.
       
   435                            The "added" parameter indicates if the mapping was successful.
       
   436 
       
   437    @SYMTestPriority        High
       
   438 
       
   439    @SYMTestStatus          Implemented
       
   440 
       
   441    @SYMTestActions         Call RApaLsSession::InsertDataMapping() with datatype, application UID and low priority
       
   442                            API Calls:\n
       
   443 						   RApaLsSession::InsertDataMapping(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid)
       
   444 
       
   445    @SYMTestExpectedResults InsertDataMapping() causes Main Panic KERN-EXEC 0
       
   446 */
       
   447 void CSysStartApparcTestCase::TestInsertDataTypeL()
       
   448 	{
       
   449 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::InsertDataMapping....Check data type mapping addition"));
       
   450 	const TDataTypePriority KPriLow = 1;
       
   451 
       
   452 	_LIT8(KLitPlainText,"text/plain");
       
   453 
       
   454 	TSecurityInfo info;
       
   455 	info.Set(RProcess());
       
   456 
       
   457 	//Main Panic KERN-EXEC 0
       
   458 	iApaLsSession.InsertDataMapping(TDataType(KLitPlainText), KPriLow, KUidTestApp);
       
   459 
       
   460 	}
       
   461 
       
   462 /**
       
   463    @SYMTestCaseID          APPFWK-APPARC-0009
       
   464 
       
   465    @SYMPREQ                PREQ967
       
   466 
       
   467    @SYMREQ                 REQ3889
       
   468 
       
   469    @SYMTestCaseDesc        Tests AppForDataType() which returns the UID of an application which can handle the specified datatype
       
   470 
       
   471    @SYMTestPriority        High
       
   472 
       
   473    @SYMTestStatus          Implemented
       
   474 
       
   475    @SYMTestActions         Call RApaLsSession::InsertDataMapping() with datatype and application UID (and priority)
       
   476                            API Calls:\n
       
   477 						   RApaLsSession::InsertDataMapping(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid)
       
   478 
       
   479    @SYMTestExpectedResults AppForDataType() causes Main Panic KERN-EXEC 0
       
   480 */
       
   481 void CSysStartApparcTestCase::TestAppForDataTypeL()
       
   482 	{
       
   483 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::AppForDataType....Check an app binding"));
       
   484 
       
   485 	_LIT8(KLitPlainText,"text/plain");
       
   486 
       
   487 	TUid retUid = KNullUid;
       
   488 
       
   489 	//Main Panic KERN-EXEC 0
       
   490 	iApaLsSession.AppForDataType(TDataType(KLitPlainText), retUid);
       
   491 
       
   492 	}
       
   493 
       
   494 
       
   495 /**
       
   496    @SYMTestCaseID          APPFWK-APPARC-0010
       
   497 
       
   498    @SYMPREQ                PREQ967
       
   499 
       
   500    @SYMREQ                 REQ3889
       
   501 
       
   502    @SYMTestCaseDesc        Tests DeleteDataMapping() which removes the linking of a datatype to the UID of an associated application
       
   503 
       
   504    @SYMTestPriority        High
       
   505 
       
   506    @SYMTestStatus          Implemented
       
   507 
       
   508    @SYMTestActions         Call RApaLsSession::DeleteDataMapping() with datatype and service UID
       
   509                            API Calls:\n
       
   510 						   RApaLsSession::DeleteDataMapping(const TDataType& aDataType, TUid aServiceUid)
       
   511 
       
   512    @SYMTestExpectedResults DeleteDataMapping() causes Main Panic KERN-EXEC 0
       
   513 */
       
   514 void CSysStartApparcTestCase::TestDeleteDataTypeL()
       
   515 	{
       
   516 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion"));
       
   517 
       
   518 	_LIT8(KLitPlainText,"text/plain");
       
   519 
       
   520 	TSecurityInfo info;
       
   521 	info.Set(RProcess());
       
   522 
       
   523 	//Main Panic KERN-EXEC 0
       
   524 	iApaLsSession.DeleteDataMapping(TDataType(KLitPlainText));
       
   525  	}
       
   526 
       
   527 
       
   528 /**
       
   529    @SYMTestCaseID          APPFWK-APPARC-0011
       
   530 
       
   531    @SYMPREQ                PREQ967
       
   532 
       
   533    @SYMREQ                 REQ3889
       
   534 
       
   535    @SYMTestCaseDesc        Test the functionality of GetServerApps with the service uid as parameter.
       
   536 
       
   537    @SYMTestPriority        High
       
   538 
       
   539    @SYMTestStatus          Implemented
       
   540 
       
   541    @SYMTestActions         Call RApaLsSession::GetServerApps() with a service uid that
       
   542    						   is not provided by any application
       
   543                            API Calls:\n
       
   544 						   RApaLsSession::GetServerApps(TUid aServiceUid) const
       
   545 
       
   546    @SYMTestExpectedResults GetServerApps() causes Main Panic KERN-EXEC 0
       
   547 
       
   548 */
       
   549 void CSysStartApparcTestCase::TestServiceDiscovery()
       
   550 	{
       
   551 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::GetServerApps....check the service uid"));
       
   552 
       
   553 	TApaAppInfo appInfo;
       
   554 
       
   555 	// Uid is not provided by any application
       
   556 	const TUid KUidNonProvidedService = {0x01020300}; // service Uid
       
   557 
       
   558 	//Main Panic KERN-EXEC 0
       
   559 	iApaLsSession.GetServerApps(KUidNonProvidedService);
       
   560 
       
   561 	}
       
   562 
       
   563 
       
   564 /**
       
   565    @SYMTestCaseID          APPFWK-APPARC-0012
       
   566 
       
   567    @SYMPREQ                PREQ967
       
   568 
       
   569    @SYMREQ                 REQ3889
       
   570 
       
   571    @SYMTestCaseDesc        Test the functionality of GetAppInfo with a Uid as a parameter
       
   572 
       
   573    @SYMTestPriority        High
       
   574 
       
   575    @SYMTestStatus          Implemented
       
   576 
       
   577    @SYMTestActions         Call RApaLsSession::GetAppInfo() with a Uid that
       
   578    						   represents a non-existing app
       
   579 
       
   580                            API Calls:\n
       
   581 						   RApaLsSession::GetAppInfo(TApaAppInfo& aInfo,TUid aAppUid) const
       
   582 
       
   583    @SYMTestExpectedResults GetAppInfo() causes Main Panic KERN-EXEC 0
       
   584 
       
   585 */
       
   586 void CSysStartApparcTestCase::TestGetAppInfo()
       
   587 	{
       
   588 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::GetAppInfo....check the app uid"));
       
   589 
       
   590 	TApaAppInfo info;
       
   591 
       
   592 	// non-existing app  causes Main Panic KERN-EXEC 0
       
   593 	iApaLsSession.GetAppInfo(info, KNullUid);
       
   594 
       
   595 	}
       
   596 
       
   597 
       
   598 /**
       
   599    @SYMTestCaseID          APPFWK-APPARC-0013
       
   600 
       
   601    @SYMPREQ                PREQ967
       
   602 
       
   603    @SYMREQ                 REQ3889
       
   604 
       
   605    @SYMTestCaseDesc        Test the functionality of AppCount
       
   606 
       
   607    @SYMTestPriority        High
       
   608 
       
   609    @SYMTestStatus          Implemented
       
   610 
       
   611    @SYMTestActions         Call RApaLsSession::AppCount()
       
   612 
       
   613 
       
   614    @SYMTestExpectedResults AppCount() causes Main Panic KERN-EXEC 0
       
   615 
       
   616 */
       
   617 void CSysStartApparcTestCase::TestAppCount()
       
   618 	{
       
   619 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::AppCount()....check list of apps"));
       
   620 
       
   621 	TInt dummyArg;
       
   622 
       
   623 	// Main Panic KERN-EXEC 0
       
   624 	iApaLsSession.AppCount(dummyArg);
       
   625 
       
   626 	}
       
   627 
       
   628 
       
   629 /**
       
   630    @SYMTestCaseID           APPFWK-APPARC-0014
       
   631 
       
   632    @SYMPREQ                 PREQ967
       
   633 
       
   634    @SYMREQ                  REQ3889
       
   635 
       
   636    @SYMTestCaseDesc         Test the functionality of CreateDocument with a Uid as a parameter
       
   637 
       
   638    @SYMTestPriority         High
       
   639 
       
   640    @SYMTestStatus           Implemented
       
   641 
       
   642    @SYMTestActions          Call RApaLsSession::CreateDocument() with a Uid of an application
       
   643    						    When Application specified exists.
       
   644 
       
   645                             API Calls:\n
       
   646 						    RApaLsSession::CreateDocument(const TDesC& aFileName, TUid aAppUid, TThreadId& aThreadId, TLaunchType aLaunchType)
       
   647 
       
   648    @SYMTestExpectedResults (1) GetAppInfo() causes Main Panic KERN-EXEC 0
       
   649 
       
   650 */
       
   651 void CSysStartApparcTestCase::TestCreateDoc()
       
   652 	{
       
   653 	RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::CreateDocument....check the app uid"));
       
   654 
       
   655 	// Set filename location
       
   656 	TPtrC apparcTestFilename(KLitTRApaLsSessionStartAppTest);
       
   657 
       
   658   	TThreadId startAppThreadID;
       
   659 
       
   660 	//Call to tested function with a existing uid (tstapp)  causes Main Panic KERN-EXEC 0
       
   661 	iApaLsSession.CreateDocument(apparcTestFilename, KUidTestApp, startAppThreadID);
       
   662 	}
       
   663 
       
   664 /**
       
   665 Reads the input config file created by sysstart_apparc_setup.bat and returns the
       
   666 test case number (Defined in sysstart_apparc_run.bat)
       
   667 @return TInt - the test case number
       
   668 */
       
   669 TInt CSysStartApparcTestCase::ReadConfigFileL()
       
   670 	{
       
   671 	RFs	fs;
       
   672  	User::LeaveIfError(fs.Connect());
       
   673  	CleanupClosePushL(fs);
       
   674 
       
   675  	RFileReadStream reader;
       
   676 	User::LeaveIfError(reader.Open(fs, KApparcConfigFile, EFileRead));
       
   677 	CleanupClosePushL(reader);
       
   678 
       
   679 	TChar delimChar('=');
       
   680 
       
   681 	TBuf8<255> aDes;
       
   682 	reader.ReadL(aDes, delimChar);
       
   683 
       
   684 	//Read in a two character representation of a number and convert to an integer
       
   685 	TChar result1(reader.ReadInt8L());
       
   686 	TChar result0(reader.ReadInt8L());
       
   687 	TInt aTestCase = result1.GetNumericValue()*10 + result0.GetNumericValue();
       
   688 
       
   689 	// clean-up
       
   690 	CleanupStack::PopAndDestroy(2, &fs);
       
   691 
       
   692 	return aTestCase;
       
   693 
       
   694 	}
       
   695 
       
   696 /**
       
   697   Write the results to the result file, to be later extracted by
       
   698   testexecute test case.
       
   699   These contain the results of the individual tests. The order in
       
   700   which these results are written in MUST match the order in which
       
   701   they are read and tested in CSysStartApparcTestStep::GetApparcResultsL()
       
   702   and the expected result tested in CSysStartApparcTestStep::Testxxx must
       
   703   match that in the test specification\n
       
   704 
       
   705   The format is:
       
   706   StartApp1LRes1 count=value1
       
   707   StartApp1LRes2 count=value2
       
   708 
       
   709   '=' is used as the deliminator.
       
   710 */
       
   711 void CSysStartApparcTestCase::WriteResultFileL()
       
   712 	{
       
   713 	RFs	fs;
       
   714  	User::LeaveIfError(fs.Connect());
       
   715  	CleanupClosePushL(fs);
       
   716 
       
   717 	RFileWriteStream writer;
       
   718 	User::LeaveIfError(writer.Replace(fs, KSsaacResultFile, EFileWrite));
       
   719 	CleanupClosePushL(writer);
       
   720 
       
   721 	// write data to file
       
   722 	writer << _L("StartApp1LRes1 count=");
       
   723 	writer.WriteInt16L(iStartApp1LRes1);
       
   724 	writer << _L("\n");
       
   725 	writer << _L("StartApp1LRes2 count=");
       
   726 	writer.WriteInt16L(iStartApp1LRes2);
       
   727 	writer << _L("\n");
       
   728 
       
   729 	writer.CommitL();
       
   730 	CleanupStack::PopAndDestroy(2, &fs);
       
   731 	}