sl@0: /* sl@0: * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "../incp/T_PMLPAR.H" sl@0: #include "TRTCOPY.h" sl@0: sl@0: #define test(cond) \ sl@0: { \ sl@0: TBool __bb = (cond); \ sl@0: TEST(__bb); \ sl@0: if (!__bb) \ sl@0: { \ sl@0: ERR_PRINTF1(_L("ERROR: Test Failed")); \ sl@0: User::Leave(1); \ sl@0: } \ sl@0: } sl@0: sl@0: LOCAL_D RFs theFs; sl@0: LOCAL_D CRichText* ComponentText; sl@0: LOCAL_D CParaFormatLayer* GlobalParaFormatLayer; sl@0: LOCAL_D CCharFormatLayer* GlobalCharFormatLayer; sl@0: LOCAL_D CTrapCleanup* TheTrapCleanup; sl@0: LOCAL_D CParser* TheParser; sl@0: sl@0: const TInt KTestCleanupStack=0x500; sl@0: sl@0: sl@0: CRichText* CT_TRTCOPY::LoadIntoTextL(TFileName& aFileName) sl@0: // sl@0: { sl@0: TRAPD(ret, sl@0: TheParser=CParser::NewL()); sl@0: CRichText* text=NULL; sl@0: TRAP(ret, sl@0: text=TheParser->ParseL(aFileName)); sl@0: GlobalParaFormatLayer=(CParaFormatLayer*)text->GlobalParaFormatLayer(); sl@0: GlobalCharFormatLayer=(CCharFormatLayer*)text->GlobalCharFormatLayer(); sl@0: delete TheParser; sl@0: TheParser=NULL; sl@0: return text; sl@0: } sl@0: sl@0: /* sl@0: CStyleList* CT_TRTCOPY::CreatePopulatedStyleList() sl@0: // sl@0: { sl@0: // sl@0: // Create style aswell. sl@0: CStyleList* list=CStyleList::NewL(); sl@0: CParagraphStyle* style1=CParagraphStyle::NewL(*GlobalParaFormatLayer,*GlobalCharFormatLayer); sl@0: CParagraphStyle* style2=CParagraphStyle::NewL(*GlobalParaFormatLayer,*GlobalCharFormatLayer); sl@0: CParagraphStyle* style3=CParagraphStyle::NewL(*GlobalParaFormatLayer,*GlobalCharFormatLayer); sl@0: list->AppendL(*style1); sl@0: list->AppendL(*style2); sl@0: list->AppendL(*style3); sl@0: return list; sl@0: } sl@0: */ sl@0: sl@0: void CT_TRTCOPY::CreateAggregateTextL() sl@0: // sl@0: { sl@0: TFileName theFileName=_L("z:\\test\\app-framework\\etext\\aggregat.pml"); sl@0: // AggregateText=LoadIntoTextL(theFileName); sl@0: // sl@0: theFileName=_L("z:\\test\\app-framework\\etext\\componnt.pml"); sl@0: ComponentText=LoadIntoTextL(theFileName); sl@0: // Insert a picture or two sl@0: CXzePicture* pic1=CXzePicture::NewL('x'); sl@0: CleanupStack::PushL(pic1); sl@0: CXzePicture* pic2=CXzePicture::NewL('z'); sl@0: CleanupStack::PushL(pic2); sl@0: // Create the picture headers sl@0: TPictureHeader hdr1; sl@0: TPictureHeader hdr2; sl@0: hdr1.iPictureType=KUidXzePictureType; sl@0: hdr1.iPicture=pic1; sl@0: hdr2.iPictureType=KUidXzePictureType; sl@0: hdr2.iPicture=pic2; sl@0: ComponentText->InsertL(0,hdr1); sl@0: ComponentText->InsertL(ComponentText->DocumentLength(),hdr2); sl@0: CleanupStack::Pop(2); // pic1,pic2 sl@0: // sl@0: // Now do the insert. sl@0: // AggregateText->InsertL(10,ComponentText); sl@0: // delete AggregateText; sl@0: delete ComponentText; sl@0: delete GlobalParaFormatLayer; sl@0: delete GlobalCharFormatLayer; sl@0: } sl@0: sl@0: sl@0: void CT_TRTCOPY::doMainL() sl@0: { sl@0: CreateAggregateTextL(); sl@0: } sl@0: sl@0: sl@0: void CT_TRTCOPY::setupCleanup() sl@0: // sl@0: // Initialise the cleanup stack. sl@0: // sl@0: { sl@0: TheTrapCleanup=CTrapCleanup::New(); sl@0: test(TheTrapCleanup!=NULL); sl@0: TRAPD(r,\ sl@0: {\ sl@0: for (TInt i=KTestCleanupStack;i>0;i--)\ sl@0: CleanupStack::PushL((TAny*)0);\ sl@0: CleanupStack::Pop(KTestCleanupStack);\ sl@0: }); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: CT_TRTCOPY::CT_TRTCOPY() sl@0: { sl@0: SetTestStepName(KTestStep_T_TRTCOPY); sl@0: } sl@0: sl@0: TVerdict CT_TRTCOPY::doTestStepL() sl@0: { sl@0: SetTestStepResult(EFail); sl@0: sl@0: INFO_PRINTF1(_L("TRTCOPY")); sl@0: setupCleanup(); sl@0: __UHEAP_MARK; sl@0: sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_TRTCOPY-0001 RichText Copy Testing ")); sl@0: TRAPD(error1, doMainL()); sl@0: sl@0: __UHEAP_MARKEND; sl@0: delete TheTrapCleanup; sl@0: sl@0: if(error1 == KErrNone) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: }