sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <txtrich.h>
|
sl@0
|
20 |
#include <txtstyle.h>
|
sl@0
|
21 |
#include <flddef.h>
|
sl@0
|
22 |
#include <fldbltin.h>
|
sl@0
|
23 |
#include <gdi.h>
|
sl@0
|
24 |
#include <conpics.h>
|
sl@0
|
25 |
#include <s32mem.h>
|
sl@0
|
26 |
#include <s32file.h>
|
sl@0
|
27 |
#include "../incp/T_PMLPAR.H"
|
sl@0
|
28 |
#include "TRTCOPY.h"
|
sl@0
|
29 |
|
sl@0
|
30 |
#define test(cond) \
|
sl@0
|
31 |
{ \
|
sl@0
|
32 |
TBool __bb = (cond); \
|
sl@0
|
33 |
TEST(__bb); \
|
sl@0
|
34 |
if (!__bb) \
|
sl@0
|
35 |
{ \
|
sl@0
|
36 |
ERR_PRINTF1(_L("ERROR: Test Failed")); \
|
sl@0
|
37 |
User::Leave(1); \
|
sl@0
|
38 |
} \
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
LOCAL_D RFs theFs;
|
sl@0
|
42 |
LOCAL_D CRichText* ComponentText;
|
sl@0
|
43 |
LOCAL_D CParaFormatLayer* GlobalParaFormatLayer;
|
sl@0
|
44 |
LOCAL_D CCharFormatLayer* GlobalCharFormatLayer;
|
sl@0
|
45 |
LOCAL_D CTrapCleanup* TheTrapCleanup;
|
sl@0
|
46 |
LOCAL_D CParser* TheParser;
|
sl@0
|
47 |
|
sl@0
|
48 |
const TInt KTestCleanupStack=0x500;
|
sl@0
|
49 |
|
sl@0
|
50 |
|
sl@0
|
51 |
CRichText* CT_TRTCOPY::LoadIntoTextL(TFileName& aFileName)
|
sl@0
|
52 |
//
|
sl@0
|
53 |
{
|
sl@0
|
54 |
TRAPD(ret,
|
sl@0
|
55 |
TheParser=CParser::NewL());
|
sl@0
|
56 |
CRichText* text=NULL;
|
sl@0
|
57 |
TRAP(ret,
|
sl@0
|
58 |
text=TheParser->ParseL(aFileName));
|
sl@0
|
59 |
GlobalParaFormatLayer=(CParaFormatLayer*)text->GlobalParaFormatLayer();
|
sl@0
|
60 |
GlobalCharFormatLayer=(CCharFormatLayer*)text->GlobalCharFormatLayer();
|
sl@0
|
61 |
delete TheParser;
|
sl@0
|
62 |
TheParser=NULL;
|
sl@0
|
63 |
return text;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
/*
|
sl@0
|
67 |
CStyleList* CT_TRTCOPY::CreatePopulatedStyleList()
|
sl@0
|
68 |
//
|
sl@0
|
69 |
{
|
sl@0
|
70 |
//
|
sl@0
|
71 |
// Create style aswell.
|
sl@0
|
72 |
CStyleList* list=CStyleList::NewL();
|
sl@0
|
73 |
CParagraphStyle* style1=CParagraphStyle::NewL(*GlobalParaFormatLayer,*GlobalCharFormatLayer);
|
sl@0
|
74 |
CParagraphStyle* style2=CParagraphStyle::NewL(*GlobalParaFormatLayer,*GlobalCharFormatLayer);
|
sl@0
|
75 |
CParagraphStyle* style3=CParagraphStyle::NewL(*GlobalParaFormatLayer,*GlobalCharFormatLayer);
|
sl@0
|
76 |
list->AppendL(*style1);
|
sl@0
|
77 |
list->AppendL(*style2);
|
sl@0
|
78 |
list->AppendL(*style3);
|
sl@0
|
79 |
return list;
|
sl@0
|
80 |
}
|
sl@0
|
81 |
*/
|
sl@0
|
82 |
|
sl@0
|
83 |
void CT_TRTCOPY::CreateAggregateTextL()
|
sl@0
|
84 |
//
|
sl@0
|
85 |
{
|
sl@0
|
86 |
TFileName theFileName=_L("z:\\test\\app-framework\\etext\\aggregat.pml");
|
sl@0
|
87 |
// AggregateText=LoadIntoTextL(theFileName);
|
sl@0
|
88 |
//
|
sl@0
|
89 |
theFileName=_L("z:\\test\\app-framework\\etext\\componnt.pml");
|
sl@0
|
90 |
ComponentText=LoadIntoTextL(theFileName);
|
sl@0
|
91 |
// Insert a picture or two
|
sl@0
|
92 |
CXzePicture* pic1=CXzePicture::NewL('x');
|
sl@0
|
93 |
CleanupStack::PushL(pic1);
|
sl@0
|
94 |
CXzePicture* pic2=CXzePicture::NewL('z');
|
sl@0
|
95 |
CleanupStack::PushL(pic2);
|
sl@0
|
96 |
// Create the picture headers
|
sl@0
|
97 |
TPictureHeader hdr1;
|
sl@0
|
98 |
TPictureHeader hdr2;
|
sl@0
|
99 |
hdr1.iPictureType=KUidXzePictureType;
|
sl@0
|
100 |
hdr1.iPicture=pic1;
|
sl@0
|
101 |
hdr2.iPictureType=KUidXzePictureType;
|
sl@0
|
102 |
hdr2.iPicture=pic2;
|
sl@0
|
103 |
ComponentText->InsertL(0,hdr1);
|
sl@0
|
104 |
ComponentText->InsertL(ComponentText->DocumentLength(),hdr2);
|
sl@0
|
105 |
CleanupStack::Pop(2); // pic1,pic2
|
sl@0
|
106 |
//
|
sl@0
|
107 |
// Now do the insert.
|
sl@0
|
108 |
// AggregateText->InsertL(10,ComponentText);
|
sl@0
|
109 |
// delete AggregateText;
|
sl@0
|
110 |
delete ComponentText;
|
sl@0
|
111 |
delete GlobalParaFormatLayer;
|
sl@0
|
112 |
delete GlobalCharFormatLayer;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
|
sl@0
|
116 |
void CT_TRTCOPY::doMainL()
|
sl@0
|
117 |
{
|
sl@0
|
118 |
CreateAggregateTextL();
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
|
sl@0
|
122 |
void CT_TRTCOPY::setupCleanup()
|
sl@0
|
123 |
//
|
sl@0
|
124 |
// Initialise the cleanup stack.
|
sl@0
|
125 |
//
|
sl@0
|
126 |
{
|
sl@0
|
127 |
TheTrapCleanup=CTrapCleanup::New();
|
sl@0
|
128 |
test(TheTrapCleanup!=NULL);
|
sl@0
|
129 |
TRAPD(r,\
|
sl@0
|
130 |
{\
|
sl@0
|
131 |
for (TInt i=KTestCleanupStack;i>0;i--)\
|
sl@0
|
132 |
CleanupStack::PushL((TAny*)0);\
|
sl@0
|
133 |
CleanupStack::Pop(KTestCleanupStack);\
|
sl@0
|
134 |
});
|
sl@0
|
135 |
test(r==KErrNone);
|
sl@0
|
136 |
}
|
sl@0
|
137 |
|
sl@0
|
138 |
CT_TRTCOPY::CT_TRTCOPY()
|
sl@0
|
139 |
{
|
sl@0
|
140 |
SetTestStepName(KTestStep_T_TRTCOPY);
|
sl@0
|
141 |
}
|
sl@0
|
142 |
|
sl@0
|
143 |
TVerdict CT_TRTCOPY::doTestStepL()
|
sl@0
|
144 |
{
|
sl@0
|
145 |
SetTestStepResult(EFail);
|
sl@0
|
146 |
|
sl@0
|
147 |
INFO_PRINTF1(_L("TRTCOPY"));
|
sl@0
|
148 |
setupCleanup();
|
sl@0
|
149 |
__UHEAP_MARK;
|
sl@0
|
150 |
|
sl@0
|
151 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-TTEXT-LEGACY-T_TRTCOPY-0001 RichText Copy Testing "));
|
sl@0
|
152 |
TRAPD(error1, doMainL());
|
sl@0
|
153 |
|
sl@0
|
154 |
__UHEAP_MARKEND;
|
sl@0
|
155 |
delete TheTrapCleanup;
|
sl@0
|
156 |
|
sl@0
|
157 |
if(error1 == KErrNone)
|
sl@0
|
158 |
{
|
sl@0
|
159 |
SetTestStepResult(EPass);
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
return TestStepResult();
|
sl@0
|
163 |
}
|