appfw/apparchitecture/tef/t_mimecontentpolicystep.cpp
changeset 29 6a787171e1de
parent 0 2e3d3ce01487
equal deleted inserted replaced
28:b0b858956ed5 29:6a787171e1de
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 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 "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".
    18  @test
    18  @test
    19  @internalComponent - Internal Symbian test code  
    19  @internalComponent - Internal Symbian test code  
    20 */
    20 */
    21 
    21 
    22 #include "t_mimecontentpolicystep.h"
    22 #include "t_mimecontentpolicystep.h"
       
    23 #include <centralrepository.h>
       
    24 #include <apmstd.h>
       
    25 
       
    26 //Closed content and extension information repository UID
       
    27 const TUid KClosedContentAndExtensionInfoRepositoryUID={0x10003A3F};
    23 
    28 
    24 _LIT(KPathjpg1, "z:\\system\\data\\type-r.jpg");
    29 _LIT(KPathjpg1, "z:\\system\\data\\type-r.jpg");
    25 _LIT(KPathjpg2, "z:\\system\\data\\propelli.jpg");
    30 _LIT(KPathjpg2, "z:\\system\\data\\propelli.jpg");
    26 _LIT(KPathdcf,  "z:\\system\\data\\sd_goo.dcf");
    31 _LIT(KPathdcf,  "z:\\system\\data\\sd_goo.dcf");
    27 _LIT(KPathdm1,  "z:\\system\\data\\fl_goo.dm");
    32 _LIT(KPathdm1,  "z:\\system\\data\\fl_goo.dm");
    74 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsDRMEnvelopeFileNameL(), NO_CLEANUP);
    79 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsDRMEnvelopeFileNameL(), NO_CLEANUP);
    75 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsClosedFileFileNameL(), iApaLsSession.FlushRecognitionCache());
    80 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsClosedFileFileNameL(), iApaLsSession.FlushRecognitionCache());
    76 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsDRMEnvelopeFileHandleL(), NO_CLEANUP);
    81 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsDRMEnvelopeFileHandleL(), NO_CLEANUP);
    77 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsClosedFileFileHandleL(), iApaLsSession.FlushRecognitionCache());
    82 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsClosedFileFileHandleL(), iApaLsSession.FlushRecognitionCache());
    78 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPOOMTestL(), iApaLsSession.FlushRecognitionCache());
    83 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPOOMTestL(), iApaLsSession.FlushRecognitionCache());
       
    84 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsClosedContentAndExtenstionInfoRepositoryReadOnlyL(), NO_CLEANUP);
    79 	}
    85 	}
    80 
    86 
    81 /**
    87 /**
    82    @SYMTestCaseID APPFWK-APPARC-0077
    88    @SYMTestCaseID APPFWK-APPARC-0077
    83 
    89 
    87   
    93   
    88    @SYMTestPriority High 
    94    @SYMTestPriority High 
    89  
    95  
    90    @SYMTestStatus Implemented
    96    @SYMTestStatus Implemented
    91   
    97   
    92    @SYMTestActions Closed types are the mime types which are listed in the ApfMimeContentPolicy.rss file.
    98    @SYMTestActions Closed types are the mime types which are listed in the 10003a3f repository file.
    93    Calls CApfMimeContentPolicy::IsClosedType(const TDesC& aMimeType); for different closed and non-closed mime types.
    99    Calls CApfMimeContentPolicy::IsClosedType(const TDesC& aMimeType); for different closed and non-closed mime types.
       
   100    And also it tests whether invalid mime types are not added to the list.
    94   
   101   
    95    @SYMTestExpectedResults The test checks whether IsClosedType returns ETrue for the Closed Mime types and EFalse for non-closed Mime types
   102    @SYMTestExpectedResults The test checks whether IsClosedType returns ETrue for the Closed Mime types and EFalse for non-closed Mime types
    96  */
   103  */
    97 void CT_MimeContentPolicyStep::CCPTestIsClosedType()
   104 void CT_MimeContentPolicyStep::CCPTestIsClosedType()
    98 	{
   105 	{
   118 	_LIT(KMimeType18, "application/javascript");
   125 	_LIT(KMimeType18, "application/javascript");
   119 	_LIT(KMimeType19, "video/3gpp");
   126 	_LIT(KMimeType19, "video/3gpp");
   120 	_LIT(KMimeType20, "video/mpeg");
   127 	_LIT(KMimeType20, "video/mpeg");
   121 	_LIT(KMimeType21, "video/quicktime");
   128 	_LIT(KMimeType21, "video/quicktime");
   122 	_LIT(KMimeType22, "video/mpeg4-generic");
   129 	_LIT(KMimeType22, "video/mpeg4-generic");
   123 								    
   130 		
       
   131     //Invalid mime types
       
   132     _LIT(KMimeType23, "/test");
       
   133     _LIT(KMimeType24, "test");
       
   134     _LIT(KMimeType25, "test/");
       
   135     _LIT(KMimeType26, "/test/");
       
   136     _LIT(KMimeType27, "test/testmime/");
       
   137     _LIT(KMimeType28, "/test/testmime");
       
   138     _LIT(KMimeType29, "test\\testmime");      
       
   139 
       
   140     
   124   
   141   
   125 	INFO_PRINTF1(_L("Tests the MIME types found on closed content list"));
   142 	INFO_PRINTF1(_L("Tests the MIME types found on closed content list"));
   126     
   143     
   127 	TEST(iCcp->IsClosedType(KMimeType0));
   144 	TEST(iCcp->IsClosedType(KMimeType0));
   128 	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType0);
   145 	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType0);
   190   	TEST(!iCcp->IsClosedType(KMimeType21));
   207   	TEST(!iCcp->IsClosedType(KMimeType21));
   191   	INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType21);
   208   	INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType21);
   192   	
   209   	
   193   	TEST(!iCcp->IsClosedType(KMimeType22));
   210   	TEST(!iCcp->IsClosedType(KMimeType22));
   194   	INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType22);
   211   	INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType22);
       
   212   	
       
   213     TEST(!iCcp->IsClosedType(KMimeType23));
       
   214     INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType23);
       
   215    
       
   216     TEST(!iCcp->IsClosedType(KMimeType24));
       
   217     INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType24);
       
   218   
       
   219     TEST(!iCcp->IsClosedType(KMimeType25));
       
   220     INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType25);
       
   221 
       
   222     TEST(!iCcp->IsClosedType(KMimeType26));
       
   223     INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType26);
       
   224 
       
   225     TEST(!iCcp->IsClosedType(KMimeType27));
       
   226     INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType27);
       
   227     
       
   228     TEST(!iCcp->IsClosedType(KMimeType28));
       
   229     INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType28); 
       
   230     
       
   231     TEST(!iCcp->IsClosedType(KMimeType29));
       
   232     INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType29);    
   195   	}
   233   	}
   196 
   234 
   197 /**
   235 /**
   198    @SYMTestCaseID APPFWK-APPARC-0078
   236    @SYMTestCaseID APPFWK-APPARC-0078
   199 
   237 
   203   
   241   
   204    @SYMTestPriority High 
   242    @SYMTestPriority High 
   205  
   243  
   206    @SYMTestStatus Implemented
   244    @SYMTestStatus Implemented
   207   
   245   
   208    @SYMTestActions Closed file extensions are the file extensions which are listed in the ApfMimeContentPolicy.rss file.
   246    @SYMTestActions Closed file extensions are the file extensions which are listed in the 10003a3f repository.
   209    Calls CApfMimeContentPolicy::IsClosedExtension(const TDesC& aFileExtension); for different closed and non-closed File Extensions.
   247    Calls CApfMimeContentPolicy::IsClosedExtension(const TDesC& aFileExtension); for different closed and non-closed File Extensions.
       
   248    And also it tests whether invalid closed extensions are not added to the list.
   210   
   249   
   211    @SYMTestExpectedResults The test checks whether IsClosedExtension returns ETrue for the Closed File Extensions and EFalse for non-closed File Extensions.
   250    @SYMTestExpectedResults The test checks whether IsClosedExtension returns ETrue for the Closed File Extensions and EFalse for non-closed File Extensions.
   212  */
   251  */
   213 void CT_MimeContentPolicyStep::CCPTestIsClosedExtension()
   252 void CT_MimeContentPolicyStep::CCPTestIsClosedExtension()
   214 	{
   253 	{
   227 	_LIT(KExtension12, "jar.mp3");
   266 	_LIT(KExtension12, "jar.mp3");
   228 	_LIT(KExtension13, ".siss");
   267 	_LIT(KExtension13, ".siss");
   229 	_LIT(KExtension14, ".sis7");
   268 	_LIT(KExtension14, ".sis7");
   230 	_LIT(KExtension15, ".0sis");
   269 	_LIT(KExtension15, ".0sis");
   231 	_LIT(KExtension16, ".gif");
   270 	_LIT(KExtension16, ".gif");
       
   271 	
       
   272 	//Invalid extension
       
   273     _LIT(KExtension17, "tst");	
   232 
   274 
   233     INFO_PRINTF1(_L("Tests the extensions found on closed content list"));
   275     INFO_PRINTF1(_L("Tests the extensions found on closed content list"));
   234 	
   276 	
   235 	TEST(iCcp->IsClosedExtension(KExtension0));
   277 	TEST(iCcp->IsClosedExtension(KExtension0));
   236    	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension0);
   278    	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension0);
   280 	TEST(!iCcp->IsClosedExtension(KExtension15));
   322 	TEST(!iCcp->IsClosedExtension(KExtension15));
   281 	INFO_PRINTF2(_L("%S is not Closed Extension"), &KExtension15);
   323 	INFO_PRINTF2(_L("%S is not Closed Extension"), &KExtension15);
   282 	
   324 	
   283 	TEST(!iCcp->IsClosedExtension(KExtension16));
   325 	TEST(!iCcp->IsClosedExtension(KExtension16));
   284 	INFO_PRINTF2(_L("%S is not Closed Extension"), &KExtension16);
   326 	INFO_PRINTF2(_L("%S is not Closed Extension"), &KExtension16);
       
   327 	
       
   328     TEST(!iCcp->IsClosedExtension(KExtension17));
       
   329     INFO_PRINTF2(_L("%S is not Closed Extension"), &KExtension17);	
   285 	}
   330 	}
   286 
   331 
   287 /**
   332 /**
   288    @SYMTestCaseID APPFWK-APPARC-0079
   333    @SYMTestCaseID APPFWK-APPARC-0079
   289 
   334 
   320   
   365   
   321    @SYMTestPriority High 
   366    @SYMTestPriority High 
   322  
   367  
   323    @SYMTestStatus Implemented
   368    @SYMTestStatus Implemented
   324   
   369   
   325    @SYMTestActions Closed files are files whose file extensions are listed in the ApfMimeContentPolicy.rss file.
   370    @SYMTestActions Closed files are files whose file extensions are listed in the 10003a3f repository.
   326    Calls CApfMimeContentPolicy::IsClosedFileL(const TDesC& aFileName); for different Closed and non-closed files.
   371    Calls CApfMimeContentPolicy::IsClosedFileL(const TDesC& aFileName); for different Closed and non-closed files.
   327    Calls CApfMimeContentPolicy::IsClosedFileL(const TDesC& aFileName); with file which is already open and checks whether \n
   372    Calls CApfMimeContentPolicy::IsClosedFileL(const TDesC& aFileName); with file which is already open and checks whether \n
   328    call succeeds.
   373    call succeeds.
   329    Calls CApfMimeContentPolicy::IsClosedFileL(const TDesC& aFileName); with Null file handle\n
   374    Calls CApfMimeContentPolicy::IsClosedFileL(const TDesC& aFileName); with Null file handle\n
   330      
   375      
   425   
   470   
   426    @SYMTestPriority High 
   471    @SYMTestPriority High 
   427  
   472  
   428    @SYMTestStatus Implemented
   473    @SYMTestStatus Implemented
   429   
   474   
   430    @SYMTestActions Closed files are files whose file extensions are listed in the ApfMimeContentPolicy.rss file.
   475    @SYMTestActions Closed files are files whose file extensions are listed in the 10003a3f repository.
   431    Calls CApfMimeContentPolicy::IsClosedFileL(RFile& aFileHandle); for different Closed and non-closed files.
   476    Calls CApfMimeContentPolicy::IsClosedFileL(RFile& aFileHandle); for different Closed and non-closed files.
   432      
   477      
   433    @SYMTestExpectedResults The test checks whether IsClosedFileL() returns EFalse for Files which are not closed and\n
   478    @SYMTestExpectedResults The test checks whether IsClosedFileL() returns EFalse for Files which are not closed and\n
   434    ETrue for files which are closed.
   479    ETrue for files which are closed.
   435  */
   480  */
   507 
   552 
   508 	__UHEAP_RESET;	
   553 	__UHEAP_RESET;	
   509 	INFO_PRINTF1(_L("OOM test Completed"));	
   554 	INFO_PRINTF1(_L("OOM test Completed"));	
   510 	}
   555 	}
   511 
   556 
       
   557 
       
   558 /**
       
   559    @SYMTestCaseID APPFWK-APPARC-0108
       
   560 
       
   561    @SYMREQ REQ410-2692
       
   562  
       
   563    @SYMTestCaseDesc Tests Closed content and extension information repository is not writable.
       
   564   
       
   565    @SYMTestPriority High 
       
   566  
       
   567    @SYMTestStatus Implemented
       
   568   
       
   569    @SYMTestActions Calls create, get, set, reset, delete functions on the repository. Checks only read operations are allowed.
       
   570      
       
   571    @SYMTestExpectedResults Tests should complete without any failure.
       
   572  */
       
   573 
       
   574 void CT_MimeContentPolicyStep::CCPTestIsClosedContentAndExtenstionInfoRepositoryReadOnlyL()
       
   575     {
       
   576     INFO_PRINTF1(_L("Testcase CCPTestIsClosedContentAndExtenstionInfoRepositoryReadOnly...."));   
       
   577     CRepository *cenrep=CRepository::NewL(KClosedContentAndExtensionInfoRepositoryUID);  
       
   578     CleanupStack::PushL(cenrep);
       
   579     TInt newKeyValue=0x00010000;
       
   580     //This key already exists in the default Closed content and extension information repository
       
   581     TInt existingKey=0x1;
       
   582     TBuf<KMaxDataTypeLength> keyData;
       
   583     TInt err=KErrNone;
       
   584     
       
   585     INFO_PRINTF1(_L("Testing creation of key in the repository"));
       
   586     err=cenrep->Create(newKeyValue, 0);
       
   587     TEST(err==KErrPermissionDenied);
       
   588     INFO_PRINTF2(_L("Error code while creating a key: %d"), err);
       
   589     
       
   590     INFO_PRINTF1(_L("Testing setting value of an existing key in the repository"));    
       
   591     err=cenrep->Set(existingKey, 0);
       
   592     TEST(err==KErrPermissionDenied);
       
   593     INFO_PRINTF2(_L("Error code while setting a value of an existing key: %d"), err);
       
   594     
       
   595     INFO_PRINTF1(_L("Testing getting value of an existing key in the repository"));
       
   596     err=cenrep->Get(existingKey, keyData);
       
   597     TEST(err==KErrNone);
       
   598     INFO_PRINTF2(_L("Error code while getting a value of an existing key: %d"), err);
       
   599     
       
   600     INFO_PRINTF1(_L("Testing resetting value of an existing key in the repository"));
       
   601     err=cenrep->Reset(existingKey);
       
   602     TEST(err==KErrPermissionDenied);
       
   603     INFO_PRINTF2(_L("Error code while reseting a value of existing key: %d"), err);
       
   604 
       
   605     INFO_PRINTF1(_L("Testing deleting an existing key in the repository"));
       
   606     err=cenrep->Delete(existingKey);
       
   607     TEST(err==KErrPermissionDenied);
       
   608     INFO_PRINTF2(_L("Error code while deleting an existing key: %d"), err);
       
   609     CleanupStack::PopAndDestroy(cenrep);
       
   610     INFO_PRINTF1(_L("Testcase CCPTestIsClosedContentAndExtenstionInfoRepositoryReadOnly completed...."));    
       
   611     }