appfw/apparchitecture/tef/T_RApaLsSessionStep.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 // t_rapalssessionstep.cpp
       
    15 //
       
    16 
       
    17 /**
       
    18  @file t_rapalssessionstep.cpp
       
    19  @test
       
    20  @internalComponent - Internal Symbian test code 
       
    21 */
       
    22 
       
    23 #include <f32file.h>
       
    24 #include <fbs.h>
       
    25 #include <s32std.h> 
       
    26 #include <s32stor.h> 
       
    27 #include <s32file.h> 
       
    28 
       
    29 #include <coecntrl.h>
       
    30 #include <coeccntx.h>
       
    31 #include <coemain.h>
       
    32 #include <coeview.h>
       
    33 #include <techview/eikdialg.h>
       
    34 #include <eikdoc.h>
       
    35 #include <eikapp.h>
       
    36 #include <eiksrvc.h>
       
    37 #include <techview/eikconso.h>
       
    38 
       
    39 #include <apaid.h>
       
    40 #include "../apparc/apadll.h"
       
    41 #include <apgaplst.h>
       
    42 #include <apgicnfl.h>
       
    43 #include <apgdoor.h>
       
    44 #include <apfrec.h>
       
    45 #include <apfctlf.h>
       
    46 #include <apgctl.h>
       
    47 #include <apgaplst.h>
       
    48 #include <apaflrec.h>
       
    49 #include <apgcli.h>
       
    50 #include <apacmdln.h>
       
    51 #include <barsread.h>
       
    52 #include "tstapp.h"
       
    53 #include "appfwk_test.h"
       
    54 #include <apgnotif.h>
       
    55 
       
    56 #include "T_RApaLsSessionStep.h"
       
    57 #include "appfwk_test_appui.h"
       
    58 #include "TRApaLsSessionStartAppTest.h"
       
    59 #include "TIconLoaderAndIconArrayForLeaks.h"  
       
    60 
       
    61 #if !defined(__E32TEST_H__)
       
    62 #include <e32test.h>
       
    63 #endif
       
    64 
       
    65 // Literals & Constants
       
    66 _LIT(KCompleted, "Completed.");
       
    67 const TUint KBytesToRead=100;
       
    68 
       
    69 
       
    70 /****************************************
       
    71  Auxiliary functions used by test cases
       
    72 *****************************************/
       
    73 void CT_RApaLsSessionTestStep::setup()
       
    74 	{
       
    75 #if defined(__EPOC32__)
       
    76 	
       
    77 	TFullName filePath=_L("c:\\docs\\tstapp.doc");
       
    78 	TFullName tempPath=_L("c:\\system\\temp\\");
       
    79 	// if we're on the rack create the directories we need
       
    80 	TParse parser;
       
    81 	parser.Set(filePath,NULL,NULL);
       
    82 	iFs.MkDirAll(parser.DriveAndPath());
       
    83 	parser.Set(tempPath,NULL,NULL);
       
    84 	iFs.MkDirAll(parser.DriveAndPath());
       
    85 #endif
       
    86 	}
       
    87 
       
    88 
       
    89 //
       
    90 // Might actually be tests......
       
    91 //
       
    92 
       
    93 void CT_RApaLsSessionTestStep::TestAppListInfoDataInterrogationSetupL()
       
    94 	{
       
    95 	//
       
    96 	INFO_PRINTF1(_L("Initialising App List Cache using GetAllApps....."));
       
    97 	TInt ret = iLs.GetAllApps();
       
    98 	TEST(ret==KErrNone);
       
    99 	INFO_PRINTF1(KCompleted);
       
   100 
       
   101 // get the full app count
       
   102 	INFO_PRINTF1(_L("Getting AppCount....."));
       
   103 	TInt count=0;
       
   104 	ret = iLs.AppCount(count);
       
   105 	TEST(ret==KErrNone);
       
   106 	TEST(count>=1);
       
   107 	INFO_PRINTF1(KCompleted);
       
   108 
       
   109 // prepare to get a list of embeddable apps
       
   110 	INFO_PRINTF1(_L("Initialising embeddable app list cache using GetEmbeddableApps....."));
       
   111 	ret = iLs.GetEmbeddableApps();
       
   112 	TEST(ret==KErrNone);
       
   113 	INFO_PRINTF1(KCompleted);
       
   114 
       
   115 // get the embedded app count
       
   116 	INFO_PRINTF1(_L("Initialising embeddable app list cache using EmbeddableAppCount....."));
       
   117 	count=0;
       
   118 	ret = iLs.EmbeddableAppCount(count);
       
   119 	TEST(ret==KErrNone);
       
   120 	TEST(count>=1);
       
   121 	INFO_PRINTF1(KCompleted);
       
   122 	}	
       
   123 
       
   124 /**
       
   125    @SYMTestCaseID T-RApaLsSessionTestStep-TestAppInfo1
       
   126   
       
   127    @SYMPREQ
       
   128   
       
   129    @SYMTestCaseDesc Test RApaLsSession::GetNextApp() 
       
   130    
       
   131    @SYMTestPriority High 
       
   132   
       
   133    @SYMTestStatus Implemented
       
   134    
       
   135    @SYMTestActions Call RApaLsSession::GetAllApps() to initialize the process of
       
   136    getting all applications in the cached list. Traverse the application list
       
   137    by calling RApaLsSession::GetNextApp() to search for application tstapp.
       
   138    Test the application info obtained from GetNextApp() to ensure the application
       
   139    info obtained is of tstapp. Complete traversal of the list to ensure that at
       
   140    the end of the list, the enum ENoMoreAppInList is returned by GetNextApp().\n
       
   141    API Calls:\n	
       
   142    RApaLsSession::GetAllApps() const\n
       
   143    RApaLsSession::GetNextApp(TApaAppInfo& aInfo) const\n
       
   144    
       
   145    @SYMTestExpectedResults The test compares the results obtained with expected values.
       
   146     
       
   147  */
       
   148 void CT_RApaLsSessionTestStep::TestAppInfo1()
       
   149 	{
       
   150 	
       
   151 	INFO_PRINTF1(_L("Testing RApaLsSession::ENoMoreAppsInList....attempt to get an app"));
       
   152     //Go to end of Applist for next test... 
       
   153 	TApaAppInfo info;
       
   154 	TInt ret = iLs.GetAllApps();
       
   155 	TEST(ret==KErrNone);
       
   156 
       
   157 	do
       
   158 		{
       
   159  		ret=iLs.GetNextApp(info);
       
   160  		}
       
   161  	while (ret != RApaLsSession::ENoMoreAppsInList);
       
   162 
       
   163 	//try to get another app (there arn't any more)
       
   164 	ret = iLs.GetNextApp(info);
       
   165 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   166 	
       
   167 	INFO_PRINTF1(KCompleted);
       
   168 	}
       
   169 
       
   170 /**
       
   171    @SYMTestCaseID T-RApaLsSessionTestStep-TestAppInfo2
       
   172   
       
   173    @SYMPREQ
       
   174   
       
   175    @SYMTestCaseDesc Test RApaLsSession::GetNextApp() 
       
   176    
       
   177    @SYMTestPriority High 
       
   178   
       
   179    @SYMTestStatus Implemented
       
   180    
       
   181    @SYMTestActions Call RApaLsSession::GetAllApps() to initialize the process of
       
   182    getting all applications in the cached list. Traverse the application list
       
   183    by calling RApaLsSession::GetNextApp() to search for application tstapp.
       
   184    Test the application information obtained from GetNextApp() to ensure that
       
   185    information retrieved is of tstapp.\n
       
   186    API Calls:\n	
       
   187    RApaLsSession::GetAllApps() const\n
       
   188    RApaLsSession::GetNextApp(TApaAppInfo& aInfo) const\n
       
   189    
       
   190    @SYMTestExpectedResults The test compares the results obtained with expected values.
       
   191     
       
   192  */
       
   193 void CT_RApaLsSessionTestStep::TestAppInfo2()
       
   194 	{
       
   195 	INFO_PRINTF1(_L("Testing RApaLsSession::GetNextApps() return info...."));
       
   196 	_LIT(KLitAppPath,"z:\\sys\\bin\\tstapp.exe");
       
   197 	TFullName appPath(KLitAppPath);
       
   198 
       
   199 	TApaAppInfo info;
       
   200 	TInt ret = iLs.GetAllApps();
       
   201 	TEST(ret==KErrNone);
       
   202 
       
   203 	do
       
   204 	{
       
   205 		iLs.GetNextApp(info);
       
   206 	}
       
   207 	while (ret==KErrNone && info.iUid!=KUidTestApp);
       
   208 		
       
   209 	TEST(ret==KErrNone);
       
   210 	TEST(info.iUid==KUidTestApp);
       
   211 	info.iFullName.LowerCase();	
       
   212 	TEST(info.iFullName.Compare(appPath) == 0);
       
   213 	INFO_PRINTF1(KCompleted);
       
   214 	}
       
   215 
       
   216 /**
       
   217    @SYMTestCaseID T-RApaLsSessionTestStep-TestAppInfo3
       
   218   
       
   219    @SYMPREQ
       
   220   
       
   221    @SYMTestCaseDesc Test RApaLsSession::GetAppInfo(). 
       
   222    
       
   223    @SYMTestPriority High 
       
   224   
       
   225    @SYMTestStatus Implemented
       
   226    
       
   227    @SYMTestActions Call RApaLsSession::GetAppInfo() by passing the Uid of test
       
   228    application tstapp and test the application info obtained from GetAppInfo()
       
   229    to ensure the obtained information is of test application tstapp.\n
       
   230    API Calls:\n	
       
   231    RApaLsSession::GetAppInfo(TApaAppInfo& aInfo,TUid aAppUid) const\n
       
   232    
       
   233    @SYMTestExpectedResults The test confirms that RApaLsSession::GetAppInfo()
       
   234    returns the expected application info.
       
   235     
       
   236  */
       
   237 void CT_RApaLsSessionTestStep::TestAppInfo3()
       
   238 	{
       
   239 	INFO_PRINTF1(_L("Testing RApaLsSession::GetAppInfo()...."));
       
   240 	_LIT(KLitAppPath,"z:\\sys\\bin\\tstapp.exe");
       
   241 	TFullName appPath(KLitAppPath);
       
   242 	// Get info for an app that exists
       
   243 	TApaAppInfo info;
       
   244 	TInt ret = iLs.GetAppInfo(info,KUidTestApp);
       
   245 	TEST(ret==KErrNone);
       
   246 	TEST(info.iUid==KUidTestApp);
       
   247 	info.iFullName.LowerCase();	
       
   248 	TEST(info.iFullName.Compare(appPath) == 0);
       
   249 	INFO_PRINTF1(KCompleted);
       
   250 	}
       
   251 
       
   252 /**
       
   253    @SYMTestCaseID T-RApaLsSessionTestStep-TestAppInfo4
       
   254   
       
   255    @SYMPREQ
       
   256   
       
   257    @SYMTestCaseDesc Test if RApaLsSession::GetAppInfo() return KErrNotFound. 
       
   258    
       
   259    @SYMTestPriority High 
       
   260   
       
   261    @SYMTestStatus Implemented
       
   262    
       
   263    @SYMTestActions The method calls RApaLsSession::GetAppInfo() by passing the null Uid
       
   264    KNullUid. Observe whether KErrNotFound is returned when Uid that doesn't match
       
   265    is passed to GetAppInfo().\n
       
   266    API Calls:\n	
       
   267    RApaLsSession::GetAppInfo(TApaAppInfo& aInfo,TUid aAppUid) const\n
       
   268    
       
   269    @SYMTestExpectedResults The test confirms RApaLsSession::GetAppInfo() returns
       
   270    KErrNotFound when no match is found for the Uid passed.\n
       
   271     
       
   272  */
       
   273 void CT_RApaLsSessionTestStep::TestAppInfo4()
       
   274 	{
       
   275 	INFO_PRINTF1(_L("Testing RApaLsSession::GetAppInfo()....non-existent app"));
       
   276 
       
   277 	TApaAppInfo info;
       
   278 	TInt ret = iLs.GetAppInfo(info,KNullUid);
       
   279 	TEST(ret==KErrNotFound);
       
   280 	INFO_PRINTF1(KCompleted);
       
   281 	}
       
   282 
       
   283 /**
       
   284    @SYMTestCaseID T-RApaLsSessionTestStep-TestServerIconSizeCountL
       
   285   
       
   286    @SYMPREQ
       
   287   
       
   288    @SYMTestCaseDesc Test Get the number of icon sizes for testapp app. 
       
   289    
       
   290    @SYMTestPriority High 
       
   291   
       
   292    @SYMTestStatus Implemented
       
   293    
       
   294    @SYMTestActions Allocate a flat dynamic buffer which would hold available icon
       
   295    sizes for tstapp. Call RApaLsSession::GetAppIconSizes() to store the sizes
       
   296    of icons available for the app tstapp to the allocated flat dynamic buffer.
       
   297    Check that it is non zero, i.e. that a number of icon sizes has been retreived
       
   298    for testapp.\n
       
   299    API Calls:\n	
       
   300    RApaLsSession::GetAppIconSizes(TUid aAppUid, CArrayFixFlat<TSize>& aArrayToFill) const\n
       
   301    
       
   302    @SYMTestExpectedResults aTestIconSizeArray->Count() is greater than 0.
       
   303     
       
   304  */
       
   305 void CT_RApaLsSessionTestStep::TestServerIconSizeCountL(CArrayFixFlat<TSize>& aTestIconSizeArray)
       
   306 	{
       
   307 	INFO_PRINTF1(_L("Test RApaLsSession::GetAppIconSizes..."));
       
   308 
       
   309 	TInt ret=iLs.GetAppIconSizes(KUidTestApp,aTestIconSizeArray);
       
   310 	if(ret==KErrNoMemory)
       
   311 		User::Leave(KErrNoMemory);
       
   312 	TEST(ret==KErrNone);
       
   313 	TEST(aTestIconSizeArray.Count()!=0);
       
   314 	
       
   315 	INFO_PRINTF1(KCompleted);
       
   316 	}
       
   317 
       
   318 
       
   319 
       
   320 /**
       
   321    @SYMTestCaseID T-RApaLsSessionTestStep-TestServerIconLoadingBySize1L
       
   322   
       
   323    @SYMPREQ
       
   324   
       
   325    @SYMTestCaseDesc Test loading of Icon by size. 
       
   326    
       
   327    @SYMTestPriority High 
       
   328   
       
   329    @SYMTestStatus Implemented
       
   330    
       
   331    @SYMTestActions Allocate a flat dynamic buffer which would hold available icon
       
   332    sizes for tstapp. Call RApaLsSession::GetAppIconSizes() to store the sizes
       
   333    of icons available for the app tstapp to the allocated flat dynamic buffer.
       
   334    Call RApaLsSession::GetAppIcon() by passing each of the icon sizes stored.
       
   335    Verify whether icon is retrieved each time by GetAppIcon().\n
       
   336    API Calls:\n	
       
   337    RApaLsSession::GetAppIcon(TUid aAppUid, TSize aSize, CApaMaskedBitmap& aAppBitmap) const\n
       
   338    
       
   339    @SYMTestExpectedResults The results obtained are compared with the expected values to verify
       
   340    functionality of RApaLsSession::GetAppIcon().
       
   341     
       
   342  */
       
   343 void CT_RApaLsSessionTestStep::TestServerIconLoadingBySize1L(CArrayFixFlat<TSize>& aTestIconSizeArray)
       
   344 	{
       
   345 	INFO_PRINTF1(_L("Test RApaLsSession::GetAppIcon....Compare icon sizes"));
       
   346 
       
   347 	for(TInt i=0;i<aTestIconSizeArray.Count();i++)
       
   348 		{
       
   349 		CApaMaskedBitmap* iconBySize=CApaMaskedBitmap::NewLC();
       
   350 		TInt ret=iLs.GetAppIcon(KUidTestApp,aTestIconSizeArray[i],*iconBySize); //by Size
       
   351 		if(ret==KErrNoMemory)
       
   352 			User::Leave(KErrNoMemory);
       
   353 		TEST(ret==KErrNone);
       
   354 		TEST(iconBySize->SizeInPixels()==aTestIconSizeArray[i]);
       
   355 		CleanupStack::PopAndDestroy(iconBySize);
       
   356 		}
       
   357 	INFO_PRINTF1(KCompleted);
       
   358 	}
       
   359 
       
   360 /**
       
   361    @SYMTestCaseID T-RApaLsSessionTestStep-TestServerIconLoadingBySize2L
       
   362   
       
   363    @SYMPREQ
       
   364   
       
   365    @SYMTestCaseDesc Test loading of Icon by size. 
       
   366    
       
   367    @SYMTestPriority High 
       
   368   
       
   369    @SYMTestStatus Implemented
       
   370    
       
   371    @SYMTestActions Allocate a flat dynamic buffer which would hold available icon
       
   372    sizes for tstapp. Call RApaLsSession::GetAppIconSizes() to store the sizes
       
   373    of icons available for the app tstapp to the allocated flat dynamic buffer.
       
   374    Call RApaLsSession::GetAppIcon() by passing each of the icon sizes stored.
       
   375    Test calling RApaLsSession::GetAppIcon() by specifying reduced size than
       
   376    the actual icon size. Since no match would be found, KErrNotFound should be
       
   377    returned.\n
       
   378    API Calls:\n	
       
   379    RApaLsSession::GetAppIcon(TUid aAppUid, TSize aSize, CApaMaskedBitmap& aAppBitmap) const\n
       
   380    
       
   381    @SYMTestExpectedResults The results obtained are compared with the expected values to verify
       
   382    functionality of RApaLsSession::GetAppIcon().
       
   383     
       
   384  */
       
   385 void CT_RApaLsSessionTestStep::TestServerIconLoadingBySize2L(CArrayFixFlat<TSize>& aTestIconSizeArray)
       
   386 	{
       
   387 	INFO_PRINTF1(_L("Test RApaLsSession::GetAppIcon....Compare icon sizes that don't match"));
       
   388 
       
   389 	// now try non exact sizes
       
   390 	CApaMaskedBitmap* iconBySize=CApaMaskedBitmap::NewLC();
       
   391 	TInt ret=iLs.GetAppIcon(KUidTestApp,(aTestIconSizeArray[0])+TSize(-5,-5),*iconBySize); //by Size
       
   392 	if(ret==KErrNoMemory)
       
   393 		User::Leave(KErrNoMemory);
       
   394 	TEST(ret==KErrNotFound);
       
   395 	CleanupStack::PopAndDestroy(iconBySize);
       
   396 	INFO_PRINTF1(KCompleted);
       
   397 	}
       
   398 
       
   399 /**
       
   400    @SYMTestCaseID T-RApaLsSessionTestStep-TestServerIconLoadingBySize3L
       
   401   
       
   402    @SYMPREQ
       
   403   
       
   404    @SYMTestCaseDesc Test loading of Icon by size. 
       
   405    
       
   406    @SYMTestPriority High 
       
   407   
       
   408    @SYMTestStatus Implemented
       
   409    
       
   410    @SYMTestActions Allocate a flat dynamic buffer which would hold available icon
       
   411    sizes for tstapp. Call RApaLsSession::GetAppIconSizes() to store the sizes
       
   412    of icons available for the app tstapp to the allocated flat dynamic buffer.
       
   413    Call RApaLsSession::GetAppIcon() by passing each of the icon sizes stored.
       
   414    Test GetAppIcon() again by specifying an increased size than the
       
   415    actual icon size. Observe whether the GetAppIcon() in this case gets the
       
   416    closest icon available.\n
       
   417    API Calls:\n	
       
   418    RApaLsSession::GetAppIcon(TUid aAppUid, TSize aSize, CApaMaskedBitmap& aAppBitmap) const\n
       
   419    
       
   420    @SYMTestExpectedResults The results obtained are compared with the expected values to verify
       
   421    functionality of RApaLsSession::GetAppIcon().
       
   422     
       
   423  */
       
   424 void CT_RApaLsSessionTestStep::TestServerIconLoadingBySize3L(CArrayFixFlat<TSize>& aTestIconSizeArray)
       
   425 	{
       
   426 	INFO_PRINTF1(_L("Test RApaLsSession::GetAppIcon....Compare icon sizes that don't match."));
       
   427 	for(TInt ii=0;ii<aTestIconSizeArray.Count();ii++)
       
   428 		{
       
   429 		CApaMaskedBitmap* iconBySize=CApaMaskedBitmap::NewLC();
       
   430 		TInt ret=iLs.GetAppIcon(KUidTestApp,(aTestIconSizeArray[ii])+TSize(5,5),*iconBySize); //by Size
       
   431 		if(ret==KErrNoMemory)
       
   432 			User::Leave(KErrNoMemory);
       
   433 		TEST(ret==KErrNone);
       
   434 		TEST(iconBySize->SizeInPixels()==aTestIconSizeArray[ii]); // should get size below always!!!
       
   435 		CleanupStack::PopAndDestroy(iconBySize);
       
   436 		}
       
   437 	INFO_PRINTF1(KCompleted);
       
   438 	}
       
   439 
       
   440 
       
   441 /**
       
   442    @SYMTestCaseID T-RApaLsSessionTestStep-TestAppListInvalidL()
       
   443   
       
   444    @SYMPREQ
       
   445   
       
   446    @SYMTestCaseDesc Test .
       
   447    
       
   448    @SYMTestPriority High 
       
   449   
       
   450    @SYMTestStatus Implemented
       
   451    
       
   452    @SYMTestActions Test RApaLsSession::AppForDocument() to recognize data type &
       
   453    applications that can handle the data type of data stored in the specified
       
   454    file. The test is performed on files of one byte and zero byte sizes.
       
   455    Observe that on both occasions the API returns Uid of an application that
       
   456    can handle text \ plain data type.\n
       
   457    Test RApaLsSession::AppForDataType() to recognize Uid of an application
       
   458    that can handle a specified data type. To do this the test calls
       
   459    RApaLsSession::RecognizeData() which gets the data type for data taken
       
   460    from a specified file. The test is performed on files of one byte and zero
       
   461    byte sizes. The test ensures that RApaLsSession::AppForDataType() doesn't
       
   462    return KNullUid for both sizes of the file.\n
       
   463    API Calls:\n	
       
   464    RApaLsSession::AppForDocument(const TDesC& aFileName, TUid& aUid, TDataType& aDataType) const\n
       
   465    RApaLsSession::RecognizeData(const TDesC& aName, const TDesC8& aBuffer, TDataRecognitionResult& aDataType) const\n
       
   466    RApaLsSession::AppForDataType(const TDataType& aDataType, TUid& aAppUid) const\n
       
   467    
       
   468    @SYMTestExpectedResults Test ensures that the data recognition functions identify the data type of
       
   469    data in a file and the application capable of handling the specified
       
   470    data type.
       
   471    
       
   472  */
       
   473 void CT_RApaLsSessionTestStep::TestAppListInvalidL()
       
   474 	{
       
   475 	__UHEAP_MARK;
       
   476 	TestAppListInvalidSetupL();
       
   477 	__UHEAP_MARKEND;
       
   478 	
       
   479 	INFO_PRINTF1(_L("Test RApaLsSession::GetNextApp() never returns RApaLsSession::EAppListInvalid."));
       
   480 
       
   481 	TApaAppInfo info;
       
   482 	TInt ret=0;
       
   483 	while(ret==KErrNone)
       
   484 		{
       
   485 		ret=iLs.GetNextApp(info);
       
   486 		}
       
   487 
       
   488 	//tests GetNextApp() never returns RApaLsSession::EAppListInvalid
       
   489 	TEST(ret!=RApaLsSession::EAppListInvalid);
       
   490 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   491 	INFO_PRINTF1(KCompleted);
       
   492 	}
       
   493 
       
   494 
       
   495 void CT_RApaLsSessionTestStep::TestAppListInvalidSetupL()
       
   496 	{
       
   497 	INFO_PRINTF1(_L("Setting up Applist invalid test."));
       
   498 	
       
   499 	_LIT(KTempAppDir, "C:\\private\\10003a3f\\import\\apps\\");
       
   500 	_LIT(KTempRegPath, "C:\\private\\10003a3f\\import\\apps\\tstapp_reg.rsc");
       
   501 	TFullName regPath=_L("z:\\private\\10003a3f\\import\\apps\\tstapp_reg.rsc");
       
   502 	
       
   503 	CFileMan* iAppListInvalidTestFileMan = CFileMan::NewL (iFs);
       
   504 	CleanupStack::PushL(iAppListInvalidTestFileMan);
       
   505 	
       
   506 	INFO_PRINTF1(_L("Copy tstapp files to C: drive......."));
       
   507 	TInt rtn=iFs.MkDirAll(KTempAppDir);
       
   508 	TEST(rtn==KErrNone||rtn==KErrAlreadyExists); 
       
   509 	TEST(iAppListInvalidTestFileMan->Copy(regPath, KTempRegPath)==KErrNone);	//Just to start the idle update.
       
   510 
       
   511 	INFO_PRINTF1(_L("Get app list......."));
       
   512 	TInt ret = iLs.GetAllApps();
       
   513 	TEST(ret==KErrNone);
       
   514 
       
   515 	INFO_PRINTF1(_L("Remove temp files from C: drive......."));
       
   516 	TRequestStatus status;
       
   517 	TTime tempTime(0); // added tempTime to avoid asynch CFileMan::Attribs request completing with KErrArgument
       
   518 	TEST(iAppListInvalidTestFileMan->Attribs(KTempAppDir,0,KEntryAttReadOnly, tempTime, CFileMan::ERecurse, status)==KErrNone);
       
   519 	
       
   520 	User::WaitForRequest(status);
       
   521 	TEST(status.Int() == KErrNone);
       
   522 	INFO_PRINTF1(_L("Deleting Reg file......."));
       
   523 	TEST(iAppListInvalidTestFileMan->Delete(KTempRegPath)==KErrNone);	//Just to start the idle update.
       
   524 	INFO_PRINTF1(_L("Removing App dir......."));
       
   525 	TEST(iAppListInvalidTestFileMan->RmDir(KTempAppDir)==KErrNone);
       
   526 	CleanupStack::PopAndDestroy(iAppListInvalidTestFileMan);
       
   527 
       
   528 	INFO_PRINTF1(KCompleted);
       
   529 	}
       
   530 
       
   531 
       
   532 
       
   533 /**
       
   534    @SYMTestCaseID T-RApaLsSessionTestStep-TestAppListRecognizeDataL
       
   535   
       
   536    @SYMPREQ
       
   537   
       
   538    @SYMTestCaseDesc Test data recognition functions of RApaLsSession.
       
   539    
       
   540    @SYMTestPriority High 
       
   541   
       
   542    @SYMTestStatus Implemented
       
   543    
       
   544    @SYMTestActions Test RApaLsSession::AppForDocument() to recognize data type &
       
   545    applications that can handle the data type of data stored in the specified
       
   546    file. The test is performed on files of one byte and zero byte sizes.
       
   547    Observe that on both occasions the API returns Uid of an application that
       
   548    can handle text \ plain data type.\n
       
   549    Test RApaLsSession::AppForDataType() to recognize Uid of an application
       
   550    that can handle a specified data type. To do this the test calls
       
   551    RApaLsSession::RecognizeData() which gets the data type for data taken
       
   552    from a specified file. The test is performed on files of one byte and zero
       
   553    byte sizes. The test ensures that RApaLsSession::AppForDataType() doesn't
       
   554    return KNullUid for both sizes of the file.\n
       
   555    API Calls:\n	
       
   556    RApaLsSession::AppForDocument(const TDesC& aFileName, TUid& aUid, TDataType& aDataType) const\n
       
   557    RApaLsSession::RecognizeData(const TDesC& aName, const TDesC8& aBuffer, TDataRecognitionResult& aDataType) const\n
       
   558    RApaLsSession::AppForDataType(const TDataType& aDataType, TUid& aAppUid) const\n
       
   559    
       
   560    @SYMTestExpectedResults Test ensures that the data recognition functions identify the data type of
       
   561    data in a file and the application capable of handling the specified
       
   562    data type.
       
   563     
       
   564  */
       
   565 void CT_RApaLsSessionTestStep::TestAppListRecognizeDataL()
       
   566 	{
       
   567 	// The following tests will only succeed if the text recogniser and an app which likes text files are both installed
       
   568 	// The tests check that file recognisers work for zero and non zero length files.
       
   569 	INFO_PRINTF1(_L("Testing AppForDocument(), RecognizeData() and AppForDataType()"));
       
   570 	TInt ret;
       
   571 	TUid appUid=KNullUid;
       
   572     TDataType dataType;
       
   573 	INFO_PRINTF1(_L("Testing 1 byte text file recognition"));
       
   574     ret = iLs.AppForDocument(_L("z:\\system\\data\\one_byte.txt"), appUid,dataType);
       
   575 	TEST(ret==KErrNone);
       
   576 	TEST(appUid!=KNullUid);
       
   577 	INFO_PRINTF1(KCompleted);
       
   578 	
       
   579 	appUid=KNullUid;
       
   580 	INFO_PRINTF1(_L("Testing zero byte text file recognition"));
       
   581     ret = iLs.AppForDocument(_L("z:\\system\\data\\zero_len.txt"), appUid,dataType);
       
   582 	TEST(ret==KErrNone);
       
   583 	TEST(appUid!=KNullUid);
       
   584 	INFO_PRINTF1(KCompleted);
       
   585 	
       
   586 	// this following exihibits a defect which was fixed for Release 6 is fixed.
       
   587 	// KNullUid was recognized for zero length text files using this method before the fix.
       
   588 	appUid=KNullUid;
       
   589 	TBuf8<255> buffer;
       
   590     buffer.FillZ(255);
       
   591     buffer[0] = 'a';	// We used to fill it entirely with zeroes but an ICL recognizer know interferes 
       
   592     					// with this, so we added an 'a'
       
   593 	TDataRecognitionResult recogResult;
       
   594 
       
   595 	appUid=KNullUid;
       
   596 	INFO_PRINTF1(_L("Testing 1 byte text file recognition - lengthy method"));
       
   597     ret = iLs.RecognizeData(_L("z:\\system\\data\\one_byte.txt"),buffer,recogResult);
       
   598 	TEST(ret==KErrNone);
       
   599     ret = iLs.AppForDataType(recogResult.iDataType,appUid);
       
   600 	TEST(ret==KErrNone);
       
   601 	TEST(appUid!=KNullUid);
       
   602 	INFO_PRINTF1(KCompleted);
       
   603 
       
   604 	appUid=KNullUid;
       
   605 	INFO_PRINTF1(_L("Testing zero byte text file recognition -lengthy method"));
       
   606 	ret = iLs.RecognizeData(_L("z:\\system\\data\\zero_len.txt"),buffer,recogResult);
       
   607 	TEST(ret==KErrNone);
       
   608     ret = iLs.AppForDataType(recogResult.iDataType,appUid);
       
   609 	TEST(ret==KErrNone);
       
   610 	TEST(appUid!=KNullUid);
       
   611 	INFO_PRINTF1(KCompleted);
       
   612 	
       
   613 	// the following attempts to open a file of an unknown mime type with extension .UnrecognisableExtention
       
   614 	
       
   615 	INFO_PRINTF1(_L("Testing RecognizeData() with unrecognizable file type..."));
       
   616 	buffer.FillZ(255);
       
   617 	_LIT8(KLitUnRecog,"");
       
   618 	iLs.FlushRecognitionCache();
       
   619 	recogResult.Reset();
       
   620 	//First call to RecognizeData() does not utilize the cache
       
   621 	User::LeaveIfError(iLs.RecognizeData(_L("z:\\system\\data\\FileWithUnknownMimeType.UnrecognisableExtention"),buffer,recogResult));
       
   622 	TEST(recogResult.iDataType.Des8().CompareF(KLitUnRecog)==0);
       
   623 	recogResult.Reset();
       
   624 	//Second call to RecognizeData() utilizes the cache
       
   625 	User::LeaveIfError(iLs.RecognizeData(_L("z:\\system\\data\\FileWithUnknownMimeType.UnrecognisableExtention"),buffer,recogResult));
       
   626 	TEST(recogResult.iDataType.Des8().CompareF(KLitUnRecog)==0);
       
   627 	INFO_PRINTF1(_L("Completed Testing unrecognizable file type..."));
       
   628 	
       
   629    	}
       
   630    	
       
   631 /**
       
   632    @SYMTestCaseID T-RApaLsSessionTestStep-TestAppListRecognizeDataBufferOnlyL
       
   633   
       
   634    @SYMPREQ INC064138
       
   635   
       
   636    @SYMTestCaseDesc Test data recognition functions of RApaLsSession without a filename.
       
   637    
       
   638    @SYMTestPriority High 
       
   639   
       
   640    @SYMTestStatus Implemented
       
   641    
       
   642    @SYMTestActions 
       
   643    
       
   644    @SYMTestExpectedResults Test ensures that the data recognition functions identify the data type of
       
   645    data in a file.
       
   646  */
       
   647 void CT_RApaLsSessionTestStep::TestAppListRecognizeDataBufferOnlyL()
       
   648 	{
       
   649 	INFO_PRINTF1(_L("Testing recognition without filename"));
       
   650 	
       
   651 	TDataRecognitionResult rr;
       
   652     _LIT8(KTestBuffer, "Text_TestRecognizer");
       
   653     rr.Reset();
       
   654     TInt error = iLs.RecognizeData(KNullDesC, KTestBuffer, rr);
       
   655     if (rr.iConfidence != CApaDataRecognizerType::ECertain)
       
   656         {
       
   657         INFO_PRINTF1(_L("Error: confidence should be ECertain"));
       
   658         TEST(EFalse);
       
   659         }
       
   660     
       
   661     _LIT8(KAnotherBuffer, "AnotherText");
       
   662     rr.Reset();
       
   663     error = iLs.RecognizeData(KNullDesC, KAnotherBuffer, rr);
       
   664     if (rr.iConfidence != CApaDataRecognizerType::EProbable)
       
   665         {
       
   666         INFO_PRINTF1(_L("Error: confidence should be EProbable"));        
       
   667         TEST(EFalse);
       
   668         }  
       
   669    
       
   670   	INFO_PRINTF1(KCompleted);
       
   671 	}
       
   672  
       
   673 /**
       
   674    @SYMTestCaseID APPFWK-APPARC-00105
       
   675   
       
   676    @SYMDEF DEF139507 :API for recognizing data from memory buffer
       
   677   
       
   678    @SYMTestCaseDesc Test data recognition functions of RApaLsSession passing data only by buffer.
       
   679    
       
   680    @SYMTestPriority High 
       
   681   
       
   682    @SYMTestStatus Implemented
       
   683    
       
   684    @SYMTestActions Test RApaLsSession::RecognizeData() to recognize the data type of the data passed only by buffer.
       
   685    
       
   686    @SYMTestExpectedResults Test ensures that the data recognition functions identify the data type of
       
   687    data passed by buffer.
       
   688  */
       
   689 void CT_RApaLsSessionTestStep::TestAppListRecognizeDataPassedByBufferL()
       
   690 	{
       
   691 	INFO_PRINTF1(_L("Testing data recognition functions of RApaLsSession passing data only by buffer"));
       
   692 
       
   693 	//tbufferonlyrec.dll recognizes KTestBuffer with confidence as ECertain 
       
   694 	TDataRecognitionResult rr;
       
   695     _LIT8(KTestBuffer, "Text_TestRecognizer");
       
   696     rr.Reset();
       
   697     TInt error = iLs.RecognizeData(KTestBuffer, rr);
       
   698     if (rr.iConfidence != CApaDataRecognizerType::ECertain)
       
   699         {
       
   700         INFO_PRINTF1(_L("Error: confidence should be ECertain"));
       
   701         TEST(EFalse);
       
   702         }
       
   703     
       
   704 	//tbufferonlyrec.dll recognizes KAnotherBuffer with confidence as EProbable
       
   705     _LIT8(KAnotherBuffer, "AnotherText");
       
   706     rr.Reset();
       
   707     error = iLs.RecognizeData(KAnotherBuffer, rr);
       
   708     if (rr.iConfidence != CApaDataRecognizerType::EProbable)
       
   709         {
       
   710         INFO_PRINTF1(_L("Error: confidence should be EProbable"));        
       
   711         TEST(EFalse);
       
   712         }  
       
   713 
       
   714 	//tbufferonlyrec.dll recognizes KSampleBuffer with confidence as ENotRecognized 
       
   715    _LIT8(KSampleBuffer, "Sample Application");
       
   716     rr.Reset();
       
   717     error = iLs.RecognizeData(KSampleBuffer, rr);
       
   718     if (rr.iConfidence != CApaDataRecognizerType::ENotRecognized)
       
   719         {
       
   720         INFO_PRINTF1(_L("Error: confidence should be ENotRecognized"));        
       
   721         TEST(EFalse);
       
   722         }  
       
   723   	INFO_PRINTF1(KCompleted);
       
   724 	}
       
   725 
       
   726 /**
       
   727    @SYMTestCaseID T-Serv2Step-DoEnquiryTestsL
       
   728   
       
   729    @SYMPREQ
       
   730   
       
   731    @SYMTestCaseDesc Tests querying of data (MIME) type information. 
       
   732    
       
   733    @SYMTestPriority High 
       
   734   
       
   735    @SYMTestStatus Implemented
       
   736    
       
   737    @SYMTestActions Test setting and getting the confidence threshold for
       
   738    successful data recognition by calling RApaLsSession::SetAcceptedConfidence()
       
   739    and RApaLsSession::GetAcceptedConfidence().\n
       
   740    Test setting and getting maximum size of the data that can be read
       
   741    from a file for the purpose of recognizing the data type by calling
       
   742    RApaLsSession::SetMaxDataBufSize() and RApaLsSession::GetMaxDataBufSize().
       
   743    Finally test retrieval of all supported data (MIME) types.\n
       
   744    API Calls:\n	
       
   745    RApaLsSession::SetAcceptedConfidence(TInt aConfidence)\n
       
   746    RApaLsSession::GetAcceptedConfidence(TInt& aConfidence) const\n
       
   747    RApaLsSession::SetMaxDataBufSize(TInt aBufSize)\n
       
   748    RApaLsSession::GetMaxDataBufSize(TInt& aBufSize) const\n
       
   749    RApaLsSession::GetSupportedDataTypesL(CDataTypeArray& aDataTypes) const\n
       
   750    
       
   751    @SYMTestExpectedResults Test results against expected values.
       
   752     
       
   753  */
       
   754 void CT_RApaLsSessionTestStep::TestSetGetAcceptedConfidenceL()
       
   755 	{
       
   756 	INFO_PRINTF1(_L("Test SetAcceptedConfidence...."));
       
   757 	
       
   758 	TInt temp=1234;
       
   759 	TInt ret=iLs.SetAcceptedConfidence(temp);
       
   760 	TSecurityInfo info;
       
   761 	info.Set(RProcess());
       
   762 	
       
   763 	info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(ret==KErrNone) :  TEST(ret==KErrPermissionDenied);
       
   764 	INFO_PRINTF1(KCompleted);
       
   765 	
       
   766 	INFO_PRINTF1(_L("Test GetAcceptedConfidence...."));
       
   767 	temp=0;
       
   768 	ret=iLs.GetAcceptedConfidence(temp);
       
   769 	TEST(ret==KErrNone);
       
   770 	TEST(temp==1234);
       
   771 	INFO_PRINTF1(KCompleted);
       
   772 	}
       
   773 
       
   774 void CT_RApaLsSessionTestStep::TestSetGetMaxDataBufSizeL()
       
   775 	{
       
   776 	INFO_PRINTF1(_L("Test SetMaxDataBufSize...."));
       
   777 
       
   778 	TInt temp=1234;
       
   779 	TInt ret=iLs.SetMaxDataBufSize(temp);
       
   780 	TEST(ret==KErrNone);
       
   781 	INFO_PRINTF1(KCompleted);
       
   782 	
       
   783 	INFO_PRINTF1(_L("Test GetMaxDataBufSize...."));
       
   784 	temp=0;
       
   785 	ret=iLs.GetMaxDataBufSize(temp);
       
   786 	TEST(ret==KErrNone);
       
   787 	TEST(temp==1234);
       
   788 	INFO_PRINTF1(KCompleted);
       
   789 	}
       
   790 
       
   791 void CT_RApaLsSessionTestStep::TestGetSupportedDataTypesL()
       
   792 {
       
   793 	INFO_PRINTF1(_L("Test GetSupportedDataTypes...."));
       
   794 
       
   795 	CDataTypeArray* dataTypes=new(ELeave) CDataTypeArray(5);
       
   796 	CleanupStack::PushL(dataTypes);
       
   797 	
       
   798 	TInt ret=iLs.GetSupportedDataTypesL(*dataTypes);
       
   799 	TEST(ret==KErrNone);
       
   800 	TEST(dataTypes->Count()>=4);
       
   801 	CleanupStack::PopAndDestroy(); // dataTypes
       
   802 
       
   803 	INFO_PRINTF1(KCompleted);
       
   804 	}
       
   805 
       
   806 
       
   807 /**
       
   808    @SYMTestCaseID T-RApaLsSessionTestStep-DoGetAllApps
       
   809   
       
   810    @SYMPREQ PHAR-5Q4FX8
       
   811   
       
   812    @SYMTestCaseDesc
       
   813    Check that RApaLsSession::GetAllApps() hasn't been
       
   814    affected by the new code to filter the app list
       
   815    based on embeddability (implemented for CR PHAR-5Q4FX8)
       
   816   
       
   817    @SYMTestPriority High
       
   818   
       
   819    @SYMTestStatus Implemented
       
   820   
       
   821    @SYMTestActions
       
   822    Call GetAllApps() once, followed by repeated calls
       
   823    to GetNextApp until something other than KErrNone is returned
       
   824   
       
   825    @SYMTestExpectedResults
       
   826    GetNextApp should return app info for the following test apps:
       
   827    TAppNotEmbeddable.exe
       
   828    TAppEmbeddable.dll
       
   829    TAppEmbeddableOnly.dll
       
   830    TAppEmbeddableUiOrStandAlone.dll
       
   831    TAppEmbeddableUiNotStandAlone.dll
       
   832    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
   833   
       
   834  */
       
   835 void CT_RApaLsSessionTestStep::DoGetAllApps()
       
   836 	{
       
   837 	INFO_PRINTF1(_L("DoGetAllApps"));
       
   838 
       
   839 	TInt ret = iLs.GetAllApps();
       
   840 	TEST(ret==KErrNone);
       
   841 
       
   842 	TApaAppInfo appInfo;
       
   843 	TUint bitFlags = 0;
       
   844 	while ((ret = iLs.GetNextApp(appInfo)) == KErrNone)
       
   845 		{
       
   846 		if (appInfo.iUid == KUidAppNotEmbeddable)
       
   847 			bitFlags |= 0x01;
       
   848 		else if (appInfo.iUid == KUidAppEmbeddable)
       
   849 			bitFlags |= 0x02;
       
   850 		else if (appInfo.iUid == KUidAppEmbeddableOnly)
       
   851 			bitFlags |= 0x04;
       
   852 		else if (appInfo.iUid == KUidAppEmbeddableUiOrStandAlone)
       
   853 			bitFlags |= 0x08;
       
   854 		else if (appInfo.iUid == KUidAppEmbeddableUiNotStandAlone)
       
   855 			bitFlags |= 0x10;
       
   856 		};
       
   857 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   858 	TEST(bitFlags == 0x1F);
       
   859 	INFO_PRINTF1(KCompleted);
       
   860 	}
       
   861 
       
   862 /**
       
   863    @SYMTestCaseID T-RApaLsSessionTestStep-DoGetEmbeddableApps
       
   864   
       
   865    @SYMPREQ PHAR-5Q4FX8
       
   866   
       
   867    @SYMTestCaseDesc
       
   868    Check that RApaLsSession::GetEmbeddableApps() hasn't been
       
   869    affected by the new code to filter the app list
       
   870    based on embeddability (implemented for CR PHAR-5Q4FX8)
       
   871   
       
   872    @SYMTestPriority High
       
   873   
       
   874    @SYMTestStatus Implemented
       
   875   
       
   876    @SYMTestActions
       
   877    Call GetEmbeddableApps() once, followed by repeated calls
       
   878    to GetNextApp until something other than KErrNone is returned
       
   879   
       
   880    @SYMTestExpectedResults
       
   881    GetNextApp should return app info for the following test apps:
       
   882    TAppEmbeddable.dll
       
   883    TAppEmbeddableOnly.dll
       
   884    and should not return app info for:
       
   885    TAppNotEmbeddable.exe
       
   886    TAppEmbeddableUiOrStandAlone.dll
       
   887    TAppEmbeddableUiNotStandAlone.dll
       
   888    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
   889   
       
   890  */
       
   891 void CT_RApaLsSessionTestStep::DoGetEmbeddableApps()
       
   892 	{
       
   893 	INFO_PRINTF1(_L("DoGetEmbeddableApps"));
       
   894 
       
   895 	TInt ret = iLs.GetEmbeddableApps();
       
   896 	TEST(ret==KErrNone);
       
   897 
       
   898 	TApaAppInfo appInfo;
       
   899 	TUint bitFlags = 0;
       
   900 	while ((ret = iLs.GetNextApp(appInfo)) == KErrNone)
       
   901 		{
       
   902 		if (appInfo.iUid == KUidAppNotEmbeddable)
       
   903 			bitFlags |= 0x01;
       
   904 		else if (appInfo.iUid == KUidAppEmbeddable)
       
   905 			bitFlags |= 0x02;
       
   906 		else if (appInfo.iUid == KUidAppEmbeddableOnly)
       
   907 			bitFlags |= 0x04;
       
   908 		else if (appInfo.iUid == KUidAppEmbeddableUiOrStandAlone)
       
   909 			bitFlags |= 0x08;
       
   910 		else if (appInfo.iUid == KUidAppEmbeddableUiNotStandAlone)
       
   911 			bitFlags |= 0x10;
       
   912 		};
       
   913 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   914 	TEST(bitFlags == 0x06);
       
   915 	INFO_PRINTF1(KCompleted);
       
   916 	}
       
   917 
       
   918 /**
       
   919    @SYMTestCaseID T-RApaLsSessionTestStep-DoEmbeddableAppCount
       
   920   
       
   921    @SYMPREQ PHAR-5Q4FX8
       
   922   
       
   923    @SYMTestCaseDesc
       
   924    The number of apps returned by GetEmbeddableApps should be the
       
   925    same as EmbeddableAppCount returns.
       
   926   
       
   927    @SYMTestPriority High
       
   928   
       
   929    @SYMTestStatus Implemented
       
   930   
       
   931    @SYMTestActions
       
   932    Count the number of apps returned by calling GetEmbeddableApps
       
   933    followed by repeated calls to GetNextApp.
       
   934    Count the number of apps returned by EmbeddableAppCount.
       
   935   
       
   936    @SYMTestExpectedResults
       
   937    The counts should be equal.
       
   938    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
   939   
       
   940  */
       
   941 void CT_RApaLsSessionTestStep::DoEmbeddableAppCount()
       
   942 	{
       
   943 	INFO_PRINTF1(_L("DoEmbeddableAppCount"));
       
   944 
       
   945 	TInt ret = iLs.GetEmbeddableApps();
       
   946 	TEST(ret==KErrNone);
       
   947 
       
   948 	TApaAppInfo appInfo;
       
   949 	TInt count1 = 0;
       
   950 	while ((ret = iLs.GetNextApp(appInfo)) == KErrNone)
       
   951 		{
       
   952 		count1 ++;
       
   953 		};
       
   954 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
   955 	
       
   956 	TInt count2 = 0;
       
   957 	ret = iLs.EmbeddableAppCount(count2);
       
   958 	TEST(ret==KErrNone);
       
   959 	TEST(count1 == count2);
       
   960 	INFO_PRINTF1(KCompleted);
       
   961 	}
       
   962 
       
   963 /**
       
   964    @SYMTestCaseID T-RApaLsSessionTestStep-DoGetAppCapability
       
   965   
       
   966    @SYMPREQ PHAR-5Q4FX8
       
   967   
       
   968    @SYMTestCaseDesc
       
   969    Confirm that the application embeddability value that a specific app
       
   970    defines in it's AIF file, matches the value returned by
       
   971    RApaLsSession::GetAppCapability.
       
   972    Check that this is true for all supported embeddability values
       
   973   
       
   974    @SYMTestPriority High
       
   975   
       
   976    @SYMTestStatus Implemented
       
   977   
       
   978    @SYMTestActions
       
   979    Call GetAppCapability for each of the following test apps:
       
   980    TAppNotEmbeddable.exe
       
   981    TAppEmbeddable.dll
       
   982    TAppEmbeddableOnly.dll
       
   983    TAppEmbeddableUiOrStandAlone.dll
       
   984    TAppEmbeddableUiNotStandAlone.dll
       
   985   
       
   986    @SYMTestExpectedResults
       
   987    For each app, GetAppCapability should return the embeddability value
       
   988    defined in the application's AIF file.
       
   989   
       
   990  */
       
   991 void CT_RApaLsSessionTestStep::DoGetAppCapability()
       
   992 	{
       
   993 	INFO_PRINTF1(_L("DoGetAppCapability"));
       
   994 
       
   995 	const TInt numberOfCapabilities = 5;
       
   996 	TUid uidArray[numberOfCapabilities];
       
   997 	uidArray[0] = KUidAppNotEmbeddable;
       
   998 	uidArray[1] = KUidAppEmbeddable;
       
   999 	uidArray[2] = KUidAppEmbeddableOnly;
       
  1000 	uidArray[3] = KUidAppEmbeddableUiOrStandAlone;
       
  1001 	uidArray[4] = KUidAppEmbeddableUiNotStandAlone;
       
  1002 
       
  1003 	const TApaAppCapability::TEmbeddability embeddabilityArray[numberOfCapabilities]
       
  1004 		= { TApaAppCapability::ENotEmbeddable,
       
  1005 			TApaAppCapability::EEmbeddable, 
       
  1006 			TApaAppCapability::EEmbeddableOnly, 
       
  1007 			TApaAppCapability::EEmbeddableUiOrStandAlone, 
       
  1008 			TApaAppCapability::EEmbeddableUiNotStandAlone };
       
  1009 
       
  1010 	for (TInt ii = 0; ii < numberOfCapabilities; ii++)
       
  1011 		{
       
  1012 		INFO_PRINTF2(_L("Testing embeddability value, %d"), uidArray[ii]);
       
  1013 		TApaAppCapabilityBuf capabilityBuf;
       
  1014 		TInt ret = iLs.GetAppCapability(capabilityBuf, uidArray[ii]);
       
  1015 		TEST(ret==KErrNone);
       
  1016 		TEST(capabilityBuf().iEmbeddability == embeddabilityArray[ii]);
       
  1017 		}
       
  1018 	INFO_PRINTF1(KCompleted);
       
  1019 	}
       
  1020 
       
  1021 /**
       
  1022    @SYMTestCaseID T-RApaLsSessionTestStep-DoGetFilteredApps1
       
  1023   
       
  1024    @SYMPREQ PHAR-5Q4FX8
       
  1025   
       
  1026    @SYMTestCaseDesc
       
  1027    Passing an empty filter to RApaLsSession::GetFilteredApps
       
  1028    should cause no apps to be returned by subsequent calls
       
  1029    to RApaLsSession::GetNextApp
       
  1030   
       
  1031    @SYMTestPriority High
       
  1032   
       
  1033    @SYMTestStatus Implemented
       
  1034   
       
  1035    @SYMTestActions
       
  1036    Call GetFilteredApps passing a default constructed filter,
       
  1037    followed by a single call to GetNextApp
       
  1038   
       
  1039    @SYMTestExpectedResults
       
  1040    GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
  1041   
       
  1042  */
       
  1043 void CT_RApaLsSessionTestStep::DoGetFilteredApps1()
       
  1044 	{
       
  1045 	INFO_PRINTF1(_L("DoGetFilteredApps1"));
       
  1046 
       
  1047 	TApaEmbeddabilityFilter filter;
       
  1048 	TInt ret = iLs.GetFilteredApps(filter);
       
  1049 	TEST(ret==KErrNone);
       
  1050 
       
  1051 	TApaAppInfo appInfo;
       
  1052 	TEST(iLs.GetNextApp(appInfo) == RApaLsSession::ENoMoreAppsInList);
       
  1053 	INFO_PRINTF1(KCompleted);
       
  1054 	}
       
  1055 
       
  1056 /**
       
  1057    @SYMTestCaseID T-RApaLsSessionTestStep-DoGetFilteredApps2
       
  1058   
       
  1059    @SYMPREQ PHAR-5Q4FX8
       
  1060   
       
  1061    @SYMTestCaseDesc
       
  1062    Passing a filter specifying only ENotEmbeddable
       
  1063    to RApaLsSession::GetFilteredApps should cause subsequent
       
  1064    calls to RApaLsSession::GetNextApp to return only
       
  1065    applications which cannot be embedded
       
  1066   
       
  1067    @SYMTestPriority High
       
  1068   
       
  1069    @SYMTestStatus Implemented
       
  1070   
       
  1071    @SYMTestActions
       
  1072    Call GetFilteredApps passing a filter containing ENotEmbeddable,
       
  1073    followed by repeated calls to GetNextApp until something other than
       
  1074    KErrNone is returned
       
  1075   
       
  1076    @SYMTestExpectedResults
       
  1077    GetNextApp should return app info for only the following test app:
       
  1078    TAppNotEmbeddable.exe
       
  1079    and should not return app info for:
       
  1080    TAppEmbeddable.dll
       
  1081    TAppEmbeddableOnly.dll
       
  1082    TAppEmbeddableUiOrStandAlone.dll
       
  1083    TAppEmbeddableUiNotStandAlone.dll
       
  1084    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
  1085  
       
  1086  */
       
  1087 void CT_RApaLsSessionTestStep::DoGetFilteredApps2()
       
  1088 	{
       
  1089 	INFO_PRINTF1(_L("DoGetFilteredApps2"));
       
  1090 
       
  1091 	TApaEmbeddabilityFilter filter;
       
  1092 	filter.AddEmbeddability(TApaAppCapability::ENotEmbeddable);
       
  1093 	TInt ret = iLs.GetFilteredApps(filter);
       
  1094 	TEST(ret==KErrNone);
       
  1095 
       
  1096 	TApaAppInfo appInfo;
       
  1097 	TUint bitFlags = 0;
       
  1098 	while ((ret = iLs.GetNextApp(appInfo)) == KErrNone)
       
  1099 		{
       
  1100 		if (appInfo.iUid == KUidAppNotEmbeddable)
       
  1101 			bitFlags |= 0x01;
       
  1102 		else if (appInfo.iUid == KUidAppEmbeddable)
       
  1103 			bitFlags |= 0x02;
       
  1104 		else if (appInfo.iUid == KUidAppEmbeddableOnly)
       
  1105 			bitFlags |= 0x04;
       
  1106 		else if (appInfo.iUid == KUidAppEmbeddableUiOrStandAlone)
       
  1107 			bitFlags |= 0x08;
       
  1108 		else if (appInfo.iUid == KUidAppEmbeddableUiNotStandAlone)
       
  1109 			bitFlags |= 0x10;
       
  1110 		}
       
  1111 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
  1112 	TEST(bitFlags == 0x01);
       
  1113 	INFO_PRINTF1(KCompleted);
       
  1114 	}
       
  1115 
       
  1116 /**
       
  1117    @SYMTestCaseID T-RApaLsSessionTestStep-DoGetFilteredApps3
       
  1118   
       
  1119    @SYMPREQ PHAR-5Q4FX8
       
  1120   
       
  1121    @SYMTestCaseDesc
       
  1122    EEmbeddableUiOrStandAlone (value 5) shares a bit flag (bit 1)
       
  1123    with EEmbeddable (value 1).
       
  1124    Confirm that a filter of EEmbeddableUiOrStandAlone only returns
       
  1125    apps that define EEmbeddableUiOrStandAlone
       
  1126   
       
  1127    @SYMTestPriority High
       
  1128   
       
  1129    @SYMTestStatus Implemented
       
  1130   
       
  1131    @SYMTestActions
       
  1132    Call GetFilteredApps passing a filter containing EEmbeddableUiOrStandAlone,
       
  1133    followed by repeated calls to GetNextApp until something other than
       
  1134    KErrNone is returned
       
  1135   
       
  1136    @SYMTestExpectedResults
       
  1137    GetNextApp should return app info for only the following test app:
       
  1138    TAppEmbeddableUiOrStandAlone.dll
       
  1139    and should not return app info for:
       
  1140    TAppEmbeddable.dll
       
  1141    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
  1142    
       
  1143  */
       
  1144 void CT_RApaLsSessionTestStep::DoGetFilteredApps3()
       
  1145 	{
       
  1146 	INFO_PRINTF1(_L("DoGetFilteredApps3"));
       
  1147 
       
  1148 	TApaEmbeddabilityFilter filter;
       
  1149 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiOrStandAlone);
       
  1150 	TInt ret = iLs.GetFilteredApps(filter);
       
  1151 	TEST(ret==KErrNone);
       
  1152 
       
  1153 	TApaAppInfo appInfo;
       
  1154 	TUint bitFlags = 0;
       
  1155 	while ((ret = iLs.GetNextApp(appInfo)) == KErrNone)
       
  1156 		{
       
  1157 		if (appInfo.iUid == KUidAppEmbeddable)
       
  1158 			bitFlags |= 0x02;
       
  1159 		else if (appInfo.iUid == KUidAppEmbeddableUiOrStandAlone)
       
  1160 			bitFlags |= 0x08;
       
  1161 		}
       
  1162 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
  1163 	TEST(bitFlags == 0x08);
       
  1164 	INFO_PRINTF1(KCompleted);
       
  1165 	}
       
  1166 
       
  1167 /**
       
  1168    @SYMTestCaseID T-RApaLsSessionTestStep-DoGetFilteredApps4
       
  1169   
       
  1170    @SYMPREQ PHAR-5Q4FX8
       
  1171   
       
  1172    @SYMTestCaseDesc
       
  1173    A filter specifying two embeddability values should
       
  1174    include apps of either embeddability
       
  1175   
       
  1176    @SYMTestPriority High
       
  1177   
       
  1178    @SYMTestStatus Implemented
       
  1179   
       
  1180    @SYMTestActions
       
  1181    Call GetFilteredApps passing a filter containing EEmbeddableUiOrStandAlone
       
  1182    and EEmbeddableUiNotStandAlone followed by repeated calls to GetNextApp
       
  1183    until something other than KErrNone is returned
       
  1184   
       
  1185    @SYMTestExpectedResults
       
  1186    GetNextApp should return app info for only the following test apps:
       
  1187    TAppEmbeddableUiOrStandAlone.dll
       
  1188    TAppEmbeddableUiNotStandAlone.dll
       
  1189    and should not return app info for:
       
  1190    TAppNotEmbeddable.exe
       
  1191    TAppEmbeddable.dll
       
  1192    TAppEmbeddableOnly.dll
       
  1193    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
  1194   
       
  1195  */
       
  1196 void CT_RApaLsSessionTestStep::DoGetFilteredApps4()
       
  1197 	{
       
  1198 	INFO_PRINTF1(_L("DoGetFilteredApps4"));
       
  1199 
       
  1200 	TApaEmbeddabilityFilter filter;
       
  1201 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiOrStandAlone);
       
  1202 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiNotStandAlone);
       
  1203 	TInt ret = iLs.GetFilteredApps(filter);
       
  1204 	TEST(ret==KErrNone);
       
  1205 
       
  1206 	TApaAppInfo appInfo;
       
  1207 	TUint bitFlags = 0;
       
  1208 	while ((ret = iLs.GetNextApp(appInfo)) == KErrNone)
       
  1209 		{
       
  1210 		if (appInfo.iUid == KUidAppNotEmbeddable)
       
  1211 			bitFlags |= 0x01;
       
  1212 		else if (appInfo.iUid == KUidAppEmbeddable)
       
  1213 			bitFlags |= 0x02;
       
  1214 		else if (appInfo.iUid == KUidAppEmbeddableOnly)
       
  1215 			bitFlags |= 0x04;
       
  1216 		else if (appInfo.iUid == KUidAppEmbeddableUiOrStandAlone)
       
  1217 			bitFlags |= 0x08;
       
  1218 		else if (appInfo.iUid == KUidAppEmbeddableUiNotStandAlone)
       
  1219 			bitFlags |= 0x10;
       
  1220 		}
       
  1221 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
  1222 	TEST(bitFlags == 0x18);
       
  1223 	INFO_PRINTF1(KCompleted);
       
  1224 	}
       
  1225 
       
  1226 /**
       
  1227    @SYMTestCaseID T-RApaLsSessionTestStep-DoGetFilteredApps5
       
  1228   
       
  1229    @SYMPREQ PHAR-5Q4FX8
       
  1230   
       
  1231    @SYMTestCaseDesc
       
  1232    Getting apps using a filter specifying all embeddability values
       
  1233    should return the same number of apps as RApaLsSession::GetAllApps()
       
  1234   
       
  1235    @SYMTestPriority High
       
  1236   
       
  1237    @SYMTestStatus Implemented
       
  1238   
       
  1239    @SYMTestActions
       
  1240    Call GetFilteredApps passing a filter containing all embeddability values,
       
  1241    and count the number of calls to GetNextApp until something other than
       
  1242    KErrNone is returned.
       
  1243    Then call GetAllApps and count the number of calls to GetNextApp until
       
  1244    something other than KErrNone is returned.
       
  1245   
       
  1246    @SYMTestExpectedResults
       
  1247    The two counts should be equal.
       
  1248    The last call in each sequence of calls to GetNextApp should return
       
  1249    RApaLsSession::ENoMoreAppsInList
       
  1250   
       
  1251  */
       
  1252 void CT_RApaLsSessionTestStep::DoGetFilteredApps5()
       
  1253 	{
       
  1254 	INFO_PRINTF1(_L("DoGetFilteredApps5"));
       
  1255 
       
  1256 	TApaEmbeddabilityFilter filter;
       
  1257 	filter.AddEmbeddability(TApaAppCapability::ENotEmbeddable);
       
  1258 	filter.AddEmbeddability(TApaAppCapability::EEmbeddable);
       
  1259 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableOnly);
       
  1260 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiOrStandAlone);
       
  1261 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiNotStandAlone);
       
  1262 	TInt ret = iLs.GetFilteredApps(filter);
       
  1263 	TEST(ret==KErrNone);
       
  1264 
       
  1265 	TApaAppInfo appInfo;
       
  1266 	TInt filteredCount = 0;
       
  1267 	while ((ret = iLs.GetNextApp(appInfo)) == KErrNone)
       
  1268 		{
       
  1269 		filteredCount++;
       
  1270 		}
       
  1271 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
  1272 
       
  1273 	ret = iLs.GetAllApps();
       
  1274 	TEST(ret==KErrNone);
       
  1275 
       
  1276 	TInt allAppsCount = 0;
       
  1277 	while ((ret = iLs.GetNextApp(appInfo)) == KErrNone)
       
  1278 		{
       
  1279 		allAppsCount++;
       
  1280 		}
       
  1281 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
  1282 
       
  1283 	TEST(filteredCount == allAppsCount);
       
  1284 	INFO_PRINTF1(KCompleted);
       
  1285 	}
       
  1286 
       
  1287 /**
       
  1288    @SYMTestCaseID T-RApaLsSessionTestStep-DoGetFilteredApps6
       
  1289   
       
  1290    @SYMPREQ PHAR-5Q4FX8
       
  1291   
       
  1292    @SYMTestCaseDesc
       
  1293    None of the following embeddability test apps support
       
  1294    screen mode 1, so none of them should be returned even
       
  1295    if the filter specifies all embeddability types.
       
  1296    TAppNotEmbeddable.exe
       
  1297    TAppEmbeddable.dll
       
  1298    TAppEmbeddableOnly.dll
       
  1299    TAppEmbeddableUiOrStandAlone.dll
       
  1300    TAppEmbeddableUiNotStandAlone.dll
       
  1301   
       
  1302    @SYMTestPriority High
       
  1303   
       
  1304    @SYMTestStatus Implemented
       
  1305   
       
  1306    @SYMTestActions
       
  1307    Call GetFilteredApps passing a filter containing all embeddability values
       
  1308    and screen mode 1, followed by repeated calls to GetNextApp until something
       
  1309    other than KErrNone is returned
       
  1310   
       
  1311    @SYMTestExpectedResults
       
  1312    GetNextApp should not return app info for any of the following test apps:
       
  1313    TAppNotEmbeddable.exe
       
  1314    TAppEmbeddable.dll
       
  1315    TAppEmbeddableOnly.dll
       
  1316    TAppEmbeddableUiOrStandAlone.dll
       
  1317    TAppEmbeddableUiNotStandAlone.dll
       
  1318    The last call to GetNextApp should return RApaLsSession::ENoMoreAppsInList
       
  1319   
       
  1320  */
       
  1321 void CT_RApaLsSessionTestStep::DoGetFilteredApps6(/*RApaLsSession& iLs*/)
       
  1322 	{
       
  1323 	INFO_PRINTF1(_L("DoGetFilteredApps6"));
       
  1324 
       
  1325 	TApaEmbeddabilityFilter filter;
       
  1326 	filter.AddEmbeddability(TApaAppCapability::ENotEmbeddable);
       
  1327 	filter.AddEmbeddability(TApaAppCapability::EEmbeddable);
       
  1328 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableOnly);
       
  1329 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiOrStandAlone);
       
  1330 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiNotStandAlone);
       
  1331 	const TInt screenMode1 = 1;
       
  1332 	TInt ret = iLs.GetFilteredApps(filter, screenMode1);
       
  1333 	TEST(ret==KErrNone);
       
  1334 
       
  1335 	TApaAppInfo appInfo;
       
  1336 	TUint bitFlags = 0;
       
  1337 	while ((ret = iLs.GetNextApp(appInfo)) == KErrNone)
       
  1338 		{
       
  1339 		if (appInfo.iUid == KUidAppNotEmbeddable)
       
  1340 			bitFlags |= 0x01;
       
  1341 		else if (appInfo.iUid == KUidAppEmbeddable)
       
  1342 			bitFlags |= 0x02;
       
  1343 		else if (appInfo.iUid == KUidAppEmbeddableOnly)
       
  1344 			bitFlags |= 0x04;
       
  1345 		else if (appInfo.iUid == KUidAppEmbeddableUiOrStandAlone)
       
  1346 			bitFlags |= 0x08;
       
  1347 		else if (appInfo.iUid == KUidAppEmbeddableUiNotStandAlone)
       
  1348 			bitFlags |= 0x10;
       
  1349 		}
       
  1350 	TEST(ret==RApaLsSession::ENoMoreAppsInList);
       
  1351 	TEST(bitFlags == 0);
       
  1352 	INFO_PRINTF1(KCompleted);
       
  1353 	}
       
  1354 	
       
  1355 /**
       
  1356    @SYMTestCaseID T-RApaLsSessionTestStep-DoTestEmbeddabilityFilter1
       
  1357   
       
  1358    @SYMPREQ PHAR-5Q4FX8
       
  1359   
       
  1360    @SYMTestCaseDesc
       
  1361    Ensure default constructed TApaEmbeddabilityFilter object is
       
  1362    initialized correctly.
       
  1363  
       
  1364    @SYMTestPriority High
       
  1365  
       
  1366    @SYMTestStatus Implemented
       
  1367   
       
  1368    @SYMTestActions
       
  1369    Construct a TApaEmbeddabilityFilter object and call
       
  1370    MatchesEmbeddability using each of the following embeddability values:
       
  1371    TApaAppCapability::ENotEmbeddable
       
  1372    TApaAppCapability::EEmbeddable
       
  1373    TApaAppCapability::EEmbeddableOnly
       
  1374    TApaAppCapability::EEmbeddableUiOrStandAlone
       
  1375    TApaAppCapability::EEmbeddableUiNotStandAlone
       
  1376   
       
  1377    @SYMTestExpectedResults
       
  1378    All calls to MatchesEmbeddability should return fiLse.
       
  1379   
       
  1380  */
       
  1381 void CT_RApaLsSessionTestStep::DoTestEmbeddabilityFilter1()
       
  1382 	{
       
  1383 	INFO_PRINTF1(_L("DoTestEmbeddabilityFilter1"));
       
  1384 
       
  1385 	TApaEmbeddabilityFilter filter;
       
  1386 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::ENotEmbeddable));
       
  1387 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::EEmbeddable));
       
  1388 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::EEmbeddableOnly));
       
  1389 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::EEmbeddableUiOrStandAlone));
       
  1390 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::EEmbeddableUiNotStandAlone));
       
  1391 	INFO_PRINTF1(KCompleted);
       
  1392 	}
       
  1393 
       
  1394 /**
       
  1395    @SYMTestCaseID T-RApaLsSessionTestStep-DoTestEmbeddabilityFilter2
       
  1396   
       
  1397    @SYMPREQ PHAR-5Q4FX8
       
  1398   
       
  1399    @SYMTestCaseDesc
       
  1400    Bit 2 is used by both EEmbeddableUiNotStandAlone and EEmbeddableOnly.
       
  1401    Make sure that setting the filter to only EEmbeddableUiNotStandAlone
       
  1402    doesn't match EEmbeddableOnly.
       
  1403   
       
  1404    @SYMTestPriority High
       
  1405   
       
  1406    @SYMTestStatus Implemented
       
  1407   
       
  1408    @SYMTestActions
       
  1409    Construct a TApaEmbeddabilityFilter object,
       
  1410    set the filter to only EEmbeddableUiNotStandAloneand
       
  1411    and call MatchesEmbeddability passing EEmbeddableOnly
       
  1412   
       
  1413    @SYMTestExpectedResults
       
  1414    MatchesEmbeddability should return fiLse.
       
  1415   
       
  1416  */
       
  1417 void CT_RApaLsSessionTestStep::DoTestEmbeddabilityFilter2()
       
  1418 	{
       
  1419 	INFO_PRINTF1(_L("DoTestEmbeddabilityFilter2"));
       
  1420 
       
  1421 	TApaEmbeddabilityFilter filter;
       
  1422 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableUiNotStandAlone);
       
  1423 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::EEmbeddableOnly));
       
  1424 	INFO_PRINTF1(KCompleted);
       
  1425 	}
       
  1426 
       
  1427 /**
       
  1428    @SYMTestCaseID T-RApaLsSessionTestStep-DoTestEmbeddabilityFilter3
       
  1429   
       
  1430    @SYMPREQ PHAR-5Q4FX8
       
  1431   
       
  1432    @SYMTestCaseDesc
       
  1433    Bit 2 is used by both EEmbeddableUiNotStandAlone and EEmbeddableOnly.
       
  1434    Make sure that setting the filter to only EEmbeddableOnly
       
  1435    doesn't match EEmbeddableUiNotStandAlone.
       
  1436   
       
  1437    @SYMTestPriority High
       
  1438   
       
  1439    @SYMTestStatus Implemented
       
  1440   
       
  1441    @SYMTestActions
       
  1442    Construct a TApaEmbeddabilityFilter object,
       
  1443    set the filter to only EEmbeddableOnly
       
  1444    and call MatchesEmbeddability passing EEmbeddableUiNotStandAlone
       
  1445   
       
  1446    @SYMTestExpectedResults
       
  1447    MatchesEmbeddability should return fiLse.
       
  1448   
       
  1449  */
       
  1450 void CT_RApaLsSessionTestStep::DoTestEmbeddabilityFilter3()
       
  1451 	{
       
  1452 	INFO_PRINTF1(_L("DoTestEmbeddabilityFilter3"));
       
  1453 
       
  1454 	TApaEmbeddabilityFilter filter;
       
  1455 	filter.AddEmbeddability(TApaAppCapability::EEmbeddableOnly);
       
  1456 	TEST(!filter.MatchesEmbeddability(TApaAppCapability::EEmbeddableUiNotStandAlone));
       
  1457 	INFO_PRINTF1(KCompleted);
       
  1458 	}
       
  1459 
       
  1460 /**
       
  1461    @SYMTestCaseID T-RApaLsSessionTestStep-DoTestEmbeddabilityFilter4
       
  1462   
       
  1463    @SYMPREQ PHAR-5Q4FX8
       
  1464   
       
  1465    @SYMTestCaseDesc
       
  1466    Ensure MatchesEmbeddability returns true when the filter only contains
       
  1467    the embeddability being matched.
       
  1468   
       
  1469    @SYMTestPriority High
       
  1470   
       
  1471    @SYMTestStatus Implemented
       
  1472   
       
  1473    @SYMTestActions
       
  1474    Construct a TApaEmbeddabilityFilter object,
       
  1475    set the filter to only EEmbeddable
       
  1476    and call MatchesEmbeddability passing EEmbeddable
       
  1477   
       
  1478    @SYMTestExpectedResults
       
  1479    MatchesEmbeddability should return true.
       
  1480   
       
  1481  */
       
  1482 void CT_RApaLsSessionTestStep::DoTestEmbeddabilityFilter4()
       
  1483 	{
       
  1484 	INFO_PRINTF1(_L("DoTestEmbeddabilityFilter4"));
       
  1485 
       
  1486 	TApaEmbeddabilityFilter filter;
       
  1487 	filter.AddEmbeddability(TApaAppCapability::EEmbeddable);
       
  1488 	TEST(filter.MatchesEmbeddability(TApaAppCapability::EEmbeddable));
       
  1489 	INFO_PRINTF1(KCompleted);
       
  1490 	}
       
  1491 
       
  1492 /**
       
  1493    @SYMTestCaseID T-RApaLsSessionTestStep-DoTestEmbeddabilityFilter5
       
  1494   
       
  1495    @SYMPREQ PHAR-5Q4FX8
       
  1496   
       
  1497    @SYMTestCaseDesc
       
  1498    Ensure MatchesEmbeddability returns true when the filter contains
       
  1499    a superset of the embeddability being matched.
       
  1500   
       
  1501    @SYMTestPriority High
       
  1502   
       
  1503    @SYMTestStatus Implemented
       
  1504   
       
  1505    @SYMTestActions
       
  1506    Construct a TApaEmbeddabilityFilter object,
       
  1507    set the filter to both ENotEmbeddable and EEmbeddable
       
  1508    and call MatchesEmbeddability passing EEmbeddable
       
  1509   
       
  1510    @SYMTestExpectedResults
       
  1511    MatchesEmbeddability should return true.
       
  1512   
       
  1513  */
       
  1514 void CT_RApaLsSessionTestStep::DoTestEmbeddabilityFilter5()
       
  1515 	{
       
  1516 	INFO_PRINTF1(_L("DoTestEmbeddabilityFilter5"));
       
  1517 
       
  1518 	TApaEmbeddabilityFilter filter;
       
  1519 	filter.AddEmbeddability(TApaAppCapability::ENotEmbeddable);
       
  1520 	filter.AddEmbeddability(TApaAppCapability::EEmbeddable);
       
  1521 	TEST(filter.MatchesEmbeddability(TApaAppCapability::EEmbeddable));
       
  1522 	INFO_PRINTF1(KCompleted);
       
  1523 	}
       
  1524 
       
  1525  /**
       
  1526    @SYMTestCaseID T-RApaLsSessionTestStep-TestGetAppCapabilityL
       
  1527   
       
  1528    @SYMPREQ
       
  1529   
       
  1530    @SYMTestCaseDesc Test interrogates the Application Architecture Server. 
       
  1531    
       
  1532    @SYMTestPriority High 
       
  1533   
       
  1534    @SYMTestStatus Implemented
       
  1535   
       
  1536    RApaLsSession::GetAppCapability(TDes8& aCapabilityBuf,TUid aAppUid) const\n
       
  1537    RApaLsSession::RecognizeSpecificData(const TDesC& aName, const TDesC8& aBuffer, const TDataType& aDataType, TBool& aResult) const\n
       
  1538    RApaLsSession::RecognizeData(const TDesC& aName, const TDesC8& aBuffer, TDataRecognitionResult& aDataType) const\n
       
  1539    RApaLsSession::GetAppIcon(TUid aAppUid, TInt aSize, CApaMaskedBitmap& aAppBitmap) const\n
       
  1540    
       
  1541    @SYMTestExpectedResults All tests compare the results obtained with the desired result.
       
  1542     
       
  1543  */
       
  1544 void CT_RApaLsSessionTestStep::TestGetAppCapabilityL()
       
  1545 	{
       
  1546 	TApaAppCapabilityBuf buf;
       
  1547 	INFO_PRINTF1(_L("Checking GetAppCapability from Test App Uid..."));
       
  1548 	TInt ret = iLs.GetAppCapability(buf,KUidTestApp);
       
  1549 	TEST(ret==KErrNone);
       
  1550 	TApaAppCapability cap=buf();
       
  1551 	TEST(cap.iEmbeddability==TApaAppCapability::EEmbeddable);
       
  1552 	TEST(!cap.iSupportsNewFile);
       
  1553 	TEST(!cap.iAppIsHidden);
       
  1554 	INFO_PRINTF1(KCompleted);
       
  1555 
       
  1556 	INFO_PRINTF1(_L("Checking GetAppCapability Null Id returns KErrNotFound..."));
       
  1557 	ret = iLs.GetAppCapability(buf,KNullUid);
       
  1558 	TEST(ret==KErrNotFound);
       
  1559 	INFO_PRINTF1(KCompleted);
       
  1560 	}
       
  1561 
       
  1562 /**
       
  1563    @SYMTestCaseID T_RApaLsSessionTestStep_TestRecognizeSpecificData
       
  1564   
       
  1565    @SYMPREQ
       
  1566   
       
  1567    @SYMTestCaseDesc Test interrogates the Application Architecture Server. 
       
  1568    
       
  1569    @SYMTestPriority High 
       
  1570   
       
  1571    @SYMTestStatus Implemented
       
  1572   
       
  1573    RApaLsSession::RecognizeSpecificData(const TDesC& aName, const TDesC8& aBuffer, const TDataType& aDataType, TBool& aResult) const\n
       
  1574    RApaLsSession::RecognizeData(const TDesC& aName, const TDesC8& aBuffer, TDataRecognitionResult& aDataType) const\n
       
  1575    RApaLsSession::GetAppIcon(TUid aAppUid, TInt aSize, CApaMaskedBitmap& aAppBitmap) const\n
       
  1576    
       
  1577    @SYMTestExpectedResults All tests compare the results obtained with the desired result.
       
  1578     
       
  1579  */
       
  1580 void CT_RApaLsSessionTestStep::TestRecognizeSpecificData()
       
  1581 {
       
  1582 	INFO_PRINTF1(_L("Checking data type information"));
       
  1583 	INFO_PRINTF1(_L("Checking RecognizeSpecificData..."));
       
  1584 	TBool isText=EFalse;
       
  1585 	TInt ret=iLs.RecognizeSpecificData(_L("a file name.txt"),_L8("Some plain text"),TDataType(_L8("text/plain")),isText);
       
  1586 	TEST(ret==KErrNone);
       
  1587 	TEST(isText);
       
  1588 
       
  1589 	INFO_PRINTF1(_L("Checking RecognizeData..."));
       
  1590 	TDataRecognitionResult result;
       
  1591 	ret=iLs.RecognizeData(_L("a file name.txt"),_L8("Some plain text"),result);
       
  1592 	TEST(ret==KErrNone);
       
  1593 	TEST(result.iDataType==TDataType(_L8("text/plain")));
       
  1594 	TEST(result.iConfidence==CApaDataRecognizerType::EProbable);
       
  1595 		
       
  1596 	isText=EFalse;
       
  1597 	INFO_PRINTF1(_L("Checking RecognizeSpecificData...unknown data type..."));
       
  1598 	ret=iLs.RecognizeSpecificData(_L("a file name.txt"),_L8("Some plain text"),TDataType(_L8("foo/bar")),isText);
       
  1599 	TEST(!isText);
       
  1600 	INFO_PRINTF1(KCompleted);
       
  1601 }
       
  1602 
       
  1603 /**
       
  1604    @SYMTestCaseID T-RApaLsSessionTestStep-TestGetAppIconL
       
  1605   
       
  1606    @SYMPREQ
       
  1607   
       
  1608    @SYMTestCaseDesc Test interrogates the Application Architecture Server. 
       
  1609    
       
  1610    @SYMTestPriority High 
       
  1611   
       
  1612    @SYMTestStatus Implemented   
       
  1613    
       
  1614    @SYMTestExpectedResults All tests compare the results obtained with the desired result.
       
  1615     
       
  1616  */
       
  1617 void CT_RApaLsSessionTestStep::TestGetAppIconL()
       
  1618 	{
       
  1619 	INFO_PRINTF1(_L("Checking icon loading by index"));
       
  1620 	CApaMaskedBitmap* icon=CApaMaskedBitmap::NewLC();
       
  1621 	TSize lastSize(0,0);
       
  1622 
       
  1623 	INFO_PRINTF1(_L("Checking index 0"));
       
  1624 	TInt ret=iLs.GetAppIcon(KUidTestApp,0,*icon);
       
  1625 	TEST(ret==KErrNone);
       
  1626 	TEST(icon->SizeInPixels().iWidth*icon->SizeInPixels().iHeight > lastSize.iWidth*lastSize.iHeight);
       
  1627 	lastSize=icon->SizeInPixels();
       
  1628 
       
  1629 	INFO_PRINTF1(_L("Checking icon index 1"));	
       
  1630 	ret=iLs.GetAppIcon(KUidTestApp,1,*icon);
       
  1631 	TEST(ret==KErrNone);
       
  1632 	TEST(icon->SizeInPixels().iWidth*icon->SizeInPixels().iHeight == lastSize.iWidth*lastSize.iHeight);
       
  1633 	lastSize=icon->SizeInPixels();
       
  1634 
       
  1635 	INFO_PRINTF1(_L("Checking icon index 2"));
       
  1636 	ret=iLs.GetAppIcon(KUidTestApp,2,*icon);
       
  1637 	TEST(ret==KErrNone);		
       
  1638 	TEST((icon->SizeInPixels().iWidth*icon->SizeInPixels().iHeight) > (lastSize.iWidth*lastSize.iHeight));
       
  1639 	lastSize=icon->SizeInPixels();
       
  1640 
       
  1641 	INFO_PRINTF1(_L("Checking icon loading unknown Uid...."));
       
  1642 	TUid uid={9999};
       
  1643 	ret=iLs.GetAppIcon(uid,0,*icon);
       
  1644 	TEST(ret==KErrNotFound);
       
  1645 	CleanupStack::PopAndDestroy(icon);
       
  1646 	INFO_PRINTF1(KCompleted);
       
  1647 	}
       
  1648 /**
       
  1649     @SYMTestCaseID APPFWK-APPARC-0085
       
  1650    
       
  1651     @SYMDEF PDEF113054: Apparc fails to detect the presence of localized MBM files  
       
  1652 	
       
  1653 	@SYMTestCaseDesc 
       
  1654 	Negative Test: Test an icon file with an extension which is not supported.
       
  1655 	
       
  1656     
       
  1657     @SYMTestPriority High 
       
  1658    
       
  1659     @SYMTestStatus Implemented
       
  1660     
       
  1661     Call GetAppViewIcon API on an App which has a localized MBM icon file associated with it with an invalid extension.
       
  1662 	GetAppViewIcon returns KErrNotSupported 
       
  1663     
       
  1664     @SYMTestExpectedResults RApaLsSession::GetAppViewIcon should return KErrNotSupported when 
       
  1665     the view icon file is an invalid icon file
       
  1666     */
       
  1667 void CT_RApaLsSessionTestStep::TestGetAppIcon2L()
       
  1668 	{
       
  1669 	CApaAppViewArray* appViews = new(ELeave) CApaAppViewArray(4);
       
  1670 	CleanupStack::PushL(appViews);
       
  1671 	TInt ret = iLs.GetAppViews(*appViews, KUidTestApp);
       
  1672 	TEST(ret==KErrNone);
       
  1673 	 	
       
  1674 	INFO_PRINTF1(_L("Negative test- checking for file extension which is not supported"));
       
  1675 	//the third view icon is not a valid mbm file
       
  1676 	const TApaAppViewInfo& viewInfo=(*appViews)[2];
       
  1677 	TEST(viewInfo.iUid != KNullUid);
       
  1678 	TEST(viewInfo.iViewCaption.Length() > 0);
       
  1679 	TEST(viewInfo.iScreenMode == 0x00);
       
  1680 	CApaMaskedBitmap* viewBitmap = CApaMaskedBitmap::NewLC();
       
  1681 	ret = iLs.GetAppViewIcon(KUidTestApp, viewInfo.iUid, TSize(50,50), *viewBitmap);
       
  1682 	TEST(ret==KErrNotSupported);
       
  1683 	INFO_PRINTF2(_L("The View icon's UID is - %d"), viewInfo.iUid);
       
  1684 		
       
  1685 	HBufC* fullIconFileName = NULL;
       
  1686 	ret = iLs.GetAppViewIcon(KUidTestApp, viewInfo.iUid, fullIconFileName);
       
  1687 	TEST(ret == KErrNone);
       
  1688 	TEST(fullIconFileName != NULL);
       
  1689 	if (fullIconFileName != NULL)
       
  1690 		{
       
  1691 		TEST(fullIconFileName->Length() > 0);
       
  1692 		INFO_PRINTF2(_L("Invalid View's icon file name is - %S"), fullIconFileName);
       
  1693 		}
       
  1694 	delete fullIconFileName;		
       
  1695 	fullIconFileName = NULL;
       
  1696 	 	
       
  1697 	CleanupStack::PopAndDestroy(viewBitmap);
       
  1698 	CleanupStack::PopAndDestroy(appViews);
       
  1699 	 	
       
  1700 	INFO_PRINTF1(KCompleted);
       
  1701 	}	
       
  1702 
       
  1703 /**
       
  1704    @SYMTestCaseID APPFWK-APPARC-0073
       
  1705   
       
  1706    @SYMDEF INC098717: support for scalable midlet icons is missing  
       
  1707   
       
  1708    @SYMTestCaseDesc Test interrogates the Application Architecture Server's GetAppIcon API . 
       
  1709    
       
  1710    @SYMTestPriority High 
       
  1711   
       
  1712    @SYMTestStatus Implemented
       
  1713    
       
  1714    @SYMTestActions Call GetAppIcon API on an app which has an icon file associated with it.
       
  1715    Again Call GetAppIcon API on an app which does not have an icon file associated with it.
       
  1716    Again Call GetAppIcon with an invalid app uid. Do it for SVG and MBM icon file.
       
  1717    
       
  1718    @SYMTestExpectedResults RApaLsSession::GetAppIcon should return KErrNotFound when 
       
  1719    an invalid app uid is passed, KErrNotFound when application does not have an icon 
       
  1720    file, KErrNone and an open file handle to the application's icon file if application 
       
  1721    has an icon file.
       
  1722  */
       
  1723 void CT_RApaLsSessionTestStep::TestGetAppIcon1L()
       
  1724 	{
       
  1725 	TestGetAppIconForMBMIconsL();
       
  1726 	TestGetAppIconForSVGIconsL();
       
  1727 	
       
  1728 	//Generic tests for both MBM and SVG icon files
       
  1729 	RFile iconFile;
       
  1730 	CleanupClosePushL(iconFile);
       
  1731 	//Testing GetAppIcon for native app without an icon file.
       
  1732 	INFO_PRINTF1(_L("Testing GetAppIcon API for an app that does not have an icon file"));
       
  1733 	const TUint KGroupNameApp = 0x10208185; //T_groupNametest app, does not have an icon file.
       
  1734 	TInt err = iLs.GetAppIcon(TUid::Uid(KGroupNameApp), iconFile);
       
  1735 	TEST(err == KErrNotFound);
       
  1736 
       
  1737 	//Checking the iconfile name when the icon file is not a physical file on the file system.
       
  1738 	CApaAppViewArray* appViews = new(ELeave) CApaAppViewArray(4);
       
  1739 	CleanupStack::PushL(appViews);
       
  1740 	TInt ret = iLs.GetAppViews(*appViews, TUid::Uid(KGroupNameApp));
       
  1741 	TEST(ret==KErrNone);
       
  1742 	TEST(appViews->Count() > 0);
       
  1743 	 	
       
  1744 	const TApaAppViewInfo& viewInfo=(*appViews)[0];
       
  1745 	TEST(viewInfo.iUid != KNullUid);
       
  1746 
       
  1747 	HBufC* fullIconFileName = NULL;
       
  1748 	ret = iLs.GetAppViewIcon(TUid::Uid(KGroupNameApp), viewInfo.iUid, fullIconFileName);
       
  1749 	TEST(ret == KErrNone);
       
  1750 	TEST(fullIconFileName != NULL);
       
  1751 	INFO_PRINTF2(_L("The View icon's UID is - %X"), viewInfo.iUid);
       
  1752 	TEST(!fullIconFileName->Compare(_L("file://c/resource/apps/tcheckiconapp.xyz")));
       
  1753 	INFO_PRINTF2(_L("View's icon file name is - %S"), fullIconFileName);
       
  1754 	
       
  1755 	delete fullIconFileName;		
       
  1756 	CleanupStack::PopAndDestroy(appViews);
       
  1757 	
       
  1758 	//Testing GetAppIcon with an invalid app UID.
       
  1759 	INFO_PRINTF1(_L("Testing GetAppIcon API with unknown app uid"));
       
  1760 	TUid invalidAppUid = {9999};
       
  1761 	err = iLs.GetAppIcon(invalidAppUid, iconFile);
       
  1762 	TEST(err == KErrNotFound);
       
  1763 	
       
  1764 	//Close icon file
       
  1765 	CleanupStack::PopAndDestroy(&iconFile);	
       
  1766 	
       
  1767 	INFO_PRINTF1(KCompleted);
       
  1768 	}
       
  1769 
       
  1770 void CT_RApaLsSessionTestStep::TestGetAppIconForMBMIconsL()
       
  1771 	{
       
  1772 	//Testing GetAppIcon for native app with MBM icon file.
       
  1773 	INFO_PRINTF1(_L("Testing GetAppIcon API for an app to retrieve an open file handle to an MBM icon file"));
       
  1774 	const TUint KTestApp = 10; //Tstapp app, has MBM icon file	
       
  1775 	
       
  1776 	RFile mbmIconFile;
       
  1777 	CleanupClosePushL(mbmIconFile);
       
  1778 	
       
  1779 	TInt err = iLs.GetAppIcon(TUid::Uid(KTestApp), mbmIconFile);
       
  1780 	TEST(err == KErrNone);
       
  1781 	
       
  1782 	_LIT(KMBMIconFileName, "z:\\resource\\apps\\tstapp.mbm");
       
  1783 	//Get the name of the icon file 
       
  1784 	TBuf<KMaxFileName> mbmIconFileName;	
       
  1785 	mbmIconFile.FullName(mbmIconFileName);
       
  1786 	TEST(mbmIconFileName.Length() != 0);
       
  1787 	if (mbmIconFileName.Length() != 0)
       
  1788 		{
       
  1789 		mbmIconFileName.LowerCase();
       
  1790 		TEST(mbmIconFileName.Compare(KMBMIconFileName) == 0);
       
  1791 		}
       
  1792 		
       
  1793 	//Try to write into the MBM icon file whose handle was returned.
       
  1794 	INFO_PRINTF1(_L("..writing into the MBM icon file whose handle was returned."));
       
  1795 	_LIT8(KSomeText, "It would not be written into the file");
       
  1796 	err = mbmIconFile.Write(KSomeText);
       
  1797 	TEST(err == KErrAccessDenied);
       
  1798 	
       
  1799 	//Try to read from the MBM icon file whose handle was returned.
       
  1800 	INFO_PRINTF1(_L("..reading from the MBM icon file whose handle was returned."));
       
  1801 	TBuf8<KBytesToRead> buffer; //buffer to read first KBytesToRead bytes of the mbm icon file.
       
  1802 	err = mbmIconFile.Read(buffer);
       
  1803 	TEST(err == KErrNone);
       
  1804 	
       
  1805 	//Close icon files.
       
  1806 	CleanupStack::PopAndDestroy(&mbmIconFile);
       
  1807 	
       
  1808 	//First KBytesToRead bytes of the icon file, this should be same as in mbm file.
       
  1809 	RFile tempFile;
       
  1810 	CleanupClosePushL(tempFile);
       
  1811 	err = tempFile.Open(iFs, KMBMIconFileName, EFileShareReadersOnly);
       
  1812 	TEST(err == KErrNone);
       
  1813 	TBuf8<KBytesToRead> buffer1;
       
  1814 	err = tempFile.Read(buffer1);
       
  1815 	TEST(err == KErrNone);	
       
  1816 	TEST(buffer == buffer1);
       
  1817 	CleanupStack::PopAndDestroy(&tempFile);
       
  1818 	}
       
  1819 	
       
  1820 void CT_RApaLsSessionTestStep::TestGetAppIconForSVGIconsL()
       
  1821 	{
       
  1822 	//Testing GetAppIcon for native app with SVG icon file.		
       
  1823 	RFile svgIconFile;
       
  1824 	CleanupClosePushL(svgIconFile);
       
  1825 	INFO_PRINTF1(_L("Testing GetAppIcon API for an app to retrieve an open file handle to an SVG icon file"));
       
  1826 	const TUint KApparcTestApp = 0x100048F3; //Tstapp app, has SVG icon file
       
  1827 	TInt err = iLs.GetAppIcon(TUid::Uid(KApparcTestApp), svgIconFile);
       
  1828 	TEST(err == KErrNone);
       
  1829 	
       
  1830 	_LIT(KSVGIconFileName, "z:\\resource\\apps\\svg_icon.svg");
       
  1831 	//Get the name of the icon file 
       
  1832 	TBuf<KMaxFileName> svgIconFileName;	
       
  1833 	svgIconFile.FullName(svgIconFileName);
       
  1834 	TEST(svgIconFileName.Length() != 0);
       
  1835 	if (svgIconFileName.Length() != 0)
       
  1836 		{
       
  1837 		svgIconFileName.LowerCase();
       
  1838 		TEST(svgIconFileName.Compare(KSVGIconFileName) == 0);
       
  1839 		}
       
  1840 			
       
  1841 	//Try to write into the icon file whose handle was returned.
       
  1842 	INFO_PRINTF1(_L("..writing into the SVG icon file whose handle was returned."));
       
  1843 	_LIT8(KSomeText, "It would not be written into the file");
       
  1844 	err = svgIconFile.Write(KSomeText);
       
  1845 	TEST(err == KErrAccessDenied);
       
  1846 	
       
  1847 	//Try to read from the icon file whose handle was returned.
       
  1848 	INFO_PRINTF1(_L("..reading from the SVG icon file whose handle was returned."));
       
  1849 	TBuf8<KBytesToRead> svgBuffer; //buffer to read first KBytesToRead bytes of the icon file. 
       
  1850 	err = svgIconFile.Read(svgBuffer);
       
  1851 	TEST(err == KErrNone);
       
  1852 	
       
  1853 	//Close icon file
       
  1854 	CleanupStack::PopAndDestroy(&svgIconFile);
       
  1855 	
       
  1856 	//First KBytesToRead bytes of the icon file, this should be same as in mbm file.
       
  1857 	RFile tempFile;	
       
  1858 	CleanupClosePushL(tempFile);
       
  1859 	err = tempFile.Open(iFs, KSVGIconFileName, EFileRead);
       
  1860 	TEST(err == KErrNone);
       
  1861 	TBuf8<KBytesToRead> buffer1;
       
  1862 	err = tempFile.Read(buffer1);
       
  1863 	TEST(err == KErrNone);
       
  1864 	TEST(svgBuffer == buffer1);
       
  1865 	CleanupStack::PopAndDestroy(&tempFile);		
       
  1866 	}
       
  1867 	
       
  1868 /**
       
  1869    @SYMTestCaseID T-RApaLsSessionTestStep-TestAppListInstallationL
       
  1870   
       
  1871    @SYMPREQ
       
  1872   
       
  1873    @SYMTestCaseDesc Test updating of Application list on installation of a new application. 
       
  1874    
       
  1875    @SYMTestPriority High 
       
  1876   
       
  1877    @SYMTestStatus Implemented
       
  1878    
       
  1879    @SYMTestActions Test updating of application list on installation of a new application. 
       
  1880    Copy the tstapp from z: import\apps folder to c: import\apps folder. 
       
  1881    Call RApaLsSession::GetAppInfo() and test the application information obtained to 
       
  1882    verify whether the application architecture server updates the application to reside in c: drive.
       
  1883    Delete the copied application and call RApaLsSession::GetAppInfo().
       
  1884    Verify that the application list updates the tstapp application to reside
       
  1885    on z: drive.\n
       
  1886    API Calls:\n	
       
  1887    RApaLsSession::GetAppInfo(TApaAppInfo& aInfo,TUid aAppUid) const\n
       
  1888    
       
  1889    @SYMTestExpectedResults The test confirms that the application architecture
       
  1890    server updates the application list on installation of a new application. It also confirms that 
       
  1891    if UID of an application which is present on import\apps folder on any non-ROM drive, is same 
       
  1892    as UID of an existing application present on z: import\apps folder then the apparc server 
       
  1893    updates the applist and uses the application residing on non-ROM drive's import\apps folder.
       
  1894     
       
  1895  */
       
  1896 void CT_RApaLsSessionTestStep::TestAppListInstallationL()
       
  1897  	{ 
       
  1898  	_LIT(KTestAppDestDir, "C:\\private\\10003a3f\\import\\apps\\" );
       
  1899  	_LIT(KTestAppSource, "Z:\\private\\10003a3f\\import\\apps\\tstapp_reg.rsc" );
       
  1900  	_LIT(KTestAppDest, "C:\\private\\10003a3f\\import\\apps\\tstapp_reg.rsc" );
       
  1901 
       
  1902  	_LIT(KTestWaitingForApplistUpdate,"Waiting %d microseconds for applist to be updated");
       
  1903  	const TInt KApplistUpdateTime = 10000000;
       
  1904 
       
  1905  	// Copy App files around and delete them to check whether 
       
  1906 	// the app list updates and stores the cache correctly.
       
  1907  	RFs	theFS;
       
  1908  	theFS.Connect();
       
  1909  
       
  1910  	// Remove Test app from the file system
       
  1911  	CFileMan* fileManager = CFileMan::NewL (theFS);
       
  1912  
       
  1913  	INFO_PRINTF1(_L("Copying the app to C"));
       
  1914  	TEST(KErrNone == fileManager->Copy (KTestAppSource, KTestAppDest, CFileMan::ERecurse));
       
  1915  	
       
  1916  	INFO_PRINTF2(KTestWaitingForApplistUpdate, KApplistUpdateTime);
       
  1917  	User::After(KApplistUpdateTime);
       
  1918  
       
  1919  	TApaAppInfo aInfo;
       
  1920  	TEST(KErrNone == iLs.GetAppInfo (aInfo, KUidTestApp));
       
  1921 
       
  1922 	TParsePtrC parse (aInfo.iFullName);
       
  1923  	_LIT (KCdrive, "C:");
       
  1924 	INFO_PRINTF1(_L("Comparing App drive location is C:... "));
       
  1925 	TEST(parse.Drive ().CompareF (KCdrive) == 0);
       
  1926  
       
  1927  	INFO_PRINTF1(_L("Removing the app from C"));
       
  1928 	TRequestStatus status;
       
  1929 	TTime tempTime(0); // added tempTime to avoid asynch CFileMan::Attribs request completing with KErrArgument
       
  1930 	TEST(fileManager->Attribs(KTestAppDest,0,KEntryAttReadOnly, tempTime, CFileMan::ERecurse, status)==KErrNone);
       
  1931 	User::WaitForRequest(status);
       
  1932 	TEST(status.Int() == KErrNone);
       
  1933  	TEST(KErrNone == fileManager->Delete (KTestAppDest, CFileMan::ERecurse));
       
  1934 	INFO_PRINTF1(_L("Removing the app dir from C"));
       
  1935 	TEST(fileManager->RmDir(KTestAppDestDir)==KErrNone);
       
  1936  	
       
  1937 	INFO_PRINTF2(KTestWaitingForApplistUpdate, KApplistUpdateTime);
       
  1938 	User::After(KApplistUpdateTime);
       
  1939  
       
  1940  	// That should put the file in the right place
       
  1941  	TEST(KErrNone == iLs.GetAppInfo( aInfo, KUidTestApp));
       
  1942 
       
  1943  	TParsePtrC parse1 (aInfo.iFullName);
       
  1944  	_LIT (KZdrive, "Z:");
       
  1945 	INFO_PRINTF1(_L("Comparing App drive location is Z:... "));
       
  1946  	TEST((parse1.Drive().CompareF(KZdrive)) == 0);
       
  1947 
       
  1948  	delete fileManager;
       
  1949  	theFS.Close();
       
  1950 
       
  1951  	INFO_PRINTF1(_L("Test TestAppListInstallationL completed"));
       
  1952  	}
       
  1953  	
       
  1954 /**
       
  1955    @SYMTestCaseID T-RApaLsSessionTestStep-TestAppListInstallation1L
       
  1956   
       
  1957    @SYMDEF DEF055654: Platform-security loop-hole for "import-directory" applications
       
  1958   
       
  1959    @SYMTestCaseDesc Test updating of Application list on installation of a new application. 
       
  1960    
       
  1961    @SYMTestPriority High 
       
  1962   
       
  1963    @SYMTestStatus Implemented
       
  1964    
       
  1965    @SYMTestActions Test updating of application list on installation of a new application. 
       
  1966    Copy the SimpleApparcTestApp from z:\private\10003a3f\apps folder to c:\private\10003a3f\import\apps
       
  1967    folder. Call RApaLsSession::GetAppInfo() and test the application information obtained to
       
  1968    verify that apparc server does not update the application to reside in c: drive
       
  1969    but on z drive. Delete the copied application and call RApaLsSession::GetAppInfo().
       
  1970    Verify that the application list does not update app list again.\n
       
  1971    API Calls:\n	
       
  1972    RApaLsSession::GetAppInfo(TApaAppInfo& aInfo,TUid aAppUid) const\n
       
  1973    
       
  1974    @SYMTestExpectedResults The test confirms that the scanning order of apparc server 
       
  1975    for applications is 'apps' folder for all ROM drives and then 'import\apps' folder 
       
  1976    for all other drives. It also confirms that if UID of an application which is present in 
       
  1977    import\apps folder on any non-ROM drive, is same as UID of an existing application present 
       
  1978    on z: apps folder then the apparc server does not update app list and uses the application
       
  1979    residing on z drive.
       
  1980     
       
  1981  */
       
  1982 void CT_RApaLsSessionTestStep::TestAppListInstallation1L()
       
  1983  	{ 
       
  1984  	_LIT(KTestAppDestDir, "C:\\private\\10003a3f\\import\\apps\\" );
       
  1985  	_LIT(KTestAppSource, "Z:\\private\\10003a3f\\apps\\SimpleApparcTestApp_reg.rsc" );
       
  1986  	_LIT(KTestAppDest, "C:\\private\\10003a3f\\import\\apps\\SimpleApparcTestApp_reg.rsc" );
       
  1987 
       
  1988  	_LIT(KTestWaitingForApplistUpdate,"Waiting %d microseconds for applist to be updated");
       
  1989  	const TInt KApplistUpdateTime=10000000;
       
  1990 
       
  1991  	// Copy reg files around and delete them to check the app list does not update. 
       
  1992  	RFs	theFS;
       
  1993  	User::LeaveIfError(theFS.Connect());
       
  1994  	CleanupClosePushL(theFS);
       
  1995  	
       
  1996  	// Remove simple app from the file system
       
  1997  	CFileMan* fileManager=CFileMan::NewL(theFS);
       
  1998  	CleanupStack::PushL(fileManager);
       
  1999  
       
  2000  	INFO_PRINTF1(_L("Copying the app to C \\import\\apps folder"));
       
  2001  	TEST(KErrNone==fileManager->Copy(KTestAppSource,KTestAppDest,CFileMan::ERecurse));
       
  2002  	
       
  2003  	INFO_PRINTF2(KTestWaitingForApplistUpdate,KApplistUpdateTime);
       
  2004  	User::After(KApplistUpdateTime);
       
  2005  
       
  2006  	TApaAppInfo appInfo;
       
  2007  	const TUid KUidSimpleApparcTestApp={0x12008ACE};
       
  2008  	TEST(KErrNone==iLs.GetAppInfo(appInfo,KUidSimpleApparcTestApp));
       
  2009 
       
  2010 	TParsePtrC parse(appInfo.iFullName);
       
  2011  	_LIT (KZdrive,"Z:");
       
  2012  	INFO_PRINTF1(_L("After copying app to C:, there should not be any update in app list:... "));
       
  2013  	INFO_PRINTF1(_L("Comparing App drive location is Z:... "));
       
  2014 	TEST(parse.Drive().CompareF(KZdrive)==0);
       
  2015  
       
  2016  	INFO_PRINTF1(_L("Removing the app from C"));
       
  2017 	TRequestStatus status;
       
  2018 	TTime tempTime(0); // added tempTime to avoid asynch CFileMan::Attribs request completing with KErrArgument
       
  2019 	TEST(fileManager->Attribs(KTestAppDest,0,KEntryAttReadOnly,tempTime,CFileMan::ERecurse,status)==KErrNone);
       
  2020 	User::WaitForRequest(status);
       
  2021 	TEST(status.Int()==KErrNone);
       
  2022  	TEST(KErrNone==fileManager->Delete(KTestAppDest, CFileMan::ERecurse));
       
  2023 
       
  2024 	INFO_PRINTF1(_L("Removing the app dir from C"));
       
  2025 	TEST(fileManager->RmDir(KTestAppDestDir)==KErrNone);
       
  2026 
       
  2027  	
       
  2028 	INFO_PRINTF2(KTestWaitingForApplistUpdate,KApplistUpdateTime);
       
  2029 	User::After(KApplistUpdateTime);
       
  2030  
       
  2031  	TEST(KErrNone==iLs.GetAppInfo(appInfo,KUidSimpleApparcTestApp));
       
  2032 
       
  2033  	TParsePtrC parse1(appInfo.iFullName);
       
  2034  	INFO_PRINTF1(_L("After removing app from C:, there should not be any update in app list:... "));
       
  2035  	INFO_PRINTF1(_L("Comparing App drive location is Z:... "));
       
  2036  	TEST((parse1.Drive().CompareF(KZdrive))==0);
       
  2037  	
       
  2038  	CleanupStack::PopAndDestroy(2, &theFS);
       
  2039 
       
  2040  	INFO_PRINTF1(_L("Test TestAppListInstallation1L completed"));
       
  2041  	} 	
       
  2042 
       
  2043 	/**
       
  2044    @SYMTestCaseID APPFWK-APPARC-0107
       
  2045    
       
  2046    @SYMDEF DEF141484 
       
  2047    
       
  2048    @SYMTestCaseDesc     Tests whether Phone booting is failed or not with pesense of 
       
  2049                         an .mbm file of size zero in the path resource\apps
       
  2050    
       
  2051    @SYMTestPriority 
       
  2052   
       
  2053    @SYMTestStatus       Implemented
       
  2054    
       
  2055    @SYMTestActions          Place an .mbm file of size zero in the path resource\apps
       
  2056    
       
  2057    @SYMTestExpectedResults  Phone booting should not fail with pesense of 
       
  2058                             an .mbm file of size zero in the path resource\apps
       
  2059     
       
  2060  */
       
  2061 void CT_RApaLsSessionTestStep::TestZeroSizedIconFileL()
       
  2062     {
       
  2063     
       
  2064     INFO_PRINTF1(_L("Test TestZeroSizedIconFileL Started.........."));
       
  2065     
       
  2066     _LIT(KTestAppDestDir, "C:\\private\\10003a3f\\import\\apps\\" );
       
  2067     _LIT(KTestAppResourceDir, "C:\\resource\\apps\\" );
       
  2068     
       
  2069     _LIT(KTestAppSource, "Z:\\apparctest\\zerosizedicon_reg.rsc" );
       
  2070     _LIT(KTestAppDest, "C:\\private\\10003a3f\\import\\apps\\zerosizedicon_reg.rsc" );
       
  2071     
       
  2072     _LIT(KTestMbmSource, "Z:\\resource\\apps\\zerosizedicon.mbm");
       
  2073     _LIT(KTestMbmDest, "C:\\resource\\apps\\zerosizedicon.mbm");
       
  2074     
       
  2075     _LIT(KTestLocSource, "Z:\\apparctest\\zerosizedicon_loc.rsc");
       
  2076     _LIT(KTestLocDest, "C:\\resource\\apps\\zerosizedicon_loc.rsc");
       
  2077    
       
  2078     TRequestStatus appScanCompleted=KRequestPending; 
       
  2079     iLs.SetNotify(EFalse,appScanCompleted); 
       
  2080     
       
  2081     RSmlTestUtils utils;
       
  2082     CleanupClosePushL(utils);
       
  2083     TEST(KErrNone == utils.Connect());
       
  2084   
       
  2085     INFO_PRINTF1(_L("Creating directory C:\\private\\10003a3f\\import\\apps\\ folder"));
       
  2086     TInt err=utils.CreateDirectoryL(KTestAppDestDir);
       
  2087     TESTEL((err==KErrNone) ||  (err==KErrAlreadyExists),err);
       
  2088 
       
  2089     INFO_PRINTF1(_L("Creating directory C:\\resource\\apps\\ folder"));
       
  2090     err=utils.CreateDirectoryL(KTestAppResourceDir);
       
  2091     TESTEL((err==KErrNone) ||  (err==KErrAlreadyExists),err);
       
  2092 
       
  2093     INFO_PRINTF1(_L("Copying _reg.rsc to C:\\private\\10003a3f\\import\\apps\\ folder"));    
       
  2094     User::LeaveIfError(utils.CopyFileL(KTestAppSource,KTestAppDest));
       
  2095     INFO_PRINTF1(_L("Copying the mbm and _loc.rsc to C:\\resource\\apps\\ folder"));
       
  2096     User::LeaveIfError(utils.CopyFileL(KTestMbmSource,KTestMbmDest));
       
  2097     User::LeaveIfError(utils.CopyFileL(KTestLocSource,KTestLocDest));
       
  2098 
       
  2099     User::WaitForRequest(appScanCompleted);
       
  2100     TEST(appScanCompleted.Int()==MApaAppListServObserver::EAppListChanged);
       
  2101 
       
  2102 	appScanCompleted=KRequestPending;
       
  2103 	iLs.SetNotify(EFalse,appScanCompleted);
       
  2104     INFO_PRINTF1(_L("Removing _reg.rsc from C:\\private\\10003a3f\\import\\apps\\ folder"));
       
  2105     TEST(KErrNone == DeleteFileL(utils, KTestAppDest));
       
  2106     INFO_PRINTF1(_L("Removing the mbm and _loc.rsc from C:\\resource\\apps\\ folder"));
       
  2107     TEST(KErrNone == DeleteFileL(utils, KTestMbmDest));
       
  2108     TEST(KErrNone == DeleteFileL(utils, KTestLocDest));
       
  2109     INFO_PRINTF1(_L("Removing the C:\\private\\10003a3f\\import\\apps\\ dir "));
       
  2110     TEST(KErrNone == utils.DeleteDirectoryL(KTestAppDestDir));
       
  2111   
       
  2112 	User::WaitForRequest(appScanCompleted);
       
  2113     CleanupStack::PopAndDestroy(&utils);//utils
       
  2114     INFO_PRINTF1(_L("Test TestZeroSizedIconFileL completed"));
       
  2115     } 
       
  2116 
       
  2117 //Deletes the file if it exists.
       
  2118 TInt CT_RApaLsSessionTestStep::DeleteFileL(RSmlTestUtils &aFs, const TDesC &aFileName)
       
  2119     {
       
  2120     TInt fileExists = EFalse;
       
  2121     TInt err;
       
  2122     aFs.IsFilePresent(aFileName, fileExists);
       
  2123     if (fileExists)
       
  2124         {
       
  2125         aFs.ChangeFilePermissionL(aFileName);
       
  2126         err=aFs.DeleteFileL(aFileName);
       
  2127         if(err==KErrNone)
       
  2128             INFO_PRINTF2(_L("Removed file %S"), &aFileName);
       
  2129         else
       
  2130             INFO_PRINTF2(_L("Failed to remove file %S"), &aFileName);
       
  2131         }
       
  2132     else
       
  2133         {
       
  2134         err=KErrNotFound;
       
  2135         }
       
  2136 
       
  2137     return(err);
       
  2138 }
       
  2139 
       
  2140 	
       
  2141 /**
       
  2142    @SYMTestCaseID T-RApaLsSessionTestStep-TestAppFolderNonRomDrivesL
       
  2143   
       
  2144    @SYMDEF DEF055654: Platform-security loop-hole for "import-directory" applications
       
  2145   
       
  2146    @SYMTestCaseDesc Test scanning of app folder for non-ROM drives. 
       
  2147   
       
  2148    @SYMTestPriority High 
       
  2149   
       
  2150    @SYMTestStatus Implemented
       
  2151    
       
  2152    @SYMTestActions Test scanning of app folder for non-ROM drives. 
       
  2153    Copy a new application AAA_reg from z:\Apparctest folder to c:\private\10003a3f\apps folder. 
       
  2154    Call RApaLsSession::GetAppInfo() and test application architecture server does not 
       
  2155    populate the new application in app list. Delete the copied application.\n
       
  2156    API Calls:\n	
       
  2157    RApaLsSession::GetAppInfo(TApaAppInfo& aInfo,TUid aAppUid) const\n
       
  2158    
       
  2159    @SYMTestExpectedResults The test confirms that the application architecture server does not 
       
  2160    scans applications residing in 'apps' folder for all non-ROM drives.    
       
  2161  */
       
  2162 void CT_RApaLsSessionTestStep::TestAppFolderNonRomDrivesL()
       
  2163  	{ 
       
  2164  	_LIT(KTestAppDestDir, "C:\\private\\10003a3f\\apps\\" );
       
  2165  	_LIT(KTestAppSource, "Z:\\Apparctest\\AAA_reg.rsc" );
       
  2166  	_LIT(KTestAppDest, "C:\\private\\10003a3f\\apps\\AAA_reg.rsc" );
       
  2167 
       
  2168  	_LIT(KTestWaitingForApplistUpdate,"Waiting %d microseconds for applist to be updated");
       
  2169  	const TInt KApplistUpdateTime=10000000;
       
  2170 
       
  2171 	INFO_PRINTF1(_L("Test scanning of app folder for non-ROM drives"));
       
  2172  	// Copy reg files around and delete them to check 
       
  2173 	// the app list does not update. 
       
  2174  	RFs	theFS;
       
  2175  	User::LeaveIfError(theFS.Connect());
       
  2176  	CleanupClosePushL(theFS);
       
  2177  
       
  2178  	// Remove simple app from the file system
       
  2179  	CFileMan* fileManager=CFileMan::NewL(theFS);
       
  2180  	CleanupStack::PushL(fileManager);
       
  2181  
       
  2182  	INFO_PRINTF1(_L("Copying AAA app to C apps folder"));
       
  2183  	TEST(KErrNone==fileManager->Copy(KTestAppSource,KTestAppDest,CFileMan::ERecurse));
       
  2184  	
       
  2185  	INFO_PRINTF2(KTestWaitingForApplistUpdate,KApplistUpdateTime);
       
  2186  	User::After(KApplistUpdateTime);
       
  2187  
       
  2188  	TApaAppInfo appInfo;
       
  2189  	// UID of AAA app is 0x10207f74
       
  2190  	const TUid KUidSimpleApp={0x10207f74};
       
  2191  	INFO_PRINTF1(_L("Finding AAA app in app list... "));
       
  2192  	TEST(KErrNotFound==iLs.GetAppInfo(appInfo,KUidSimpleApp));
       
  2193 
       
  2194 	INFO_PRINTF1(_L("Removing AAA app from C apps folder"));
       
  2195 	TRequestStatus status;
       
  2196 	TTime tempTime(0); // added tempTime to avoid asynch CFileMan::Attribs request completing with KErrArgument
       
  2197 	TEST(fileManager->Attribs(KTestAppDest,0,KEntryAttReadOnly,tempTime,CFileMan::ERecurse,status)==KErrNone);
       
  2198 	User::WaitForRequest(status);
       
  2199 	TEST(status.Int()==KErrNone);
       
  2200  	TEST(KErrNone==fileManager->Delete(KTestAppDest,CFileMan::ERecurse));
       
  2201 
       
  2202 	INFO_PRINTF1(_L("Removing the app dir from C"));
       
  2203 	TEST(fileManager->RmDir(KTestAppDestDir)==KErrNone);
       
  2204 
       
  2205  	
       
  2206 	INFO_PRINTF2(KTestWaitingForApplistUpdate,KApplistUpdateTime);
       
  2207 	User::After(KApplistUpdateTime);
       
  2208  	
       
  2209  	INFO_PRINTF1(_L("Finding AAA app in app list... "));
       
  2210  	TEST(KErrNotFound==iLs.GetAppInfo(appInfo,KUidSimpleApp));
       
  2211  	
       
  2212  	CleanupStack::PopAndDestroy(2, &theFS);
       
  2213 
       
  2214  	INFO_PRINTF1(_L("Test scanning of app folder for non-ROM drives completed"));
       
  2215  	}
       
  2216  	
       
  2217 /**
       
  2218    @SYMTestCaseID T-RApaLsSessionTestStep-DoNumDefIconsTestL
       
  2219   
       
  2220    @SYMDEF DEF037571 - Provide a better alternative to CApaAppInfoFileReader::NumberOfBitmaps'
       
  2221   
       
  2222    @SYMTestCaseDesc  
       
  2223    
       
  2224    @SYMTestPriority High 
       
  2225   
       
  2226    @SYMTestStatus Implemented
       
  2227    
       
  2228    @SYMTestActions 
       
  2229    API Calls:\n	
       
  2230    RApaLsSession::GetAppIconSizes() \n
       
  2231    RApaLsSession::NumberOfOwnDefinedIcons(appUid, iconCount)
       
  2232    @SYMTestExpectedResults
       
  2233     
       
  2234  */
       
  2235 void CT_RApaLsSessionTestStep::DoNumDefIconsTestL()
       
  2236 	{
       
  2237 	INFO_PRINTF1(_L("Testing RApaLsSession::NumberOfOwnDefinedIcons"));
       
  2238 
       
  2239 	CArrayFixFlat<TSize>* array = new(ELeave) CArrayFixFlat<TSize>(4);
       
  2240 	CleanupStack::PushL(array);
       
  2241 
       
  2242 	// Test the GetAppIconSizes function, check 3 icons are returned (default icons)
       
  2243 	INFO_PRINTF1(_L("Testing GetAppIconSizes"));
       
  2244 	TUid appUid;
       
  2245 	appUid.iUid = 0x12008ACE;	// SimpleApparcTestApp UID
       
  2246 	TInt err = iLs.GetAppIconSizes(appUid, *array);
       
  2247 	TEST(err == KErrNone);
       
  2248 	TEST(array->Count() == 3);
       
  2249 
       
  2250 	// Test the NumberOfOwnDefinedIcons function, check count is zero (no own defined icons)
       
  2251 	INFO_PRINTF1(_L("Testing NumberOfOwnDefinedIcons (SimpleApparcTestApp)"));
       
  2252 	TInt iconCount = -1;
       
  2253 	err = iLs.NumberOfOwnDefinedIcons(appUid, iconCount);
       
  2254 	TEST(err == KErrNone);
       
  2255 	TEST(iconCount == 0);
       
  2256 
       
  2257 	// Test NumberOfOwnDefinedIcons again, this time with Agenda app UID (icons defined)
       
  2258 	INFO_PRINTF1(_L("Testing NumberOfOwnDefinedIcons (Paint app)"));
       
  2259 	iconCount = -1;
       
  2260 	appUid.iUid = 0x10003A5C;//agenda  app UID
       
  2261 	err = iLs.NumberOfOwnDefinedIcons(appUid, iconCount);
       
  2262 	TEST(err == KErrNone);
       
  2263 	TEST(iconCount == 3);
       
  2264 
       
  2265 	CleanupStack::PopAndDestroy(array);
       
  2266 
       
  2267 	INFO_PRINTF1(_L("NumberOfOwnDefinedIcons test complete"));
       
  2268 	}
       
  2269 
       
  2270 
       
  2271 void CT_RApaLsSessionTestStep::TestMatchesSecurityPolicy()
       
  2272 	{
       
  2273 	TUid appUid;
       
  2274 	appUid.iUid=0X10009f9a;
       
  2275     TBool matches;
       
  2276    
       
  2277     //Testing with valid TSecurityPolicy
       
  2278     INFO_PRINTF1(_L("Testing MatchesSecurityPolicy with valid TSecurityPolicy"));
       
  2279     iLs.MatchesSecurityPolicy(matches, appUid, TSecurityPolicy(TVendorId(0x70000001)));
       
  2280     TEST(matches);
       
  2281     INFO_PRINTF1(KCompleted);
       
  2282     
       
  2283     //Testing with invalid TSecurityPolicy
       
  2284     INFO_PRINTF1(_L("Testing MatchesSecurityPolicy with invalid TSecurityPolicy"));
       
  2285     APPFWK_NEGATIVE_PLATSEC_START;
       
  2286     iLs.MatchesSecurityPolicy(matches, appUid, TSecurityPolicy(TVendorId(0x70000002)));
       
  2287     APPFWK_NEGATIVE_PLATSEC_FINISH;
       
  2288     TEST(!matches);
       
  2289     INFO_PRINTF1(KCompleted);
       
  2290 	}
       
  2291 
       
  2292 void CT_RApaLsSessionTestStep::TestGetAppViewsL()
       
  2293 	{
       
  2294 	INFO_PRINTF1(_L("Testing RApaLsSession::GetAppViews() with a valid app uid"));
       
  2295 
       
  2296 	CApaAppViewArray* appViews = new(ELeave) CApaAppViewArray(4);
       
  2297 	CleanupStack::PushL(appViews);
       
  2298 
       
  2299 	TInt ret = iLs.GetAppViews(*appViews, KUidTestApp);
       
  2300 	TEST(ret==KErrNone);
       
  2301 	
       
  2302 	// check appviews contain entries
       
  2303 	const TInt count=appViews->Count();
       
  2304 	TEST(count > 0);
       
  2305 	TInt testNumberOfIcons = count-1;
       
  2306 	//the last view is invalid. Hence it checks till count-1 
       
  2307 	for (TInt ii=0; ii<testNumberOfIcons; ii++)
       
  2308 		{
       
  2309 		const TApaAppViewInfo& viewInfo=(*appViews)[ii];
       
  2310 		TEST(viewInfo.iUid != KNullUid);
       
  2311 		TEST(viewInfo.iViewCaption.Length() > 0);
       
  2312 		TEST(viewInfo.iScreenMode == 0x00);
       
  2313 
       
  2314 		// check icons in the views
       
  2315 		CApaMaskedBitmap* viewBitmap = CApaMaskedBitmap::NewLC();
       
  2316 		ret = iLs.GetAppViewIcon(KUidTestApp, viewInfo.iUid, TSize(50,50), *viewBitmap);
       
  2317 		TEST(ret==KErrNone);
       
  2318 		CleanupStack::PopAndDestroy(viewBitmap);
       
  2319 		
       
  2320 		HBufC* fullFileName = NULL;
       
  2321 		ret = iLs.GetAppViewIcon(KUidTestApp, viewInfo.iUid, fullFileName);
       
  2322 		TEST(ret == KErrNone);
       
  2323 		TEST(fullFileName != NULL);
       
  2324 		if (fullFileName != NULL)
       
  2325 			{
       
  2326 			TEST(fullFileName->Length() > 0);
       
  2327 			}
       
  2328 		delete fullFileName;		
       
  2329 		fullFileName = NULL;		
       
  2330 		}
       
  2331 
       
  2332 	CleanupStack::PopAndDestroy(appViews);
       
  2333     INFO_PRINTF1(KCompleted);
       
  2334 	}
       
  2335 
       
  2336 void CT_RApaLsSessionTestStep::TestGetAppViewsFailureL()
       
  2337 	{
       
  2338 	INFO_PRINTF1(_L("Testing RApaLsSession::GetAppViews() with an invalid app uid"));
       
  2339 
       
  2340 	const TUid appUid={10000}; // invalid uid
       
  2341 	CApaAppViewArray* appViews = new(ELeave) CApaAppViewArray(2);
       
  2342 	CleanupStack::PushL(appViews);
       
  2343 	
       
  2344 	//Create App View array
       
  2345 	TInt ret = iLs.GetAppViews(*appViews, appUid);
       
  2346 	TEST(ret=KErrNotFound);
       
  2347 	
       
  2348 	CleanupStack::PopAndDestroy(appViews);
       
  2349     INFO_PRINTF1(KCompleted);
       
  2350 	}
       
  2351 
       
  2352 void CT_RApaLsSessionTestStep::IconLoadingTestCasesL()
       
  2353 	{
       
  2354 	CArrayFixFlat<TSize>* testIconSizeArray;
       
  2355 	testIconSizeArray=new(ELeave) CArrayFixFlat<TSize>(3);
       
  2356 	CleanupStack::PushL(testIconSizeArray);
       
  2357 	TestServerIconSizeCountL(*testIconSizeArray);
       
  2358 	TestServerIconLoadingBySize1L(*testIconSizeArray);
       
  2359 	TestServerIconLoadingBySize2L(*testIconSizeArray);
       
  2360 	TestServerIconLoadingBySize3L(*testIconSizeArray);
       
  2361 	CleanupStack::PopAndDestroy(testIconSizeArray);
       
  2362 	}
       
  2363 
       
  2364 void CT_RApaLsSessionTestStep::AppInfoTestCasesL()
       
  2365 	{
       
  2366 	TestAppListInfoDataInterrogationSetupL();
       
  2367 					
       
  2368 	TestAppInfo1();
       
  2369 	TestAppInfo2();
       
  2370 	TestAppInfo3();
       
  2371 	TestAppInfo4();
       
  2372 	
       
  2373 	TestGetAppCapabilityL();
       
  2374 	TestRecognizeSpecificData();
       
  2375 
       
  2376 	TestSetGetAcceptedConfidenceL();
       
  2377 	TestSetGetMaxDataBufSizeL();
       
  2378 			
       
  2379 	TestGetSupportedDataTypesL();
       
  2380 	TestGetAppIconL();
       
  2381 	TestGetAppIcon1L();
       
  2382 	TestGetAppIcon2L();
       
  2383 
       
  2384 	TestGetAppViewsL();
       
  2385 	TestGetAppViewsFailureL();
       
  2386 	}
       
  2387 
       
  2388 void CT_RApaLsSessionTestStep::EmbeddedAppsTestCases()
       
  2389 	{
       
  2390 	DoGetAllApps();
       
  2391 	DoGetEmbeddableApps();
       
  2392 	DoEmbeddableAppCount();
       
  2393 	DoGetAppCapability();
       
  2394 	DoGetFilteredApps1();
       
  2395 	DoGetFilteredApps2();
       
  2396 	DoGetFilteredApps3();
       
  2397 	DoGetFilteredApps4();
       
  2398 	DoGetFilteredApps5();
       
  2399 	DoGetFilteredApps6();
       
  2400 	DoTestEmbeddabilityFilter1();
       
  2401 	DoTestEmbeddabilityFilter2();
       
  2402 	DoTestEmbeddabilityFilter3();
       
  2403 	DoTestEmbeddabilityFilter4();
       
  2404 	DoTestEmbeddabilityFilter5();
       
  2405 	}
       
  2406 	
       
  2407 void CT_RApaLsSessionTestStep::TestNotifyOnDataMappingChangeL()
       
  2408 	{
       
  2409 	INFO_PRINTF1(_L("Test RApaLsSession::TestNotifyOnDataMappingChangeL()"));
       
  2410 	RApaLsSession lsMappingChange;
       
  2411 	lsMappingChange.Connect();
       
  2412 	CleanupClosePushL(lsMappingChange);
       
  2413 	TRequestStatus status;
       
  2414 	lsMappingChange.NotifyOnDataMappingChange(status);
       
  2415 	//Test for TestCancelNotifyOnDataMappingChange
       
  2416 	lsMappingChange.CancelNotifyOnDataMappingChange();
       
  2417 	User::WaitForRequest(status);
       
  2418 	TEST( status ==KErrCancel);
       
  2419 	//Test for TestNotifyOnDataMappingChangeL
       
  2420 	lsMappingChange.NotifyOnDataMappingChange(status);
       
  2421 	const TUid KTestUidValue1={10101010};
       
  2422 	const TDataType dataType(_L8("sonew/else"));
       
  2423 	iLs.InsertDataMapping(dataType,KDataTypePriorityHigh,KTestUidValue1);
       
  2424 	User::WaitForRequest(status);
       
  2425 	TEST(status==KErrNone);
       
  2426 	TEST(KErrNone == iLs.DeleteDataMapping(dataType));
       
  2427 	CleanupStack::PopAndDestroy(&lsMappingChange);
       
  2428 	INFO_PRINTF1(KCompleted);
       
  2429 	}
       
  2430 
       
  2431 /**
       
  2432    @SYMTestCaseID T_RApaLsSessionTestStep_TestDataPriorityForUnTrustedApps
       
  2433   
       
  2434    @SYMDEF	DEF063982
       
  2435   
       
  2436    @SYMTestCaseDesc Tests the Un-Trusted Apps Datatypepriority assigned through 
       
  2437 	RApaLsSession::InsertDataMapping(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid)\n
       
  2438    
       
  2439    @SYMTestPriority High 
       
  2440   
       
  2441    @SYMTestStatus Implemented
       
  2442 
       
  2443    @SYMTestExpectedResults All tests compare the results obtained with the desired result.
       
  2444 */
       
  2445 void CT_RApaLsSessionTestStep::TestDataPriorityForUnTrustedApps()
       
  2446 	{
       
  2447 	INFO_PRINTF1(_L("TestDataPriorityForUnTrustedApps about to start..."));
       
  2448 	const TUid KUidUnTrustedApp = {0x10207f8C};
       
  2449 	const TUid KUidTrustedApp = {0x10207f8D};
       
  2450 	TInt ret;
       
  2451 	TBool insertVal = EFalse;
       
  2452 	//There is no restriction for the Trusted Apps datapriority
       
  2453 	TDataTypePriority KTrustedAppPriority = {KDataTypeUnTrustedPriorityThreshold+1};
       
  2454 	//The data priority for UnTrusted Apps is greater than the Threshold
       
  2455 	TDataTypePriority KUnTrustedAppPriority = {KDataTypeUnTrustedPriorityThreshold+10};
       
  2456 	_LIT8(KLitMimeTypeTestData,"test/data");
       
  2457 	ret = iLs.InsertDataMapping(TDataType(KLitMimeTypeTestData),KTrustedAppPriority,KUidTrustedApp);
       
  2458 	//UnTrusted Apps data priority will be reduced to Security Threshold if it is greater than it.
       
  2459 	ret = iLs.InsertDataMappingIfHigher(TDataType(KLitMimeTypeTestData),KUnTrustedAppPriority,KUidUnTrustedApp,insertVal);
       
  2460 	TUid testUid;
       
  2461 	ret = iLs.AppForDataType(TDataType(KLitMimeTypeTestData),testUid);
       
  2462 	TEST(ret == KErrNone);
       
  2463 	TEST(testUid == KUidTrustedApp);
       
  2464 	INFO_PRINTF1(_L("Completed"));
       
  2465 	}
       
  2466 
       
  2467 /**
       
  2468    @SYMTestCaseID T_RApaLsSessionTestStep_TestDataPriorityForUnTrustedAppsRegFile
       
  2469   
       
  2470    @SYMDEF	DEF063982
       
  2471   
       
  2472    @SYMTestCaseDesc Tests the UnTrusted Apps Datatypepriority assigned through the registration files
       
  2473    
       
  2474    @SYMTestPriority High 
       
  2475   
       
  2476    @SYMTestStatus Implemented
       
  2477    
       
  2478    @SYMTestExpectedResults All tests compare the results obtained with the desired result.
       
  2479  */
       
  2480 void CT_RApaLsSessionTestStep::TestDataPriorityForUnTrustedAppsRegFile()
       
  2481 	{
       
  2482 	INFO_PRINTF1(_L("TestDataPriorityForUnTrustedAppsRegFile about to start..."));
       
  2483 	const TUid KUidRegTrustedApp = {0x10207f8F};
       
  2484 	_LIT8(KLitMimeTypeTestData,"text/html");
       
  2485 	TUid testUid;
       
  2486 	TInt ret;
       
  2487 	//The datatype priority of UnTrusted Apps is reduced to Threshold.  
       
  2488 	ret = iLs.AppForDataType(TDataType(KLitMimeTypeTestData),testUid);
       
  2489 	TEST(ret == KErrNone);
       
  2490 	TEST(testUid == KUidRegTrustedApp);
       
  2491 	INFO_PRINTF1(_L("Completed"));
       
  2492 	}
       
  2493 	
       
  2494 /**
       
  2495    @SYMTestCaseID T_RApaLsSessionTestStep_TestIconLoaderAndIconArrayMemoryLeaksL
       
  2496   
       
  2497    @SYMDEF	PDEF104113
       
  2498   
       
  2499    @SYMTestCaseDesc Checks there's no memory leaks when a CApaAppIconArray oject 
       
  2500    is created and deleted
       
  2501    
       
  2502    @SYMTestPriority High 
       
  2503   
       
  2504    @SYMTestStatus Implemented
       
  2505    
       
  2506    @SYMTestActions It creates an object of CApaAppIconArray class and deletes it. 
       
  2507    Then test there is no memory leak from the creation to destory the object.
       
  2508    
       
  2509    @SYMTestExpectedResults There should be no memory leak checked by __UHEAP_MARK 
       
  2510    and __UHEAP_MARKEND.
       
  2511  */
       
  2512  
       
  2513 void CT_RApaLsSessionTestStep::TestIconLoaderAndIconArrayMemoryLeaksL()
       
  2514 	{
       
  2515 	INFO_PRINTF1(_L("Test TestIconLoaderAndIconArrayMemoryLeaksL"));
       
  2516 	__UHEAP_MARK;
       
  2517 	TIconLoaderAndIconArrayForLeaks::TestIconLoaderAndIconArrayL();
       
  2518 	__UHEAP_MARKEND;
       
  2519 	INFO_PRINTF1(_L("Completed"));
       
  2520 	}
       
  2521 
       
  2522 void CT_RApaLsSessionTestStep::RunTestCasesL()
       
  2523 	{
       
  2524 	//make sure the RFbsSession doesn't have to allocate buffer since it would change the heap
       
  2525 	CFbsBitmap* bufferAllocator = new(ELeave) CFbsBitmap;
       
  2526 	CleanupStack::PushL(bufferAllocator);
       
  2527 	bufferAllocator->Create(TSize(200,1), EColor16M);
       
  2528 	CleanupStack::PopAndDestroy(bufferAllocator);
       
  2529 
       
  2530 	
       
  2531 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestAppListInvalidL(), iLs.ClearAppInfoArray() );
       
  2532 	//DONT_CHECK due to file system changes
       
  2533 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestAppListInstallationL(), NO_CLEANUP);
       
  2534 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestAppListInstallation1L(), NO_CLEANUP);
       
  2535 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestAppFolderNonRomDrivesL(), NO_CLEANUP);
       
  2536     HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestZeroSizedIconFileL(), NO_CLEANUP);
       
  2537     HEAP_TEST_LS_SESSION(iLs, 0, 0, IconLoadingTestCasesL(), NO_CLEANUP);
       
  2538 	HEAP_TEST_LS_SESSION(iLs, 0, 0, AppInfoTestCasesL(), iLs.ClearAppInfoArray(); NO_CLEANUP);
       
  2539 	HEAP_TEST_LS_SESSION(iLs, 0, 0, EmbeddedAppsTestCases(), iLs.ClearAppInfoArray() );
       
  2540 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, DoNumDefIconsTestL(), NO_CLEANUP);
       
  2541 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestMatchesSecurityPolicy(), NO_CLEANUP);
       
  2542 	//DONT_CHECK since there's a new typestore
       
  2543 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestNotifyOnDataMappingChangeL(), NO_CLEANUP);
       
  2544 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestAppListRecognizeDataBufferOnlyL(), iLs.FlushRecognitionCache() );
       
  2545 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestAppListRecognizeDataPassedByBufferL(), iLs.FlushRecognitionCache() );
       
  2546 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestAppListRecognizeDataL(), iLs.FlushRecognitionCache() );
       
  2547 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestDataPriorityForUnTrustedApps(), NO_CLEANUP);
       
  2548 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestDataPriorityForUnTrustedAppsRegFile(), NO_CLEANUP);
       
  2549 	TestIconLoaderAndIconArrayMemoryLeaksL();
       
  2550 	}
       
  2551 
       
  2552 /**
       
  2553    Destructor
       
  2554  */
       
  2555 CT_RApaLsSessionTestStep::~CT_RApaLsSessionTestStep()
       
  2556 	{
       
  2557 	RFbsSession::Disconnect();
       
  2558 	iFs.Close();
       
  2559 	iLs.Close();
       
  2560 	}
       
  2561 
       
  2562 /**
       
  2563    Constructor
       
  2564  */
       
  2565 CT_RApaLsSessionTestStep::CT_RApaLsSessionTestStep()
       
  2566 	{
       
  2567 	FbsStartup();
       
  2568 	TInt ret=RFbsSession::Connect();
       
  2569 	TEST(ret==KErrNone);
       
  2570 
       
  2571 	ret=iFs.Connect();
       
  2572 	TEST(ret==KErrNone);
       
  2573 	
       
  2574 	setup();
       
  2575 
       
  2576 	ret = iLs.Connect();
       
  2577 	TEST(ret==KErrNone);
       
  2578 	
       
  2579 	// Call base class method to set up the human readable name for logging
       
  2580 	SetTestStepName(KT_RApaLsSessionStep);
       
  2581 	}
       
  2582 
       
  2583 /**
       
  2584    @return - TVerdict code
       
  2585    Override of base class virtual
       
  2586  */
       
  2587 TVerdict CT_RApaLsSessionTestStep::doTestStepPreambleL()
       
  2588 	{
       
  2589 	SetTestStepResult(EPass);
       
  2590 	return TestStepResult();
       
  2591 	}
       
  2592 
       
  2593 /**
       
  2594    @return - TVerdict code
       
  2595    Override of base class virtual
       
  2596  */
       
  2597 TVerdict CT_RApaLsSessionTestStep::doTestStepPostambleL()
       
  2598 	{
       
  2599 	return TestStepResult();
       
  2600 	}
       
  2601 
       
  2602 
       
  2603 TVerdict CT_RApaLsSessionTestStep::doTestStepL()
       
  2604 	{
       
  2605 	INFO_PRINTF1(_L("Testing Apparc...T_RApaLsSession Test Cases Running..."));
       
  2606 
       
  2607 	TRAPD(ret,RunTestCasesL())
       
  2608 	TEST(ret==KErrNone);
       
  2609 	
       
  2610 	INFO_PRINTF1(_L("...T_RApaLsSession Test Cases Completed."));
       
  2611 
       
  2612 	return TestStepResult();
       
  2613 	}
       
  2614 	
       
  2615