localisation/apparchitecture/tef/T_RApaLsSessionStep.cpp
branchSymbian3
changeset 57 b8d18c84f71c
parent 6 c108117318cb
equal deleted inserted replaced
56:aa99f2208aad 57:b8d18c84f71c
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
       
    14 // t_rapalssessionstep.cpp
    14 //
    15 //
    15 
    16 
    16 
    17 /**
    17 
    18  @file t_rapalssessionstep.cpp
    18 /**
       
    19  @file
       
    20  @test
    19  @test
    21  @internalComponent - Internal Symbian test code 
    20  @internalComponent - Internal Symbian test code 
    22 */
    21 */
    23 
    22 
    24 #include <f32file.h>
    23 #include <f32file.h>
    29 
    28 
    30 #include <coecntrl.h>
    29 #include <coecntrl.h>
    31 #include <coeccntx.h>
    30 #include <coeccntx.h>
    32 #include <coemain.h>
    31 #include <coemain.h>
    33 #include <coeview.h>
    32 #include <coeview.h>
    34 #include <eikdialg.h>
    33 #include <mw/eikdialg.h>
    35 #include <eikdoc.h>
    34 #include <eikdoc.h>
    36 #include <eikapp.h>
    35 #include <eikapp.h>
    37 #include <eiksrvc.h>
    36 #include <eiksrvc.h>
    38 #include <eikconso.h>
    37 #include <mw/eikconso.h>
    39 
    38 
    40 #include <apaid.h>
    39 #include <apaid.h>
    41 #include "..\apparc\apadll.h"
    40 #include "../apparc/apadll.h"
    42 #include <apgaplst.h>
    41 #include <apgaplst.h>
    43 #include <apgicnfl.h>
    42 #include <apgicnfl.h>
    44 #include <apgdoor.h>
    43 #include <apgdoor.h>
    45 #include <apfrec.h>
    44 #include <apfrec.h>
    46 #include <apfctlf.h>
    45 #include <apfctlf.h>
    47 #include <apgctl.h>
    46 #include <apgctl.h>
    48 #include <apgaplst.h>
    47 #include <apgaplst.h>
    49 #include <apaflrec.h>
    48 #include <apaflrec.h>
    50 #include <apgcli.h>
    49 #include <apgcli.h>
    51 #include <apacmdln.h>
    50 #include <apacmdln.h>
    52 #include <apsserv.h>
       
    53 #include <barsread.h>
    51 #include <barsread.h>
    54 #include "tstapp.h"
    52 #include "tstapp.h"
    55 #include <appfwk_test.h>
    53 #include "appfwk_test.h"
       
    54 #include <apgnotif.h>
    56 
    55 
    57 #include "T_RApaLsSessionStep.h"
    56 #include "T_RApaLsSessionStep.h"
    58 #include "appfwk_test_AppUi.h"
    57 #include "appfwk_test_appui.h"
    59 #include "TRApaLsSessionStartAppTest.h"
    58 #include "TRApaLsSessionStartAppTest.h"
    60 #include "TIconLoaderAndIconArrayForLeaks.h"  
    59 #include "TIconLoaderAndIconArrayForLeaks.h"  
    61 
    60 
    62 #if !defined(__E32TEST_H__)
    61 #if !defined(__E32TEST_H__)
    63 #include <e32test.h>
    62 #include <e32test.h>
    85 	iFs.MkDirAll(parser.DriveAndPath());
    84 	iFs.MkDirAll(parser.DriveAndPath());
    86 #endif
    85 #endif
    87 	}
    86 	}
    88 
    87 
    89 
    88 
    90 ////////////////////////////
    89 //
    91 // Might actually be tests......
    90 // Might actually be tests......
    92 /////////////////////////////
    91 //
    93 
    92 
    94 void CT_RApaLsSessionTestStep::TestAppListInfoDataInterrogationSetupL()
    93 void CT_RApaLsSessionTestStep::TestAppListInfoDataInterrogationSetupL()
    95 	{
    94 	{
    96 	//
    95 	//
    97 	INFO_PRINTF1(_L("Initialising App List Cache using GetAllApps....."));
    96 	INFO_PRINTF1(_L("Initialising App List Cache using GetAllApps....."));
   503 	
   502 	
   504 	CFileMan* iAppListInvalidTestFileMan = CFileMan::NewL (iFs);
   503 	CFileMan* iAppListInvalidTestFileMan = CFileMan::NewL (iFs);
   505 	CleanupStack::PushL(iAppListInvalidTestFileMan);
   504 	CleanupStack::PushL(iAppListInvalidTestFileMan);
   506 	
   505 	
   507 	INFO_PRINTF1(_L("Copy tstapp files to C: drive......."));
   506 	INFO_PRINTF1(_L("Copy tstapp files to C: drive......."));
   508 	TInt rtn=iFs.MkDir(KTempAppDir);
   507 	TInt rtn=iFs.MkDirAll(KTempAppDir);
   509 	TEST(rtn==KErrNone||rtn==KErrAlreadyExists); 
   508 	TEST(rtn==KErrNone||rtn==KErrAlreadyExists); 
   510 	TEST(iAppListInvalidTestFileMan->Copy(regPath, KTempRegPath)==KErrNone);	//Just to start the idle update.
   509 	TEST(iAppListInvalidTestFileMan->Copy(regPath, KTempRegPath)==KErrNone);	//Just to start the idle update.
   511 
   510 
   512 	INFO_PRINTF1(_L("Get app list......."));
   511 	INFO_PRINTF1(_L("Get app list......."));
   513 	TInt ret = iLs.GetAllApps();
   512 	TInt ret = iLs.GetAllApps();
   668         TEST(EFalse);
   667         TEST(EFalse);
   669         }  
   668         }  
   670    
   669    
   671   	INFO_PRINTF1(KCompleted);
   670   	INFO_PRINTF1(KCompleted);
   672 	}
   671 	}
   673    	
   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 
   674 /**
   726 /**
   675    @SYMTestCaseID T-Serv2Step-DoEnquiryTestsL
   727    @SYMTestCaseID T-Serv2Step-DoEnquiryTestsL
   676   
   728   
   677    @SYMPREQ
   729    @SYMPREQ
   678   
   730   
  1695 	HBufC* fullIconFileName = NULL;
  1747 	HBufC* fullIconFileName = NULL;
  1696 	ret = iLs.GetAppViewIcon(TUid::Uid(KGroupNameApp), viewInfo.iUid, fullIconFileName);
  1748 	ret = iLs.GetAppViewIcon(TUid::Uid(KGroupNameApp), viewInfo.iUid, fullIconFileName);
  1697 	TEST(ret == KErrNone);
  1749 	TEST(ret == KErrNone);
  1698 	TEST(fullIconFileName != NULL);
  1750 	TEST(fullIconFileName != NULL);
  1699 	INFO_PRINTF2(_L("The View icon's UID is - %X"), viewInfo.iUid);
  1751 	INFO_PRINTF2(_L("The View icon's UID is - %X"), viewInfo.iUid);
  1700 	TEST(!fullIconFileName->Compare(_L("file:///c/resource/apps/tcheckiconapp.xyz")));
  1752 	TEST(!fullIconFileName->Compare(_L("file://c/resource/apps/tcheckiconapp.xyz")));
  1701 	INFO_PRINTF2(_L("View's icon file name is - %S"), fullIconFileName);
  1753 	INFO_PRINTF2(_L("View's icon file name is - %S"), fullIconFileName);
  1702 	
  1754 	
  1703 	delete fullIconFileName;		
  1755 	delete fullIconFileName;		
  1704 	CleanupStack::PopAndDestroy(appViews);
  1756 	CleanupStack::PopAndDestroy(appViews);
  1705 	
  1757 	
  1986  	CleanupStack::PopAndDestroy(2, &theFS);
  2038  	CleanupStack::PopAndDestroy(2, &theFS);
  1987 
  2039 
  1988  	INFO_PRINTF1(_L("Test TestAppListInstallation1L completed"));
  2040  	INFO_PRINTF1(_L("Test TestAppListInstallation1L completed"));
  1989  	} 	
  2041  	} 	
  1990 
  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 	
  1991 /**
  2141 /**
  1992    @SYMTestCaseID T-RApaLsSessionTestStep-TestAppFolderNonRomDrivesL
  2142    @SYMTestCaseID T-RApaLsSessionTestStep-TestAppFolderNonRomDrivesL
  1993   
  2143   
  1994    @SYMDEF DEF055654: Platform-security loop-hole for "import-directory" applications
  2144    @SYMDEF DEF055654: Platform-security loop-hole for "import-directory" applications
  1995   
  2145   
  2357    Then test there is no memory leak from the creation to destory the object.
  2507    Then test there is no memory leak from the creation to destory the object.
  2358    
  2508    
  2359    @SYMTestExpectedResults There should be no memory leak checked by __UHEAP_MARK 
  2509    @SYMTestExpectedResults There should be no memory leak checked by __UHEAP_MARK 
  2360    and __UHEAP_MARKEND.
  2510    and __UHEAP_MARKEND.
  2361  */
  2511  */
       
  2512  
  2362 void CT_RApaLsSessionTestStep::TestIconLoaderAndIconArrayMemoryLeaksL()
  2513 void CT_RApaLsSessionTestStep::TestIconLoaderAndIconArrayMemoryLeaksL()
  2363 	{
  2514 	{
  2364 	INFO_PRINTF1(_L("Test TestIconLoaderAndIconArrayMemoryLeaksL"));
  2515 	INFO_PRINTF1(_L("Test TestIconLoaderAndIconArrayMemoryLeaksL"));
  2365 	__UHEAP_MARK;
  2516 	__UHEAP_MARK;
  2366 	TIconLoaderAndIconArrayForLeaks::TestIconLoaderAndIconArrayL();
  2517 	TIconLoaderAndIconArrayForLeaks::TestIconLoaderAndIconArrayL();
  2380 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestAppListInvalidL(), iLs.ClearAppInfoArray() );
  2531 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestAppListInvalidL(), iLs.ClearAppInfoArray() );
  2381 	//DONT_CHECK due to file system changes
  2532 	//DONT_CHECK due to file system changes
  2382 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestAppListInstallationL(), NO_CLEANUP);
  2533 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestAppListInstallationL(), NO_CLEANUP);
  2383 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestAppListInstallation1L(), NO_CLEANUP);
  2534 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestAppListInstallation1L(), NO_CLEANUP);
  2384 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestAppFolderNonRomDrivesL(), NO_CLEANUP);
  2535 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestAppFolderNonRomDrivesL(), NO_CLEANUP);
  2385 	HEAP_TEST_LS_SESSION(iLs, 0, 0, IconLoadingTestCasesL(), 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);
  2386 	HEAP_TEST_LS_SESSION(iLs, 0, 0, AppInfoTestCasesL(), iLs.ClearAppInfoArray(); NO_CLEANUP);
  2538 	HEAP_TEST_LS_SESSION(iLs, 0, 0, AppInfoTestCasesL(), iLs.ClearAppInfoArray(); NO_CLEANUP);
  2387 	HEAP_TEST_LS_SESSION(iLs, 0, 0, EmbeddedAppsTestCases(), iLs.ClearAppInfoArray() );
  2539 	HEAP_TEST_LS_SESSION(iLs, 0, 0, EmbeddedAppsTestCases(), iLs.ClearAppInfoArray() );
  2388 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, DoNumDefIconsTestL(), NO_CLEANUP);
  2540 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, DoNumDefIconsTestL(), NO_CLEANUP);
  2389 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestMatchesSecurityPolicy(), NO_CLEANUP);
  2541 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestMatchesSecurityPolicy(), NO_CLEANUP);
  2390 	//DONT_CHECK since there's a new typestore
  2542 	//DONT_CHECK since there's a new typestore
  2391 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestNotifyOnDataMappingChangeL(), NO_CLEANUP);
  2543 	HEAP_TEST_LS_SESSION(iLs, 0, DONT_CHECK, TestNotifyOnDataMappingChangeL(), NO_CLEANUP);
  2392 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestAppListRecognizeDataBufferOnlyL(), iLs.FlushRecognitionCache() );
  2544 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestAppListRecognizeDataBufferOnlyL(), iLs.FlushRecognitionCache() );
       
  2545 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestAppListRecognizeDataPassedByBufferL(), iLs.FlushRecognitionCache() );
  2393 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestAppListRecognizeDataL(), iLs.FlushRecognitionCache() );
  2546 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestAppListRecognizeDataL(), iLs.FlushRecognitionCache() );
  2394 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestDataPriorityForUnTrustedApps(), NO_CLEANUP);
  2547 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestDataPriorityForUnTrustedApps(), NO_CLEANUP);
  2395 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestDataPriorityForUnTrustedAppsRegFile(), NO_CLEANUP);
  2548 	HEAP_TEST_LS_SESSION(iLs, 0, 0, TestDataPriorityForUnTrustedAppsRegFile(), NO_CLEANUP);
  2396 	TestIconLoaderAndIconArrayMemoryLeaksL();
  2549 	TestIconLoaderAndIconArrayMemoryLeaksL();
  2397 	}
  2550 	}
  2457 	INFO_PRINTF1(_L("...T_RApaLsSession Test Cases Completed."));
  2610 	INFO_PRINTF1(_L("...T_RApaLsSession Test Cases Completed."));
  2458 
  2611 
  2459 	return TestStepResult();
  2612 	return TestStepResult();
  2460 	}
  2613 	}
  2461 	
  2614 	
       
  2615