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