imagingext_pub/exif_api/tsrc/src/ExifModifyTest100.cpp
changeset 0 469c91dae73b
equal deleted inserted replaced
-1:000000000000 0:469c91dae73b
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: ExifLibTest
       
    15 *
       
    16 */
       
    17 #include "ExifLibTestInc.h"
       
    18 
       
    19 // Test for fast option
       
    20 
       
    21 // Exif.Modify.101
       
    22 // Instantiate an Exif modifier with valid Exif image
       
    23 // Modified Exif modifier instance in EModify mode is returned.
       
    24 void CExifModifyTest::ExifModify101L()
       
    25 	{
       
    26     
       
    27 	HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif);
       
    28 	CleanupStack::PushL(exif);
       
    29 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
    30 	if(!modify)
       
    31 		User::Leave(KErrGeneral);
       
    32 	delete modify;
       
    33 	CleanupStack::PopAndDestroy(exif);
       
    34     
       
    35     /*
       
    36 	HBufC8* exif = TUtils::ReadFileL(iFs, KFullExif);
       
    37 	CleanupStack::PushL(exif);
       
    38 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify);
       
    39 	if(!modify)
       
    40 		User::Leave(KErrGeneral);
       
    41     modify->SetCustomRenderedL(0);
       
    42     HBufC8* b = modify->WriteDataL(*exif);
       
    43     RFile file;
       
    44 	User::LeaveIfError(file.Open(iFs, _L("C:\\FullExif.jpg"), EFileWrite));
       
    45  
       
    46     file.Write(b->Des());
       
    47     file.Close();
       
    48     delete b;
       
    49 */
       
    50 	}
       
    51 
       
    52 // Exif.Modify.102
       
    53 // Try to instantiate an Exif modifier with invalid/ corrupted Exif image
       
    54 // Leaves with proper error code.
       
    55 void CExifModifyTest::ExifModify102L()
       
    56 	{
       
    57 	// Various invalid/ corrupted Exif images
       
    58 	HBufC8* exif = TUtils::ReadFileL(iFs, KInvalidExif1);
       
    59 	CleanupStack::PushL(exif);
       
    60 	CExifModify* modify = 0;
       
    61     TRAPD( error, modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing) );
       
    62     if ( ( error != KErrCorrupt ) || ( modify ) )
       
    63         {
       
    64         if ( modify )
       
    65             {
       
    66             delete modify;
       
    67             }
       
    68         if ( error )
       
    69             {
       
    70             User::Leave( error );
       
    71             }
       
    72         User::Leave( KErrGeneral );
       
    73         }
       
    74 	CleanupStack::PopAndDestroy(exif);
       
    75 
       
    76 	exif = TUtils::ReadFileL(iFs, KInvalidExif2);
       
    77 	CleanupStack::PushL(exif);
       
    78     TRAP( error, modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing) );
       
    79     if ( ( error != KErrCorrupt ) || ( modify ) )
       
    80         {
       
    81         if ( modify )
       
    82             {
       
    83             delete modify;
       
    84             }
       
    85         if ( error )
       
    86             {
       
    87             User::Leave( error );
       
    88             }
       
    89         User::Leave( KErrGeneral );
       
    90         }
       
    91 	CleanupStack::PopAndDestroy(exif);
       
    92 
       
    93 	exif = TUtils::ReadFileL(iFs, KInvalidExif3);
       
    94 	CleanupStack::PushL(exif);
       
    95     TRAP( error, modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing) );
       
    96     if ( ( error != KErrCorrupt ) || ( modify ) )
       
    97         {
       
    98         if ( modify )
       
    99             {
       
   100             delete modify;
       
   101             }
       
   102         if ( error )
       
   103             {
       
   104             User::Leave( error );
       
   105             }
       
   106         User::Leave( KErrGeneral );
       
   107         }
       
   108 	CleanupStack::PopAndDestroy(exif);
       
   109 
       
   110 	exif = TUtils::ReadFileL(iFs, KInvalidExif4);
       
   111 	CleanupStack::PushL(exif);
       
   112     TRAP( error, modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing) );
       
   113     if ( ( error != KErrCorrupt ) || ( modify ) )
       
   114         {
       
   115         if ( modify )
       
   116             {
       
   117             delete modify;
       
   118             }
       
   119         if ( error )
       
   120             {
       
   121             User::Leave( error );
       
   122             }
       
   123         User::Leave( KErrGeneral );
       
   124         }
       
   125 	CleanupStack::PopAndDestroy(exif);
       
   126 
       
   127 	exif = TUtils::ReadFileL(iFs, KInvalidExif5);
       
   128 	CleanupStack::PushL(exif);
       
   129     TRAP( error, modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing) );
       
   130     if ( ( error != KErrCorrupt ) || ( modify ) )
       
   131         {
       
   132         if ( modify )
       
   133             {
       
   134             delete modify;
       
   135             }
       
   136         if ( error )
       
   137             {
       
   138             User::Leave( error );
       
   139             }
       
   140         User::Leave( KErrGeneral );
       
   141         }
       
   142 	CleanupStack::PopAndDestroy(exif);
       
   143 
       
   144 	exif = TUtils::ReadFileL(iFs, KInvalidExif6);
       
   145 	CleanupStack::PushL(exif);
       
   146     TRAP( error, modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing) );
       
   147     if ( ( error != KErrCorrupt ) || ( modify ) )
       
   148         {
       
   149         if ( modify )
       
   150             {
       
   151             delete modify;
       
   152             }
       
   153         if ( error )
       
   154             {
       
   155             User::Leave( error );
       
   156             }
       
   157         User::Leave( KErrGeneral );
       
   158         }
       
   159 	CleanupStack::PopAndDestroy(exif);
       
   160 
       
   161     /* Supported, but uncompressed thumbnail is skipped */
       
   162 	exif = TUtils::ReadFileL(iFs, KNotSupportedExif1);
       
   163 	CleanupStack::PushL(exif);
       
   164     TRAP( error, modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing) );
       
   165     if ( ( error != KErrNone ) || ( !modify ) )
       
   166         {
       
   167         if ( modify )
       
   168             {
       
   169             delete modify;
       
   170             }
       
   171         if ( error )
       
   172             {
       
   173             User::Leave( error );
       
   174             }
       
   175         User::Leave( KErrGeneral );
       
   176         }
       
   177     delete modify;
       
   178     modify = NULL;
       
   179 	CleanupStack::PopAndDestroy(exif);
       
   180 
       
   181     /* Supported, but unsupported (uncompressed) thumbnail is skipped */
       
   182 	exif = TUtils::ReadFileL(iFs, KNotSupportedExif2);
       
   183 	CleanupStack::PushL(exif);
       
   184     TRAP( error, modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing) );
       
   185     if ( ( error != KErrCorrupt ) )
       
   186         {
       
   187         if ( modify )
       
   188             {
       
   189             delete modify;
       
   190             }
       
   191         if ( error )
       
   192             {
       
   193             User::Leave( error );
       
   194             }
       
   195         User::Leave( KErrGeneral );
       
   196         }
       
   197     delete modify;
       
   198 	CleanupStack::PopAndDestroy(exif);
       
   199     }
       
   200 
       
   201 // Exif.Modify.103
       
   202 // Retrieve reader instance for the related Exif data.
       
   203 // Returns unmodifiable reader instance.
       
   204 void CExifModifyTest::ExifModify103L()
       
   205 	{
       
   206 	HBufC8* exif = TUtils::ReadFileL(iFs, KFullExif);
       
   207 	CleanupStack::PushL(exif);
       
   208 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
   209 	CleanupStack::PushL(modify);
       
   210 
       
   211 	const CExifRead* reader = modify->Reader();
       
   212 	if(!reader)
       
   213 		User::Leave(KErrGeneral);
       
   214 
       
   215 	CleanupStack::PopAndDestroy(modify);
       
   216 	CleanupStack::PopAndDestroy(exif);
       
   217 	}
       
   218 
       
   219 // Exif.Modify.104
       
   220 // Insert/ Update a valid tag into the specified IFD in Exif data.
       
   221 // The given tag instance is inserted or updated.
       
   222 void CExifModifyTest::ExifModify104L()
       
   223 	{
       
   224 // For each IFD.
       
   225 	HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif);
       
   226 	CleanupStack::PushL(exif);
       
   227 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
   228 	CleanupStack::PushL(modify);
       
   229 
       
   230 
       
   231 	HBufC8* buf = TUtils::CreateDummyBufL(16);
       
   232 	CleanupStack::PushL(buf);
       
   233 	TExifTagInfo tag(KIdImageDescription, CExifTag::ETagAscii, 16);
       
   234 	modify->SetTagL(EIfd0, tag, buf->Des());
       
   235 	CleanupStack::PopAndDestroy(buf);
       
   236 
       
   237 	buf = TUtils::CreateDummyBufL(20);
       
   238 	CleanupStack::PushL(buf);
       
   239 	tag.iId = KIdUserComment;
       
   240 	tag.iDataType = CExifTag::ETagUndefined;
       
   241 	tag.iDataCount = 20; 
       
   242 	modify->SetTagL(EIfdExif, tag, buf->Des());
       
   243 	CleanupStack::PopAndDestroy(buf);
       
   244 
       
   245 	buf = TUtils::CreateDummyBufL(2);
       
   246 	CleanupStack::PushL(buf);
       
   247 	*(reinterpret_cast<TUint16*>(const_cast<TUint8*>(buf->Ptr()))) = 0;
       
   248 	tag.iId = KIdExposureProgram;
       
   249 	tag.iDataType = CExifTag::ETagShort;
       
   250 	tag.iDataCount = 1;
       
   251 	modify->SetTagL(EIfdExif, tag, buf->Des());
       
   252 	CleanupStack::PopAndDestroy(buf);
       
   253 
       
   254 	buf = TUtils::CreateDummyBufL(1);
       
   255 	CleanupStack::PushL(buf);
       
   256 	tag.iId = 3;
       
   257 	tag.iDataType = CExifTag::ETagAscii;
       
   258 	tag.iDataCount = 1;
       
   259 	modify->SetTagL(EIfdGps, tag, buf->Des());
       
   260 	CleanupStack::PopAndDestroy(buf);
       
   261 
       
   262 	buf = TUtils::CreateDummyBufL(3);
       
   263 	CleanupStack::PushL(buf);
       
   264 	tag.iId = 1;
       
   265 	tag.iDataType = CExifTag::ETagAscii;
       
   266 	tag.iDataCount = 3;
       
   267 	modify->SetTagL(EIfdIntOp, tag, buf->Des());
       
   268 	CleanupStack::PopAndDestroy(buf);
       
   269 
       
   270 	buf = TUtils::CreateDummyBufL(2);
       
   271 	CleanupStack::PushL(buf);
       
   272 	*(reinterpret_cast<TUint16*>(const_cast<TUint8*>(buf->Ptr()))) = 2;
       
   273 	tag.iId = KIdResolutionUnit;
       
   274 	tag.iDataType = CExifTag::ETagShort;
       
   275 	tag.iDataCount = 1; 
       
   276 	modify->SetTagL(EIfd1, tag, buf->Des());
       
   277 	CleanupStack::PopAndDestroy(buf);
       
   278 
       
   279 	CleanupStack::PopAndDestroy(modify);
       
   280 	CleanupStack::PopAndDestroy(exif);	
       
   281 	}
       
   282 
       
   283 // Exif.Modify.105
       
   284 // Try to insert/ update a valid tag into the specified IFD in Exif data.
       
   285 // Leaves with proper error code.
       
   286 void CExifModifyTest::ExifModify105L()
       
   287 	{
       
   288 //* Tag is not allowed to be inserted into the specified IFD,
       
   289 	HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif);
       
   290 	CleanupStack::PushL(exif);
       
   291 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
   292 	CleanupStack::PushL(modify);
       
   293 
       
   294 
       
   295 	HBufC8* buf = TUtils::CreateDummyBufL(16);
       
   296 	CleanupStack::PushL(buf);
       
   297 	TExifTagInfo tag(KIdImageDescription, CExifTag::ETagAscii, 16);
       
   298 	TRAPD(error, modify->SetTagL(EIfdExif, tag, buf->Des()));
       
   299 	if(error != KErrNotSupported)
       
   300 	{
       
   301 		if(error)
       
   302 			User::Leave(error);
       
   303 		User::Leave(KErrGeneral);
       
   304 	}
       
   305 	CleanupStack::PopAndDestroy(buf);
       
   306 
       
   307 	buf = TUtils::CreateDummyBufL(20);
       
   308 	CleanupStack::PushL(buf);
       
   309 	tag.iId = KIdUserComment;
       
   310 	tag.iDataType = CExifTag::ETagUndefined;
       
   311 	tag.iDataCount = 20; 
       
   312 	TRAP(error, modify->SetTagL(EIfd1, tag, buf->Des()));
       
   313 	if(error != KErrNotSupported)
       
   314 	{
       
   315 		if(error)
       
   316 			User::Leave(error);
       
   317 		User::Leave(KErrGeneral);
       
   318 	}
       
   319 	CleanupStack::PopAndDestroy(buf);
       
   320 
       
   321 	buf = TUtils::CreateDummyBufL(2);
       
   322 	CleanupStack::PushL(buf);
       
   323 	*(reinterpret_cast<TUint16*>(const_cast<TUint8*>(buf->Ptr()))) = 0;
       
   324 	tag.iId = KIdExposureProgram;
       
   325 	tag.iDataType = CExifTag::ETagShort;
       
   326 	tag.iDataCount = 1; 
       
   327 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   328 	if(error != KErrNotSupported)
       
   329 	{
       
   330 		if(error)
       
   331 			User::Leave(error);
       
   332 		User::Leave(KErrGeneral);
       
   333 	}
       
   334 	CleanupStack::PopAndDestroy(buf);
       
   335 
       
   336 	buf = TUtils::CreateDummyBufL(2);
       
   337 	CleanupStack::PushL(buf);
       
   338 	tag.iId = 3;
       
   339 	tag.iDataType = CExifTag::ETagAscii;
       
   340 	tag.iDataCount = 2; 
       
   341 	TRAP(error, modify->SetTagL(EIfdIntOp, tag, buf->Des()));
       
   342 	if(error != KErrNotSupported)
       
   343 	{
       
   344 		if(error)
       
   345 			User::Leave(error);
       
   346 		User::Leave(KErrGeneral);
       
   347 	}
       
   348 
       
   349 	CleanupStack::PopAndDestroy(buf);
       
   350 
       
   351 	buf = TUtils::CreateDummyBufL(3);
       
   352 	CleanupStack::PushL(buf);
       
   353 	tag.iId = 1;
       
   354 	tag.iDataType = CExifTag::ETagAscii;
       
   355 	tag.iDataCount = 3; 
       
   356 	TRAP(error, modify->SetTagL(EIfdExif, tag, buf->Des()));
       
   357 	if(error != KErrNotSupported)
       
   358 	{
       
   359 		if(error)
       
   360 			User::Leave(error);
       
   361 		User::Leave(KErrGeneral);
       
   362 	}
       
   363 	CleanupStack::PopAndDestroy(buf);
       
   364 
       
   365 	buf = TUtils::CreateDummyBufL(2);
       
   366 	CleanupStack::PushL(buf);
       
   367 	*(reinterpret_cast<TUint16*>(const_cast<TUint8*>(buf->Ptr()))) = 2;
       
   368 	tag.iId = KIdResolutionUnit;
       
   369 	tag.iDataType = CExifTag::ETagShort;
       
   370 	tag.iDataCount = 1; 
       
   371 	TRAP(error, modify->SetTagL(EIfdGps, tag, buf->Des()));
       
   372 	if(error != KErrNotSupported)
       
   373 	{
       
   374 		if(error)
       
   375 			User::Leave(error);
       
   376 		User::Leave(KErrGeneral);
       
   377 	}
       
   378 	CleanupStack::PopAndDestroy(buf);
       
   379 
       
   380     //* The Exif data size exceeds 64K"
       
   381 	buf = TUtils::CreateDummyBufL(65000);
       
   382 	CleanupStack::PushL(buf);
       
   383 	tag.iId = KIdImageDescription;
       
   384 	tag.iDataType = CExifTag::ETagAscii;
       
   385 	tag.iDataCount = 65000; 
       
   386 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   387 	if(error != KErrOverflow)
       
   388 	{
       
   389 		if(error)
       
   390 			User::Leave(error);
       
   391 		User::Leave(KErrGeneral);
       
   392 	}
       
   393 	CleanupStack::PopAndDestroy(buf);
       
   394 
       
   395 	// Tag ID is invalid,	
       
   396 	buf = TUtils::CreateDummyBufL(19);
       
   397 	CleanupStack::PushL(buf);
       
   398 	tag.iId = 200;
       
   399 	tag.iDataType = CExifTag::ETagAscii;
       
   400 	tag.iDataCount = 19; 
       
   401 	TRAP(error, modify->SetTagL(EIfdGps, tag, buf->Des()));
       
   402 	if(error != KErrNotSupported)
       
   403 	{
       
   404 		if(error)
       
   405 			User::Leave(error);
       
   406 		User::Leave(KErrGeneral);
       
   407 	}
       
   408 	CleanupStack::PopAndDestroy(buf);
       
   409 
       
   410 	//Tag ID doesn't match with the data type, (Full validity)
       
   411 	//* Not supported yet!!!
       
   412 	buf = TUtils::CreateDummyBufL(19);
       
   413 	CleanupStack::PushL(buf);
       
   414 	tag.iId = KIdImageDescription;
       
   415 	tag.iDataType = CExifTag::ETagByte;
       
   416 	tag.iDataCount = 19; 
       
   417 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   418 	if(error != KErrNotSupported)
       
   419         {
       
   420 		if(error)
       
   421 			User::Leave(error);
       
   422 		User::Leave(KErrGeneral);
       
   423         }
       
   424 	CleanupStack::PopAndDestroy(buf);
       
   425 	//*/
       
   426 
       
   427 	//Data count doesn't match with the given tag data size
       
   428 	buf = TUtils::CreateDummyBufL(19);
       
   429 	CleanupStack::PushL(buf);
       
   430 	tag.iId = KIdImageDescription;
       
   431 	tag.iDataType = CExifTag::ETagAscii;
       
   432 	tag.iDataCount = 24; 
       
   433 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   434 	if(error != KErrArgument)
       
   435 	{
       
   436 		if(error)
       
   437 			User::Leave(error);
       
   438 		User::Leave(KErrGeneral);
       
   439 	}
       
   440 	CleanupStack::PopAndDestroy(buf);
       
   441 
       
   442 	//Tag data value is not valid (Full validity)
       
   443     // !! DROPPED
       
   444 	/* Not supported yet!!!
       
   445 	buf = TUtils::CreateDummyBufL(2);
       
   446 	CleanupStack::PushL(buf);
       
   447 	tag.iId = KIdImageDescription;
       
   448 	tag.iDataType = CExifTag::ETagShort;
       
   449 	tag.iDataCount = 2; 
       
   450 	*(reinterpret_cast<TUint16*>(const_cast<TUint8*>(buf->Ptr()))) = 200;
       
   451 	TRAP(error, modify->SetTagL(EIfdExif, tag, buf->Des()));
       
   452 	if(error != KErrArgument)
       
   453 	{
       
   454 		if(error)
       
   455 			User::Leave(error);
       
   456 		User::Leave(KErrGeneral);
       
   457 	}
       
   458 	CleanupStack::PopAndDestroy(buf);
       
   459     */
       
   460 
       
   461     // Tag cannot be modified
       
   462 	buf = TUtils::CreateDummyBufL(4);
       
   463 	CleanupStack::PushL(buf);
       
   464 	tag.iId = KIdExifIfdPointer;
       
   465 	tag.iDataType = CExifTag::ETagAscii;
       
   466 	tag.iDataCount = 4; 
       
   467 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   468 	if(error != KErrNotSupported)
       
   469 	{
       
   470 		if(error)
       
   471 			User::Leave(error);
       
   472 		User::Leave(KErrGeneral);
       
   473 	}
       
   474 	CleanupStack::PopAndDestroy(buf);
       
   475 	buf = TUtils::CreateDummyBufL(4);
       
   476 	CleanupStack::PushL(buf);
       
   477 	tag.iId = KIdGpsIfdPointer;
       
   478 	tag.iDataType = CExifTag::ETagAscii;
       
   479 	tag.iDataCount = 4; 
       
   480 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   481 	if(error != KErrNotSupported)
       
   482 	{
       
   483 		if(error)
       
   484 			User::Leave(error);
       
   485 		User::Leave(KErrGeneral);
       
   486 	}
       
   487 	CleanupStack::PopAndDestroy(buf);
       
   488 	buf = TUtils::CreateDummyBufL(4);
       
   489 	CleanupStack::PushL(buf);
       
   490 	tag.iId = KIdIntOpIfdPointer;
       
   491 	tag.iDataType = CExifTag::ETagAscii;
       
   492 	tag.iDataCount = 4; 
       
   493 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   494 	if(error != KErrNotSupported)
       
   495 	{
       
   496 		if(error)
       
   497 			User::Leave(error);
       
   498 		User::Leave(KErrGeneral);
       
   499 	}
       
   500 	CleanupStack::PopAndDestroy(buf);
       
   501 	buf = TUtils::CreateDummyBufL(4);
       
   502 	CleanupStack::PushL(buf);
       
   503 	tag.iId = KIdJpegInterchangeFormat;
       
   504 	tag.iDataType = CExifTag::ETagAscii;
       
   505 	tag.iDataCount = 4; 
       
   506 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   507 	if(error != KErrNotSupported)
       
   508 	{
       
   509 		if(error)
       
   510 			User::Leave(error);
       
   511 		User::Leave(KErrGeneral);
       
   512 	}
       
   513 	CleanupStack::PopAndDestroy(buf);
       
   514 	buf = TUtils::CreateDummyBufL(4);
       
   515 	CleanupStack::PushL(buf);
       
   516 	tag.iId = KIdJpegInterchangeFormatLength;
       
   517 	tag.iDataType = CExifTag::ETagAscii;
       
   518 	tag.iDataCount = 4; 
       
   519 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   520 	if(error != KErrNotSupported)
       
   521 	{
       
   522 		if(error)
       
   523 			User::Leave(error);
       
   524 		User::Leave(KErrGeneral);
       
   525 	}
       
   526 	CleanupStack::PopAndDestroy(buf);
       
   527 	buf = TUtils::CreateDummyBufL(4);
       
   528 	CleanupStack::PushL(buf);
       
   529 	tag.iId = KIdExifVersion;
       
   530 	tag.iDataType = CExifTag::ETagAscii;
       
   531 	tag.iDataCount = 4; 
       
   532 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   533 	if(error != KErrNotSupported)
       
   534 	{
       
   535 		if(error)
       
   536 			User::Leave(error);
       
   537 		User::Leave(KErrGeneral);
       
   538 	}
       
   539 	CleanupStack::PopAndDestroy(buf);
       
   540 	buf = TUtils::CreateDummyBufL(4);
       
   541 	CleanupStack::PushL(buf);
       
   542 	tag.iId = KIdGpsVersion;
       
   543 	tag.iDataType = CExifTag::ETagAscii;
       
   544 	tag.iDataCount = 4; 
       
   545 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   546 	if(error != KErrNotSupported)
       
   547 	{
       
   548 		if(error)
       
   549 			User::Leave(error);
       
   550 		User::Leave(KErrGeneral);
       
   551 	}
       
   552 	CleanupStack::PopAndDestroy(buf);
       
   553 	buf = TUtils::CreateDummyBufL(4);
       
   554 	CleanupStack::PushL(buf);
       
   555 	tag.iId = KIdFlashPixVersion;
       
   556 	tag.iDataType = CExifTag::ETagAscii;
       
   557 	tag.iDataCount = 4; 
       
   558 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   559 	if(error != KErrNotSupported)
       
   560 	{
       
   561 		if(error)
       
   562 			User::Leave(error);
       
   563 		User::Leave(KErrGeneral);
       
   564 	}
       
   565 	CleanupStack::PopAndDestroy(buf);
       
   566 	buf = TUtils::CreateDummyBufL(4);
       
   567 	CleanupStack::PushL(buf);
       
   568 	tag.iId = KIdCompression;
       
   569 	tag.iDataType = CExifTag::ETagAscii;
       
   570 	tag.iDataCount = 4; 
       
   571 	TRAP(error, modify->SetTagL(EIfd0, tag, buf->Des()));
       
   572 	if(error != KErrNotSupported)
       
   573 	{
       
   574 		if(error)
       
   575 			User::Leave(error);
       
   576 		User::Leave(KErrGeneral);
       
   577 	}
       
   578 	CleanupStack::PopAndDestroy(buf);
       
   579 
       
   580 
       
   581 	CleanupStack::PopAndDestroy(modify);
       
   582 	CleanupStack::PopAndDestroy(exif);	
       
   583 	}
       
   584 
       
   585 // Exif.Modify.106
       
   586 // Remove a tag from the specified IFD in Exif data.
       
   587 // Removes the tag from the specified IFD.
       
   588 void CExifModifyTest::ExifModify106L()
       
   589 	{
       
   590     // For each IFD.
       
   591 	HBufC8* exif = TUtils::ReadFileL(iFs, KFullExif);
       
   592 	CleanupStack::PushL(exif);
       
   593 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
   594 	CleanupStack::PushL(modify);
       
   595 
       
   596     User::LeaveIfError(modify->DeleteTag(EIfd0, KIdXResolution));
       
   597 
       
   598     User::LeaveIfError(modify->DeleteTag(EIfdExif, KIdExposureProgram));
       
   599 
       
   600     User::LeaveIfError(modify->DeleteTag(EIfd1, KIdResolutionUnit));
       
   601 
       
   602     User::LeaveIfError(modify->DeleteTag(EIfdGps, 27));
       
   603 
       
   604     User::LeaveIfError(modify->DeleteTag(EIfdIntOp, 1));
       
   605     
       
   606 	CleanupStack::PopAndDestroy(modify);
       
   607 	CleanupStack::PopAndDestroy(exif);	
       
   608 	}
       
   609 
       
   610 // Exif.Modify.107
       
   611 // Try to remove a tag from the specified IFD  in Exif data.
       
   612 // Returns proper error code.
       
   613 void CExifModifyTest::ExifModify107L()
       
   614 	{
       
   615     //"For each IFD;
       
   616 //* IFD exists but tag doesn't exist,
       
   617 //* IFD doesn't exist"
       
   618 
       
   619 	HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif);
       
   620 	CleanupStack::PushL(exif);
       
   621 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
   622 	CleanupStack::PushL(modify);
       
   623     TInt error = modify->DeleteTag(EIfd0, 0x013f);
       
   624     if(error != KErrNotFound)
       
   625         {
       
   626         if(error)
       
   627             {
       
   628             User::Leave(error);
       
   629             }
       
   630         User::Leave(KErrGeneral);
       
   631         }
       
   632 
       
   633     error = modify->DeleteTag(EIfdExif, KIdMakerNote);
       
   634     if(error != KErrNotFound)
       
   635         {
       
   636         if(error)
       
   637             {
       
   638             User::Leave(error);
       
   639             }
       
   640         User::Leave(KErrGeneral);
       
   641         }
       
   642 
       
   643     error = modify->DeleteTag(EIfd1, KIdCompression);
       
   644     if(error != KErrNotSupported)
       
   645         {
       
   646         if(error)
       
   647             {
       
   648             User::Leave(error);
       
   649             }
       
   650         User::Leave(KErrGeneral);
       
   651         }
       
   652 
       
   653     error = modify->DeleteTag(EIfdIntOp, 4);
       
   654     if(error != KErrNotFound)
       
   655         {
       
   656         if(error)
       
   657             {
       
   658             User::Leave(error);
       
   659             }
       
   660         User::Leave(KErrGeneral);
       
   661         }
       
   662 
       
   663     error = modify->DeleteTag(EIfdGps, 27);
       
   664     if(error != KErrNotFound)
       
   665         {
       
   666         if(error)
       
   667             {
       
   668             User::Leave(error);
       
   669             }
       
   670         User::Leave(KErrGeneral);
       
   671         }
       
   672     
       
   673 //* Invalid tag ID
       
   674     error = modify->DeleteTag(EIfdExif, 0x0205);
       
   675     if(error != KErrNotSupported)
       
   676         {
       
   677         if(error)
       
   678             {
       
   679             User::Leave(error);
       
   680             }
       
   681         User::Leave(KErrGeneral);
       
   682         }
       
   683 
       
   684 //* Tag cannot be removed!
       
   685     error = modify->DeleteTag(EIfdExif, KIdGpsIfdPointer);
       
   686     if(error != KErrNotSupported)
       
   687         {
       
   688         if(error)
       
   689             {
       
   690             User::Leave(error);
       
   691             }
       
   692         User::Leave(KErrGeneral);
       
   693         }
       
   694     error = modify->DeleteTag(EIfdExif, KIdFlashPixVersion);
       
   695     if(error != KErrNotSupported)
       
   696         {
       
   697         if(error)
       
   698             {
       
   699             User::Leave(error);
       
   700             }
       
   701         User::Leave(KErrGeneral);
       
   702         }
       
   703     error = modify->DeleteTag(EIfdExif, KIdExifIfdPointer);
       
   704     if(error != KErrNotSupported)
       
   705         {
       
   706         if(error)
       
   707             {
       
   708             User::Leave(error);
       
   709             }
       
   710         User::Leave(KErrGeneral);
       
   711         }
       
   712     error = modify->DeleteTag(EIfdExif, KIdIntOpIfdPointer);
       
   713     if(error != KErrNotSupported)
       
   714         {
       
   715         if(error)
       
   716             {
       
   717             User::Leave(error);
       
   718             }
       
   719         User::Leave(KErrGeneral);
       
   720         }
       
   721     error = modify->DeleteTag(EIfdExif, KIdJpegInterchangeFormat);
       
   722     if(error != KErrNotSupported)
       
   723         {
       
   724         if(error)
       
   725             {
       
   726             User::Leave(error);
       
   727             }
       
   728         User::Leave(KErrGeneral);
       
   729         }
       
   730     error = modify->DeleteTag(EIfdExif, KIdGpsVersion);
       
   731     if(error != KErrNotSupported)
       
   732         {
       
   733         if(error)
       
   734             {
       
   735             User::Leave(error);
       
   736             }
       
   737         User::Leave(KErrGeneral);
       
   738         }
       
   739     error = modify->DeleteTag(EIfdExif, KIdJpegInterchangeFormatLength);
       
   740     if(error != KErrNotSupported)
       
   741         {
       
   742         if(error)
       
   743             {
       
   744             User::Leave(error);
       
   745             }
       
   746         User::Leave(KErrGeneral);
       
   747         }    
       
   748     error = modify->DeleteTag(EIfdExif, KIdExifVersion);
       
   749     if(error != KErrNotSupported)
       
   750         {
       
   751         if(error)
       
   752             {
       
   753             User::Leave(error);
       
   754             }
       
   755         User::Leave(KErrGeneral);
       
   756         }
       
   757 	CleanupStack::PopAndDestroy(modify);
       
   758 	CleanupStack::PopAndDestroy(exif);	
       
   759 	}
       
   760 
       
   761 // Exif.Modify.108
       
   762 // Remove an IFD from the Exif data.
       
   763 // Removes the IFD from the Exif data.
       
   764 void CExifModifyTest::ExifModify108L()
       
   765 	{
       
   766     // For each IFD.
       
   767 	HBufC8* exif = TUtils::ReadFileL(iFs, KFullExif);
       
   768 	CleanupStack::PushL(exif);
       
   769 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
   770 	CleanupStack::PushL(modify);
       
   771 
       
   772     // Not allowed to delete Ifd0 and ExifIfd
       
   773     // User::LeaveIfError(modify->DeleteIfd(EIfd0));
       
   774     // User::LeaveIfError(modify->DeleteIfd(EIfdExif));
       
   775     User::LeaveIfError(modify->DeleteIfd(EIfd1));
       
   776     User::LeaveIfError(modify->DeleteIfd(EIfdGps));
       
   777     User::LeaveIfError(modify->DeleteIfd(EIfdIntOp));
       
   778 
       
   779 	CleanupStack::PopAndDestroy(modify);
       
   780 	CleanupStack::PopAndDestroy(exif);	
       
   781 	}
       
   782 
       
   783 // Exif.Modify.109
       
   784 // Try to remove an IFD from the Exif data, which doesn't contain that IFD.
       
   785 // Returns proper error code.
       
   786 void CExifModifyTest::ExifModify109L()
       
   787 	{
       
   788     // For each IFD.
       
   789 	HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif);
       
   790 	CleanupStack::PushL(exif);
       
   791 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
   792 	CleanupStack::PushL(modify);
       
   793     TInt error = modify->DeleteIfd(EIfdGps);
       
   794 
       
   795     if(error != KErrNotFound)
       
   796         {
       
   797         if(error)
       
   798             {
       
   799             User::Leave(error);
       
   800             }
       
   801         User::Leave(KErrGeneral);
       
   802         }
       
   803 
       
   804     error = modify->DeleteIfd(EIfd0);
       
   805     if(error != KErrArgument)
       
   806         {
       
   807         if(error)
       
   808             {
       
   809             User::Leave(error);
       
   810             }
       
   811         User::Leave(KErrGeneral);
       
   812         }
       
   813 
       
   814     // IFD cannot be removed
       
   815     error = modify->DeleteIfd(EIfd0);
       
   816     if( error != KErrArgument)
       
   817         {
       
   818         if(error)
       
   819             {
       
   820             User::Leave(error);
       
   821             }
       
   822         User::Leave(KErrGeneral);
       
   823         }
       
   824 
       
   825     error = modify->DeleteIfd(EIfdExif);
       
   826     if( error != KErrArgument)
       
   827         {
       
   828         if(error)
       
   829             {
       
   830             User::Leave(error);
       
   831             }
       
   832         User::Leave(KErrGeneral);
       
   833         }
       
   834 	CleanupStack::PopAndDestroy(modify);
       
   835 	CleanupStack::PopAndDestroy(exif);	
       
   836 	}
       
   837 
       
   838 // Exif.Modify.110
       
   839 // Insert/ Update compressed Exif thumbnail image into the the Exif data.
       
   840 // Inserts/ Updates the Exif thumbnail image
       
   841 void CExifModifyTest::ExifModify110L()
       
   842 	{
       
   843 	HBufC8* exif = TUtils::ReadFileL(iFs, KNoThumbnail);
       
   844 	CleanupStack::PushL(exif);
       
   845 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
   846 	CleanupStack::PushL(modify);
       
   847 
       
   848 	HBufC8* thumbnail = TUtils::ReadFileL(iFs, KValidThumbnail);
       
   849 	CleanupStack::PushL(thumbnail);
       
   850 	modify->SetThumbnailL(thumbnail->Des());
       
   851 	CleanupStack::PopAndDestroy(thumbnail);
       
   852 
       
   853 	CleanupStack::PopAndDestroy(modify);
       
   854 	CleanupStack::PopAndDestroy(exif);	
       
   855 	}
       
   856 
       
   857 // Exif.Modify.111
       
   858 // Try to Insert/ Update compressed Exif thumbnail image with in invalid cases.
       
   859 // Leaves with proper error code.
       
   860 void CExifModifyTest::ExifModify111L()
       
   861 	{
       
   862 	HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif);
       
   863 	CleanupStack::PushL(exif);
       
   864 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
   865 	CleanupStack::PushL(modify);
       
   866 
       
   867 //"* Given thumbnail data is not valid compressed Exif thumbnail image, !! Not supported yet !!
       
   868     HBufC8* buf = TUtils::CreateDummyBufL(8000);
       
   869 	CleanupStack::PushL(buf);
       
   870 	TRAPD( error, modify->SetThumbnailL(buf->Des()) );
       
   871     if ( error != KErrCorrupt )
       
   872         {
       
   873         if ( error )
       
   874             {
       
   875             User::Leave( error );
       
   876             }
       
   877         User::Leave( KErrGeneral );
       
   878         }
       
   879     CleanupStack::PopAndDestroy( buf );
       
   880 
       
   881 //* The Exif data size exceeds 64K"
       
   882 	TExifTagInfo tag(KIdImageDescription, CExifTag::ETagAscii, 52000);
       
   883     buf = TUtils::CreateDummyBufL(52000);
       
   884 	CleanupStack::PushL(buf);
       
   885 	modify->SetTagL(EIfd0, tag, buf->Des());
       
   886 	CleanupStack::PopAndDestroy(buf);
       
   887 
       
   888 	HBufC8* thumbnail = TUtils::ReadFileL(iFs, KValidThumbnail);
       
   889 	CleanupStack::PushL(thumbnail);
       
   890 	TRAP( error, modify->SetThumbnailL(thumbnail->Des()) );
       
   891     if ( error != KErrOverflow )
       
   892         {
       
   893         if ( error )
       
   894             {
       
   895             User::Leave( error );
       
   896             }
       
   897         User::Leave( KErrGeneral );
       
   898         }
       
   899 	CleanupStack::PopAndDestroy(thumbnail);
       
   900 
       
   901     CleanupStack::PopAndDestroy(modify);
       
   902 	CleanupStack::PopAndDestroy(exif);
       
   903 	}
       
   904 
       
   905 // Exif.Modify.112
       
   906 // Remove compressed Exif thumbnail image from the Exif data.
       
   907 // Removes the thumbnail image.
       
   908 void CExifModifyTest::ExifModify112L()
       
   909 	{
       
   910 	HBufC8* exif = TUtils::ReadFileL(iFs, KFullExif);
       
   911 	CleanupStack::PushL(exif);
       
   912 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
   913 	CleanupStack::PushL(modify);
       
   914 
       
   915     User::LeaveIfError(modify->RemoveThumbnail());
       
   916 
       
   917 	CleanupStack::PopAndDestroy(modify);
       
   918 	CleanupStack::PopAndDestroy(exif);
       
   919 	}
       
   920 
       
   921 // Exif.Modify.113
       
   922 // Try to remove compressed Exif thumbnail image from the Exif data.
       
   923 // Returns proper error code.
       
   924 void CExifModifyTest::ExifModify113L()
       
   925 	{
       
   926 	HBufC8* exif = TUtils::ReadFileL(iFs, KNoThumbnail);
       
   927 	CleanupStack::PushL(exif);
       
   928 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
   929 	CleanupStack::PushL(modify);
       
   930     TInt error = modify->RemoveThumbnail();
       
   931 
       
   932     if(error != KErrNotFound)
       
   933         {
       
   934         if(error)
       
   935             {
       
   936             User::Leave(error);
       
   937             }
       
   938         User::Leave(KErrGeneral);
       
   939         }
       
   940         
       
   941 
       
   942 	CleanupStack::PopAndDestroy(modify);
       
   943 	CleanupStack::PopAndDestroy(exif);
       
   944 	}
       
   945 
       
   946 // Exif.Modify.114
       
   947 // Write the final Exif image to a buffer.
       
   948 // Writes the whole Exif image in a buffer, and returns the buffer.
       
   949 void CExifModifyTest::ExifModify114L()
       
   950 	{
       
   951 	HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif);
       
   952 	CleanupStack::PushL(exif);
       
   953 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
   954 	CleanupStack::PushL(modify);
       
   955 
       
   956 	// Insert Tags
       
   957 	HBufC8* buf = 0;
       
   958 	TUint16 tmp1 = 0;
       
   959 	TUint32 tmp3 = 0;
       
   960 	TUint32 tmp4 = 0;
       
   961     TInt32 tmp5 = 0;
       
   962     TInt32 tmp6 = 0;
       
   963 
       
   964 	buf = TUtils::CreateDummyBufL(10);
       
   965 	CleanupStack::PushL(buf);
       
   966     modify->SetUserCommentL(buf->Des());
       
   967 	CleanupStack::PopAndDestroy(buf);
       
   968 	buf = 0;
       
   969 
       
   970 	buf = TUtils::CreateDummyBufL(4);
       
   971 	CleanupStack::PushL(buf);
       
   972     modify->SetModelL(buf->Des());
       
   973 	CleanupStack::PopAndDestroy(buf);
       
   974 	buf = 0;
       
   975 
       
   976     tmp1 = 0;
       
   977     modify->SetMeteringModeL(tmp1);
       
   978 
       
   979     tmp5 = 1;
       
   980     tmp6 = 1;
       
   981     modify->SetExposureBiasValueL(tmp5, tmp6);
       
   982 
       
   983     tmp5 = 0;
       
   984     tmp6 = 1;
       
   985     modify->SetShutterSpeedValueL(tmp5, tmp6);
       
   986 
       
   987     modify->SetBrightnessValueL(tmp5, tmp6);
       
   988 
       
   989     modify->SetCustomRenderedL(0);
       
   990 
       
   991     modify->SetGainControlL(0);
       
   992 
       
   993 	buf = TUtils::CreateDummyBufL(19);
       
   994 	CleanupStack::PushL(buf);
       
   995     buf->Des().Copy(_L("2004:01:19 11:00:00"));
       
   996     modify->SetDateTimeOriginalL(buf->Des());
       
   997     modify->SetDateTimeDigitizedL(buf->Des());
       
   998 	CleanupStack::PopAndDestroy(buf);
       
   999 	buf = 0;
       
  1000 
       
  1001     tmp5 = 1;
       
  1002     tmp6 = 1;
       
  1003     modify->SetApertureValueL(tmp5, tmp6);
       
  1004 
       
  1005 	tmp3 = 72;
       
  1006 	tmp4 = 1;
       
  1007 	modify->SetXResolutionL(tmp3, tmp4);
       
  1008 	modify->SetYResolutionL(tmp3, tmp4);
       
  1009 	tmp1 = 2;
       
  1010 	modify->SetResolutionUnitL(tmp1);
       
  1011 	tmp1 = 1;
       
  1012 	modify->SetYCbCrPositioningL(tmp1);
       
  1013 
       
  1014 	modify->SetComponentsConfigurationL(1, 2, 3, 0);
       
  1015 	tmp1 = 1;
       
  1016 	modify->SetColorSpaceL(tmp1);
       
  1017 	tmp3 = 1024;
       
  1018 	modify->SetPixelXDimensionL(tmp3);
       
  1019 	tmp3 = 768;
       
  1020 	modify->SetPixelYDimensionL(tmp3);
       
  1021 
       
  1022 
       
  1023 	buf = TUtils::CreateDummyBufL(5);
       
  1024 	CleanupStack::PushL(buf);
       
  1025 	modify->SetImageDescriptionL(buf->Des());
       
  1026 	CleanupStack::PopAndDestroy(buf);
       
  1027 	buf = 0;
       
  1028 
       
  1029 	
       
  1030 	buf = TUtils::CreateDummyBufL(768*2);
       
  1031 	CleanupStack::PushL(buf);
       
  1032 	modify->SetTransferFunctionL(buf->Des());
       
  1033 	CleanupStack::PopAndDestroy(buf);
       
  1034 	buf = 0;
       
  1035 	
       
  1036 	modify->SetExposureModeL(0);
       
  1037 	modify->SetWhiteBalanceL(0);
       
  1038 	modify->SetSceneCaptureTypeL(0);
       
  1039 	modify->SetExposureProgramL(0);
       
  1040 	
       
  1041 	modify->SetLightSourceL(0);
       
  1042 
       
  1043 	buf = TUtils::CreateDummyBufL(16);
       
  1044 	CleanupStack::PushL(buf);
       
  1045 	modify->SetMakerNoteL(buf->Des());
       
  1046 	CleanupStack::PopAndDestroy(buf);
       
  1047 	buf = 0;
       
  1048 
       
  1049 	HBufC8* buffer = modify->WriteDataL(exif->Des());
       
  1050 	if(!buffer)
       
  1051 		User::Leave(KErrGeneral);
       
  1052 	delete buffer;
       
  1053 	buffer = 0;
       
  1054 
       
  1055     TPtrC8 tmpDes;
       
  1056 	buffer = modify->WriteDataL( tmpDes );
       
  1057 	if(!buffer)
       
  1058 		User::Leave(KErrGeneral);
       
  1059 	delete buffer;
       
  1060 
       
  1061 
       
  1062 	CleanupStack::PopAndDestroy(modify);
       
  1063 	CleanupStack::PopAndDestroy(exif);	
       
  1064 	}
       
  1065 
       
  1066 
       
  1067 // Exif.Modify.115
       
  1068 // Try to write the final Exif image to a buffer for invalid cases or incorrect original data buffer
       
  1069 // Leaves with proper error code.
       
  1070 void CExifModifyTest::ExifModify115L()
       
  1071 	{
       
  1072 	HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif);
       
  1073 	CleanupStack::PushL(exif);
       
  1074 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
  1075 	CleanupStack::PushL(modify);
       
  1076 
       
  1077 //"* Given buffer content is not the same with the original buffer content.
       
  1078     TInt error = 0;
       
  1079 	HBufC8* buf = 0;
       
  1080     HBufC8* buffer = 0;
       
  1081     
       
  1082     buf = TUtils::CreateDummyBufL( exif->Length() );
       
  1083     CleanupStack::PushL( buf );
       
  1084     TRAP( error, buffer = modify->WriteDataL( *buf ) );
       
  1085     if ( ( error != KErrArgument ) || ( buffer ) )
       
  1086         {
       
  1087         if ( buffer )
       
  1088             delete buffer;
       
  1089         if ( error )
       
  1090             {
       
  1091             User::Leave( error );
       
  1092             }
       
  1093         User::Leave( KErrGeneral );
       
  1094         }
       
  1095     CleanupStack::PopAndDestroy( buf );
       
  1096 
       
  1097     buf = TUtils::CreateDummyBufL( exif->Length() - 5 );
       
  1098     CleanupStack::PushL( buf );
       
  1099     TRAP( error, buffer = modify->WriteDataL( *buf ) );
       
  1100     if ( ( error != KErrArgument ) || ( buffer ) )
       
  1101         {
       
  1102         if ( buffer )
       
  1103             delete buffer;
       
  1104         if ( error )
       
  1105             {
       
  1106             User::Leave( error );
       
  1107             }
       
  1108         User::Leave( KErrGeneral );
       
  1109         }
       
  1110     CleanupStack::PopAndDestroy( buf );
       
  1111 
       
  1112     buf = TUtils::CreateDummyBufL( exif->Length() );
       
  1113     CleanupStack::PushL( buf );
       
  1114     buf->Des().Copy( exif->Ptr(), exif->Length() / 2 - 10 );
       
  1115     buf->Des().SetLength( exif->Length() );
       
  1116     TRAP( error, buffer = modify->WriteDataL( *buf ) );
       
  1117     if ( ( error != KErrArgument ) || ( buffer ) )
       
  1118         {
       
  1119         if ( buffer )
       
  1120             delete buffer;
       
  1121         if ( error )
       
  1122             {
       
  1123             User::Leave( error );
       
  1124             }
       
  1125         User::Leave( KErrGeneral );
       
  1126         }
       
  1127     CleanupStack::PopAndDestroy( buf );
       
  1128 
       
  1129     buf = TUtils::CreateDummyBufL( exif->Length() );
       
  1130     CleanupStack::PushL( buf );
       
  1131     buf->Des().Copy( exif->Ptr(), exif->Length() / 2 + 10 );
       
  1132     buf->Des().SetLength( exif->Length() );
       
  1133     TRAP( error, buffer = modify->WriteDataL( *buf ) );
       
  1134     if ( ( error != KErrArgument ) || ( buffer ) )
       
  1135         {
       
  1136         if ( buffer )
       
  1137             delete buffer;
       
  1138         if ( error )
       
  1139             {
       
  1140             User::Leave( error );
       
  1141             }
       
  1142         User::Leave( KErrGeneral );
       
  1143         }
       
  1144     CleanupStack::PopAndDestroy( buf );
       
  1145 
       
  1146 //* The Exif data doesn't contain all mandatory tags"
       
  1147 
       
  1148 	// Insert Tags
       
  1149 	TUint16 tmp1 = 0;
       
  1150 	TUint32 tmp3 = 0;
       
  1151 	TUint32 tmp4 = 0;
       
  1152 
       
  1153 	tmp3 = 72;
       
  1154 	tmp4 = 1;
       
  1155 	modify->SetXResolutionL(tmp3, tmp4);
       
  1156 	tmp1 = 2;
       
  1157 	modify->SetResolutionUnitL(tmp1);
       
  1158 
       
  1159 	modify->SetComponentsConfigurationL(1, 2, 3, 0);
       
  1160 	tmp1 = 1;
       
  1161 	modify->SetColorSpaceL(tmp1);
       
  1162 	tmp3 = 768;
       
  1163 	modify->SetPixelYDimensionL(tmp3);
       
  1164     modify->DeleteTag(EIfdExif, KIdPixelXDimension);
       
  1165 
       
  1166 
       
  1167 	buf = TUtils::CreateDummyBufL(5);
       
  1168 	CleanupStack::PushL(buf);
       
  1169 	modify->SetImageDescriptionL(buf->Des());
       
  1170 	CleanupStack::PopAndDestroy(buf);
       
  1171 	buf = 0;
       
  1172 
       
  1173 	
       
  1174 	buf = TUtils::CreateDummyBufL(768*2);
       
  1175 	CleanupStack::PushL(buf);
       
  1176 	modify->SetTransferFunctionL(buf->Des());
       
  1177 	CleanupStack::PopAndDestroy(buf);
       
  1178 	buf = 0;
       
  1179 	
       
  1180 	modify->SetExposureModeL(0);
       
  1181 	modify->SetWhiteBalanceL(0);
       
  1182 	modify->SetSceneCaptureTypeL(0);
       
  1183 	modify->SetExposureProgramL(0);
       
  1184 	
       
  1185 	modify->SetLightSourceL(0);
       
  1186 
       
  1187 	buf = TUtils::CreateDummyBufL(16);
       
  1188 	CleanupStack::PushL(buf);
       
  1189 	modify->SetMakerNoteL(buf->Des());
       
  1190 	CleanupStack::PopAndDestroy(buf);
       
  1191 	buf = 0;
       
  1192 
       
  1193 	buffer = 0;
       
  1194 	TRAP(error, buffer = modify->WriteDataL(exif->Des()));
       
  1195 	if(buffer)
       
  1196 		{
       
  1197 		delete buffer;
       
  1198 		User::Leave(KErrGeneral);
       
  1199 		}
       
  1200 	if(error != KErrNotReady)
       
  1201 	    {
       
  1202 		if(error)
       
  1203 			User::Leave(error);
       
  1204 		User::Leave(KErrGeneral);
       
  1205 	    }
       
  1206 
       
  1207   	buffer = 0;
       
  1208 	TPtrC8 tmpDes;
       
  1209     TRAP(error, buffer = modify->WriteDataL( tmpDes ));
       
  1210 	if(buffer)
       
  1211 		{
       
  1212 		delete buffer;
       
  1213 		User::Leave(KErrGeneral);
       
  1214 		}
       
  1215 	if(error != KErrNotReady)
       
  1216 	    {
       
  1217 		if(error)
       
  1218 			User::Leave(error);
       
  1219 		User::Leave(KErrGeneral);
       
  1220 	    }
       
  1221 
       
  1222 	CleanupStack::PopAndDestroy(modify);
       
  1223 	CleanupStack::PopAndDestroy(exif);	
       
  1224 	}
       
  1225 
       
  1226 // Exif.Modify.116
       
  1227 // Test the behavior of the previous test cases after the Exif image is written into a buffer (WriteDataL) called.
       
  1228 // Leaves with or returns proper error code.
       
  1229 // CHANGED:
       
  1230 // This feature is changed. Multiple usage is allowed any more. Test using the modifier after WriteDataL function.
       
  1231 void CExifModifyTest::ExifModify116L()
       
  1232 	{
       
  1233 	HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif);
       
  1234 	CleanupStack::PushL(exif);
       
  1235 	CExifModify* modify = CExifModify::NewL(*exif, CExifModify::EModify, CExifModify::ENoJpegParsing);
       
  1236 	CleanupStack::PushL(modify);
       
  1237 
       
  1238 	// Insert Tags
       
  1239 	TUint16 tmp1 = 0;
       
  1240 	TUint32 tmp3 = 0;
       
  1241 	TUint32 tmp4 = 0;
       
  1242 
       
  1243 	tmp3 = 72;
       
  1244 	tmp4 = 1;
       
  1245 	modify->SetXResolutionL(tmp3, tmp4);
       
  1246 	tmp1 = 2;
       
  1247 	modify->SetResolutionUnitL(tmp1);
       
  1248 
       
  1249 	modify->SetComponentsConfigurationL(1, 2, 3, 0);
       
  1250 	tmp1 = 1;
       
  1251 	modify->SetColorSpaceL(tmp1);
       
  1252 	tmp3 = 768;
       
  1253 	modify->SetPixelYDimensionL(tmp3);
       
  1254     modify->DeleteTag(EIfdExif, KIdPixelXDimension);
       
  1255 
       
  1256     HBufC8* buffer = NULL;
       
  1257     TRAPD( error, buffer = modify->WriteDataL( exif->Des() ) );
       
  1258     if( (error != KErrNotReady) || (buffer) )
       
  1259         {
       
  1260         if( buffer )
       
  1261             delete buffer;
       
  1262         buffer = 0;
       
  1263         if( error )
       
  1264             {
       
  1265             User::Leave( error);
       
  1266             }
       
  1267         User::Leave( KErrGeneral );
       
  1268         }
       
  1269 
       
  1270     TPtrC8 tmpDes;
       
  1271 
       
  1272     TRAP( error, buffer = modify->WriteDataL( tmpDes ) );
       
  1273     if( (error != KErrNotReady) || (buffer) )
       
  1274         {
       
  1275         if( buffer )
       
  1276             delete buffer;
       
  1277         buffer = 0;
       
  1278         if( error )
       
  1279             {
       
  1280             User::Leave( error);
       
  1281             }
       
  1282         User::Leave( KErrGeneral );
       
  1283         }
       
  1284 
       
  1285     modify->SetPixelXDimensionL(1024);
       
  1286     
       
  1287     TRAP( error, buffer = modify->WriteDataL( tmpDes ) );
       
  1288     if( (error != KErrNone) || (!buffer) )
       
  1289         {
       
  1290         if( buffer )
       
  1291             delete buffer;
       
  1292         buffer = 0;
       
  1293         if( error )
       
  1294             {
       
  1295             User::Leave( error);
       
  1296             }
       
  1297         User::Leave( KErrGeneral );
       
  1298         }
       
  1299     delete buffer;
       
  1300     buffer = 0;
       
  1301 
       
  1302     TRAP( error, buffer = modify->WriteDataL( exif->Des() ) );
       
  1303     if( (error != KErrNone) || (!buffer) )
       
  1304         {
       
  1305         if( buffer )
       
  1306             delete buffer;
       
  1307         buffer = 0;
       
  1308         if( error )
       
  1309             {
       
  1310             User::Leave( error);
       
  1311             }
       
  1312         User::Leave( KErrGeneral );
       
  1313         }
       
  1314 
       
  1315     CleanupStack::PushL(buffer);
       
  1316     RFile file;
       
  1317 	TBuf<255> fileName;
       
  1318     fileName.Copy(KRootOut);
       
  1319 	fileName.Append(_L("out\\"));
       
  1320 	fileName.Append(_L("Modify116_01.jpg"));
       
  1321 	if(file.Open(iFs, fileName, EFileWrite) != KErrNone)
       
  1322         {
       
  1323 		if(file.Create(iFs, fileName, EFileWrite) != KErrNone)
       
  1324             {
       
  1325             fileName.Copy(KRootC);
       
  1326 	        fileName.Append(_L("out\\"));
       
  1327 	        fileName.Append(_L("Modify116_01.jpg"));
       
  1328 	        if(file.Open(iFs, fileName, EFileWrite) != KErrNone)
       
  1329                 {
       
  1330 		        if(file.Create(iFs, fileName, EFileWrite) != KErrNone)
       
  1331                     {
       
  1332                     fileName.Copy(KRootData);
       
  1333 	                fileName.Append(_L("out\\"));
       
  1334 	                fileName.Append(_L("Modify116_01.jpg"));
       
  1335 	                if(file.Open(iFs, fileName, EFileWrite) != KErrNone)
       
  1336                         {
       
  1337                         User::LeaveIfError(file.Create(iFs, fileName, EFileWrite));    
       
  1338                         }
       
  1339                     }
       
  1340                 }
       
  1341             }
       
  1342         }
       
  1343  
       
  1344     file.Write(buffer->Des());
       
  1345     file.Close();
       
  1346     CleanupStack::PopAndDestroy(buffer);
       
  1347     buffer = 0;
       
  1348 
       
  1349     TRAP( error, buffer = modify->WriteDataL( tmpDes ) );
       
  1350     if( (error != KErrNone) || (!buffer) )
       
  1351         {
       
  1352         if( buffer )
       
  1353             delete buffer;
       
  1354         buffer = 0;
       
  1355         if( error )
       
  1356             {
       
  1357             User::Leave( error);
       
  1358             }
       
  1359         User::Leave( KErrGeneral );
       
  1360         }
       
  1361     delete buffer;
       
  1362     buffer = 0;
       
  1363 
       
  1364     TRAP( error, buffer = modify->WriteDataL( exif->Des() ) );
       
  1365     if( (error != KErrNone) || (!buffer) )
       
  1366         {
       
  1367         if( buffer )
       
  1368             delete buffer;
       
  1369         buffer = 0;
       
  1370         if( error )
       
  1371             {
       
  1372             User::Leave( error);
       
  1373             }
       
  1374         User::Leave( KErrGeneral );
       
  1375         }
       
  1376 
       
  1377     CleanupStack::PushL(buffer);
       
  1378     fileName.Copy(KRootOut);
       
  1379 	fileName.Append(_L("out\\"));
       
  1380 	fileName.Append(_L("Modify116_02.jpg"));
       
  1381 	if(file.Open(iFs, fileName, EFileWrite) != KErrNone)
       
  1382         {
       
  1383 		if(file.Create(iFs, fileName, EFileWrite) != KErrNone)
       
  1384             {
       
  1385             fileName.Copy(KRootC);
       
  1386 	        fileName.Append(_L("out\\"));
       
  1387 	        fileName.Append(_L("Modify116_02.jpg"));
       
  1388 	        if(file.Open(iFs, fileName, EFileWrite) != KErrNone)
       
  1389                 {
       
  1390 		        if(file.Create(iFs, fileName, EFileWrite) != KErrNone)
       
  1391                     {
       
  1392                     fileName.Copy(KRootData);
       
  1393 	                fileName.Append(_L("out\\"));
       
  1394 	                fileName.Append(_L("Modify116_02.jpg"));
       
  1395 	                if(file.Open(iFs, fileName, EFileWrite) != KErrNone)
       
  1396                         {
       
  1397                         User::LeaveIfError(file.Create(iFs, fileName, EFileWrite));    
       
  1398                         }
       
  1399                     }
       
  1400                 }
       
  1401             }
       
  1402         }
       
  1403  
       
  1404     file.Write(buffer->Des());
       
  1405     file.Close();
       
  1406     CleanupStack::PopAndDestroy(buffer);
       
  1407     buffer = 0;
       
  1408 
       
  1409     modify->DeleteTag(EIfdExif, KIdPixelXDimension);
       
  1410 
       
  1411     TRAP( error, buffer = modify->WriteDataL( exif->Des() ) );
       
  1412     if( (error != KErrNotReady) || (buffer) )
       
  1413         {
       
  1414         if( buffer )
       
  1415             delete buffer;
       
  1416         buffer = 0;
       
  1417         if( error )
       
  1418             {
       
  1419             User::Leave( error);
       
  1420             }
       
  1421         User::Leave( KErrGeneral );
       
  1422         }    
       
  1423 
       
  1424     TRAP( error, buffer = modify->WriteDataL( tmpDes ) );
       
  1425     if( (error != KErrNotReady) || (buffer) )
       
  1426         {
       
  1427         if( buffer )
       
  1428             delete buffer;
       
  1429         buffer = 0;
       
  1430         if( error )
       
  1431             {
       
  1432             User::Leave( error);
       
  1433             }
       
  1434         User::Leave( KErrGeneral );
       
  1435         }  
       
  1436 
       
  1437 	CleanupStack::PopAndDestroy(modify);
       
  1438 	CleanupStack::PopAndDestroy(exif);	
       
  1439 	}
       
  1440 
       
  1441 // Exif.Modify.118
       
  1442 // Try to retrieve the Exif APP1 segment when the Exif is not complete yet.
       
  1443 // Leaves with KErrNotReady.
       
  1444 void CExifModifyTest::ExifModify118L()
       
  1445 	{
       
  1446 	HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif);
       
  1447 	CleanupStack::PushL(exif);
       
  1448     CExifModify* modify = CExifModify::NewL( *exif, CExifModify::EModify );
       
  1449 	CleanupStack::PushL( modify );
       
  1450 
       
  1451     modify->DeleteTag( EIfd0, KIdXResolution );
       
  1452     HBufC8* appSegment = 0;
       
  1453     TRAPD( error, appSegment = modify->Reader()->GetExifAppSegmentL() );
       
  1454     if ( (error != KErrNotReady) || ( appSegment ) )
       
  1455         {
       
  1456         if ( appSegment )
       
  1457             delete appSegment;
       
  1458         User::Leave( KErrGeneral );
       
  1459         }
       
  1460 
       
  1461 	CleanupStack::PopAndDestroy( modify );
       
  1462 	CleanupStack::PopAndDestroy( exif );
       
  1463 	}
       
  1464 
       
  1465 // Exif.Modify.119
       
  1466 // Check NULL character at the end of ASCII type tags
       
  1467 // Returns error for invalid cases and behaves properly for other cases.
       
  1468 void CExifModifyTest::ExifModify119L()
       
  1469 	{
       
  1470 	HBufC8* exif = TUtils::ReadFileL(iFs, KValidExif);
       
  1471 	CleanupStack::PushL(exif);
       
  1472     CExifModify* modify = CExifModify::NewL( *exif, CExifModify::EModify );
       
  1473 	CleanupStack::PushL( modify );
       
  1474 
       
  1475 	HBufC8* buf = TUtils::CreateDummyBufL(19);
       
  1476 	CleanupStack::PushL(buf);
       
  1477     buf->Des().Copy(_L("2004:01:19 11:00:00"));
       
  1478     modify->SetDateTimeOriginalL(buf->Des());
       
  1479 	CleanupStack::PopAndDestroy(buf);
       
  1480 	buf = 0;
       
  1481     buf = modify->Reader()->GetDateTimeOriginalL();
       
  1482     CleanupStack::PushL(buf);
       
  1483     if ( ( buf->Des().Ptr()[buf->Des().Length() - 1] != NULL ) &&
       
  1484         ( buf->Des().Length() != 20 ) )
       
  1485         {
       
  1486         User::Leave( KErrGeneral );
       
  1487         }
       
  1488 	CleanupStack::PopAndDestroy(buf);
       
  1489 	buf = 0;
       
  1490 
       
  1491 	buf = TUtils::CreateDummyBufL(20);
       
  1492 	CleanupStack::PushL(buf);
       
  1493     buf->Des().Copy(_L("2004:01:19 11:00:00\0"));
       
  1494     modify->SetDateTimeOriginalL(buf->Des());
       
  1495 	CleanupStack::PopAndDestroy(buf);
       
  1496 	buf = 0;
       
  1497     buf = modify->Reader()->GetDateTimeOriginalL();
       
  1498     CleanupStack::PushL(buf);
       
  1499     if ( ( buf->Des().Ptr()[buf->Des().Length() - 1] != NULL ) &&
       
  1500         ( buf->Des().Length() != 20 ) )
       
  1501         {
       
  1502         User::Leave( KErrGeneral );
       
  1503         }
       
  1504 	CleanupStack::PopAndDestroy(buf);
       
  1505 	buf = 0;
       
  1506 
       
  1507 	buf = TUtils::CreateDummyBufL(18);
       
  1508 	CleanupStack::PushL(buf);
       
  1509     buf->Des().Copy(_L("2004:01:19 11:00:0"));
       
  1510     TRAPD( error, modify->SetDateTimeOriginalL(buf->Des()) );
       
  1511     if ( error != KErrNotSupported )
       
  1512         {
       
  1513         User::LeaveIfError( error );
       
  1514         User::Leave( KErrGeneral );
       
  1515         }
       
  1516 	CleanupStack::PopAndDestroy(buf);
       
  1517 	buf = 0;
       
  1518 
       
  1519 	buf = TUtils::CreateDummyBufL(20);
       
  1520 	CleanupStack::PushL(buf);
       
  1521     buf->Des().Copy(_L("2004:01:19 11:00:001"));
       
  1522     TRAP( error, modify->SetDateTimeOriginalL(buf->Des()) );
       
  1523     if ( error != KErrNotSupported )
       
  1524         {
       
  1525         User::LeaveIfError( error );
       
  1526         User::Leave( KErrGeneral );
       
  1527         }
       
  1528 	CleanupStack::PopAndDestroy(buf);
       
  1529 	buf = 0;
       
  1530 
       
  1531 	buf = TUtils::CreateDummyBufL(12);
       
  1532 	CleanupStack::PushL(buf);
       
  1533 	TExifTagInfo tag(KIdRelatedSoundFile, CExifTag::ETagAscii, 12);
       
  1534 	modify->SetTagL(EIfdExif, tag, buf->Des());
       
  1535 	CleanupStack::PopAndDestroy(buf);
       
  1536     buf = modify->Reader()->GetRelatedSoundFileL();
       
  1537     CleanupStack::PushL(buf);
       
  1538     if ( ( buf->Des().Ptr()[buf->Des().Length() - 1] != NULL ) &&
       
  1539         ( buf->Des().Length() != 13 ) )
       
  1540         {
       
  1541         User::Leave( KErrGeneral );
       
  1542         }
       
  1543 	CleanupStack::PopAndDestroy(buf);
       
  1544 	buf = 0;
       
  1545 
       
  1546 	buf = TUtils::CreateDummyBufL(13);
       
  1547 	CleanupStack::PushL(buf);
       
  1548 	TExifTagInfo tag2(KIdRelatedSoundFile, CExifTag::ETagAscii, 13);
       
  1549     *( CONST_CAST( TUint8*, buf->Des().Ptr()) + 12 ) = NULL;
       
  1550 	modify->SetTagL(EIfdExif, tag2, buf->Des());
       
  1551 	CleanupStack::PopAndDestroy(buf);
       
  1552     buf = modify->Reader()->GetRelatedSoundFileL();
       
  1553     CleanupStack::PushL(buf);
       
  1554     if ( ( buf->Des().Ptr()[buf->Des().Length() - 1] != NULL ) &&
       
  1555         ( buf->Des().Length() != 13 ) )
       
  1556         {
       
  1557         User::Leave( KErrGeneral );
       
  1558         }
       
  1559 	CleanupStack::PopAndDestroy(buf);
       
  1560 	buf = 0;
       
  1561 
       
  1562 	buf = TUtils::CreateDummyBufL(14);
       
  1563 	CleanupStack::PushL(buf);
       
  1564     *( CONST_CAST( TUint8*, buf->Des().Ptr()) + 13 ) = NULL;
       
  1565 	TExifTagInfo tag3(KIdRelatedSoundFile, CExifTag::ETagAscii, 14);
       
  1566 	TRAP( error, modify->SetTagL(EIfdExif, tag3, buf->Des()) );
       
  1567     if ( error != KErrNotSupported )
       
  1568         {
       
  1569         User::LeaveIfError( error );
       
  1570         User::Leave( KErrGeneral );
       
  1571         }
       
  1572 	CleanupStack::PopAndDestroy(buf);
       
  1573     buf = 0;
       
  1574 
       
  1575 	buf = TUtils::CreateDummyBufL(11);
       
  1576 	CleanupStack::PushL(buf);
       
  1577 	TExifTagInfo tag4(KIdRelatedSoundFile, CExifTag::ETagAscii, 11);
       
  1578 	TRAP( error, modify->SetTagL(EIfdExif, tag4, buf->Des()) );
       
  1579     if ( error != KErrNotSupported )
       
  1580         {
       
  1581         User::LeaveIfError( error );
       
  1582         User::Leave( KErrGeneral );
       
  1583         }
       
  1584 	CleanupStack::PopAndDestroy(buf);
       
  1585     buf = 0;
       
  1586 
       
  1587 	CleanupStack::PopAndDestroy( modify );
       
  1588 	CleanupStack::PopAndDestroy( exif );
       
  1589 	}
       
  1590 
       
  1591 // Exif.Modify.117
       
  1592 // Test the behavior of the previous test cases in OOM situations.
       
  1593 // Successfully operates or leaves with OOM error, without any memory leaks.
       
  1594 void CExifModifyTest::ExifModify117L()
       
  1595 	{
       
  1596     // OOM in EXIF.Modify.101- EXIF.Modify.116
       
  1597 	TInt error = KErrGeneral;
       
  1598 	TInt i = 0;
       
  1599 
       
  1600 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1601 	RDebug::Print(_L("ExifModify101L() memory test"));
       
  1602 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1603 	for(i = 1; i < 500; i++)
       
  1604 #else
       
  1605     for(i = 1; i < 10; i++)
       
  1606 #endif
       
  1607 		{
       
  1608 		__UHEAP_MARK;
       
  1609 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1610 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1611 #else
       
  1612         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1613 #endif
       
  1614 		TRAP(error, ExifModify101L());
       
  1615 		if(error)
       
  1616 			{
       
  1617 			if(error != KErrNoMemory)
       
  1618 				{
       
  1619 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1620 				User::Leave(KErrGeneral);
       
  1621 				}
       
  1622 			}
       
  1623 		else
       
  1624 			{
       
  1625 			__UHEAP_MARKEND;
       
  1626 			break;
       
  1627 			}
       
  1628 		__UHEAP_MARKEND;
       
  1629 		}
       
  1630 
       
  1631 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1632 	RDebug::Print(_L("ExifModify102L() memory test"));
       
  1633 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1634 	for(i = 1; i < 500; i++)
       
  1635 #else
       
  1636     for(i = 1; i < 10; i++)
       
  1637 #endif
       
  1638 		{
       
  1639 		__UHEAP_MARK;
       
  1640 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1641 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1642 #else
       
  1643         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1644 #endif
       
  1645 		TRAP(error, ExifModify102L());
       
  1646 		if(error)
       
  1647 			{
       
  1648 			if(error != KErrNoMemory)
       
  1649 				{
       
  1650 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1651 				User::Leave(KErrGeneral);
       
  1652 				}
       
  1653 			}
       
  1654 		else
       
  1655 			{
       
  1656 			__UHEAP_MARKEND;
       
  1657 			break;
       
  1658 			}
       
  1659 		__UHEAP_MARKEND;
       
  1660 		}
       
  1661 
       
  1662 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1663 	RDebug::Print(_L("ExifModify103L() memory test"));
       
  1664 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1665 	for(i = 1; i < 500; i++)
       
  1666 #else
       
  1667     for(i = 1; i < 10; i++)
       
  1668 #endif
       
  1669 		{
       
  1670 		__UHEAP_MARK;
       
  1671 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1672 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1673 #else
       
  1674         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1675 #endif
       
  1676 		TRAP(error, ExifModify103L());
       
  1677 		if(error)
       
  1678 			{
       
  1679 			if(error != KErrNoMemory)
       
  1680 				{
       
  1681 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1682 				User::Leave(KErrGeneral);
       
  1683 				}
       
  1684 			}
       
  1685 		else
       
  1686 			{
       
  1687 			__UHEAP_MARKEND;
       
  1688 			break;
       
  1689 			}
       
  1690 		__UHEAP_MARKEND;
       
  1691 		}
       
  1692 
       
  1693 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1694 	RDebug::Print(_L("ExifModify104L() memory test"));
       
  1695 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1696 	for(i = 1; i < 500; i++)
       
  1697 #else
       
  1698     for(i = 1; i < 10; i++)
       
  1699 #endif
       
  1700 		{
       
  1701 		__UHEAP_MARK;
       
  1702 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1703 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1704 #else
       
  1705         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1706 #endif
       
  1707 		TRAP(error, ExifModify104L());
       
  1708 		if(error)
       
  1709 			{
       
  1710 			if(error != KErrNoMemory)
       
  1711 				{
       
  1712 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1713 				User::Leave(KErrGeneral);
       
  1714 				}
       
  1715 			}
       
  1716 		else
       
  1717 			{
       
  1718 			__UHEAP_MARKEND;
       
  1719 			break;
       
  1720 			}
       
  1721 		__UHEAP_MARKEND;
       
  1722 		}
       
  1723 
       
  1724 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1725 	RDebug::Print(_L("ExifModify105L() memory test"));
       
  1726 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1727 	for(i = 1; i < 500; i++)
       
  1728 #else
       
  1729     for(i = 1; i < 10; i++)
       
  1730 #endif
       
  1731 		{
       
  1732 		__UHEAP_MARK;
       
  1733 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1734 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1735 #else
       
  1736         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1737 #endif
       
  1738 		TRAP(error, ExifModify105L());
       
  1739 		if(error)
       
  1740 			{
       
  1741 			if(error != KErrNoMemory)
       
  1742 				{
       
  1743 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1744 				User::Leave(KErrGeneral);
       
  1745 				}
       
  1746 			}
       
  1747 		else
       
  1748 			{
       
  1749 			__UHEAP_MARKEND;
       
  1750 			break;
       
  1751 			}
       
  1752 		__UHEAP_MARKEND;
       
  1753 		}
       
  1754 
       
  1755 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1756 	RDebug::Print(_L("ExifModify106L() memory test"));
       
  1757 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1758 	for(i = 1; i < 500; i++)
       
  1759 #else
       
  1760     for(i = 1; i < 10; i++)
       
  1761 #endif
       
  1762 		{
       
  1763 		__UHEAP_MARK;
       
  1764 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1765 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1766 #else
       
  1767         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1768 #endif
       
  1769 		TRAP(error, ExifModify106L());
       
  1770 		if(error)
       
  1771 			{
       
  1772 			if(error != KErrNoMemory)
       
  1773 				{
       
  1774 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1775 				User::Leave(KErrGeneral);
       
  1776 				}
       
  1777 			}
       
  1778 		else
       
  1779 			{
       
  1780 			__UHEAP_MARKEND;
       
  1781 			break;
       
  1782 			}
       
  1783 		__UHEAP_MARKEND;
       
  1784 		}
       
  1785 
       
  1786 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1787 	RDebug::Print(_L("ExifModify107L() memory test"));
       
  1788 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1789 	for(i = 1; i < 500; i++)
       
  1790 #else
       
  1791     for(i = 1; i < 10; i++)
       
  1792 #endif
       
  1793 		{
       
  1794 		__UHEAP_MARK;
       
  1795 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1796 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1797 #else
       
  1798         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1799 #endif
       
  1800 		TRAP(error, ExifModify107L());
       
  1801 		if(error)
       
  1802 			{
       
  1803 			if(error != KErrNoMemory)
       
  1804 				{
       
  1805 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1806 				User::Leave(KErrGeneral);
       
  1807 				}
       
  1808 			}
       
  1809 		else
       
  1810 			{
       
  1811 			__UHEAP_MARKEND;
       
  1812 			break;
       
  1813 			}
       
  1814 		__UHEAP_MARKEND;
       
  1815 		}
       
  1816 
       
  1817 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1818 	RDebug::Print(_L("ExifModify108L() memory test"));
       
  1819 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1820 	for(i = 1; i < 500; i++)
       
  1821 #else
       
  1822     for(i = 1; i < 10; i++)
       
  1823 #endif
       
  1824 		{
       
  1825 		__UHEAP_MARK;
       
  1826 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1827 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1828 #else
       
  1829         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1830 #endif
       
  1831 		TRAP(error, ExifModify108L());
       
  1832 		if(error)
       
  1833 			{
       
  1834 			if(error != KErrNoMemory)
       
  1835 				{
       
  1836 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1837 				User::Leave(KErrGeneral);
       
  1838 				}
       
  1839 			}
       
  1840 		else
       
  1841 			{
       
  1842 			__UHEAP_MARKEND;
       
  1843 			break;
       
  1844 			}
       
  1845 		__UHEAP_MARKEND;
       
  1846 		}
       
  1847 
       
  1848 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1849 	RDebug::Print(_L("ExifModify109L() memory test"));
       
  1850 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1851 	for(i = 1; i < 500; i++)
       
  1852 #else
       
  1853     for(i = 1; i < 10; i++)
       
  1854 #endif
       
  1855 		{
       
  1856 		__UHEAP_MARK;
       
  1857 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1858 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1859 #else
       
  1860         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1861 #endif
       
  1862 		TRAP(error, ExifModify109L());
       
  1863 		if(error)
       
  1864 			{
       
  1865 			if(error != KErrNoMemory)
       
  1866 				{
       
  1867 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1868 				User::Leave(KErrGeneral);
       
  1869 				}
       
  1870 			}
       
  1871 		else
       
  1872 			{
       
  1873 			__UHEAP_MARKEND;
       
  1874 			break;
       
  1875 			}
       
  1876 		__UHEAP_MARKEND;
       
  1877 		}
       
  1878 
       
  1879 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1880 	RDebug::Print(_L("ExifModify110L() memory test"));
       
  1881 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1882 	for(i = 1; i < 500; i++)
       
  1883 #else
       
  1884     for(i = 1; i < 10; i++)
       
  1885 #endif
       
  1886 		{
       
  1887 		__UHEAP_MARK;
       
  1888 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1889 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1890 #else
       
  1891         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1892 #endif
       
  1893 		TRAP(error, ExifModify110L());
       
  1894 		if(error)
       
  1895 			{
       
  1896 			if(error != KErrNoMemory)
       
  1897 				{
       
  1898 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1899 				User::Leave(KErrGeneral);
       
  1900 				}
       
  1901 			}
       
  1902 		else
       
  1903 			{
       
  1904 			__UHEAP_MARKEND;
       
  1905 			break;
       
  1906 			}
       
  1907 		__UHEAP_MARKEND;
       
  1908 		}
       
  1909 
       
  1910 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1911 	RDebug::Print(_L("ExifModify111L() memory test"));
       
  1912 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1913 	for(i = 1; i < 500; i++)
       
  1914 #else
       
  1915     for(i = 1; i < 10; i++)
       
  1916 #endif
       
  1917 		{
       
  1918 		__UHEAP_MARK;
       
  1919 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1920 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1921 #else
       
  1922         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1923 #endif
       
  1924 		TRAP(error, ExifModify111L());
       
  1925 		if(error)
       
  1926 			{
       
  1927 			if(error != KErrNoMemory)
       
  1928 				{
       
  1929 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1930 				User::Leave(KErrGeneral);
       
  1931 				}
       
  1932 			}
       
  1933 		else
       
  1934 			{
       
  1935 			__UHEAP_MARKEND;
       
  1936 			break;
       
  1937 			}
       
  1938 		__UHEAP_MARKEND;
       
  1939 		}
       
  1940 
       
  1941 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1942 	RDebug::Print(_L("ExifModify112L() memory test"));
       
  1943 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1944 	for(i = 1; i < 500; i++)
       
  1945 #else
       
  1946     for(i = 1; i < 10; i++)
       
  1947 #endif
       
  1948 		{
       
  1949 		__UHEAP_MARK;
       
  1950 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1951 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1952 #else
       
  1953         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1954 #endif
       
  1955 		TRAP(error, ExifModify112L());
       
  1956 		if(error)
       
  1957 			{
       
  1958 			if(error != KErrNoMemory)
       
  1959 				{
       
  1960 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1961 				User::Leave(KErrGeneral);
       
  1962 				}
       
  1963 			}
       
  1964 		else
       
  1965 			{
       
  1966 			__UHEAP_MARKEND;
       
  1967 			break;
       
  1968 			}
       
  1969 		__UHEAP_MARKEND;
       
  1970 		}
       
  1971 
       
  1972 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1973 	RDebug::Print(_L("ExifModify113L() memory test"));
       
  1974 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1975 	for(i = 1; i < 500; i++)
       
  1976 #else
       
  1977     for(i = 1; i < 10; i++)
       
  1978 #endif
       
  1979 		{
       
  1980 		__UHEAP_MARK;
       
  1981 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  1982 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  1983 #else
       
  1984         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  1985 #endif
       
  1986 		TRAP(error, ExifModify113L());
       
  1987 		if(error)
       
  1988 			{
       
  1989 			if(error != KErrNoMemory)
       
  1990 				{
       
  1991 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  1992 				User::Leave(KErrGeneral);
       
  1993 				}
       
  1994 			}
       
  1995 		else
       
  1996 			{
       
  1997 			__UHEAP_MARKEND;
       
  1998 			break;
       
  1999 			}
       
  2000 		__UHEAP_MARKEND;
       
  2001 		}
       
  2002 
       
  2003 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  2004 	RDebug::Print(_L("ExifModify114L() memory test"));
       
  2005 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  2006 	for(i = 1; i < 500; i++)
       
  2007 #else
       
  2008     for(i = 1; i < 10; i++)
       
  2009 #endif
       
  2010 		{
       
  2011 		__UHEAP_MARK;
       
  2012 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  2013 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  2014 #else
       
  2015         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  2016 #endif
       
  2017 		TRAP(error, ExifModify114L());
       
  2018 		if(error)
       
  2019 			{
       
  2020 			if(error != KErrNoMemory)
       
  2021 				{
       
  2022 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  2023 				User::Leave(KErrGeneral);
       
  2024 				}
       
  2025 			}
       
  2026 		else
       
  2027 			{
       
  2028 			__UHEAP_MARKEND;
       
  2029 			break;
       
  2030 			}
       
  2031 		__UHEAP_MARKEND;
       
  2032 		}
       
  2033 
       
  2034 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  2035 	RDebug::Print(_L("ExifModify115L() memory test"));
       
  2036 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  2037 	for(i = 1; i < 500; i++)
       
  2038 #else
       
  2039     for(i = 1; i < 10; i++)
       
  2040 #endif
       
  2041 		{
       
  2042 		__UHEAP_MARK;
       
  2043 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  2044 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  2045 #else
       
  2046         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  2047 #endif
       
  2048 		TRAP(error, ExifModify115L());
       
  2049 		if(error)
       
  2050 			{
       
  2051 			if(error != KErrNoMemory)
       
  2052 				{
       
  2053 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  2054 				User::Leave(KErrGeneral);
       
  2055 				}
       
  2056 			}
       
  2057 		else
       
  2058 			{
       
  2059 			__UHEAP_MARKEND;
       
  2060 			break;
       
  2061 			}
       
  2062 		__UHEAP_MARKEND;
       
  2063 		}
       
  2064 
       
  2065 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  2066 	RDebug::Print(_L("ExifModify116L() memory test"));
       
  2067 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  2068 	for(i = 1; i < 500; i++)
       
  2069 #else
       
  2070     for(i = 1; i < 10; i++)
       
  2071 #endif
       
  2072 		{
       
  2073 		__UHEAP_MARK;
       
  2074 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  2075 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  2076 #else
       
  2077         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  2078 #endif
       
  2079 		TRAP(error, ExifModify116L());
       
  2080 		if(error)
       
  2081 			{
       
  2082 			if(error != KErrNoMemory)
       
  2083 				{
       
  2084 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  2085 				User::Leave(KErrGeneral);
       
  2086 				}
       
  2087 			}
       
  2088 		else
       
  2089 			{
       
  2090 			__UHEAP_MARKEND;
       
  2091 			break;
       
  2092 			}
       
  2093 		__UHEAP_MARKEND;
       
  2094 		}
       
  2095 
       
  2096 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  2097 	RDebug::Print(_L("ExifModify118L() memory test"));
       
  2098 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  2099 	for(i = 1; i < 500; i++)
       
  2100 #else
       
  2101     for(i = 1; i < 10; i++)
       
  2102 #endif
       
  2103 		{
       
  2104 		__UHEAP_MARK;
       
  2105 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  2106 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  2107 #else
       
  2108         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  2109 #endif
       
  2110 		TRAP(error, ExifModify118L());
       
  2111 		if(error)
       
  2112 			{
       
  2113 			if(error != KErrNoMemory)
       
  2114 				{
       
  2115 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  2116 				User::Leave(KErrGeneral);
       
  2117 				}
       
  2118 			}
       
  2119 		else
       
  2120 			{
       
  2121 			__UHEAP_MARKEND;
       
  2122 			break;
       
  2123 			}
       
  2124 		__UHEAP_MARKEND;
       
  2125 		}
       
  2126 
       
  2127 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  2128 	RDebug::Print(_L("ExifModify119L() memory test"));
       
  2129 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  2130 	for(i = 1; i < 500; i++)
       
  2131 #else
       
  2132     for(i = 1; i < 10; i++)
       
  2133 #endif
       
  2134 		{
       
  2135 		__UHEAP_MARK;
       
  2136 #if ( ( defined __WINS__ ) || ( defined __WINSCW__) )
       
  2137 		__UHEAP_SETFAIL( RHeap::EFailNext, i );
       
  2138 #else
       
  2139         __UHEAP_SETFAIL( RHeap::ERandom, i );
       
  2140 #endif
       
  2141 		TRAP(error, ExifModify119L());
       
  2142 		if(error)
       
  2143 			{
       
  2144 			if(error != KErrNoMemory)
       
  2145 				{
       
  2146 				__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  2147 				User::Leave(KErrGeneral);
       
  2148 				}
       
  2149 			}
       
  2150 		else
       
  2151 			{
       
  2152 			__UHEAP_MARKEND;
       
  2153 			break;
       
  2154 			}
       
  2155 		__UHEAP_MARKEND;
       
  2156 		}
       
  2157 
       
  2158 	__UHEAP_SETFAIL( RHeap::ENone, 0 );
       
  2159 	}
       
  2160