appfw/apparchitecture/tef/T_Serv2Step.CPP
changeset 0 2e3d3ce01487
child 29 6a787171e1de
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2007-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 // Test wrapper to Application Architecture Server.
       
    15 // Tests Application information, Data recognition and application
       
    16 // launching capabilities of the application architecture server.\n
       
    17 // 
       
    18 // t_serv2step.cpp
       
    19 //
       
    20 
       
    21 /**
       
    22  @file t_serv2step.cpp
       
    23  @test 
       
    24  @internalComponent - Internal Symbian test code
       
    25 */
       
    26 
       
    27 #include <f32file.h>
       
    28 #include <fbs.h>
       
    29 #include <apaid.h>
       
    30 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    31 #include <apaidpartner.h>
       
    32 #include <apgicnflpartner.h>
       
    33 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
    34 #include <apgaplst.h>
       
    35 #include <apaflrec.h>
       
    36 #include "testableapalssession.h"
       
    37 #include <apacmdln.h>
       
    38 #include <apfrec.h>
       
    39 #include <datastor.h>
       
    40 #include <apgicnfl.h>
       
    41 #include <apasvst.h>
       
    42 #include "tstapp.h"
       
    43 //
       
    44 #include <e32test.h>
       
    45 #include "T_Serv2Step.h"
       
    46 
       
    47 #include <coemain.h>
       
    48 #include <eikenv.h>
       
    49 #include "TAppEmbedUids.h"
       
    50 #include "appfwk_test_utils.h"
       
    51 
       
    52 // Constants
       
    53 const TInt KOneSecondDelay = 1000000;
       
    54 
       
    55 
       
    56 /**
       
    57   This function accepts a filename with full path and searches all available
       
    58   drives for the presence of file.
       
    59   The method returns Filename if a match is found. 
       
    60 */
       
    61 TFileName CT_Serv2Step::SearchAndReturnCompleteFileName(const TDesC& aFileName)
       
    62 	{
       
    63 	RFs fs;
       
    64 	TInt ret = fs.Connect();
       
    65 	TEST(ret==KErrNone);
       
    66 
       
    67 	TParsePtrC parse(aFileName);
       
    68 	TFindFile findFile(fs);
       
    69 	ret = findFile.FindByDir(parse.NameAndExt(), parse.Path());
       
    70 	if (ret!=KErrNone)
       
    71 		{
       
    72 		TBuf<64> buffer;
       
    73 		buffer.Format(_L("Error while finding the file, %d"), ret);
       
    74 		}
       
    75 	fs.Close();
       
    76 	return findFile.File();
       
    77 	}
       
    78 
       
    79 
       
    80 /**
       
    81   @SYMTestCaseID T-Serv2Step-AppInfoTest1
       
    82   
       
    83   @SYMPREQ
       
    84   
       
    85   @SYMTestCaseDesc Test RApaLsSession::GetNextApp() 
       
    86   
       
    87   @SYMTestPriority High 
       
    88   
       
    89   @SYMTestStatus Implemented
       
    90   
       
    91   @SYMTestActions Call RApaLsSession::GetAllApps() to initialize the process of
       
    92   getting all applications in the cached list. Traverse the application list
       
    93   by calling RApaLsSession::GetNextApp() to search for application tstapp.
       
    94   Test the application info obtained from GetNextApp() to ensure the application
       
    95   info obtained is of tstapp. Complete traversal of the list to ensure that at
       
    96   the end of the list, the enum ENoMoreAppInList is returned by GetNextApp().\n
       
    97   API Calls:\n	
       
    98   RApaLsSession::GetAllApps() const\n
       
    99   RApaLsSession::GetNextApp(TApaAppInfo& aInfo) const\n
       
   100   
       
   101   @SYMTestExpectedResults The test compares the results obtained with expected values.
       
   102    
       
   103  */
       
   104 void CT_Serv2Step::AppInfoTest1(RApaLsSession& aLs)
       
   105 	{
       
   106 	_LIT(KLitAppPath,"z:\\sys\\bin\\tstapp.exe");
       
   107 	TFullName appPath(KLitAppPath);
       
   108 	//Search for TestApp
       
   109 	TApaAppInfo info;
       
   110 	TInt ret = aLs.GetAllApps();
       
   111 	TEST(ret==KErrNone);
       
   112 	
       
   113 	do
       
   114 		{
       
   115 		ret=aLs.GetNextApp(info);
       
   116 		} 
       
   117 		while (ret==KErrNone && info.iUid!=KUidTestApp);
       
   118 	
       
   119 	TEST(ret==KErrNone);
       
   120 	info.iFullName.LowerCase();	
       
   121 	TEST(info.iFullName.Compare(appPath) == 0);
       
   122 
       
   123 	//Make sure ENoMoreAppsInList is returned at the end of list.
       
   124 	do
       
   125 		{
       
   126  		ret=aLs.GetNextApp(info);
       
   127  		}
       
   128  		while (ret != RApaLsSession::ENoMoreAppsInList);
       
   129  
       
   130  	ret=aLs.GetNextApp(info);
       
   131  	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   132 	}
       
   133 
       
   134 
       
   135 /**
       
   136    @SYMTestCaseID T-Serv2Step-DoCheckServerIconLoadingBySizeL
       
   137   
       
   138    @SYMPREQ
       
   139   
       
   140    @SYMTestCaseDesc Test loading of Icon by size. 
       
   141    
       
   142    @SYMTestPriority High 
       
   143   
       
   144    @SYMTestStatus Implemented
       
   145    
       
   146    @SYMTestActions Allocate a flat dynamic buffer which would hold available icon
       
   147    sizes for tstapp. Call RApaLsSession::GetAppIconSizes() to store the sizes
       
   148    of icons available for the app tstapp to the allocated flat dynamic buffer.
       
   149    Call RApaLsSession::GetAppIcon() by passing each of the icon sizes stored.
       
   150    Verify whether icon is retrieved each time by GetAppIcon().
       
   151    Test calling RApaLsSession::GetAppIcon() by specifying reduced size than
       
   152    the actual icon size. Since no match would be found, KErrNotFound should be
       
   153    returned. Test GetAppIcon() again by specifying an increased size than the
       
   154    actual icon size. Observe whether the GetAppIcon() in this case gets the
       
   155    closest icon available.\n
       
   156    API Calls:\n	
       
   157    RApaLsSession::GetAppIcon(TUid aAppUid, TSize aSize, CApaMaskedBitmap& aAppBitmap) const\n
       
   158    
       
   159    @SYMTestExpectedResults The results obtained are compared with the expected values to verify
       
   160    functionality of RApaLsSession::GetAppIcon().
       
   161     
       
   162  */
       
   163 void CT_Serv2Step::DoCheckServerIconLoadingBySizeL(RApaLsSession& aLs)
       
   164 	{
       
   165 	CArrayFixFlat<TSize>* array=new(ELeave) CArrayFixFlat<TSize>(3);
       
   166 	CleanupStack::PushL(array);
       
   167 	TInt ret=KErrNone;
       
   168 	ret=aLs.GetAppIconSizes(KUidTestApp,*array);
       
   169 	if(ret==KErrNoMemory)
       
   170 		User::Leave(KErrNoMemory);
       
   171 	TEST(ret==KErrNone);
       
   172 	TEST(array->Count());
       
   173 	for(TInt i=0;i<array->Count();i++)
       
   174 		{
       
   175 		CApaMaskedBitmap* iconBySize=CApaMaskedBitmap::NewLC();
       
   176 		ret=aLs.GetAppIcon(KUidTestApp,(*array)[i],*iconBySize); //by Size
       
   177 		if(ret==KErrNoMemory)
       
   178 			User::Leave(KErrNoMemory);
       
   179 		TEST(ret==KErrNone);
       
   180 		TEST(iconBySize->SizeInPixels()==(*array)[i]);
       
   181 		CleanupStack::PopAndDestroy(); //iconBySize
       
   182 		}
       
   183 
       
   184 	// now try non exact sizes
       
   185 	CApaMaskedBitmap* iconBySize=CApaMaskedBitmap::NewLC();
       
   186 	ret=aLs.GetAppIcon(KUidTestApp,((*array)[0])+TSize(-5,-5),*iconBySize); //by Size
       
   187 	if(ret==KErrNoMemory)
       
   188 		User::Leave(KErrNoMemory);
       
   189 	TEST(ret==KErrNotFound);
       
   190 	CleanupStack::PopAndDestroy(); //iconBySize
       
   191 
       
   192 	for(TInt ii=0;ii<array->Count();ii++)
       
   193 		{
       
   194 		CApaMaskedBitmap* iconBySize=CApaMaskedBitmap::NewLC();
       
   195 		ret=aLs.GetAppIcon(KUidTestApp,((*array)[ii])+TSize(5,5),*iconBySize); //by Size
       
   196 		if(ret==KErrNoMemory)
       
   197 			User::Leave(KErrNoMemory);
       
   198 		TEST(ret==KErrNone);
       
   199 		TEST(iconBySize->SizeInPixels()==(*array)[ii]); // should get size below always!!!
       
   200 		CleanupStack::PopAndDestroy(); //iconBySize
       
   201 		}
       
   202 	CleanupStack::PopAndDestroy(); //array
       
   203 	}
       
   204 
       
   205 
       
   206 /**
       
   207    @SYMTestCaseID T-Serv2Step-AppInfoTest3
       
   208   
       
   209    @SYMPREQ
       
   210   
       
   211    @SYMTestCaseDesc Test RApaLsSession::GetNextApp() 
       
   212    
       
   213    @SYMTestPriority High 
       
   214   
       
   215    @SYMTestStatus Implemented
       
   216    
       
   217    @SYMTestActions Call RApaLsSession::GetAllApps() to initialize the process of
       
   218    getting all applications in the cached list. Traverse the application list
       
   219    by calling RApaLsSession::GetNextApp() to search for application tstapp.
       
   220    Test the application information obtained from GetNextApp() to ensure that
       
   221    information retrieved is of tstapp.\n
       
   222    API Calls:\n	
       
   223    RApaLsSession::GetAllApps() const\n
       
   224    RApaLsSession::GetNextApp(TApaAppInfo& aInfo) const\n
       
   225    
       
   226    @SYMTestExpectedResults The test compares the results obtained with expected values.
       
   227     
       
   228  */
       
   229 void CT_Serv2Step::AppInfoTest3(RApaLsSession& aLs)
       
   230 	{
       
   231 	_LIT(KLitAppPath,"z:\\sys\\bin\\tstapp.exe");
       
   232 	TFullName appPath(KLitAppPath);
       
   233 	// get the first app...
       
   234 	TApaAppInfo info;
       
   235 	TInt ret = aLs.GetAllApps();
       
   236 	TEST(ret==KErrNone);
       
   237 
       
   238 	do
       
   239 		{
       
   240 		aLs.GetNextApp(info);
       
   241 		}
       
   242 		while (info.iUid!=KUidTestApp);
       
   243 		
       
   244 	TEST(ret==KErrNone);
       
   245 	TEST(info.iUid==KUidTestApp);
       
   246 	info.iFullName.LowerCase();	
       
   247 	TEST(info.iFullName.Compare(appPath) == 0);
       
   248 	}
       
   249 
       
   250 
       
   251 /**
       
   252    @SYMTestCaseID T-Serv2Step-AppInfoTest4
       
   253   
       
   254    @SYMPREQ
       
   255   
       
   256    @SYMTestCaseDesc Test RApaLsSession::GetAppInfo(). 
       
   257    
       
   258    @SYMTestPriority High 
       
   259   
       
   260    @SYMTestStatus Implemented
       
   261    
       
   262    @SYMTestActions Call RApaLsSession::GetAppInfo() by passing the Uid of test
       
   263    application tstapp and test the application info obtained from GetAppInfo()
       
   264    to ensure the obtained information is of test application tstapp.\n
       
   265    API Calls:\n	
       
   266    RApaLsSession::GetAppInfo(TApaAppInfo& aInfo,TUid aAppUid) const\n
       
   267    
       
   268    @SYMTestExpectedResults The test confirms that RApaLsSession::GetAppInfo()
       
   269    returns the expected application info.
       
   270     
       
   271  */
       
   272 void CT_Serv2Step::AppInfoTest4(RApaLsSession& aLs)
       
   273 	{
       
   274 	_LIT(KLitAppPath,"z:\\sys\\bin\\tstapp.exe");
       
   275 	TFullName appPath(KLitAppPath);
       
   276 	// Get info for an app that exists
       
   277 	TApaAppInfo info;
       
   278 	TInt ret = aLs.GetAppInfo(info,KUidTestApp);
       
   279 	TEST(ret==KErrNone);
       
   280 	TEST(info.iUid==KUidTestApp);
       
   281 	info.iFullName.LowerCase();	
       
   282 	TEST(info.iFullName.Compare(appPath) == 0);
       
   283 	}
       
   284 	
       
   285 
       
   286 /**
       
   287    @SYMTestCaseID T-Serv2Step-AppInfoTest5
       
   288  
       
   289    @SYMPREQ
       
   290   
       
   291    @SYMTestCaseDesc Test if RApaLsSession::GetAppInfo() return KErrNotFound. 
       
   292    
       
   293    @SYMTestPriority High 
       
   294   
       
   295    @SYMTestStatus Implemented
       
   296    
       
   297    @SYMTestActions The method calls RApaLsSession::GetAppInfo() by passing the null Uid
       
   298    KNullUid. Observe whether KErrNotFound is returned when Uid that doesn't match
       
   299    is passed to GetAppInfo().\n
       
   300    API Calls:\n	
       
   301    RApaLsSession::GetAppInfo(TApaAppInfo& aInfo,TUid aAppUid) const\n
       
   302    
       
   303    @SYMTestExpectedResults The test confirms RApaLsSession::GetAppInfo() returns
       
   304    KErrNotFound when no match is found for the Uid passed.\n
       
   305     
       
   306  */
       
   307 void CT_Serv2Step::AppInfoTest5(RApaLsSession& aLs)
       
   308 	{
       
   309 	// get info for a non-existant app
       
   310 	TApaAppInfo info;
       
   311 	TInt ret = aLs.GetAppInfo(info,KNullUid);
       
   312 	TEST(ret==KErrNotFound);
       
   313 	}
       
   314 	
       
   315 
       
   316 /**
       
   317   Auxiliary Fn for Test Case ID T-Serv2Step-AppInfoTest1, T-Serv2Step-AppInfoTest3, T-Serv2Step-AppInfoTest4, T-Serv2Step-AppInfoTest5
       
   318  
       
   319   This function initiates test for retrieving Application Information.
       
   320  
       
   321 */
       
   322 void CT_Serv2Step::DoAppInfoTests(RApaLsSession& aLs)
       
   323 	{
       
   324 	AppInfoTest1(aLs);
       
   325 	AppInfoTest3(aLs);
       
   326 	AppInfoTest4(aLs);
       
   327 	AppInfoTest5(aLs);
       
   328 	}
       
   329 
       
   330 
       
   331 /**
       
   332    @SYMTestCaseID T-Serv2Step-StartAppTests1L
       
   333   
       
   334    @SYMPREQ
       
   335   
       
   336    @SYMTestCaseDesc Test Launching of an application. 
       
   337    
       
   338    @SYMTestPriority High 
       
   339   
       
   340    @SYMTestStatus Implemented
       
   341    
       
   342    @SYMTestActions Prepare command line information to start an application using
       
   343    CApaCommandLine Apis.Call RApaLsSession::StartApp() to start an
       
   344    application defined by the command line information.\n
       
   345    Test the launching of application for following scenarios:\n
       
   346    (1) When Application specified by command line exists.\n
       
   347    (2) When Application specified by command line does not exist.\n
       
   348    API Calls:\n	
       
   349    RApaLsSession::StartApp(const CApaCommandLine& aCommandLine)\n
       
   350    
       
   351    @SYMTestExpectedResults The test observes that StartApp() returns KErrNone and
       
   352    starts the app in the first scenario. In the second case KErrNotFound is
       
   353    returned.
       
   354     
       
   355  */	
       
   356 void CT_Serv2Step::StartAppTests1L(RApaLsSession& aLs)
       
   357 {
       
   358 	CApaCommandLine* cmdLn=CApaCommandLine::NewLC();
       
   359 	TFileName filename;
       
   360 	_LIT(KLitExePath,"\\sys\\bin\\texe.exe");
       
   361 	TFullName exePath(KLitExePath);
       
   362 	filename = SearchAndReturnCompleteFileName(exePath);
       
   363 	
       
   364 	_LIT8(KLitDogfish,"dogfish");
       
   365 	_LIT(KLitWibble,"wibble");
       
   366 	cmdLn->SetExecutableNameL(filename);
       
   367 	cmdLn->SetTailEndL(KLitDogfish);
       
   368 	
       
   369 	TThreadId Id;
       
   370 	TInt ret = aLs.StartApp(*cmdLn,Id); // explicit
       
   371 	TEST(ret==KErrNone);
       
   372 
       
   373 	//Wait till the thread exits
       
   374 	if (ret==KErrNone)	
       
   375 		{
       
   376 		RThread thread;
       
   377 		TRequestStatus status;
       
   378 		
       
   379 		User::LeaveIfError(thread.Open(Id));
       
   380 		thread.Rendezvous(status);
       
   381 		User::WaitForRequest(status);
       
   382 		thread.Close();
       
   383 		}
       
   384 
       
   385 	// start a non-existant app
       
   386 	cmdLn->SetExecutableNameL(KLitWibble);
       
   387 	ret = aLs.StartApp(*cmdLn);
       
   388 	TEST(ret==KErrNotFound);
       
   389 	//
       
   390 	//
       
   391 	CleanupStack::PopAndDestroy(); // cmdLn
       
   392 
       
   393 }
       
   394 
       
   395 
       
   396 /**
       
   397 * Auxiliary Fn for Test Case ID T_Serv2Step_StartAppTests1L, T_Serv2Step_StartAppTests3L
       
   398 *
       
   399 * This method tests launching of an application from command line by calling
       
   400 * CT_Serv2Step::StartAppTests1L().
       
   401 *
       
   402 */
       
   403 void CT_Serv2Step::DoStartAppTestsL(RApaLsSession& aLs)
       
   404 	{
       
   405 	INFO_PRINTF1(_L("Checking application launching"));
       
   406 
       
   407 	// start the test exe
       
   408 	StartAppTests1L(aLs);
       
   409 	}
       
   410 
       
   411 /**
       
   412    @SYMTestCaseID T-Serv2Step-DoEnquiryTestsL
       
   413   
       
   414    @SYMPREQ
       
   415   
       
   416    @SYMTestCaseDesc Tests querying of data (MIME) type information. 
       
   417    
       
   418    @SYMTestPriority High 
       
   419   
       
   420    @SYMTestStatus Implemented
       
   421    
       
   422    @SYMTestActions Test setting and getting the confidence threshold for
       
   423    successful data recognition by calling RApaLsSession::SetAcceptedConfidence()
       
   424    and RApaLsSession::GetAcceptedConfidence().\n
       
   425    Test setting and getting maximum size of the data that can be read
       
   426    from a file for the purpose of recognizing the data type by calling
       
   427    RApaLsSession::SetMaxDataBufSize() and RApaLsSession::GetMaxDataBufSize().
       
   428    Finally test retrieval of all supported data (MIME) types.\n
       
   429    API Calls:\n	
       
   430    RApaLsSession::SetAcceptedConfidence(TInt aConfidence)\n
       
   431    RApaLsSession::GetAcceptedConfidence(TInt& aConfidence) const\n
       
   432    RApaLsSession::SetMaxDataBufSize(TInt aBufSize)\n
       
   433    RApaLsSession::GetMaxDataBufSize(TInt& aBufSize) const\n
       
   434    RApaLsSession::GetSupportedDataTypesL(CDataTypeArray& aDataTypes) const\n
       
   435    
       
   436    @SYMTestExpectedResults Test results against expected values.
       
   437     
       
   438  */
       
   439 void CT_Serv2Step::DoEnquiryTestsL(RApaLsSession& aLs)
       
   440 	{
       
   441 	TInt temp=1234;
       
   442 	TInt ret;
       
   443 	TSecurityInfo info;
       
   444 	info.Set(RProcess());
       
   445 	
       
   446 	TBool hasCapability=info.iCaps.HasCapability(ECapabilityWriteDeviceData);
       
   447 	
       
   448 	if(hasCapability)
       
   449 		{
       
   450 		ret=aLs.SetAcceptedConfidence(temp);
       
   451 		INFO_PRINTF2(_L(" Error= %d \n"),ret);
       
   452 		TEST(ret==KErrNone);
       
   453 		}
       
   454 	else
       
   455 		{
       
   456 		ret=aLs.SetAcceptedConfidence(temp);
       
   457 		INFO_PRINTF2(_L(" Error= %d \n"),ret);
       
   458 		TEST(ret==KErrPermissionDenied);
       
   459 		}
       
   460 	temp=0;
       
   461 	ret=aLs.GetAcceptedConfidence(temp);
       
   462 	TEST(ret==KErrNone);
       
   463 	TEST(temp==1234);
       
   464 	ret=aLs.SetMaxDataBufSize(temp);
       
   465 	TEST(ret==KErrNone);
       
   466 	temp=0;
       
   467 	ret=aLs.GetMaxDataBufSize(temp);
       
   468 	CDataTypeArray* dataTypes=new(ELeave) CDataTypeArray(5);
       
   469 	CleanupStack::PushL(dataTypes);
       
   470 	TInt err=0;
       
   471 	TInt failRate=0;
       
   472 	for (failRate=1;failRate<=KMaxTInt;failRate++)
       
   473 		{
       
   474 		__UHEAP_RESET;
       
   475 		__UHEAP_SETFAIL(RHeap::EFailNext,failRate);
       
   476 		TRAP(err, ret=aLs.GetSupportedDataTypesL(*dataTypes));
       
   477 		if (err!=KErrNoMemory)
       
   478 			{
       
   479 		 	if (err==KErrNone)
       
   480 		 		{
       
   481 		 		err=ret;
       
   482 		 		}
       
   483 		 	break;
       
   484 		 	}
       
   485 		}
       
   486 	__UHEAP_RESET;
       
   487 	TEST(ret==KErrNone);
       
   488 	TEST(err==KErrNone);
       
   489 	TEST(dataTypes->Count()>=4);
       
   490 	CleanupStack::PopAndDestroy(); // dataTypes
       
   491 	}
       
   492 
       
   493 /**
       
   494    @SYMTestCaseID T-Serv2-DoGetAllApps
       
   495   
       
   496    @SYMPREQ PHAR-5Q4FX8
       
   497   
       
   498    @SYMTestCaseDesc
       
   499    Check that RApaLsSession::GetAllApps() hasn't been
       
   500    affected by the new code to filter the app list
       
   501    based on embeddability (implemented for CR PHAR-5Q4FX8)
       
   502   
       
   503    @SYMTestPriority High
       
   504   
       
   505    @SYMTestStatus Implemented
       
   506   
       
   507    @SYMTestActions
       
   508    Call GetAllApps() once, followed by repeated calls
       
   509    to GetNextApp until something other than KErrNone is returned
       
   510   
       
   511    @SYMTestExpectedResults
       
   512    GetNextApp should return app info for the following test apps:
       
   513    TAppNotEmbeddable.app
       
   514    TAppEmbeddable.app
       
   515    TAppEmbeddableOnly.app
       
   516    TAppEmbeddableUiOrStandAlone.app
       
   517    TAppEmbeddableUiNotStandAlone.app
       
   518    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
   519   
       
   520  */
       
   521 void CT_Serv2Step::DoGetAllApps(RApaLsSession& aLs)
       
   522 	{
       
   523 	INFO_PRINTF1(_L("DoGetAllApps"));
       
   524 
       
   525 	TInt ret = aLs.GetAllApps();
       
   526 	TEST(ret==KErrNone);
       
   527 
       
   528 	TApaAppInfo appInfo;
       
   529 	TUint bitFlags = 0;
       
   530 	while ((ret = aLs.GetNextApp(appInfo)) == KErrNone)
       
   531 		{
       
   532 		if (appInfo.iUid == KUidAppNotEmbeddable)
       
   533 			bitFlags |= 0x01;
       
   534 		else if (appInfo.iUid == KUidAppEmbeddable)
       
   535 			bitFlags |= 0x02;
       
   536 		else if (appInfo.iUid == KUidAppEmbeddableOnly)
       
   537 			bitFlags |= 0x04;
       
   538 		else if (appInfo.iUid == KUidAppEmbeddableUiOrStandAlone)
       
   539 			bitFlags |= 0x08;
       
   540 		else if (appInfo.iUid == KUidAppEmbeddableUiNotStandAlone)
       
   541 			bitFlags |= 0x10;
       
   542 		}
       
   543 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   544 	TEST(bitFlags == 0x1F);
       
   545 	}
       
   546 	
       
   547 	
       
   548 /* 
       
   549    @SYMTestCaseID T-Serv2-LaunchAppThruCreateDocL
       
   550   
       
   551    @SYMTestCaseDesc
       
   552    Check for the functionality of  RApaLsSession::CreateDocument(). 
       
   553    
       
   554    @SYMTestPriority High
       
   555   
       
   556    @SYMTestStatus Implemented
       
   557    
       
   558    @SYMTestActions 
       
   559    Call CreateDocument(const TDesC& aFileName, TUid aAppUid, TThreadId& aThreadId)
       
   560    
       
   561    @SYMTestExpectedResults
       
   562    Verify whether the Application is launched and Document is created for the respective 
       
   563    Application UID passed.  
       
   564 */
       
   565 
       
   566 void CT_Serv2Step::LaunchAppThruCreateDocL(RApaLsSession& aLs)
       
   567 	{
       
   568 	INFO_PRINTF1(_L("LaunchAppThruCreateDocL"));
       
   569 	_LIT(KFileName, "c:\\nofile.txt");
       
   570 	TThreadId startAppThreadID;
       
   571 	TInt errCreate=aLs.CreateDocument(KFileName,KUidAppEmbeddable,startAppThreadID);
       
   572 	TEST(errCreate == KErrNone);
       
   573 	
       
   574 	//we need to close the started thread, if appropiate
       
   575 	if (errCreate==KErrNone)	
       
   576 		{
       
   577 		RThread thread;
       
   578 		User::LeaveIfError(thread.Open(startAppThreadID));
       
   579 		CleanupClosePushL(thread);
       
   580 
       
   581 		RProcess process;
       
   582 		User::LeaveIfError(thread.Process(process));
       
   583 		CleanupClosePushL(process);
       
   584 
       
   585 		process.Kill(0);
       
   586 		
       
   587 		CleanupStack::PopAndDestroy(&process);
       
   588 		CleanupStack::PopAndDestroy(&thread);
       
   589 		}
       
   590 		
       
   591 	}
       
   592 	
       
   593 /**
       
   594    @SYMTestCaseID T-Serv2-DoGetEmbeddableApps
       
   595   
       
   596    @SYMPREQ PHAR-5Q4FX8
       
   597   
       
   598    @SYMTestCaseDesc
       
   599    Check that RApaLsSession::GetEmbeddableApps() hasn't been
       
   600    affected by the new code to filter the app list
       
   601    based on embeddability (implemented for CR PHAR-5Q4FX8)
       
   602   
       
   603    @SYMTestPriority High
       
   604   
       
   605    @SYMTestStatus Implemented
       
   606   
       
   607    @SYMTestActions
       
   608    Call GetEmbeddableApps() once, followed by repeated calls
       
   609    to GetNextApp until something other than KErrNone is returned
       
   610   
       
   611    @SYMTestExpectedResults
       
   612    GetNextApp should return app info for the following test apps:
       
   613    TAppEmbeddable.app
       
   614    TAppEmbeddableOnly.app
       
   615    and should not return app info for:
       
   616    TAppNotEmbeddable.app
       
   617    TAppEmbeddableUiOrStandAlone.app
       
   618    TAppEmbeddableUiNotStandAlone.app
       
   619    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
   620   
       
   621  */
       
   622 void CT_Serv2Step::DoGetEmbeddableApps(RApaLsSession& aLs)
       
   623 	{
       
   624 	INFO_PRINTF1(_L("DoGetEmbeddableApps"));
       
   625 
       
   626 	TInt ret = aLs.GetEmbeddableApps();
       
   627 	TEST(ret==KErrNone);
       
   628 
       
   629 	TApaAppInfo appInfo;
       
   630 	TUint bitFlags = 0;
       
   631 	while ((ret = aLs.GetNextApp(appInfo)) == KErrNone)
       
   632 		{
       
   633 		if (appInfo.iUid == KUidAppNotEmbeddable)
       
   634 			bitFlags |= 0x01;
       
   635 		else if (appInfo.iUid == KUidAppEmbeddable)
       
   636 			bitFlags |= 0x02;
       
   637 		else if (appInfo.iUid == KUidAppEmbeddableOnly)
       
   638 			bitFlags |= 0x04;
       
   639 		else if (appInfo.iUid == KUidAppEmbeddableUiOrStandAlone)
       
   640 			bitFlags |= 0x08;
       
   641 		else if (appInfo.iUid == KUidAppEmbeddableUiNotStandAlone)
       
   642 			bitFlags |= 0x10;
       
   643 		}
       
   644 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   645 	TEST(bitFlags == 0x06);
       
   646 	}
       
   647 
       
   648 /**
       
   649    @SYMTestCaseID T-Serv2-DoEmbeddableAppCount
       
   650   
       
   651    @SYMPREQ PHAR-5Q4FX8
       
   652   
       
   653    @SYMTestCaseDesc
       
   654    The number of apps returned by GetEmbeddableApps should be the
       
   655    same as EmbeddableAppCount returns.
       
   656   
       
   657    @SYMTestPriority High
       
   658   
       
   659    @SYMTestStatus Implemented
       
   660   
       
   661    @SYMTestActions
       
   662    Count the number of apps returned by calling GetEmbeddableApps
       
   663    followed by repeated calls to GetNextApp.
       
   664    Count the number of apps returned by EmbeddableAppCount.
       
   665   
       
   666    @SYMTestExpectedResults
       
   667    The counts should be equal.
       
   668    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
   669   
       
   670  */
       
   671 void CT_Serv2Step::DoEmbeddableAppCount(RApaLsSession& aLs)
       
   672 	{
       
   673 	INFO_PRINTF1(_L("DoEmbeddableAppCount"));
       
   674 
       
   675 	TInt ret = aLs.GetEmbeddableApps();
       
   676 	TEST(ret==KErrNone);
       
   677 
       
   678 	TApaAppInfo appInfo;
       
   679 	TInt count1 = 0;
       
   680 	while ((ret = aLs.GetNextApp(appInfo)) == KErrNone)
       
   681 		{
       
   682 		count1 ++;
       
   683 		}
       
   684 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   685 
       
   686 	TInt count2 = 0;
       
   687 	ret = aLs.EmbeddableAppCount(count2);
       
   688 	TEST(ret==KErrNone);
       
   689 
       
   690 	TEST(count1 == count2);
       
   691 	}
       
   692 
       
   693 /**
       
   694    @SYMTestCaseID T-Serv2-DoGetAppCapability
       
   695   
       
   696    @SYMPREQ PHAR-5Q4FX8
       
   697   
       
   698    @SYMTestCaseDesc
       
   699    Confirm that the application embeddability value that a specific app
       
   700    defines in it's AIF file, matches the value returned by
       
   701    RApaLsSession::GetAppCapability.
       
   702    Check that this is true for all supported embeddability values
       
   703   
       
   704    @SYMTestPriority High
       
   705   
       
   706    @SYMTestStatus Implemented
       
   707   
       
   708    @SYMTestActions
       
   709    Call GetAppCapability for each of the following test apps:
       
   710    TAppNotEmbeddable.app
       
   711    TAppEmbeddable.app
       
   712    TAppEmbeddableOnly.app
       
   713    TAppEmbeddableUiOrStandAlone.app
       
   714    TAppEmbeddableUiNotStandAlone.app
       
   715   
       
   716    @SYMTestExpectedResults
       
   717    For each app, GetAppCapability should return the embeddability value
       
   718    defined in the application's AIF file.
       
   719   
       
   720  */
       
   721 void CT_Serv2Step::DoGetAppCapability(RApaLsSession& aLs)
       
   722 	{
       
   723 	INFO_PRINTF1(_L("DoGetAppCapability"));
       
   724 
       
   725 	TApaAppCapabilityBuf capabilityBuf;
       
   726 	TInt ret;
       
   727 	const TInt numberOfCapabilities = 5;
       
   728 	TUid uidArray[numberOfCapabilities];
       
   729 	uidArray[0] = KUidAppNotEmbeddable;
       
   730 	uidArray[1] = KUidAppEmbeddable;
       
   731 	uidArray[2] = KUidAppEmbeddableOnly;
       
   732 	uidArray[3] = KUidAppEmbeddableUiOrStandAlone;
       
   733 	uidArray[4] = KUidAppEmbeddableUiNotStandAlone;
       
   734 
       
   735 	const TApaAppCapability::TEmbeddability embeddabilityArray[numberOfCapabilities]
       
   736 		= { TApaAppCapability::ENotEmbeddable,
       
   737 			TApaAppCapability::EEmbeddable, 
       
   738 			TApaAppCapability::EEmbeddableOnly, 
       
   739 			TApaAppCapability::EEmbeddableUiOrStandAlone, 
       
   740 			TApaAppCapability::EEmbeddableUiNotStandAlone };
       
   741 
       
   742 	for (TInt ii = 0; ii < numberOfCapabilities; ii++)
       
   743 		{
       
   744 		ret = aLs.GetAppCapability(capabilityBuf, uidArray[ii]);
       
   745 		TEST(ret==KErrNone);
       
   746 		TEST(capabilityBuf().iEmbeddability == embeddabilityArray[ii]);
       
   747 		}
       
   748 	}
       
   749 
       
   750 /**
       
   751    @SYMTestCaseID T-Serv2-DoGetFilteredApps1
       
   752   
       
   753    @SYMPREQ PHAR-5Q4FX8
       
   754   
       
   755    @SYMTestCaseDesc
       
   756    Passing an empty filter to RApaLsSession::GetFilteredApps
       
   757    should cause no apps to be returned by subsequent calls
       
   758    to RApaLsSession::GetNextApp
       
   759   
       
   760    @SYMTestPriority High
       
   761   
       
   762    @SYMTestStatus Implemented
       
   763   
       
   764    @SYMTestActions
       
   765    Call GetFilteredApps passing a default constructed filter,
       
   766    followed by a single call to GetNextApp
       
   767   
       
   768    @SYMTestExpectedResults
       
   769    GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
   770   
       
   771  */
       
   772 void CT_Serv2Step::DoGetFilteredApps1(RApaLsSession& aLs)
       
   773 	{
       
   774 	INFO_PRINTF1(_L("DoGetFilteredApps1"));
       
   775 
       
   776 	TApaEmbeddabilityFilter filter;
       
   777 	TInt ret = aLs.GetFilteredApps(filter);
       
   778 	TEST(ret==KErrNone);
       
   779 
       
   780 	TApaAppInfo appInfo;
       
   781 	TEST(aLs.GetNextApp(appInfo) == RApaLsSession::ENoMoreAppsInList);
       
   782 	}
       
   783 
       
   784 /**
       
   785    @SYMTestCaseID T-Serv2-DoGetFilteredApps2
       
   786   
       
   787    @SYMPREQ PHAR-5Q4FX8
       
   788   
       
   789    @SYMTestCaseDesc
       
   790    Passing a filter specifying only ENotEmbeddable
       
   791    to RApaLsSession::GetFilteredApps should cause subsequent
       
   792    calls to RApaLsSession::GetNextApp to return only
       
   793    applications which cannot be embedded
       
   794   
       
   795    @SYMTestPriority High
       
   796   
       
   797    @SYMTestStatus Implemented
       
   798   
       
   799    @SYMTestActions
       
   800    Call GetFilteredApps passing a filter containing ENotEmbeddable,
       
   801    followed by repeated calls to GetNextApp until something other than
       
   802    KErrNone is returned
       
   803   
       
   804    @SYMTestExpectedResults
       
   805    GetNextApp should return app info for only the following test app:
       
   806    TAppNotEmbeddable.app
       
   807    and should not return app info for:
       
   808    TAppEmbeddable.app
       
   809    TAppEmbeddableOnly.app
       
   810    TAppEmbeddableUiOrStandAlone.app
       
   811    TAppEmbeddableUiNotStandAlone.app
       
   812    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
   813   
       
   814  */
       
   815 void CT_Serv2Step::DoGetFilteredApps2(RApaLsSession& aLs)
       
   816 	{
       
   817 	INFO_PRINTF1(_L("DoGetFilteredApps2"));
       
   818 
       
   819 	TApaEmbeddabilityFilter filter;
       
   820 	filter.AddEmbeddability(TApaAppCapability::ENotEmbeddable);
       
   821 	TInt ret = aLs.GetFilteredApps(filter);
       
   822 	TEST(ret==KErrNone);
       
   823 
       
   824 	TApaAppInfo appInfo;
       
   825 	TUint bitFlags = 0;
       
   826 	while ((ret = aLs.GetNextApp(appInfo)) == KErrNone)
       
   827 		{
       
   828 		if (appInfo.iUid == KUidAppNotEmbeddable)
       
   829 			bitFlags |= 0x01;
       
   830 		else if (appInfo.iUid == KUidAppEmbeddable)
       
   831 			bitFlags |= 0x02;
       
   832 		else if (appInfo.iUid == KUidAppEmbeddableOnly)
       
   833 			bitFlags |= 0x04;
       
   834 		else if (appInfo.iUid == KUidAppEmbeddableUiOrStandAlone)
       
   835 			bitFlags |= 0x08;
       
   836 		else if (appInfo.iUid == KUidAppEmbeddableUiNotStandAlone)
       
   837 			bitFlags |= 0x10;
       
   838 		}
       
   839 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   840 	TEST(bitFlags == 0x01);
       
   841 	}
       
   842 
       
   843 /**
       
   844    @SYMTestCaseID T-Serv2-DoGetFilteredApps3
       
   845   
       
   846    @SYMPREQ PHAR-5Q4FX8
       
   847   
       
   848    @SYMTestCaseDesc
       
   849    EEmbeddableUiOrStandAlone (value 5) shares a bit flag (bit 1)
       
   850    with EEmbeddable (value 1).
       
   851    Confirm that a filter of EEmbeddableUiOrStandAlone only returns
       
   852    apps that define EEmbeddableUiOrStandAlone
       
   853   
       
   854    @SYMTestPriority High
       
   855   
       
   856    @SYMTestStatus Implemented
       
   857   
       
   858    @SYMTestActions
       
   859    Call GetFilteredApps passing a filter containing EEmbeddableUiOrStandAlone,
       
   860    followed by repeated calls to GetNextApp until something other than
       
   861    KErrNone is returned
       
   862   
       
   863    @SYMTestExpectedResults
       
   864    GetNextApp should return app info for only the following test app:
       
   865    TAppEmbeddableUiOrStandAlone.app
       
   866    and should not return app info for:
       
   867    TAppEmbeddable.app
       
   868    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
   869   
       
   870  */
       
   871 void CT_Serv2Step::DoGetFilteredApps3(RApaLsSession& aLs)
       
   872 	{
       
   873 	INFO_PRINTF1(_L("DoGetFilteredApps3"));
       
   874 
       
   875 	TApaEmbeddabilityFilter filter;
       
   876 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiOrStandAlone);
       
   877 	TInt ret = aLs.GetFilteredApps(filter);
       
   878 	TEST(ret==KErrNone);
       
   879 
       
   880 	TApaAppInfo appInfo;
       
   881 	TUint bitFlags = 0;
       
   882 	while ((ret = aLs.GetNextApp(appInfo)) == KErrNone)
       
   883 		{
       
   884 		if (appInfo.iUid == KUidAppEmbeddable)
       
   885 			bitFlags |= 0x02;
       
   886 		else if (appInfo.iUid == KUidAppEmbeddableUiOrStandAlone)
       
   887 			bitFlags |= 0x08;
       
   888 		}
       
   889 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   890 	TEST(bitFlags == 0x08);
       
   891 	}
       
   892 
       
   893 /**
       
   894    @SYMTestCaseID T-Serv2-DoGetFilteredApps4
       
   895  
       
   896    @SYMPREQ PHAR-5Q4FX8
       
   897   
       
   898    @SYMTestCaseDesc
       
   899    A filter specifying two embeddability values should
       
   900    include apps of either embeddability
       
   901   
       
   902    @SYMTestPriority High
       
   903   
       
   904    @SYMTestStatus Implemented
       
   905   
       
   906    @SYMTestActions
       
   907    Call GetFilteredApps passing a filter containing EEmbeddableUiOrStandAlone
       
   908    and EEmbeddableUiNotStandAlone followed by repeated calls to GetNextApp
       
   909    until something other than KErrNone is returned
       
   910   
       
   911    @SYMTestExpectedResults
       
   912    GetNextApp should return app info for only the following test apps:
       
   913    TAppEmbeddableUiOrStandAlone.app
       
   914    TAppEmbeddableUiNotStandAlone.app
       
   915    and should not return app info for:
       
   916    TAppNotEmbeddable.app
       
   917    TAppEmbeddable.app
       
   918    TAppEmbeddableOnly.app
       
   919    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
   920   
       
   921  */
       
   922 void CT_Serv2Step::DoGetFilteredApps4(RApaLsSession& aLs)
       
   923 	{
       
   924 	INFO_PRINTF1(_L("DoGetFilteredApps4"));
       
   925 
       
   926 	TApaEmbeddabilityFilter filter;
       
   927 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiOrStandAlone);
       
   928 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiNotStandAlone);
       
   929 	TInt ret = aLs.GetFilteredApps(filter);
       
   930 	TEST(ret==KErrNone);
       
   931 
       
   932 	TApaAppInfo appInfo;
       
   933 	TUint bitFlags = 0;
       
   934 	while ((ret = aLs.GetNextApp(appInfo)) == KErrNone)
       
   935 		{
       
   936 		if (appInfo.iUid == KUidAppNotEmbeddable)
       
   937 			bitFlags |= 0x01;
       
   938 		else if (appInfo.iUid == KUidAppEmbeddable)
       
   939 			bitFlags |= 0x02;
       
   940 		else if (appInfo.iUid == KUidAppEmbeddableOnly)
       
   941 			bitFlags |= 0x04;
       
   942 		else if (appInfo.iUid == KUidAppEmbeddableUiOrStandAlone)
       
   943 			bitFlags |= 0x08;
       
   944 		else if (appInfo.iUid == KUidAppEmbeddableUiNotStandAlone)
       
   945 			bitFlags |= 0x10;
       
   946 		}
       
   947 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   948 	TEST(bitFlags == 0x18);
       
   949 	}
       
   950 
       
   951 /**
       
   952    @SYMTestCaseID T-Serv2-DoGetFilteredApps5
       
   953   
       
   954    @SYMPREQ PHAR-5Q4FX8
       
   955   
       
   956    @SYMTestCaseDesc
       
   957    Getting apps using a filter specifying all embeddability values
       
   958    should return the same number of apps as RApaLsSession::GetAllApps()
       
   959   
       
   960    @SYMTestPriority High
       
   961   
       
   962    @SYMTestStatus Implemented
       
   963   
       
   964    @SYMTestActions
       
   965    Call GetFilteredApps passing a filter containing all embeddability values,
       
   966    and count the number of calls to GetNextApp until something other than
       
   967    KErrNone is returned.
       
   968    Then call GetAllApps and count the number of calls to GetNextApp until
       
   969    something other than KErrNone is returned.
       
   970   
       
   971    @SYMTestExpectedResults
       
   972    The two counts should be equal.
       
   973    The last call in each sequence of calls to GetNextApp should return
       
   974    RApaLsSession::ENoMoreAppsInList
       
   975   
       
   976  */
       
   977 void CT_Serv2Step::DoGetFilteredApps5(RApaLsSession& aLs)
       
   978 	{
       
   979 	INFO_PRINTF1(_L("DoGetFilteredApps5"));
       
   980 
       
   981 	TApaEmbeddabilityFilter filter;
       
   982 	filter.AddEmbeddability(TApaAppCapability::ENotEmbeddable);
       
   983 	filter.AddEmbeddability(TApaAppCapability::EEmbeddable);
       
   984 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableOnly);
       
   985 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiOrStandAlone);
       
   986 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiNotStandAlone);
       
   987 	TInt ret = aLs.GetFilteredApps(filter);
       
   988 	TEST(ret==KErrNone);
       
   989 
       
   990 	TApaAppInfo appInfo;
       
   991 	TInt filteredCount = 0;
       
   992 	while ((ret = aLs.GetNextApp(appInfo)) == KErrNone)
       
   993 		{
       
   994 		filteredCount++;
       
   995 		}
       
   996 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   997 
       
   998 	ret = aLs.GetAllApps();
       
   999 	TEST(ret==KErrNone);
       
  1000 
       
  1001 	TInt allAppsCount = 0;
       
  1002 	while ((ret = aLs.GetNextApp(appInfo)) == KErrNone)
       
  1003 		{
       
  1004 		allAppsCount++;
       
  1005 		}
       
  1006 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
  1007 
       
  1008 	TEST(filteredCount == allAppsCount);
       
  1009 	}
       
  1010 
       
  1011 /**
       
  1012    @SYMTestCaseID T-Serv2-DoGetFilteredApps6
       
  1013   
       
  1014    @SYMPREQ PHAR-5Q4FX8
       
  1015   
       
  1016    @SYMTestCaseDesc
       
  1017    None of the following embeddability test apps support
       
  1018    screen mode 1, so none of them should be returned even
       
  1019    if the filter specifies all embeddability types.
       
  1020    TAppNotEmbeddable.app
       
  1021    TAppEmbeddable.app
       
  1022    TAppEmbeddableOnly.app
       
  1023    TAppEmbeddableUiOrStandAlone.app
       
  1024    TAppEmbeddableUiNotStandAlone.app
       
  1025   
       
  1026    @SYMTestPriority High
       
  1027   
       
  1028    @SYMTestStatus Implemented
       
  1029   
       
  1030    @SYMTestActions
       
  1031    Call GetFilteredApps passing a filter containing all embeddability values
       
  1032    and screen mode 1, followed by repeated calls to GetNextApp until something
       
  1033    other than KErrNone is returned
       
  1034   
       
  1035    @SYMTestExpectedResults
       
  1036    GetNextApp should not return app info for any of the following test apps:
       
  1037    TAppNotEmbeddable.app
       
  1038    TAppEmbeddable.app
       
  1039    TAppEmbeddableOnly.app
       
  1040    TAppEmbeddableUiOrStandAlone.app
       
  1041    TAppEmbeddableUiNotStandAlone.app
       
  1042    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
  1043   
       
  1044  */
       
  1045 void CT_Serv2Step::DoGetFilteredApps6(RApaLsSession& aLs)
       
  1046 	{
       
  1047 	INFO_PRINTF1(_L("DoGetFilteredApps6"));
       
  1048 
       
  1049 	TApaEmbeddabilityFilter filter;
       
  1050 	filter.AddEmbeddability(TApaAppCapability::ENotEmbeddable);
       
  1051 	filter.AddEmbeddability(TApaAppCapability::EEmbeddable);
       
  1052 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableOnly);
       
  1053 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiOrStandAlone);
       
  1054 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiNotStandAlone);
       
  1055 	const TInt screenMode1 = 1;
       
  1056 	TInt ret = aLs.GetFilteredApps(filter, screenMode1);
       
  1057 	TEST(ret==KErrNone);
       
  1058 
       
  1059 	TApaAppInfo appInfo;
       
  1060 	TUint bitFlags = 0;
       
  1061 	while ((ret = aLs.GetNextApp(appInfo)) == KErrNone)
       
  1062 		{
       
  1063 		if (appInfo.iUid == KUidAppNotEmbeddable)
       
  1064 			bitFlags |= 0x01;
       
  1065 		else if (appInfo.iUid == KUidAppEmbeddable)
       
  1066 			bitFlags |= 0x02;
       
  1067 		else if (appInfo.iUid == KUidAppEmbeddableOnly)
       
  1068 			bitFlags |= 0x04;
       
  1069 		else if (appInfo.iUid == KUidAppEmbeddableUiOrStandAlone)
       
  1070 			bitFlags |= 0x08;
       
  1071 		else if (appInfo.iUid == KUidAppEmbeddableUiNotStandAlone)
       
  1072 			bitFlags |= 0x10;
       
  1073 		}
       
  1074 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
  1075 	TEST(bitFlags == 0);
       
  1076 	}
       
  1077 
       
  1078 /**
       
  1079    @SYMTestCaseID T-Serv2-DoTestEmbeddabilityFilter1
       
  1080   
       
  1081    @SYMPREQ PHAR-5Q4FX8
       
  1082   
       
  1083    @SYMTestCaseDesc
       
  1084    Ensure default constructed TApaEmbeddabilityFilter object is
       
  1085    initialized correctly.
       
  1086   
       
  1087    @SYMTestPriority High
       
  1088   
       
  1089    @SYMTestStatus Implemented
       
  1090   
       
  1091    @SYMTestActions
       
  1092    Construct a TApaEmbeddabilityFilter object and call
       
  1093    MatchesEmbeddability using each of the following embeddability values:
       
  1094    TApaAppCapability::ENotEmbeddable
       
  1095    TApaAppCapability::EEmbeddable
       
  1096    TApaAppCapability::EEmbeddableOnly
       
  1097    TApaAppCapability::EEmbeddableUiOrStandAlone
       
  1098    TApaAppCapability::EEmbeddableUiNotStandAlone
       
  1099   
       
  1100    @SYMTestExpectedResults
       
  1101    All calls to MatchesEmbeddability should return false.
       
  1102   
       
  1103  */
       
  1104 void CT_Serv2Step::DoTestEmbeddabilityFilter1()
       
  1105 	{
       
  1106 	INFO_PRINTF1(_L("DoTestEmbeddabilityFilter1"));
       
  1107 
       
  1108 	TApaEmbeddabilityFilter filter;
       
  1109 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::ENotEmbeddable));
       
  1110 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::EEmbeddable));
       
  1111 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::EEmbeddableOnly));
       
  1112 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::EEmbeddableUiOrStandAlone));
       
  1113 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::EEmbeddableUiNotStandAlone));
       
  1114 	}
       
  1115 
       
  1116 /**
       
  1117    @SYMTestCaseID T-Serv2-DoTestEmbeddabilityFilter2
       
  1118   
       
  1119    @SYMPREQ PHAR-5Q4FX8
       
  1120   
       
  1121    @SYMTestCaseDesc
       
  1122    Bit 2 is used by both EEmbeddableUiNotStandAlone and EEmbeddableOnly.
       
  1123    Make sure that setting the filter to only EEmbeddableUiNotStandAlone
       
  1124    doesn't match EEmbeddableOnly.
       
  1125   
       
  1126    @SYMTestPriority High
       
  1127   
       
  1128    @SYMTestStatus Implemented
       
  1129   
       
  1130    @SYMTestActions
       
  1131    Construct a TApaEmbeddabilityFilter object,
       
  1132    set the filter to only EEmbeddableUiNotStandAloneand
       
  1133    and call MatchesEmbeddability passing EEmbeddableOnly
       
  1134   
       
  1135    @SYMTestExpectedResults
       
  1136    MatchesEmbeddability should return false.
       
  1137   
       
  1138  */
       
  1139 void CT_Serv2Step::DoTestEmbeddabilityFilter2()
       
  1140 	{
       
  1141 	INFO_PRINTF1(_L("DoTestEmbeddabilityFilter2"));
       
  1142 
       
  1143 	TApaEmbeddabilityFilter filter;
       
  1144 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiNotStandAlone);
       
  1145 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::EEmbeddableOnly));
       
  1146 	}
       
  1147 
       
  1148 /**
       
  1149    @SYMTestCaseID T-Serv2-DoTestEmbeddabilityFilter3
       
  1150   
       
  1151    @SYMPREQ PHAR-5Q4FX8
       
  1152   
       
  1153    @SYMTestCaseDesc
       
  1154    Bit 2 is used by both EEmbeddableUiNotStandAlone and EEmbeddableOnly.
       
  1155    Make sure that setting the filter to only EEmbeddableOnly
       
  1156    doesn't match EEmbeddableUiNotStandAlone.
       
  1157   
       
  1158    @SYMTestPriority High
       
  1159   
       
  1160    @SYMTestStatus Implemented
       
  1161   
       
  1162    @SYMTestActions
       
  1163    Construct a TApaEmbeddabilityFilter object,
       
  1164    set the filter to only EEmbeddableOnly
       
  1165    and call MatchesEmbeddability passing EEmbeddableUiNotStandAlone
       
  1166   
       
  1167    @SYMTestExpectedResults
       
  1168    MatchesEmbeddability should return false.
       
  1169   
       
  1170  */
       
  1171 void CT_Serv2Step::DoTestEmbeddabilityFilter3()
       
  1172 	{
       
  1173 	INFO_PRINTF1(_L("DoTestEmbeddabilityFilter3"));
       
  1174 
       
  1175 	TApaEmbeddabilityFilter filter;
       
  1176 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableOnly);
       
  1177 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::EEmbeddableUiNotStandAlone));
       
  1178 	}
       
  1179 
       
  1180 /**
       
  1181    @SYMTestCaseID T-Serv2-DoTestEmbeddabilityFilter4
       
  1182   
       
  1183    @SYMPREQ PHAR-5Q4FX8
       
  1184  
       
  1185    @SYMTestCaseDesc
       
  1186    Ensure MatchesEmbeddability returns true when the filter only contains
       
  1187    the embeddability being matched.
       
  1188   
       
  1189    @SYMTestPriority High
       
  1190   
       
  1191    @SYMTestStatus Implemented
       
  1192    
       
  1193    @SYMTestActions
       
  1194    Construct a TApaEmbeddabilityFilter object,
       
  1195    set the filter to only EEmbeddable
       
  1196    and call MatchesEmbeddability passing EEmbeddable
       
  1197   
       
  1198    @SYMTestExpectedResults
       
  1199    MatchesEmbeddability should return true.
       
  1200   
       
  1201  */
       
  1202 void CT_Serv2Step::DoTestEmbeddabilityFilter4()
       
  1203 	{
       
  1204 	INFO_PRINTF1(_L("DoTestEmbeddabilityFilter4"));
       
  1205 
       
  1206 	TApaEmbeddabilityFilter filter;
       
  1207 	filter.AddEmbeddability(TApaAppCapability::EEmbeddable);
       
  1208 	TEST(filter.MatchesEmbeddability(TApaAppCapability::EEmbeddable));
       
  1209 	}
       
  1210 
       
  1211 /**
       
  1212    @SYMTestCaseID T-Serv2-DoTestEmbeddabilityFilter5
       
  1213   
       
  1214    @SYMPREQ PHAR-5Q4FX8
       
  1215   
       
  1216    @SYMTestCaseDesc
       
  1217    Ensure MatchesEmbeddability returns true when the filter contains
       
  1218    a superset of the embeddability being matched.
       
  1219   
       
  1220    @SYMTestPriority High
       
  1221   
       
  1222    @SYMTestStatus Implemented
       
  1223   
       
  1224    @SYMTestActions
       
  1225    Construct a TApaEmbeddabilityFilter object,
       
  1226    set the filter to both ENotEmbeddable and EEmbeddable
       
  1227    and call MatchesEmbeddability passing EEmbeddable
       
  1228   
       
  1229    @SYMTestExpectedResults
       
  1230    MatchesEmbeddability should return true.
       
  1231   
       
  1232  */
       
  1233 void CT_Serv2Step::DoTestEmbeddabilityFilter5()
       
  1234 	{
       
  1235 	INFO_PRINTF1(_L("DoTestEmbeddabilityFilter5"));
       
  1236 
       
  1237 	TApaEmbeddabilityFilter filter;
       
  1238 	filter.AddEmbeddability(TApaAppCapability::ENotEmbeddable);
       
  1239 	filter.AddEmbeddability(TApaAppCapability::EEmbeddable);
       
  1240 	TEST(filter.MatchesEmbeddability(TApaAppCapability::EEmbeddable));
       
  1241 	}
       
  1242 
       
  1243 
       
  1244 /**
       
  1245    @SYMTestCaseID T-Serv2Step-DoInterrogationTestsL
       
  1246   
       
  1247    @SYMPREQ
       
  1248   
       
  1249    @SYMTestCaseDesc Test interrogates the Application Architecture Server. 
       
  1250    
       
  1251    @SYMTestPriority High 
       
  1252   
       
  1253    @SYMTestStatus Implemented
       
  1254    
       
  1255    @SYMTestActions Test Application Architecture Server's ability to:\n
       
  1256    (1) Retrieve list of all applications in the cache list by calling 
       
  1257    RApaLsSession::GetAllApps().The test also calls RApaLsSession::AppCount()
       
  1258    to retrieve the number of applications in the list.\n
       
  1259    (2) Retrieve list of all embeddable applications from the cache list
       
  1260    by calling RApaLsSession::GetEmbeddableApps().The test also calls
       
  1261    RApaLsSession::EmbeddableAppCount() to retrieve the number of
       
  1262    embeddable applications in the list.\n
       
  1263    (3) Retrieve application information.\n
       
  1264    (4) Retrieve capability of an existing & non-existing application by
       
  1265    calling RApaLsSession::GetAppCapability().\n
       
  1266    (5) Check and retrieve Data (MIME) type information of data taken from a
       
  1267    specified file by calling RApaLsSession::RecognizeSpecificData().
       
  1268    This is confirmed by taking data from the same file and checking
       
  1269    the data type information by calling RApaLsSession::RecognizeData().\n
       
  1270    (6) Retrieve application icon by calling RApaLsSession::GetAppIcon().\n
       
  1271    API Calls:\n	
       
  1272    RApaLsSession::GetAllApps() const\n
       
  1273    RApaLsSession::AppCount(TInt& aCount) const\n
       
  1274    RApaLsSession::EmbeddableAppCount(TInt& aCount) const\n
       
  1275    RApaLsSession::GetEmbeddableApps() const\n
       
  1276    RApaLsSession::GetAppCapability(TDes8& aCapabilityBuf,TUid aAppUid) const\n
       
  1277    RApaLsSession::RecognizeSpecificData(const TDesC& aName, const TDesC8& aBuffer, const TDataType& aDataType, TBool& aResult) const\n
       
  1278    RApaLsSession::RecognizeData(const TDesC& aName, const TDesC8& aBuffer, TDataRecognitionResult& aDataType) const\n
       
  1279    RApaLsSession::GetAppIcon(TUid aAppUid, TInt aSize, CApaMaskedBitmap& aAppBitmap) const\n
       
  1280    
       
  1281    @SYMTestExpectedResults All tests compare the results obtained with the desired result.
       
  1282     
       
  1283  */
       
  1284 void CT_Serv2Step::DoInterrogationTestsL(RApaLsSession& aLs)
       
  1285 	{
       
  1286 	INFO_PRINTF1(_L("Interogating the server"));
       
  1287 
       
  1288 	TInt ret = aLs.GetAllApps(); // SC - test
       
  1289 	TEST(ret==KErrNone);
       
  1290 
       
  1291 	// get the full app count
       
  1292 	TInt count=0;
       
  1293 	ret = aLs.AppCount(count);
       
  1294 	TEST(ret==KErrNone);
       
  1295 	TEST(count>=1);
       
  1296 
       
  1297 	// get the embedded app count
       
  1298 	count=0;
       
  1299 	ret = aLs.EmbeddableAppCount(count);
       
  1300 	TEST(ret==KErrNone);
       
  1301 	TEST(count>=1);
       
  1302 
       
  1303 	// prepare to get a list of embeddable apps
       
  1304 	ret = aLs.GetEmbeddableApps();
       
  1305 	TEST(ret==KErrNone);
       
  1306 	DoAppInfoTests(aLs);
       
  1307 
       
  1308 	// Get the capability of an app that exists
       
  1309 	TApaAppCapabilityBuf buf;
       
  1310 	ret = aLs.GetAppCapability(buf, KUidTestApp);
       
  1311 	TEST(ret==KErrNone);
       
  1312 	TApaAppCapability cap=buf();
       
  1313 	TEST(cap.iEmbeddability==TApaAppCapability::EEmbeddable);
       
  1314 	TEST(!cap.iSupportsNewFile);
       
  1315 	TEST(!cap.iAppIsHidden);
       
  1316 
       
  1317 	// get the capability of a non-existant app
       
  1318 	ret = aLs.GetAppCapability(buf, KNullUid);
       
  1319 	TEST(ret==KErrNotFound);
       
  1320 
       
  1321 	INFO_PRINTF1(_L("Checking data type information"));
       
  1322 	TBool isText;
       
  1323 	ret=aLs.RecognizeSpecificData(_L("a file name.txt"),_L8("Some plain text"),TDataType(_L8("text/plain")),isText);
       
  1324 	TEST(ret==KErrNone);
       
  1325 	TEST(isText);
       
  1326 	TDataRecognitionResult result;
       
  1327 	ret=aLs.RecognizeData(_L("a file name.txt"),_L8("Some plain text"),result);
       
  1328 	TEST(ret==KErrNone);
       
  1329 	TEST(result.iDataType==TDataType(_L8("text/plain")));
       
  1330 	TEST(result.iConfidence==CApaDataRecognizerType::EProbable);
       
  1331 	isText=EFalse;
       
  1332 	ret=aLs.RecognizeSpecificData(_L("a file name.txt"),_L8("Some plain text"),TDataType(_L8("foo/bar")),isText);
       
  1333 	TEST(!isText);
       
  1334 
       
  1335 	INFO_PRINTF1(_L("Checking icon loading by index"));
       
  1336 	CApaMaskedBitmap* icon=CApaMaskedBitmap::NewLC();
       
  1337 
       
  1338 	TSize lastSize(0,0);
       
  1339 	ret=aLs.GetAppIcon(KUidTestApp,0,*icon);
       
  1340 	TEST(ret==KErrNone);
       
  1341 	TEST(icon->SizeInPixels().iWidth*icon->SizeInPixels().iHeight > lastSize.iWidth*lastSize.iHeight);
       
  1342 	lastSize=icon->SizeInPixels();
       
  1343 		
       
  1344 	ret=aLs.GetAppIcon(KUidTestApp,1,*icon);
       
  1345 	TEST(ret==KErrNone);
       
  1346 
       
  1347 	TEST(icon->SizeInPixels().iWidth*icon->SizeInPixels().iHeight == lastSize.iWidth*lastSize.iHeight);
       
  1348 	lastSize=icon->SizeInPixels();
       
  1349 
       
  1350 	ret=aLs.GetAppIcon(KUidTestApp,2,*icon);
       
  1351 	TEST(ret==KErrNone);
       
  1352 	TEST((icon->SizeInPixels().iWidth*icon->SizeInPixels().iHeight) > (lastSize.iWidth*lastSize.iHeight));
       
  1353 	lastSize=icon->SizeInPixels();
       
  1354 
       
  1355 
       
  1356 	TUid uid={9999};
       
  1357 	ret=aLs.GetAppIcon(uid,0,*icon);
       
  1358 	TEST(ret==KErrNotFound);
       
  1359 	CleanupStack::PopAndDestroy(icon);
       
  1360 	}
       
  1361 
       
  1362 
       
  1363 /**
       
  1364    @SYMTestCaseID T-Serv2Step-DoInstallationTestL
       
  1365   
       
  1366    @SYMPREQ
       
  1367   
       
  1368    @SYMTestCaseDesc Test updating of Application list on installation of a new application. 
       
  1369    
       
  1370    @SYMTestPriority High 
       
  1371   
       
  1372    @SYMTestStatus Implemented
       
  1373    
       
  1374    @SYMTestActions Test updating of application list on installation of a new
       
  1375    application. Copy the tstapp from z: drive to c: drive. Call RApaLsSession::GetAppInfo()
       
  1376    and test the application information obtained to verify whether the
       
  1377    application architecture server updates the application to reside in c: drive.
       
  1378    Delete the copied application and call RApaLsSession::GetAppInfo().
       
  1379    Verify that the application list updates the tstapp application to reside
       
  1380    on z: drive.\n
       
  1381    API Calls:\n	
       
  1382    RApaLsSession::GetAppInfo(TApaAppInfo& aInfo,TUid aAppUid) const\n
       
  1383    
       
  1384    @SYMTestExpectedResults The test confirms that the application architecture
       
  1385    server updates the application list on installation of a new application.
       
  1386     
       
  1387  */
       
  1388 void CT_Serv2Step::DoInstallationTestL (RApaLsSession ls)
       
  1389  	{
       
  1390  	_LIT(KTestAppDestDir, "C:\\private\\10003a3f\\import\\apps\\" );
       
  1391  	_LIT(KTestAppSource, "Z:\\private\\10003a3f\\import\\apps\\tstapp_reg.rsc" );
       
  1392  	_LIT(KTestAppDest, "C:\\private\\10003a3f\\import\\apps\\tstapp_reg.rsc" );
       
  1393 
       
  1394  	_LIT(KTestWaitingForApplistUpdate,"\nWaiting %d microseconds for applist to be updated");
       
  1395  	const TInt KApplistUpdateTime = 8000000;
       
  1396 
       
  1397  	// Copy App files around and delete them to check whether 
       
  1398 	// the app list updates and stores the cache correctly.
       
  1399  	RFs	theFs;
       
  1400  	theFs.Connect();
       
  1401  
       
  1402  	// Remove Test app from the file system
       
  1403  	CFileMan* fileManager = CFileMan::NewL (theFs);
       
  1404  
       
  1405  	INFO_PRINTF1(_L("Copying the app to C"));
       
  1406  	TEST(KErrNone == fileManager->Copy (KTestAppSource, KTestAppDest, CFileMan::ERecurse));
       
  1407  	
       
  1408  	INFO_PRINTF2(KTestWaitingForApplistUpdate, KApplistUpdateTime);
       
  1409  	User::After(KApplistUpdateTime);
       
  1410  
       
  1411  	TApaAppInfo aInfo;
       
  1412  	TEST(KErrNone == ls.GetAppInfo (aInfo, KUidTestApp));
       
  1413 
       
  1414 	TParsePtrC parse (aInfo.iFullName);
       
  1415  	_LIT (KCdrive, "C:");
       
  1416 	INFO_PRINTF1(_L("Comparing App drive location is C:... "));
       
  1417 	TEST(parse.Drive ().CompareF (KCdrive) == 0);
       
  1418  
       
  1419  	INFO_PRINTF1(_L("Removing the app from C"));
       
  1420 	TTime tempTime(0);
       
  1421 	fileManager->Attribs(KTestAppDest,0,KEntryAttReadOnly, tempTime, CFileMan::ERecurse);
       
  1422  	TEST(KErrNone == fileManager->Delete (KTestAppDest, CFileMan::ERecurse));
       
  1423 	INFO_PRINTF1(_L("Removing the app dir from C"));
       
  1424 	TEST(fileManager->RmDir(KTestAppDestDir)==KErrNone);
       
  1425  	
       
  1426 	INFO_PRINTF2(KTestWaitingForApplistUpdate, KApplistUpdateTime);
       
  1427 	User::After(KApplistUpdateTime);
       
  1428  
       
  1429  	// That should put the file in the right place
       
  1430  	TEST(KErrNone == ls.GetAppInfo( aInfo, KUidTestApp));
       
  1431 
       
  1432  	TParsePtrC parse1 (aInfo.iFullName);
       
  1433  	_LIT (KZdrive, "Z:");
       
  1434 	INFO_PRINTF1(_L("Comparing App drive location is Z:... "));
       
  1435  	TEST((parse1.Drive().CompareF(KZdrive)) == 0);
       
  1436  	
       
  1437  	delete fileManager;
       
  1438  	theFs.Close();
       
  1439  }
       
  1440 
       
  1441 //
       
  1442 // Tests the new RApaLsSession::NumberOfOwnDefinedIcons function
       
  1443 // See TeamTrack 'DEF037571 - Provide a better alternative to CApaAppInfoFileReader::NumberOfBitmaps'
       
  1444 //
       
  1445 void CT_Serv2Step::DoNumDefIconsTestL(RApaLsSession& aSession)
       
  1446 	{
       
  1447 	INFO_PRINTF1(_L("Testing RApaLsSession::NumberOfOwnDefinedIcons"));
       
  1448 	TInt err = KErrNone;
       
  1449 
       
  1450 	CArrayFixFlat<TSize>* array = new(ELeave) CArrayFixFlat<TSize>(4);
       
  1451 	CleanupStack::PushL(array);
       
  1452 
       
  1453 	// Test the GetAppIconSizes function, check 3 icons are returned (default icons)
       
  1454 	INFO_PRINTF1(_L("Testing GetAppIconSizes"));
       
  1455 	TUid appUid;
       
  1456 	appUid.iUid = 0x12008ACE;	// SimpleApparcTestApp UID
       
  1457 	err = aSession.GetAppIconSizes(appUid, *array);
       
  1458 	TEST(err == KErrNone);
       
  1459 	TEST(array->Count() == 3);
       
  1460 
       
  1461 	// Test the NumberOfOwnDefinedIcons function, check count is zero (no own defined icons)
       
  1462 	INFO_PRINTF1(_L("Testing NumberOfOwnDefinedIcons (SimpleApparcTestApp)"));
       
  1463 	TInt iconCount = -1;
       
  1464 	err = aSession.NumberOfOwnDefinedIcons(appUid, iconCount);
       
  1465 	TEST(err == KErrNone);
       
  1466 	TEST(iconCount == 0);
       
  1467 
       
  1468 	// Test NumberOfOwnDefinedIcons again, this time with Contacts app UID (icons defined)
       
  1469 	INFO_PRINTF1(_L("Testing NumberOfOwnDefinedIcons (Contacts app)"));
       
  1470 	iconCount = -1;
       
  1471 	appUid.iUid = 0x10003a74;	// Contacts app UID
       
  1472 
       
  1473 	err = aSession.NumberOfOwnDefinedIcons(appUid, iconCount);
       
  1474 	TEST(err == KErrNone);
       
  1475 	TEST(iconCount == 3);
       
  1476 
       
  1477 	INFO_PRINTF1(_L("NumberOfOwnDefinedIcons test complete"));
       
  1478 
       
  1479 	CleanupStack::PopAndDestroy(array);
       
  1480 	}
       
  1481 
       
  1482 /** Test RecognizeData() */	
       
  1483 void CT_Serv2Step::DoRecognizeDataL(RApaLsSession& aLs)
       
  1484 	{
       
  1485 	INFO_PRINTF1(_L("Testing RApaLsSession::RecognizeData"));
       
  1486 	
       
  1487 	_LIT(KExistingFile, "Z:\\ApparcTest\\apparctest_t_Serv2.script");
       
  1488 	_LIT(KNonExistingFile, "x:\\non-existing directory\\non-existing file.any");
       
  1489 	_LIT(KWeirdFileName, "\\c:\\  : weird...txt");
       
  1490 	_LIT8(KFileContents, "just some random noice, we don't really care about the result");
       
  1491 	_LIT8(KTextPlainMimeType, "text/plain");
       
  1492 	
       
  1493 	RFs fs;
       
  1494 	TEST(KErrNone == fs.Connect());
       
  1495 	CleanupClosePushL(fs);
       
  1496 	
       
  1497 	// make sure KExistingFile really exists and that KNonExistingFile doesn't
       
  1498 	TTime modificationTime;
       
  1499 	TEST(KErrNone == fs.Modified(KExistingFile, modificationTime));
       
  1500 	TEST(KErrNone != fs.Modified(KNonExistingFile, modificationTime));
       
  1501 
       
  1502 	// test with existing file (result will be cached)
       
  1503 	TDataRecognitionResult recData;
       
  1504 	TEST(KErrNone == aLs.RecognizeData(KExistingFile, KFileContents, recData));
       
  1505 	TEST(0 ==        recData.iDataType.Des8().Compare(KTextPlainMimeType));
       
  1506 	
       
  1507 	// test to get result from the cache (not possible to know if we succeed though)
       
  1508 	TEST(KErrNone == aLs.RecognizeData(KExistingFile, KFileContents, recData));
       
  1509 	TEST(0 ==        recData.iDataType.Des8().Compare(KTextPlainMimeType));
       
  1510 	
       
  1511 	//test with non-existing file (result won't be cached)	
       
  1512 	TEST(KErrNone == aLs.RecognizeData(KNonExistingFile, KFileContents, recData));
       
  1513 	TEST(0 ==        recData.iDataType.Des8().Compare(KTextPlainMimeType));
       
  1514 	
       
  1515 	//test with empty file name (result won't be cached)
       
  1516 	TEST(KErrNone == aLs.RecognizeData(KNullDesC, KFileContents, recData));
       
  1517 	TEST(0 ==        recData.iDataType.Des8().Compare(KTextPlainMimeType));
       
  1518 
       
  1519 	//test with weird file name (result won't be cached)
       
  1520 	TEST(KErrNone == aLs.RecognizeData(KWeirdFileName, KFileContents, recData));
       
  1521 	TEST(0 ==        recData.iDataType.Des8().Compare(KTextPlainMimeType));
       
  1522 	
       
  1523 	CleanupStack::PopAndDestroy(&fs);
       
  1524 	}
       
  1525 
       
  1526 /**
       
  1527    @SYMTestCaseID APPFWK-APPARC-0074
       
  1528   
       
  1529    @SYMDEF DEF099084: Apparc server's MIME type recognition cache can become out of date   
       
  1530   
       
  1531    @SYMTestCaseDesc Test checks whether the MIME type recognition cache maintained by apparc server is
       
  1532 					flushed when it receives the ECom change notification., i.e., either when a new ecom plugin is installed 
       
  1533 					or an existing ecom plugin is uninstalled.
       
  1534    
       
  1535    @SYMTestPriority High
       
  1536   
       
  1537    @SYMTestStatus Implemented
       
  1538    
       
  1539    @SYMTestActions Calls RecognizeData() to test the MIME type returned, 
       
  1540    when
       
  1541    1. When there is no existing "mime/mmr1" recognizer installed.
       
  1542    2. "mime/mmr1" recognizer with EPossible confidence is installed.
       
  1543    3. "mime/mmr1" recognizer is uninstalled.
       
  1544    It tests whether the mime type recognition cache maintained by the apparc server gets flushed
       
  1545    when any new ecom plugin is installed or when an existing ecom plugin is uninstalled.
       
  1546    
       
  1547    @SYMTestExpectedResults RecognizeData() returns CApaDataRecognizerType::ENotRecognized when "mime/mmr1" recognizer is not
       
  1548    installed.  RecognizeData() returns CApaDataRecognizerType::EPossible when "mime/mmr1" recognizer with EPossible confidence is installed.
       
  1549    RecognizeData() returns CApaDataRecognizerType::ENotRecognized when "mime/mmr1" recognizer with EPossible confidence is uninstalled.
       
  1550  */
       
  1551  
       
  1552 void CT_Serv2Step::TestRecognitionCacheL(RApaLsSession& aLs)
       
  1553 	{
       
  1554 	INFO_PRINTF1(_L("Testing fix for DEF099084: Apparc server's MIME type recognition cache can become out of date "));
       
  1555 	INFO_PRINTF1(_L("Testing MIME type recognition cache ..."));
       
  1556 
       
  1557 	_LIT(KLitDocPath, "Z:\\system\\data\\TApsRecogAppTest.mmr");
       
  1558 	_LIT8(KMimeMmrType,"mime/mmr1");
       
  1559 
       
  1560 	TDataRecognitionResult recogResult;
       
  1561 	TBuf8<255> buffer;
       
  1562 	buffer.FillZ(255);
       
  1563 	recogResult.Reset();
       
  1564 		
       
  1565 	// Since recognizer for "mime\mmr1" mime type is not yet installed, call to RecognizeData()
       
  1566 	// returns CApaDataRecognizerType::ENotRecognized.
       
  1567 	INFO_PRINTF1(_L("MIME type recognition cache is not used..."));
       
  1568 	User::LeaveIfError(aLs.RecognizeData(KLitDocPath, buffer, recogResult));
       
  1569 	TEST(recogResult.iConfidence == CApaDataRecognizerType::ENotRecognized);
       
  1570 
       
  1571 	INFO_PRINTF1(_L("Installs new mime/mmr1 recognizer plugin file "));
       
  1572 	RSmlTestUtils fs;
       
  1573 	CleanupClosePushL(fs);
       
  1574 	User::LeaveIfError(fs.Connect());
       
  1575 	
       
  1576 	// Ensure c:\\resource\\plugins is created, otherwise leave from this teststep
       
  1577 	_LIT(KRecogRscTargetDir,"C:\\resource\\plugins\\");
       
  1578 	TInt err = fs.CreateDirectoryL(KRecogRscTargetDir);
       
  1579 	TESTEL((err == KErrNone || err == KErrAlreadyExists), err);
       
  1580 	
       
  1581 	// Ensure c:\\sys\\bin is created, otherwise leave from this teststep
       
  1582 	_LIT(KDllRecogTargetDir,"C:\\sys\\bin\\");
       
  1583 	err = fs.CreateDirectoryL(KDllRecogTargetDir);
       
  1584 	TESTEL((err == KErrNone || err == KErrAlreadyExists), err);
       
  1585 
       
  1586 	// Copy recmime_1.rsc from z:\\ to c:\\resource\\plugins, to trigger the rescan for plugins.
       
  1587 	_LIT(KRecogRscSourcePath, "Z:\\system\\data\\recmime_1.rsc");
       
  1588 	_LIT(KRecogRscTargetPath,"C:\\resource\\plugins\\recmime_1.rsc");
       
  1589 
       
  1590 	err = fs.CopyFileL(KRecogRscSourcePath, KRecogRscTargetPath);
       
  1591 	TEST(err == KErrNone);
       
  1592 
       
  1593 	// Copy recmime_*.dll from z:\\ to c:\\sys\\bin.
       
  1594 	_LIT(KRecogDllTargetPath, "C:\\sys\\bin\\recmime_1.dll");
       
  1595 
       
  1596 	#ifdef __WINS__ 
       
  1597 		_LIT(KRecogDllSourcePathWinscw, "Z:\\system\\data\\recmime_winscw.dll");
       
  1598 		err = fs.CopyFileL(KRecogDllSourcePathWinscw, KRecogDllTargetPath);
       
  1599 	#else
       
  1600 		_LIT(KRecogDllSourcePathArmv5, "Z:\\system\\data\\recmime_armv5.dll");
       
  1601 		err = fs.CopyFileL(KRecogDllSourcePathArmv5, KRecogDllTargetPath);
       
  1602 	#endif
       
  1603 	TEST(err == KErrNone);
       
  1604 
       
  1605 	INFO_PRINTF2(_L("Waits %d seconds for new mime/mmr1 recognizer with EPossible confidence to be installed."), (4 * KOneSecondDelay)/1000000);	
       
  1606 	User::After(4 * KOneSecondDelay);
       
  1607 	
       
  1608 	// Without fix for DEF099084: Apparc server's MIME type recognition cache can become out of date 
       
  1609 	// RApaLsSession::RecognizeData() would return CApaDataRecognizerType::ENotRecognized (ie., Mime Recognition cache
       
  1610 	// would not have been flushed when new recognizer is installed).
       
  1611 	INFO_PRINTF1(_L("MIME type recognition cache is flushed when a new recogizer is installed"));
       
  1612 	recogResult.Reset();
       
  1613 	User::LeaveIfError(aLs.RecognizeData(KLitDocPath, buffer, recogResult));
       
  1614 	TEST(recogResult.iDataType.Des8().CompareF(KMimeMmrType) == 0);
       
  1615 	TEST(recogResult.iConfidence == CApaDataRecognizerType::EPossible);
       
  1616 		
       
  1617 	// Second call to RecognizeData() utilizes the Mime type Recognition cache.
       
  1618 	INFO_PRINTF1(_L("MIME type recognition cache is used..."));
       
  1619 	recogResult.Reset();
       
  1620 	User::LeaveIfError(aLs.RecognizeData(KLitDocPath, buffer, recogResult));
       
  1621 	TEST(recogResult.iDataType.Des8().CompareF(KMimeMmrType) == 0);
       
  1622 	TEST(recogResult.iConfidence == CApaDataRecognizerType::EPossible);
       
  1623 	
       
  1624 	// Delete the plugin resource file of the recognizer with EPossible confidence which was installed during the test from z:.
       
  1625 	TInt fileExists = EFalse;
       
  1626 	fs.IsFilePresent(KRecogRscTargetPath, fileExists);
       
  1627 	if (fileExists)
       
  1628 		{
       
  1629 		fs.ChangeFilePermissionL(KRecogRscTargetPath); // clear readonly attribute inherited from z:
       
  1630 		err = fs.DeleteFileL(KRecogRscTargetPath);
       
  1631 		if(err == KErrNone) 
       
  1632 			INFO_PRINTF1(_L("Removed temporary file recmime_1.rsc"));
       
  1633 		else 
       
  1634 			INFO_PRINTF1(_L("Failed to remove temporary file recmime_1.rsc"));	
       
  1635 		}
       
  1636 
       
  1637 	INFO_PRINTF2(_L("Waits %d seconds for the data recognizer list maintained by EMIME to be updated"), (10 * KOneSecondDelay)/1000000);	
       
  1638  	User::After(10 * KOneSecondDelay);
       
  1639 	
       
  1640 	// Since "mime/mmr1" recognizer is uninstalled, mime/mmr1 mime type is not recognized. 
       
  1641 	INFO_PRINTF1(_L("MIME type recognition cache is flushed when a existing recogizer is uninstalled"));
       
  1642 	recogResult.Reset();
       
  1643 	User::LeaveIfError(aLs.RecognizeData(KLitDocPath, buffer, recogResult));
       
  1644 	TEST(recogResult.iConfidence == CApaDataRecognizerType::ENotRecognized);
       
  1645 	
       
  1646 	CleanupStack::PopAndDestroy(&fs);
       
  1647 	}
       
  1648 
       
  1649 /**
       
  1650   Auxiliary Fn for the entire Test Step
       
  1651  
       
  1652   This method initiates all the tests.
       
  1653 */
       
  1654 TInt CT_Serv2Step::DoServComTestL()
       
  1655 	{
       
  1656 	INFO_PRINTF1(_L("Testing Server Com"));
       
  1657 	
       
  1658 	
       
  1659 	RFs theServFs;
       
  1660 	TInt ret = theServFs.Connect();
       
  1661 	TEST(ret==KErrNone);
       
  1662 	CleanupClosePushL(theServFs);
       
  1663 
       
  1664 	// Connect to the server
       
  1665     RTestableApaLsSession ls;
       
  1666 	ret = ls.ConnectWithoutWaitingForListPopulation();
       
  1667 	TEST(ret==KErrNone);
       
  1668 	CleanupClosePushL(ls);
       
  1669 	
       
  1670 	
       
  1671 	INFO_PRINTF1(_L("Waiting applist to be generated.\n"));
       
  1672 	TRequestStatus requeststatus;
       
  1673 	ls.RegisterListPopulationCompleteObserver(requeststatus);
       
  1674 	
       
  1675 	//Testing the CancelListPopulationCompleteObserver
       
  1676 	TEST(ls.CancelListPopulationCompleteObserver() == KErrNone);
       
  1677 	User::WaitForRequest(requeststatus); 
       
  1678 
       
  1679 	ls.RegisterListPopulationCompleteObserver(requeststatus);
       
  1680 	User::WaitForRequest(requeststatus);
       
  1681 	TEST(requeststatus == KErrNone);
       
  1682 
       
  1683 	//make sure the RFbsSession doesn't have to allocate buffer since it would change the heap
       
  1684 	CFbsBitmap* bufferAllocator = new(ELeave) CFbsBitmap;
       
  1685 	CleanupStack::PushL(bufferAllocator);
       
  1686 	TEST(bufferAllocator->Create(TSize(200,1), EColor16M) == KErrNone);
       
  1687 	CleanupStack::PopAndDestroy(bufferAllocator);
       
  1688 	
       
  1689 	//
       
  1690 	HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, DoInterrogationTestsL(ls), ls.ClearAppInfoArray(); ls.FlushRecognitionCache(); );
       
  1691 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoGetAllApps(ls), ls.ClearAppInfoArray() );
       
  1692 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoGetEmbeddableApps(ls), ls.ClearAppInfoArray() );
       
  1693 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoEmbeddableAppCount(ls), ls.ClearAppInfoArray() );
       
  1694 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoGetAppCapability(ls), ls.ClearAppInfoArray() );
       
  1695 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoGetFilteredApps1(ls), NO_CLEANUP);
       
  1696 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoGetFilteredApps2(ls), ls.ClearAppInfoArray() );
       
  1697 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoGetFilteredApps3(ls), ls.ClearAppInfoArray() );
       
  1698 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoGetFilteredApps4(ls), ls.ClearAppInfoArray() );
       
  1699 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoGetFilteredApps5(ls), ls.ClearAppInfoArray() );
       
  1700 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoGetFilteredApps6(ls), ls.ClearAppInfoArray() );
       
  1701 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoTestEmbeddabilityFilter1(), ls.ClearAppInfoArray() );
       
  1702 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoTestEmbeddabilityFilter2(), ls.ClearAppInfoArray() );
       
  1703 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoTestEmbeddabilityFilter3(), ls.ClearAppInfoArray() );
       
  1704 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoTestEmbeddabilityFilter4(), ls.ClearAppInfoArray() );
       
  1705 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoTestEmbeddabilityFilter5(), ls.ClearAppInfoArray() );
       
  1706 	//DONT_CHECK due to file system changes
       
  1707 	HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, TestRecognitionCacheL(ls), ls.FlushRecognitionCache());
       
  1708 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoRecognizeDataL(ls), ls.FlushRecognitionCache() );
       
  1709 	HEAP_TEST_LS_SESSION(ls, 0, 0, LaunchAppThruCreateDocL(ls), ls.FlushRecognitionCache() );
       
  1710 
       
  1711 
       
  1712 	INFO_PRINTF1(_L("Checking icon loading by size - including OOM tests\n"));
       
  1713 	ret = KErrNoMemory;
       
  1714 	for(TInt fail=0; ret == KErrNoMemory; fail++)
       
  1715 		{
       
  1716 		__UHEAP_FAILNEXT(fail);
       
  1717 		__UHEAP_MARK;
       
  1718 		TRAP(ret, DoCheckServerIconLoadingBySizeL(ls));
       
  1719 		__UHEAP_SETFAIL(RHeap::ENone,0);// turn failure off
       
  1720 		__UHEAP_MARKEND;
       
  1721 		TEST((ret==KErrNoMemory || ret==KErrNone));
       
  1722 		}
       
  1723 
       
  1724 	//DONT_CHECK due to app is started and that app opens up another RApaLsSession (which changes the server's heap)
       
  1725 	HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, DoStartAppTestsL(ls), ls.FlushRecognitionCache() );
       
  1726 	HEAP_TEST_LS_SESSION(ls, 0, 0, DoEnquiryTestsL(ls), NO_CLEANUP);
       
  1727 	//DONT_CHECK due to changes to file system
       
  1728 	HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, DoInstallationTestL(ls), ls.ClearAppInfoArray() );
       
  1729 	HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, DoNumDefIconsTestL(ls), ls.ClearAppInfoArray() );
       
  1730 	
       
  1731 	//
       
  1732 	// close the server session and we have done some type store reloading
       
  1733 	CleanupStack::PopAndDestroy(2, &theServFs);
       
  1734 
       
  1735 	return KErrNone;
       
  1736 	}
       
  1737 
       
  1738 CT_Serv2Step::~CT_Serv2Step()
       
  1739 /**
       
  1740    Destructor
       
  1741  */
       
  1742 	{
       
  1743 	}
       
  1744 
       
  1745 CT_Serv2Step::CT_Serv2Step()
       
  1746 /**
       
  1747    Constructor
       
  1748  */
       
  1749 	{
       
  1750 	// Call base class method to set up the human readable name for logging
       
  1751 	SetTestStepName(KT_Serv2Step);
       
  1752 	}
       
  1753 
       
  1754 TVerdict CT_Serv2Step::doTestStepPreambleL()
       
  1755 /**
       
  1756    @return - TVerdict code
       
  1757    Override of base class virtual
       
  1758  */
       
  1759 	{
       
  1760 	SetTestStepResult(EPass);
       
  1761 	return TestStepResult();
       
  1762 	}
       
  1763 
       
  1764 TVerdict CT_Serv2Step::doTestStepPostambleL()
       
  1765 /**
       
  1766    @return - TVerdict code
       
  1767    Override of base class virtual
       
  1768  */
       
  1769 	{
       
  1770 	return TestStepResult();
       
  1771 	}
       
  1772 
       
  1773 TVerdict CT_Serv2Step::doTestStepL()
       
  1774 /**
       
  1775    Override of base class virtual.
       
  1776    @return - TVerdict code
       
  1777  */
       
  1778 {
       
  1779 	FbsStartup();
       
  1780 	TInt ret = RFbsSession::Connect();
       
  1781 	TEST(ret==KErrNone);
       
  1782 
       
  1783 	// set up the directory structure
       
  1784 	RFs theFs;
       
  1785 	ret = theFs.Connect();
       
  1786 	TEST(ret==KErrNone);
       
  1787 	CleanupClosePushL(theFs);
       
  1788 	
       
  1789 	// run the testcode (inside an alloc heaven harness)
       
  1790 	INFO_PRINTF1(_L("About to test server in process"));
       
  1791 	TRAP(ret,DoServComTestL());
       
  1792 	INFO_PRINTF2(_L("  DoServComTestL completes with %d"), ret);
       
  1793 	TEST(ret==KErrNone);
       
  1794 
       
  1795 	// Cleanup
       
  1796 	CleanupStack::PopAndDestroy(&theFs);
       
  1797 
       
  1798 	INFO_PRINTF1(_L("Test Completed!"));	
       
  1799 	return TestStepResult();
       
  1800 
       
  1801 }
       
  1802