localisation/apparchitecture/tef/t_mimecontentpolicystep.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 /**
       
    19  @file
       
    20  @test
       
    21  @internalComponent - Internal Symbian test code  
       
    22 */
       
    23 
       
    24 #include "t_mimecontentpolicystep.h"
       
    25 
       
    26 _LIT(KPathjpg1, "z:\\system\\data\\type-r.jpg");
       
    27 _LIT(KPathjpg2, "z:\\system\\data\\propelli.jpg");
       
    28 _LIT(KPathdcf,  "z:\\system\\data\\sd_goo.dcf");
       
    29 _LIT(KPathdm1,  "z:\\system\\data\\fl_goo.dm");
       
    30 _LIT(KPathgif,  "z:\\system\\data\\gif_wallpaper.gif");
       
    31 _LIT(KPathdm2,  "z:\\system\\data\\jpeg_wes.dm");
       
    32 
       
    33 /**
       
    34    Constructor
       
    35  */	
       
    36 CT_MimeContentPolicyStep::CT_MimeContentPolicyStep()
       
    37 	{
       
    38 	// Call base class method to set up the human readable name for logging*/
       
    39 	SetTestStepName(KT_MimeContentPolicyStep);
       
    40 	}
       
    41 
       
    42 /**
       
    43    Destructor
       
    44  */
       
    45 CT_MimeContentPolicyStep::~CT_MimeContentPolicyStep()
       
    46 	{
       
    47 	delete iCcp;
       
    48 	iApaLsSession.Close();
       
    49 	iFs.Close();
       
    50 	}
       
    51 
       
    52 TVerdict CT_MimeContentPolicyStep::doTestStepL()
       
    53 	{
       
    54 	INFO_PRINTF1(_L("Testing Apparc...T_MimeContentPolicyStep Test Cases Running..."));
       
    55 	TInt error = iApaLsSession.Connect();
       
    56 	TEST(error == KErrNone);
       
    57 
       
    58 	error = iFs.Connect();
       
    59 	TEST(error == KErrNone);
       
    60 	
       
    61 	iCcp = CApfMimeContentPolicy::NewL();
       
    62 	
       
    63 	User::LeaveIfError(iFs.ShareProtected());
       
    64 
       
    65 	TRAPD(ret,RunTestCasesL())
       
    66 	TEST(ret==KErrNone);
       
    67 	
       
    68 	INFO_PRINTF1(_L("...T_MimeContentPolicyStep Test Cases Completed."));
       
    69 	return TestStepResult();
       
    70 	}
       
    71 
       
    72 void CT_MimeContentPolicyStep::RunTestCasesL()
       
    73 	{
       
    74 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsClosedType(), NO_CLEANUP);
       
    75 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsClosedExtension(), NO_CLEANUP);
       
    76 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsDRMEnvelopeFileNameL(), NO_CLEANUP);
       
    77 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsClosedFileFileNameL(), iApaLsSession.FlushRecognitionCache());
       
    78 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsDRMEnvelopeFileHandleL(), NO_CLEANUP);
       
    79 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPTestIsClosedFileFileHandleL(), iApaLsSession.FlushRecognitionCache());
       
    80 	HEAP_TEST_LS_SESSION(iApaLsSession, 0, 0, CCPOOMTestL(), iApaLsSession.FlushRecognitionCache());
       
    81 	}
       
    82 
       
    83 /**
       
    84    @SYMTestCaseID APPFWK-APPARC-0077
       
    85 
       
    86    @SYMREQ REQ7736
       
    87  
       
    88    @SYMTestCaseDesc Tests IsClosedType() method for different mime types
       
    89   
       
    90    @SYMTestPriority High 
       
    91  
       
    92    @SYMTestStatus Implemented
       
    93   
       
    94    @SYMTestActions Closed types are the mime types which are listed in the ApfMimeContentPolicy.rss file.
       
    95    Calls CApfMimeContentPolicy::IsClosedType(const TDesC& aMimeType); for different closed and non-closed mime types.
       
    96   
       
    97    @SYMTestExpectedResults The test checks whether IsClosedType returns ETrue for the Closed Mime types and EFalse for non-closed Mime types
       
    98  */
       
    99 void CT_MimeContentPolicyStep::CCPTestIsClosedType()
       
   100 	{
       
   101 	_LIT(KMimeType0, "application/vnd.oma.drm.message");
       
   102 	_LIT(KMimeType1, "application/vnd.oma.drm.rights+xml");
       
   103 	_LIT(KMimeType2, "application/vnd.oma.drm.rights+wbxml");
       
   104 	_LIT(KMimeType3, "application/vnd.nokia.ringing-tone");
       
   105 	_LIT(KMimeType4, "audio/amr-wb");
       
   106 	_LIT(KMimeType5, "audio/sp-midi");
       
   107 	_LIT(KMimeType6, "image/vnd.nok.3Dscreensaver");
       
   108 	_LIT(KMimeType7, "image/vnd.nok-wallpaper");
       
   109 	_LIT(KMimeType8, "image/vnd.nok-oplogo");
       
   110 	_LIT(KMimeType9, "image/vnd.nok-oplogo-color");
       
   111 	_LIT(KMimeType10, "application/java");
       
   112 	_LIT(KMimeType11, "application/java-archive");
       
   113 	_LIT(KMimeType12, "application/x-java-archive");
       
   114 	_LIT(KMimeType13, "text/vnd.sun.j2me.app-descriptor");
       
   115 	_LIT(KMimeType14, "application/x-NokiaGameData");
       
   116 	_LIT(KMimeType15, "application/vnd.symbian.install");
       
   117 	_LIT(KMimeType16, "x-epoc/x-sisx-app"); 
       
   118 
       
   119 	_LIT(KMimeType17, "image/tiff");
       
   120 	_LIT(KMimeType18, "application/javascript");
       
   121 	_LIT(KMimeType19, "video/3gpp");
       
   122 	_LIT(KMimeType20, "video/mpeg");
       
   123 	_LIT(KMimeType21, "video/quicktime");
       
   124 	_LIT(KMimeType22, "video/mpeg4-generic");
       
   125 								    
       
   126   
       
   127 	INFO_PRINTF1(_L("Tests the MIME types found on closed content list"));
       
   128     
       
   129 	TEST(iCcp->IsClosedType(KMimeType0));
       
   130 	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType0);
       
   131     
       
   132 	TEST(iCcp->IsClosedType(KMimeType1));
       
   133 	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType1);		
       
   134 	
       
   135 	TEST(iCcp->IsClosedType(KMimeType2));
       
   136 	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType2);
       
   137     
       
   138 	TEST(iCcp->IsClosedType(KMimeType3));
       
   139 	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType3);
       
   140    
       
   141 	TEST(iCcp->IsClosedType(KMimeType4));
       
   142   	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType4);
       
   143    
       
   144 	TEST(iCcp->IsClosedType(KMimeType5));
       
   145   	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType5);
       
   146     
       
   147 	TEST(iCcp->IsClosedType(KMimeType6));
       
   148     INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType6);
       
   149     
       
   150 	TEST(iCcp->IsClosedType(KMimeType7));
       
   151    	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType7);
       
   152     
       
   153 	TEST(iCcp->IsClosedType(KMimeType8));
       
   154    	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType8);
       
   155 
       
   156 	TEST(iCcp->IsClosedType(KMimeType9));
       
   157   	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType9);
       
   158 
       
   159 	TEST(iCcp->IsClosedType(KMimeType10));
       
   160   	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType10);
       
   161   	
       
   162 	TEST(iCcp->IsClosedType(KMimeType11));
       
   163   	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType11);
       
   164   	
       
   165 	TEST(iCcp->IsClosedType(KMimeType12));
       
   166   	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType12);
       
   167 
       
   168 	TEST(iCcp->IsClosedType(KMimeType13));
       
   169   	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType13);
       
   170 
       
   171 	TEST(iCcp->IsClosedType(KMimeType14));
       
   172   	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType14);
       
   173 
       
   174 	TEST(iCcp->IsClosedType(KMimeType15));
       
   175   	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType15);
       
   176 
       
   177 	TEST(iCcp->IsClosedType(KMimeType16));
       
   178   	INFO_PRINTF2(_L("%S is Closed Type"), &KMimeType16);
       
   179   	
       
   180   	TEST(!iCcp->IsClosedType(KMimeType17));
       
   181   	INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType17);
       
   182   	
       
   183   	TEST(!iCcp->IsClosedType(KMimeType18));
       
   184   	INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType18);
       
   185   	
       
   186   	TEST(!iCcp->IsClosedType(KMimeType19));
       
   187   	INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType19);
       
   188   	
       
   189   	TEST(!iCcp->IsClosedType(KMimeType20));
       
   190   	INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType20);
       
   191   	
       
   192   	TEST(!iCcp->IsClosedType(KMimeType21));
       
   193   	INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType21);
       
   194   	
       
   195   	TEST(!iCcp->IsClosedType(KMimeType22));
       
   196   	INFO_PRINTF2(_L("%S is not Closed Type"), &KMimeType22);
       
   197   	}
       
   198 
       
   199 /**
       
   200    @SYMTestCaseID APPFWK-APPARC-0078
       
   201 
       
   202    @SYMREQ REQ7736
       
   203  
       
   204    @SYMTestCaseDesc Tests IsClosedExtension() method for various File Extensions
       
   205   
       
   206    @SYMTestPriority High 
       
   207  
       
   208    @SYMTestStatus Implemented
       
   209   
       
   210    @SYMTestActions Closed file extensions are the file extensions which are listed in the ApfMimeContentPolicy.rss file.
       
   211    Calls CApfMimeContentPolicy::IsClosedExtension(const TDesC& aFileExtension); for different closed and non-closed File Extensions.
       
   212   
       
   213    @SYMTestExpectedResults The test checks whether IsClosedExtension returns ETrue for the Closed File Extensions and EFalse for non-closed File Extensions.
       
   214  */
       
   215 void CT_MimeContentPolicyStep::CCPTestIsClosedExtension()
       
   216 	{
       
   217 	_LIT(KExtension0,  ".dm");
       
   218 	_LIT(KExtension1,  ".dr");
       
   219 	_LIT(KExtension2,  ".drc");
       
   220 	_LIT(KExtension3,  ".ott");
       
   221 	_LIT(KExtension4,  ".awb");
       
   222 	_LIT(KExtension5,  ".mid");
       
   223 	_LIT(KExtension6,  ".c3d");
       
   224 	_LIT(KExtension7,  ".jar");
       
   225 	_LIT(KExtension8,  ".ngd");
       
   226 	_LIT(KExtension9,  ".sis");
       
   227 	_LIT(KExtension10,  ".sisx");
       
   228 	_LIT(KExtension11, ".jpg");
       
   229 	_LIT(KExtension12, "jar.mp3");
       
   230 	_LIT(KExtension13, ".siss");
       
   231 	_LIT(KExtension14, ".sis7");
       
   232 	_LIT(KExtension15, ".0sis");
       
   233 	_LIT(KExtension16, ".gif");
       
   234 
       
   235     INFO_PRINTF1(_L("Tests the extensions found on closed content list"));
       
   236 	
       
   237 	TEST(iCcp->IsClosedExtension(KExtension0));
       
   238    	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension0);
       
   239 
       
   240 	TEST(iCcp->IsClosedExtension(KExtension1));
       
   241    	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension1);
       
   242 	
       
   243 	TEST(iCcp->IsClosedExtension(KExtension2));
       
   244 	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension2);
       
   245 
       
   246 	TEST(iCcp->IsClosedExtension(KExtension3));
       
   247 	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension3);
       
   248 	
       
   249 	TEST(iCcp->IsClosedExtension(KExtension4));
       
   250 	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension4);
       
   251 	
       
   252 	TEST(iCcp->IsClosedExtension(KExtension5));
       
   253 	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension5);
       
   254 	
       
   255 	TEST(iCcp->IsClosedExtension(KExtension6));
       
   256 	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension6);					
       
   257 
       
   258 	TEST(iCcp->IsClosedExtension(KExtension7));
       
   259 	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension7);
       
   260 
       
   261 	TEST(iCcp->IsClosedExtension(KExtension8));
       
   262 	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension8);
       
   263 
       
   264 	TEST(iCcp->IsClosedExtension(KExtension9));
       
   265 	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension9);
       
   266 
       
   267 	TEST(iCcp->IsClosedExtension(KExtension10));
       
   268 	INFO_PRINTF2(_L("%S is Closed Extension"), &KExtension10);
       
   269 	
       
   270 	TEST(!iCcp->IsClosedExtension(KExtension11));
       
   271 	INFO_PRINTF2(_L("%S is not Closed Extension"), &KExtension11);
       
   272 	
       
   273 	TEST(!iCcp->IsClosedExtension(KExtension12));
       
   274 	INFO_PRINTF2(_L("%S is not Closed Extension"), &KExtension12);
       
   275 	
       
   276 	TEST(!iCcp->IsClosedExtension(KExtension13));
       
   277 	INFO_PRINTF2(_L("%S is not Closed Extension"), &KExtension13);
       
   278 	
       
   279 	TEST(!iCcp->IsClosedExtension(KExtension14));
       
   280 	INFO_PRINTF2(_L("%S is not Closed Extension"), &KExtension14);
       
   281 	
       
   282 	TEST(!iCcp->IsClosedExtension(KExtension15));
       
   283 	INFO_PRINTF2(_L("%S is not Closed Extension"), &KExtension15);
       
   284 	
       
   285 	TEST(!iCcp->IsClosedExtension(KExtension16));
       
   286 	INFO_PRINTF2(_L("%S is not Closed Extension"), &KExtension16);
       
   287 	}
       
   288 
       
   289 /**
       
   290    @SYMTestCaseID APPFWK-APPARC-0079
       
   291 
       
   292    @SYMREQ REQ7736
       
   293  
       
   294    @SYMTestCaseDesc Tests IsDRMEnvelopeL() method for various files.
       
   295   
       
   296    @SYMTestPriority High 
       
   297  
       
   298    @SYMTestStatus Implemented
       
   299   
       
   300    @SYMTestActions Calls CApfMimeContentPolicy::IsDRMEnvelopeL(const TDesC& aFileName); for different not DRM Envelopes files.
       
   301      
       
   302    @SYMTestExpectedResults The test checks whether IsDRMEnvelopeL() returns EFalse for non-DRM protected Files.
       
   303  */
       
   304 void CT_MimeContentPolicyStep::CCPTestIsDRMEnvelopeFileNameL()
       
   305 	{
       
   306     INFO_PRINTF1(_L("Tests given files are DRM envelopes given the file name"));
       
   307       	
       
   308 	TEST(!iCcp->IsDRMEnvelopeL(KPathjpg1));
       
   309 	TEST(!iCcp->IsDRMEnvelopeL(KPathjpg2));
       
   310 	TEST(!iCcp->IsDRMEnvelopeL(KPathdcf));
       
   311 	TEST(!iCcp->IsDRMEnvelopeL(KPathdm1));
       
   312     TEST(!iCcp->IsDRMEnvelopeL(KPathgif));
       
   313 	TEST(!iCcp->IsDRMEnvelopeL(KPathdm2));
       
   314 	}
       
   315 
       
   316 /**
       
   317    @SYMTestCaseID APPFWK-APPARC-0080
       
   318 
       
   319    @SYMREQ REQ7736
       
   320  
       
   321    @SYMTestCaseDesc Tests IsClosedFileL() method for various files.
       
   322   
       
   323    @SYMTestPriority High 
       
   324  
       
   325    @SYMTestStatus Implemented
       
   326   
       
   327    @SYMTestActions Closed files are files whose file extensions are listed in the ApfMimeContentPolicy.rss file.
       
   328    Calls CApfMimeContentPolicy::IsClosedFileL(const TDesC& aFileName); for different Closed and non-closed files.
       
   329    Calls CApfMimeContentPolicy::IsClosedFileL(const TDesC& aFileName); with file which is already open and checks whether \n
       
   330    call succeeds.
       
   331    Calls CApfMimeContentPolicy::IsClosedFileL(const TDesC& aFileName); with Null file handle\n
       
   332      
       
   333    @SYMTestExpectedResults The test checks whether 
       
   334    1. IsClosedFileL() returns EFalse for Files which are not closed and ETrue for files which are closed.  
       
   335    2. IsClosedFileL() call succeeds even if we pass a open file handle.
       
   336    3. IsClosedFileL() leaves with KErrBadHandle if a null file handle is passed.
       
   337  */
       
   338 void CT_MimeContentPolicyStep::CCPTestIsClosedFileFileNameL()
       
   339 	{
       
   340 	INFO_PRINTF1(_L("Tests given files are Closed Files using the FileName"));
       
   341     	
       
   342 	TEST(!iCcp->IsClosedFileL(KPathjpg1));
       
   343     
       
   344     // File passed to IsClosedFileL is already open.
       
   345     RFile fileHandle;
       
   346 	TEST((fileHandle.Open(iFs, KPathjpg2, EFileShareAny)) == KErrNone);
       
   347 	CleanupClosePushL(fileHandle);
       
   348 	TEST(!iCcp->IsClosedFileL(KPathjpg2));
       
   349 	CleanupStack::PopAndDestroy(&fileHandle);
       
   350     
       
   351 	// Bad File Handle is passed to IsClosedFileL API
       
   352     RFile nullFileHandle;
       
   353     INFO_PRINTF1(_L("Tests IsClosedFileL method passing null file handle"));
       
   354 	TRAPD(err, iCcp->IsClosedFileL(nullFileHandle));
       
   355 	TEST(err == KErrBadHandle);
       
   356 
       
   357 	// Check file extension.	
       
   358 	TParse parser;
       
   359 	parser.Set(KPathdm2, NULL, NULL);
       
   360 	TEST(iCcp->IsClosedExtension(parser.Ext()));
       
   361 	INFO_PRINTF2(_L("%S is Closed File"), &KPathdm2);
       
   362 
       
   363 	CApfMimeContentPolicy* mimeContentPolicy = CApfMimeContentPolicy::NewL(iFs);
       
   364 	CleanupStack::PushL(mimeContentPolicy);
       
   365   	TEST(!mimeContentPolicy->IsClosedFileL(KPathdcf));
       
   366   	INFO_PRINTF2(_L("%S is not Closed File"), &KPathdcf);
       
   367   	CleanupStack::PopAndDestroy(mimeContentPolicy);
       
   368 
       
   369 	mimeContentPolicy = CApfMimeContentPolicy::NewLC(iFs);
       
   370 	TEST(!mimeContentPolicy->IsClosedFileL(KPathgif));
       
   371 	INFO_PRINTF2(_L("%S is not Closed File"), &KPathgif);
       
   372 	CleanupStack::PopAndDestroy(mimeContentPolicy);
       
   373 	}
       
   374 
       
   375 TBool CT_MimeContentPolicyStep::DoCCPTestUsingFileHandleL(const TDesC &aName, TBool aIsDRMEnvelope)
       
   376 	{
       
   377 	TBool ret = EFalse;
       
   378     RFile fileHandle;
       
   379 
       
   380 	TInt err;
       
   381 	err = fileHandle.Open(iFs, aName, EFileShareReadersOrWriters);
       
   382     TEST(err == KErrNone);
       
   383 	CleanupClosePushL(fileHandle);
       
   384 
       
   385 	if (aIsDRMEnvelope)
       
   386 		ret = iCcp->IsDRMEnvelopeL(fileHandle);
       
   387 	else
       
   388 		ret = iCcp->IsClosedFileL(fileHandle);
       
   389 
       
   390     CleanupStack::PopAndDestroy(&fileHandle);
       
   391 	return ret;
       
   392 	}
       
   393 
       
   394 /**
       
   395    @SYMTestCaseID APPFWK-APPARC-0081
       
   396 
       
   397    @SYMREQ REQ7736
       
   398  
       
   399    @SYMTestCaseDesc Tests IsDRMEnvelopeL() method for various files.
       
   400   
       
   401    @SYMTestPriority High 
       
   402  
       
   403    @SYMTestStatus Implemented
       
   404   
       
   405    @SYMTestActions Calls CApfMimeContentPolicy::IsDRMEnvelopeL(RFile& aFileHandle); for different non-DRM Envelopes files.
       
   406      
       
   407    @SYMTestExpectedResults The test checks whether IsDRMEnvelopeL() returns EFalse for Files which are not DRM protected.
       
   408  */
       
   409 void CT_MimeContentPolicyStep::CCPTestIsDRMEnvelopeFileHandleL()
       
   410 	{
       
   411     INFO_PRINTF1(_L("Tests given files are DRM envelopes given the file handle"));     
       
   412 
       
   413 	TEST(!DoCCPTestUsingFileHandleL(KPathjpg1, ETrue));
       
   414 	TEST(!DoCCPTestUsingFileHandleL(KPathjpg2, ETrue));
       
   415 	TEST(!DoCCPTestUsingFileHandleL(KPathdcf, ETrue));
       
   416 	TEST(!DoCCPTestUsingFileHandleL(KPathdm1, ETrue));
       
   417 	TEST(!DoCCPTestUsingFileHandleL(KPathgif, ETrue));
       
   418 	TEST(!DoCCPTestUsingFileHandleL(KPathdm2, ETrue));
       
   419 	}
       
   420 
       
   421 /**
       
   422    @SYMTestCaseID APPFWK-APPARC-0082
       
   423 
       
   424    @SYMREQ REQ7736
       
   425  
       
   426    @SYMTestCaseDesc Tests IsClosedFileL() method for various files.
       
   427   
       
   428    @SYMTestPriority High 
       
   429  
       
   430    @SYMTestStatus Implemented
       
   431   
       
   432    @SYMTestActions Closed files are files whose file extensions are listed in the ApfMimeContentPolicy.rss file.
       
   433    Calls CApfMimeContentPolicy::IsClosedFileL(RFile& aFileHandle); for different Closed and non-closed files.
       
   434      
       
   435    @SYMTestExpectedResults The test checks whether IsClosedFileL() returns EFalse for Files which are not closed and\n
       
   436    ETrue for files which are closed.
       
   437  */
       
   438 void CT_MimeContentPolicyStep::CCPTestIsClosedFileFileHandleL()
       
   439 	{
       
   440    	INFO_PRINTF1(_L("Tests given files are Closed Files using File Handle"));
       
   441 
       
   442 	TEST(!DoCCPTestUsingFileHandleL(KPathjpg1, EFalse));
       
   443 	TEST(!DoCCPTestUsingFileHandleL(KPathjpg2, EFalse));
       
   444 	TEST(!DoCCPTestUsingFileHandleL(KPathdcf, EFalse));
       
   445 	TEST(DoCCPTestUsingFileHandleL(KPathdm1, EFalse));
       
   446 	TEST(!DoCCPTestUsingFileHandleL(KPathgif, EFalse));
       
   447 	TEST(DoCCPTestUsingFileHandleL(KPathdm2, EFalse));
       
   448 	}
       
   449 	
       
   450 /**
       
   451    @SYMTestCaseID APPFWK-APPARC-0084
       
   452 
       
   453    @SYMREQ REQ7736
       
   454  
       
   455    @SYMTestCaseDesc OOM test for CApfMimeContentPolicy's NewL() and IsClosedFileL() methods.
       
   456   
       
   457    @SYMTestPriority High 
       
   458  
       
   459    @SYMTestStatus Implemented
       
   460   
       
   461    @SYMTestActions Calls CApfMimeContentPolicy's NewL() and IsClosedFileL() methods under OOM conditions.
       
   462      
       
   463    @SYMTestExpectedResults Tests should complete without any memory leaks.
       
   464  */
       
   465 void CT_MimeContentPolicyStep::CCPOOMTestL()
       
   466 	{
       
   467 	INFO_PRINTF1(_L("OOM test for CApfMimeContentPolicy"));
       
   468 	CApfMimeContentPolicy* mimeContentPolicy = NULL;
       
   469 	
       
   470 	TInt fail = 0;
       
   471 	for (fail = 1; ; fail++)
       
   472 		{
       
   473 		__UHEAP_SETFAIL(RHeap::EDeterministic, fail);
       
   474 		__UHEAP_MARK;
       
   475 		TRAPD(err, mimeContentPolicy = CApfMimeContentPolicy::NewLC(); CleanupStack::Pop(mimeContentPolicy));
       
   476 		TEST(err == KErrNone || err == KErrNoMemory);
       
   477 		if (err == KErrNone)
       
   478 			{
       
   479 			delete mimeContentPolicy;
       
   480 			__UHEAP_MARKEND;
       
   481 			break;
       
   482 			}
       
   483 		__UHEAP_MARKEND;
       
   484 		}
       
   485 	
       
   486 	__UHEAP_RESET;	
       
   487 	TRAPD(err, mimeContentPolicy = CApfMimeContentPolicy::NewL());
       
   488 	CleanupStack::PushL(mimeContentPolicy);
       
   489 	TEST(err == KErrNone);
       
   490 	
       
   491 	TInt ret = KErrNone;
       
   492 	for (fail = 1; ; fail++)
       
   493 		{
       
   494 		__UHEAP_SETFAIL(RHeap::EDeterministic, fail);
       
   495 		__UHEAP_MARK;
       
   496 		TRAP(err, ret = mimeContentPolicy->IsClosedFileL(KPathdm1));
       
   497 		TEST(err == KErrNone || err == KErrNoMemory);
       
   498 		if (err == KErrNone)
       
   499 			{
       
   500 			INFO_PRINTF1(_L("OOM Test for IsClosedFileL Method"));	
       
   501 			TEST(ret);
       
   502 			INFO_PRINTF2(_L("%S is Closed File"), &KPathdm1);
       
   503 			CleanupStack::PopAndDestroy(mimeContentPolicy);
       
   504 			__UHEAP_MARKEND;
       
   505 			break;
       
   506 			}
       
   507 		__UHEAP_MARKEND;
       
   508 		}
       
   509 
       
   510 	__UHEAP_RESET;	
       
   511 	INFO_PRINTF1(_L("OOM test Completed"));	
       
   512 	}