textrendering/texthandling/ttext/T_PICRES.CPP
changeset 51 a7c938434754
parent 0 1fb32624e06b
child 55 336bee5c2d35
equal deleted inserted replaced
44:601ab138ba0b 51:a7c938434754
     1 /*
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    20 #include <e32base.h>
    20 #include <e32base.h>
    21 
    21 
    22 #include <gdi.h>
    22 #include <gdi.h>
    23 #include <conpics.h>
    23 #include <conpics.h>
    24 #include <s32file.h>
    24 #include <s32file.h>
    25 #include <e32test.h>
       
    26 
    25 
    27 #include <txtrich.h>
    26 #include <txtrich.h>
    28 #include <txtfmlyr.h>
    27 #include <txtfmlyr.h>
    29 #include "TXTMRTSR.H"
    28 #include "TXTMRTSR.H"
    30 
    29 
    31 #include "../incp/T_PMLPAR.H"
    30 #include "../incp/T_PMLPAR.H"
       
    31 #include "T_PICRES.h"
       
    32 
       
    33 LOCAL_D CTestStep *pTestStep = NULL;
       
    34 #define test(cond)											\
       
    35 	{														\
       
    36 	TBool __bb = (cond);									\
       
    37 	pTestStep->TEST(__bb);									\
       
    38 	if (!__bb)												\
       
    39 		{													\
       
    40 		pTestStep->ERR_PRINTF1(_L("ERROR: Test Failed"));	\
       
    41 		User::Leave(1);										\
       
    42 		}													\
       
    43 	}
       
    44 #undef INFO_PRINTF1
       
    45 #undef INFO_PRINTF2
       
    46 // copy from tefexportconst.h
       
    47 #define INFO_PRINTF1(p1)        pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1))
       
    48 #define INFO_PRINTF2(p1, p2)    pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2))
       
    49 
    32 
    50 
    33 #define UNUSED_VAR(a) a = a
    51 #define UNUSED_VAR(a) a = a
    34 
    52 
    35 const TInt KTestCleanupStack=0x40;
    53 const TInt KTestCleanupStack=0x40;
    36 
    54 
    53 	CRichText* iText;
    71 	CRichText* iText;
    54 	const CParaFormatLayer* iGlobalParaFormatLayer;
    72 	const CParaFormatLayer* iGlobalParaFormatLayer;
    55 	const CCharFormatLayer* iGlobalCharFormatLayer;
    73 	const CCharFormatLayer* iGlobalCharFormatLayer;
    56 	};
    74 	};
    57 
    75 
    58 
       
    59 LOCAL_D RTest test(_L("Testing Picture Restorer mechanism"));
       
    60 LOCAL_D CTrapCleanup* TheTrapCleanup;
    76 LOCAL_D CTrapCleanup* TheTrapCleanup;
    61 LOCAL_D RFs TheFs;  // the file server
    77 LOCAL_D RFs TheFs;  // the file server
    62 LOCAL_D RFile TheFile;  // the data file
    78 LOCAL_D RFile TheFile;  // the data file
    63 LOCAL_D CFileStore* TheStore;  // concrete CStreamStore
    79 LOCAL_D CFileStore* TheStore;  // concrete CStreamStore
    64 LOCAL_D CParser* TheParser;
    80 LOCAL_D CParser* TheParser;
   360 //
   376 //
   361 //  Now store the stuff again
   377 //  Now store the stuff again
   362 	TRAPD(ret,
   378 	TRAPD(ret,
   363 	TheContainer->iText->DetachFromStoreL(CPicture::EDetachFull));
   379 	TheContainer->iText->DetachFromStoreL(CPicture::EDetachFull));
   364 	if (ret==KErrNotSupported)
   380 	if (ret==KErrNotSupported)
   365 		test.Printf(_L("   SIMULATION: Some picture data is not supported by the current factory."));
   381 	    INFO_PRINTF1(_L("   SIMULATION: Some picture data is not supported by the current factory."));
   366 //	if (aAlwaysFailToLoad)
   382 //	if (aAlwaysFailToLoad)
   367 //		test(error==KErrNotFound);
   383 //		test(error==KErrNotFound);
   368 //	else
   384 //	else
   369 //		test(error==KErrNone);
   385 //		test(error==KErrNone);
   370 	id=KNullStreamId;
   386 	id=KNullStreamId;
   377 	delete (CParaFormatLayer*)TheContainer->iGlobalParaFormatLayer;
   393 	delete (CParaFormatLayer*)TheContainer->iGlobalParaFormatLayer;
   378 	delete (CCharFormatLayer*)TheContainer->iGlobalCharFormatLayer;
   394 	delete (CCharFormatLayer*)TheContainer->iGlobalCharFormatLayer;
   379     TheContainer->RestoreL(*TheStore,id,factory);
   395     TheContainer->RestoreL(*TheStore,id,factory);
   380 	TInt pictureCount=TheContainer->iText->PictureCount();
   396 	TInt pictureCount=TheContainer->iText->PictureCount();
   381 	if (aAlwaysFailToLoad)
   397 	if (aAlwaysFailToLoad)
       
   398 	    {
   382 		test(pictureCount==1);
   399 		test(pictureCount==1);
       
   400 	    }
   383 	else
   401 	else
       
   402 	    {
   384 		test(pictureCount==3);
   403 		test(pictureCount==3);
       
   404 	    }
   385 //
   405 //
   386 	delete factory;
   406 	delete factory;
   387 	CleanupStack::PopAndDestroy();  // TheStore
   407 	CleanupStack::PopAndDestroy();  // TheStore
   388 	TheFs.Close();
   408 	TheFs.Close();
   389     }
   409     }
   391 
   411 
   392 LOCAL_C  void GoL()
   412 LOCAL_C  void GoL()
   393 // Run the tests
   413 // Run the tests
   394 //
   414 //
   395 	{
   415 	{
   396 	test.Start(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_PICRES-0001 RichText Storing - with pictures deferred loading "));
   416 	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_PICRES-0001 RichText Storing - with pictures deferred loading "));
   397 	TheContainer=CContainer::NewL();
   417 	TheContainer=CContainer::NewL();
   398 	TRAPD(r,
   418 	TRAPD(r,
   399 	testPictureRestorer());
   419 	testPictureRestorer());
   400 	test(r==KErrNone);
   420 	test(r==KErrNone);
   401 	delete TheContainer;  // deletes the rich text, which deletes the contained pictures.
   421 	delete TheContainer;  // deletes the rich text, which deletes the contained pictures.
   402 	//
   422 	//
   403 	//
   423 	//
   404 	test.Next(_L("RichText Storing - with pictures auto loading"));
   424 	INFO_PRINTF1(_L("RichText Storing - with pictures auto loading"));
   405 	TheContainer=CContainer::NewL();
   425 	TheContainer=CContainer::NewL();
   406 	TRAP(r,
   426 	TRAP(r,
   407 	testPictureRestorer(EFalse));  // DO NOT DEFER PICTURE LOADING
   427 	testPictureRestorer(EFalse));  // DO NOT DEFER PICTURE LOADING
   408 	test(r==KErrNone);
   428 	test(r==KErrNone);
   409 	delete TheContainer;  // deletes the rich text, which deletes the contained pictures.
   429 	delete TheContainer;  // deletes the rich text, which deletes the contained pictures.
   410 //
   430 //
   411 //
   431 //
   412 //
   432 //
   413 	test.Next(_L("Testing no missing picture app's"));
   433 	INFO_PRINTF1(_L("Testing no missing picture app's"));
   414 	TheContainer=CContainer::NewL();
   434 	TheContainer=CContainer::NewL();
   415 	TRAP(r,
   435 	TRAP(r,
   416 	testPictureRestorer2());
   436 	testPictureRestorer2());
   417 	test(r==KErrNone);
   437 	test(r==KErrNone);
   418 	delete TheContainer;  // deletes the rich text, which deletes the contained pictures.
   438 	delete TheContainer;  // deletes the rich text, which deletes the contained pictures.
   419 	//
   439 	//
   420 	//
   440 	//
   421 /*
   441 /*
   422 	TEST NOW REDUNDANT AS OF NEW PICTURE CONTAINMENT MECHANISM AS AT RELEASE 073
   442 	TEST NOW REDUNDANT AS OF NEW PICTURE CONTAINMENT MECHANISM AS AT RELEASE 073
   423 
   443 
   424 	test.Next(_L("Testing missing picture app's"));
   444 	INFO_PRINTF1(_L("Testing missing picture app's"));
   425 	TheContainer=CContainer::NewL();
   445 	TheContainer=CContainer::NewL();
   426 	TRAP(r,
   446 	TRAP(r,
   427 	testPictureRestorer2(ETrue));  // ALWAYS FAIL TO DETACH FROM STORE
   447 	testPictureRestorer2(ETrue));  // ALWAYS FAIL TO DETACH FROM STORE
   428 	test(r==KErrNone);
   448 	test(r==KErrNone);
   429 	delete TheContainer;  // deletes the rich text, which deletes the contained pictures.
   449 	delete TheContainer;  // deletes the rich text, which deletes the contained pictures.
   475 		{
   495 		{
   476 		RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
   496 		RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
   477 		}
   497 		}
   478 	}
   498 	}
   479 
   499 
   480 GLDEF_C TInt E32Main()
   500 CT_PICRES::CT_PICRES()
   481 //
       
   482 // Test the streaming framework.
       
   483 //
       
   484     {
   501     {
   485 
   502     SetTestStepName(KTestStep_T_PICRES);
   486 	test.Title();
   503     pTestStep = this;
       
   504     }
       
   505 
       
   506 TVerdict CT_PICRES::doTestStepL()
       
   507     {
       
   508     SetTestStepResult(EFail);
       
   509 
       
   510     INFO_PRINTF1(_L("Testing Picture Restorer mechanism"));
   487     __UHEAP_MARK;
   511     __UHEAP_MARK;
   488 	setupCleanup();
   512     setupCleanup();
   489 	TRAPD(r,GoL());
   513     TRAPD(r,GoL());
   490     test(r == KErrNone);
   514 
   491 
   515     delete TheTrapCleanup;
   492 	delete TheTrapCleanup;
   516     
   493 	
   517     __UHEAP_MARKEND;
   494 	__UHEAP_MARKEND;
   518     
   495 	
   519     ::DeleteDataFile(KOutputFile);      //deletion of data files must be before call to End() - DEF047652
   496 	::DeleteDataFile(KOutputFile);		//deletion of data files must be before call to End() - DEF047652
   520     ::DeleteDataFile(KOutputFile1); 
   497 	::DeleteDataFile(KOutputFile1);	
   521 
   498 	
   522     if (r == KErrNone)
   499 	test.End();
   523         {
   500 	test.Close();
   524         SetTestStepResult(EPass);
   501 
   525         }
   502 	return 0;
   526 
       
   527     return TestStepResult();
   503     }
   528     }