sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-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 |
#include <e32std.h>
|
sl@0
|
19 |
#include <e32test.h>
|
sl@0
|
20 |
#include <frmtlay.h>
|
sl@0
|
21 |
#include <frmtview.h>
|
sl@0
|
22 |
#include <frmconst.h>
|
sl@0
|
23 |
#include <txtlaydc.h>
|
sl@0
|
24 |
#include <txtetext.h>
|
sl@0
|
25 |
#include <w32std.h>
|
sl@0
|
26 |
#include "TGraphicsContext.h"
|
sl@0
|
27 |
#include "tcustomcharmapping.h"
|
sl@0
|
28 |
|
sl@0
|
29 |
namespace LocalToTCustomCharMapping
|
sl@0
|
30 |
{
|
sl@0
|
31 |
class CPinkSquare : public CPicture
|
sl@0
|
32 |
{
|
sl@0
|
33 |
public:
|
sl@0
|
34 |
// Size of square in twips.
|
sl@0
|
35 |
// 600 is 15 pixels using the standard test graphics device at
|
sl@0
|
36 |
// its default resolution.
|
sl@0
|
37 |
enum { KWidth = 600, KHeight = 600 };
|
sl@0
|
38 |
CPinkSquare()
|
sl@0
|
39 |
{}
|
sl@0
|
40 |
void Draw(CGraphicsContext& aGc, const TPoint& aTopLeft, const TRect& aClipRect, MGraphicsDeviceMap* aMap) const
|
sl@0
|
41 |
{
|
sl@0
|
42 |
// This picture is a magenta square
|
sl@0
|
43 |
TPoint size(KWidth, KHeight);
|
sl@0
|
44 |
if (aMap)
|
sl@0
|
45 |
size = aMap->TwipsToPixels(size);
|
sl@0
|
46 |
TRect rect(aTopLeft, aTopLeft + size);
|
sl@0
|
47 |
aGc.SetClippingRect(aClipRect);
|
sl@0
|
48 |
aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
|
sl@0
|
49 |
aGc.SetPenColor(KRgbMagenta);
|
sl@0
|
50 |
aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
|
sl@0
|
51 |
aGc.SetBrushColor(KRgbMagenta);
|
sl@0
|
52 |
aGc.DrawRect(rect);
|
sl@0
|
53 |
}
|
sl@0
|
54 |
void ExternalizeL(RWriteStream&) const
|
sl@0
|
55 |
{}
|
sl@0
|
56 |
void GetOriginalSizeInTwips(TSize& a) const
|
sl@0
|
57 |
{
|
sl@0
|
58 |
a.iWidth = CPinkSquare::KWidth;
|
sl@0
|
59 |
a.iHeight = CPinkSquare::KHeight;
|
sl@0
|
60 |
}
|
sl@0
|
61 |
};
|
sl@0
|
62 |
|
sl@0
|
63 |
_LIT(KEnd, "\x2029");
|
sl@0
|
64 |
class TDocModel : public MLayDoc
|
sl@0
|
65 |
{
|
sl@0
|
66 |
public:
|
sl@0
|
67 |
TDocModel(const TDesC& aDes)
|
sl@0
|
68 |
: iDes(&aDes), iParagraphFormat(0)
|
sl@0
|
69 |
{}
|
sl@0
|
70 |
void SetParagraphFormat(CParaFormat* a)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
iParagraphFormat = a;
|
sl@0
|
73 |
}
|
sl@0
|
74 |
// From MLayDoc
|
sl@0
|
75 |
TInt LdDocumentLength() const
|
sl@0
|
76 |
{ return iDes->Length(); }
|
sl@0
|
77 |
TInt LdToParagraphStart(TInt& a) const
|
sl@0
|
78 |
{
|
sl@0
|
79 |
TInt curr = a;
|
sl@0
|
80 |
if (a < LdDocumentLength())
|
sl@0
|
81 |
{
|
sl@0
|
82 |
a = iDes->Left(a).LocateReverse(0x2029);
|
sl@0
|
83 |
a = a < 0? 0 : a + 1;
|
sl@0
|
84 |
}
|
sl@0
|
85 |
return curr - a;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
void GetParagraphFormatL(CParaFormat* aFormat, TInt) const
|
sl@0
|
88 |
{
|
sl@0
|
89 |
if (iParagraphFormat)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
aFormat->CopyL(*iParagraphFormat);
|
sl@0
|
92 |
return;
|
sl@0
|
93 |
}
|
sl@0
|
94 |
aFormat->Reset();
|
sl@0
|
95 |
TTabStop tabStop;
|
sl@0
|
96 |
tabStop.iTwipsPosition = 1000;
|
sl@0
|
97 |
tabStop.iType = TTabStop::ELeftTab;
|
sl@0
|
98 |
aFormat->StoreTabL(tabStop);
|
sl@0
|
99 |
}
|
sl@0
|
100 |
void GetChars(TPtrC& aView,TCharFormat& aFormat, TInt aStartPos)const
|
sl@0
|
101 |
{
|
sl@0
|
102 |
TCharFormat cf;
|
sl@0
|
103 |
aFormat = cf;
|
sl@0
|
104 |
if (aStartPos == LdDocumentLength())
|
sl@0
|
105 |
aView.Set(KEnd);
|
sl@0
|
106 |
else
|
sl@0
|
107 |
aView.Set(iDes->Mid(aStartPos));
|
sl@0
|
108 |
}
|
sl@0
|
109 |
TInt GetPictureSizeInTwips(TSize& aSize, TInt aPos) const
|
sl@0
|
110 |
{
|
sl@0
|
111 |
if ((*iDes)[aPos] != KPictureCharacter)
|
sl@0
|
112 |
return KErrNotFound;
|
sl@0
|
113 |
aSize.iWidth = CPinkSquare::KWidth;
|
sl@0
|
114 |
aSize.iHeight = CPinkSquare::KHeight;
|
sl@0
|
115 |
return KErrNone;
|
sl@0
|
116 |
}
|
sl@0
|
117 |
CPicture* PictureHandleL(TInt aPos, TForcePictureLoad) const
|
sl@0
|
118 |
{
|
sl@0
|
119 |
if ((*iDes)[aPos] != KPictureCharacter)
|
sl@0
|
120 |
return 0;
|
sl@0
|
121 |
return new(ELeave) CPinkSquare;
|
sl@0
|
122 |
}
|
sl@0
|
123 |
TBool EnquirePageBreak(TInt aPos, TInt aLength)const
|
sl@0
|
124 |
{
|
sl@0
|
125 |
return iDes->Mid(aPos, aLength).Locate(0x000C) < 0?
|
sl@0
|
126 |
EFalse : ETrue;
|
sl@0
|
127 |
}
|
sl@0
|
128 |
TBool SelectParagraphLabel(TInt)
|
sl@0
|
129 |
{ return EFalse; }
|
sl@0
|
130 |
void CancelSelectLabel()
|
sl@0
|
131 |
{}
|
sl@0
|
132 |
private:
|
sl@0
|
133 |
const TDesC* iDes;
|
sl@0
|
134 |
CParaFormat* iParagraphFormat;
|
sl@0
|
135 |
};
|
sl@0
|
136 |
}
|
sl@0
|
137 |
using namespace LocalToTCustomCharMapping;
|
sl@0
|
138 |
|
sl@0
|
139 |
class CTestTextView // slightly naughty
|
sl@0
|
140 |
{
|
sl@0
|
141 |
public:
|
sl@0
|
142 |
static void SetContextForFlickerFreeRedraw(CTextView* aView, CBitmapContext* aContext)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
aView->iOffScreenContext = aContext;
|
sl@0
|
145 |
}
|
sl@0
|
146 |
};
|
sl@0
|
147 |
|
sl@0
|
148 |
|
sl@0
|
149 |
static const TInt KTestCases = 5;
|
sl@0
|
150 |
static const TInt KVariants = 2;
|
sl@0
|
151 |
|
sl@0
|
152 |
// For tests 0 to 3 the source string consists of:
|
sl@0
|
153 |
// 'Y' <hard space> 'Z' <normal space> <non-breaking hyphen> <zero width space>
|
sl@0
|
154 |
static const TPtrC KTestStrings[KTestCases][KVariants] =
|
sl@0
|
155 |
{
|
sl@0
|
156 |
{ // Test remapping with no custom remapper and flags set to invisible
|
sl@0
|
157 |
// The non-breaking hyphen is turned into a normal hyphen
|
sl@0
|
158 |
// The zero width space disappears (0xFFFF) and the hard space becomes a normal space
|
sl@0
|
159 |
// All done by MTmCustom::Map()
|
sl@0
|
160 |
_S("\x0059\x00A0\x005A\x0020\x2011\x200B"),
|
sl@0
|
161 |
_S("\xFFFF\x0059\x0020\x005A\x0020\x002D\xFFFF\xFFFF"),
|
sl@0
|
162 |
},
|
sl@0
|
163 |
{ // Test remapping with no custom remapper and flags set to visible
|
sl@0
|
164 |
// The non-breaking hyphen becomes a tilde
|
sl@0
|
165 |
// The normal space and the zero width space become visible middle dots
|
sl@0
|
166 |
// The hard (non-breaking) space becomes a degree sign
|
sl@0
|
167 |
// The paragraph sign becomes a pilcrow
|
sl@0
|
168 |
// All done by MTmCustom::Map()
|
sl@0
|
169 |
_S("\x0059\x00A0\x005A\x0020\x2011\x200B"),
|
sl@0
|
170 |
_S("\xFFFF\x0059\x00B0\x005A\x00B7\x007E\x00B7\x00B6\xFFFF"),
|
sl@0
|
171 |
},
|
sl@0
|
172 |
{ // Test remapping with custom remapper and flags set to invisible
|
sl@0
|
173 |
// The non-breaking hyphen is turned into a normal hyphen
|
sl@0
|
174 |
// The zero width space disappears (0xFFFF) and the hard space becomes a normal space
|
sl@0
|
175 |
// All done by MTmCustom::Map()
|
sl@0
|
176 |
// The hard (non-breaking) space becomes a caret
|
sl@0
|
177 |
// This is done by the custom remapper
|
sl@0
|
178 |
_S("\x0059\x00A0\x005A\x0020\x2011\x200B"),
|
sl@0
|
179 |
_S("\xFFFF\x0059\x005E\x005A\x0020\x002D\xFFFF\xFFFF"),
|
sl@0
|
180 |
},
|
sl@0
|
181 |
{ // Test remapping with custom remapper and flags set to visible
|
sl@0
|
182 |
// The non-breaking hyphen becomes a tilde
|
sl@0
|
183 |
// The zero width space become visible middle dots
|
sl@0
|
184 |
// All done by MTmCustom::Map()
|
sl@0
|
185 |
// The normal space remains a normal (invisible) space because default behaviour is overidden
|
sl@0
|
186 |
// The hard (non-breaking) space becomes a caret
|
sl@0
|
187 |
// The paragraph sign becomes a capital P
|
sl@0
|
188 |
// All done by the custom remapper
|
sl@0
|
189 |
_S("\x0059\x00A0\x005A\x0020\x2011\x200B"),
|
sl@0
|
190 |
_S("\xFFFF\x0059\x005E\x005A\x0020\x007E\x00B7\x0050\xFFFF"),
|
sl@0
|
191 |
},
|
sl@0
|
192 |
{
|
sl@0
|
193 |
// Test remapping with no custom remapper and some flags explicitly set to invisible
|
sl@0
|
194 |
// The non-breaking hyphen is turned into a normal hyphen
|
sl@0
|
195 |
// The zero width space disappears (0xFFFF) and the hard space becomes a normal space
|
sl@0
|
196 |
// All done by MTmCustom::Map()
|
sl@0
|
197 |
_S("\x0059\x00A0\x005A\x0020\x2011\x200B"),
|
sl@0
|
198 |
_S("\xFFFF\x0059\x0020\x005A\x0020\x002D\xFFFF\xFFFF"),
|
sl@0
|
199 |
}
|
sl@0
|
200 |
};
|
sl@0
|
201 |
|
sl@0
|
202 |
|
sl@0
|
203 |
class CCustomRemapper : public MFormCustomInvisibleCharacterRemapper
|
sl@0
|
204 |
{
|
sl@0
|
205 |
public:
|
sl@0
|
206 |
static CCustomRemapper* NewL();
|
sl@0
|
207 |
~CCustomRemapper();
|
sl@0
|
208 |
TUint Remap(TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility, const TLayDocTextSource& aLayDoc);
|
sl@0
|
209 |
private:
|
sl@0
|
210 |
CCustomRemapper();
|
sl@0
|
211 |
};
|
sl@0
|
212 |
|
sl@0
|
213 |
CCustomRemapper* CCustomRemapper::NewL()
|
sl@0
|
214 |
{
|
sl@0
|
215 |
CCustomRemapper* me = new(ELeave) CCustomRemapper;
|
sl@0
|
216 |
return me;
|
sl@0
|
217 |
}
|
sl@0
|
218 |
|
sl@0
|
219 |
CCustomRemapper::~CCustomRemapper()
|
sl@0
|
220 |
{
|
sl@0
|
221 |
}
|
sl@0
|
222 |
|
sl@0
|
223 |
TUint CCustomRemapper::Remap(TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility, const TLayDocTextSource& aLayDoc)
|
sl@0
|
224 |
{
|
sl@0
|
225 |
switch (aChar)
|
sl@0
|
226 |
{
|
sl@0
|
227 |
case CEditableText::EParagraphDelimiter:
|
sl@0
|
228 |
if (aNonPrintingCharVisibility.ParagraphDelimitersVisible())
|
sl@0
|
229 |
return 0x0050; // capital P - override when visible
|
sl@0
|
230 |
break;
|
sl@0
|
231 |
|
sl@0
|
232 |
case CEditableText::ESpace:
|
sl@0
|
233 |
return aChar; // don't remap but don't pass it on - override default
|
sl@0
|
234 |
// break statement was removed.
|
sl@0
|
235 |
|
sl@0
|
236 |
case CEditableText::ENonBreakingSpace:
|
sl@0
|
237 |
return 0x005E; // Caret - override always - visible or not
|
sl@0
|
238 |
// break statement was removed.
|
sl@0
|
239 |
default:
|
sl@0
|
240 |
break; // do nothing
|
sl@0
|
241 |
}
|
sl@0
|
242 |
|
sl@0
|
243 |
// If not mapping special characters, or not mapping this particular character, use the default mapping.
|
sl@0
|
244 |
return DefaultMapping(aChar, aNonPrintingCharVisibility, aLayDoc);
|
sl@0
|
245 |
}
|
sl@0
|
246 |
|
sl@0
|
247 |
CCustomRemapper::CCustomRemapper()
|
sl@0
|
248 |
{
|
sl@0
|
249 |
}
|
sl@0
|
250 |
|
sl@0
|
251 |
void CTCustomCharMappingStep::DoTestL(TDes& aText, CTextLayout* /*aLayout*/, CTestGraphicsDevice* aDevice, CTextView* aView, TTestNum aTestNum)
|
sl@0
|
252 |
{
|
sl@0
|
253 |
aText = KTestStrings[aTestNum][0];
|
sl@0
|
254 |
aDevice->LineArray().ResetLineArray();
|
sl@0
|
255 |
aView->HandleGlobalChangeL();
|
sl@0
|
256 |
const TTestGCDisplayLine* line1 = &(aDevice->LineArray().Line(0));
|
sl@0
|
257 |
const TTestGCDisplayLine* line2 = aDevice->LineArray().Find(KTestStrings[aTestNum][1]);
|
sl@0
|
258 |
TEST(0 != line1);
|
sl@0
|
259 |
TEST(0 != line2);
|
sl@0
|
260 |
// Can't always do a direct comparison of lines because same string
|
sl@0
|
261 |
// may appear in more than one line, so compare contents
|
sl@0
|
262 |
TEST(line1->iLineData.Compare(line2->iLineData) == 0);
|
sl@0
|
263 |
}
|
sl@0
|
264 |
|
sl@0
|
265 |
|
sl@0
|
266 |
/**
|
sl@0
|
267 |
@SYMTestCaseID SYSLIB-FORM-CT-0147
|
sl@0
|
268 |
@SYMTestCaseDesc Test installation and deinstallation of custom remapper
|
sl@0
|
269 |
@SYMTestPriority High
|
sl@0
|
270 |
@SYMTestActions Test installation and deinstallation of custom remapper
|
sl@0
|
271 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
272 |
@SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable
|
sl@0
|
273 |
*/
|
sl@0
|
274 |
void CTCustomCharMappingStep::RunInstallationTestsL()
|
sl@0
|
275 |
{
|
sl@0
|
276 |
// Note: If you need to move these heap checks any further "in" to focus
|
sl@0
|
277 |
// on a specific test then you will have to move all the setup code in as
|
sl@0
|
278 |
// well - and still preserve the two different display widths in use
|
sl@0
|
279 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0147 "));
|
sl@0
|
280 |
__UHEAP_MARK;
|
sl@0
|
281 |
CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
|
sl@0
|
282 |
CleanupStack::PushL(scheduler);
|
sl@0
|
283 |
CActiveScheduler::Install(scheduler);
|
sl@0
|
284 |
TBuf<100> text;
|
sl@0
|
285 |
TDocModel docModel(text);
|
sl@0
|
286 |
TRect displayRect(0, 0, KDisplayWidth, KDisplayHeight);
|
sl@0
|
287 |
CTextLayout* layout = CTextLayout::NewL(&docModel, displayRect.Width());
|
sl@0
|
288 |
CleanupStack::PushL(layout);
|
sl@0
|
289 |
CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect.Size(), 0);
|
sl@0
|
290 |
CleanupStack::PushL(device);
|
sl@0
|
291 |
CTextView* view = CTextView::NewL(layout, displayRect, device, device, 0, 0, 0);
|
sl@0
|
292 |
CleanupStack::PushL(view);
|
sl@0
|
293 |
// This is used to force the use of CTestGraphicsContext instead of a normal one
|
sl@0
|
294 |
CWindowGc* offScreenContext;
|
sl@0
|
295 |
User::LeaveIfError(device->CreateContext(offScreenContext));
|
sl@0
|
296 |
CleanupStack::PushL(offScreenContext);
|
sl@0
|
297 |
CTestTextView::SetContextForFlickerFreeRedraw(view, offScreenContext);
|
sl@0
|
298 |
|
sl@0
|
299 |
// OK, let's get down to testing
|
sl@0
|
300 |
MFormCustomInvisibleCharacterRemapper* remapper;
|
sl@0
|
301 |
// read what the ptr is set to - check it is null
|
sl@0
|
302 |
remapper = layout->GetCustomInvisibleCharacterRemapper();
|
sl@0
|
303 |
INFO_PRINTF1(_L("Test uninstalled"));
|
sl@0
|
304 |
TEST(remapper == NULL);
|
sl@0
|
305 |
|
sl@0
|
306 |
// install a custom remapper - get the ptr - check it is set
|
sl@0
|
307 |
MFormCustomInvisibleCharacterRemapper* customRemapper = CCustomRemapper::NewL();
|
sl@0
|
308 |
layout->SetCustomInvisibleCharacterRemapper(customRemapper);
|
sl@0
|
309 |
remapper = layout->GetCustomInvisibleCharacterRemapper();
|
sl@0
|
310 |
INFO_PRINTF1(_L("Test installed"));
|
sl@0
|
311 |
TEST(remapper == customRemapper);
|
sl@0
|
312 |
|
sl@0
|
313 |
// set the ptr back to null (deinstall) - get the ptr - check it is null
|
sl@0
|
314 |
layout->SetCustomInvisibleCharacterRemapper(NULL);
|
sl@0
|
315 |
remapper = layout->GetCustomInvisibleCharacterRemapper();
|
sl@0
|
316 |
INFO_PRINTF1(_L("Test uninstalled again"));
|
sl@0
|
317 |
TEST(remapper == NULL);
|
sl@0
|
318 |
|
sl@0
|
319 |
delete customRemapper;
|
sl@0
|
320 |
|
sl@0
|
321 |
CleanupStack::PopAndDestroy(offScreenContext);
|
sl@0
|
322 |
CleanupStack::PopAndDestroy(view);
|
sl@0
|
323 |
CleanupStack::PopAndDestroy(device);
|
sl@0
|
324 |
CleanupStack::PopAndDestroy(layout);
|
sl@0
|
325 |
CleanupStack::PopAndDestroy(scheduler);
|
sl@0
|
326 |
__UHEAP_MARKEND;
|
sl@0
|
327 |
}
|
sl@0
|
328 |
|
sl@0
|
329 |
|
sl@0
|
330 |
/**
|
sl@0
|
331 |
@SYMTestCaseID SYSLIB-FORM-CT-0148
|
sl@0
|
332 |
@SYMTestCaseDesc Test behaviour without custom remapper installed
|
sl@0
|
333 |
@SYMTestPriority High
|
sl@0
|
334 |
@SYMTestActions Test behaviour without custom remapper installed
|
sl@0
|
335 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
336 |
@SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable
|
sl@0
|
337 |
*/
|
sl@0
|
338 |
void CTCustomCharMappingStep::RunDefaultBehaviourTestsL()
|
sl@0
|
339 |
{
|
sl@0
|
340 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0148 "));
|
sl@0
|
341 |
CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
|
sl@0
|
342 |
CleanupStack::PushL(scheduler);
|
sl@0
|
343 |
CActiveScheduler::Install(scheduler);
|
sl@0
|
344 |
TBuf<100> text;
|
sl@0
|
345 |
TDocModel docModel(text);
|
sl@0
|
346 |
TRect displayRect(0, 0, KDisplayWidth, KDisplayHeight);
|
sl@0
|
347 |
CTextLayout* layout = CTextLayout::NewL(&docModel, displayRect.Width());
|
sl@0
|
348 |
CleanupStack::PushL(layout);
|
sl@0
|
349 |
CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect.Size(), 0);
|
sl@0
|
350 |
CleanupStack::PushL(device);
|
sl@0
|
351 |
CTextView* view = CTextView::NewL(layout, displayRect, device, device, 0, 0, 0);
|
sl@0
|
352 |
CleanupStack::PushL(view);
|
sl@0
|
353 |
// This is used to force the use of CTestGraphicsContext instead of a normal one
|
sl@0
|
354 |
CWindowGc* offScreenContext;
|
sl@0
|
355 |
User::LeaveIfError(device->CreateContext(offScreenContext));
|
sl@0
|
356 |
CleanupStack::PushL(offScreenContext);
|
sl@0
|
357 |
CTestTextView::SetContextForFlickerFreeRedraw(view, offScreenContext);
|
sl@0
|
358 |
|
sl@0
|
359 |
// Start by making sure no custom remapper is installed
|
sl@0
|
360 |
MFormCustomInvisibleCharacterRemapper* remapper;
|
sl@0
|
361 |
remapper = layout->GetCustomInvisibleCharacterRemapper();
|
sl@0
|
362 |
TEST(remapper == NULL);
|
sl@0
|
363 |
|
sl@0
|
364 |
// Set all invisible characters to be invisible
|
sl@0
|
365 |
TNonPrintingCharVisibility visibility;
|
sl@0
|
366 |
visibility.SetNoneVisible();
|
sl@0
|
367 |
layout->SetNonPrintingCharsVisibility(visibility);
|
sl@0
|
368 |
|
sl@0
|
369 |
// Test remapping with no custom remapper and flags set to invisible
|
sl@0
|
370 |
INFO_PRINTF1(_L("Test uninstalled behaviour - flags invisible"));
|
sl@0
|
371 |
DoTestL(text, layout, device, view, EDefaultBehaviourInvisible);
|
sl@0
|
372 |
|
sl@0
|
373 |
// Now set all invisible characters to be visible
|
sl@0
|
374 |
visibility.SetAllVisible();
|
sl@0
|
375 |
layout->SetNonPrintingCharsVisibility(visibility);
|
sl@0
|
376 |
|
sl@0
|
377 |
// Test remapping with no custom remapper and flags set to visible
|
sl@0
|
378 |
INFO_PRINTF1(_L("Test uninstalled behaviour - flags visible"));
|
sl@0
|
379 |
DoTestL(text, layout, device, view, EDefaultBehaviourVisible);
|
sl@0
|
380 |
|
sl@0
|
381 |
// Test remapping with no custom remapper and some flags explicitly set to invisible
|
sl@0
|
382 |
INFO_PRINTF1(_L("Test uninstalled behaviour - some flags invisible"));
|
sl@0
|
383 |
//Set all invisible characters to be visible
|
sl@0
|
384 |
visibility.SetAllVisible();
|
sl@0
|
385 |
//Set some attributes explicitly to be invisible
|
sl@0
|
386 |
visibility.SetSpacesVisible(EFalse);
|
sl@0
|
387 |
visibility.SetTabsVisible(EFalse);
|
sl@0
|
388 |
visibility.SetPotentialHyphensVisible(EFalse);
|
sl@0
|
389 |
visibility.SetParagraphDelimitersVisible(EFalse);
|
sl@0
|
390 |
visibility.SetPageBreaksVisible(EFalse);
|
sl@0
|
391 |
visibility.SetNonBreakingSpacesVisible(EFalse);
|
sl@0
|
392 |
visibility.SetNonBreakingHyphensVisible(EFalse);
|
sl@0
|
393 |
visibility.SetLineBreaksVisible(EFalse);
|
sl@0
|
394 |
layout->SetNonPrintingCharsVisibility(visibility);
|
sl@0
|
395 |
//Test if the visibility is set accordingly
|
sl@0
|
396 |
DoTestL(text, layout, device, view, ENewTest);
|
sl@0
|
397 |
|
sl@0
|
398 |
CleanupStack::PopAndDestroy(offScreenContext);
|
sl@0
|
399 |
CleanupStack::PopAndDestroy(view);
|
sl@0
|
400 |
CleanupStack::PopAndDestroy(device);
|
sl@0
|
401 |
CleanupStack::PopAndDestroy(layout);
|
sl@0
|
402 |
CleanupStack::PopAndDestroy(scheduler);
|
sl@0
|
403 |
}
|
sl@0
|
404 |
|
sl@0
|
405 |
|
sl@0
|
406 |
/**
|
sl@0
|
407 |
@SYMTestCaseID SYSLIB-FORM-CT-0149
|
sl@0
|
408 |
@SYMTestCaseDesc Test behaviour with custom remapper installed
|
sl@0
|
409 |
@SYMTestPriority High
|
sl@0
|
410 |
@SYMTestActions Test behaviour with custom remapper installed
|
sl@0
|
411 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
412 |
@SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable
|
sl@0
|
413 |
*/
|
sl@0
|
414 |
void CTCustomCharMappingStep::RunCustomBehaviourTestsL()
|
sl@0
|
415 |
{
|
sl@0
|
416 |
// Note: If you need to move these heap checks any further "in" to focus
|
sl@0
|
417 |
// on a specific test then you will have to move all the setup code in as
|
sl@0
|
418 |
// well - and still preserve the two different display widths in use
|
sl@0
|
419 |
INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0149 "));
|
sl@0
|
420 |
__UHEAP_MARK;
|
sl@0
|
421 |
CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
|
sl@0
|
422 |
CleanupStack::PushL(scheduler);
|
sl@0
|
423 |
CActiveScheduler::Install(scheduler);
|
sl@0
|
424 |
TBuf<100> text;
|
sl@0
|
425 |
TDocModel docModel(text);
|
sl@0
|
426 |
TRect displayRect(0, 0, KDisplayWidth, KDisplayHeight);
|
sl@0
|
427 |
CTextLayout* layout = CTextLayout::NewL(&docModel, displayRect.Width());
|
sl@0
|
428 |
CleanupStack::PushL(layout);
|
sl@0
|
429 |
CTestGraphicsDevice* device = CTestGraphicsDevice::NewL(displayRect.Size(), 0);
|
sl@0
|
430 |
CleanupStack::PushL(device);
|
sl@0
|
431 |
CTextView* view = CTextView::NewL(layout, displayRect, device, device, 0, 0, 0);
|
sl@0
|
432 |
CleanupStack::PushL(view);
|
sl@0
|
433 |
// This is used to force the use of CTestGraphicsContext instead of a normal one
|
sl@0
|
434 |
CWindowGc* offScreenContext;
|
sl@0
|
435 |
User::LeaveIfError(device->CreateContext(offScreenContext));
|
sl@0
|
436 |
CleanupStack::PushL(offScreenContext);
|
sl@0
|
437 |
CTestTextView::SetContextForFlickerFreeRedraw(view, offScreenContext);
|
sl@0
|
438 |
|
sl@0
|
439 |
// We need to install a custom remapper
|
sl@0
|
440 |
MFormCustomInvisibleCharacterRemapper* remapper;
|
sl@0
|
441 |
MFormCustomInvisibleCharacterRemapper* customRemapper = CCustomRemapper::NewL();
|
sl@0
|
442 |
layout->SetCustomInvisibleCharacterRemapper(customRemapper);
|
sl@0
|
443 |
remapper = layout->GetCustomInvisibleCharacterRemapper();
|
sl@0
|
444 |
TEST(remapper == customRemapper);
|
sl@0
|
445 |
|
sl@0
|
446 |
// Set all invisible characters to be invisible
|
sl@0
|
447 |
TNonPrintingCharVisibility visibility;
|
sl@0
|
448 |
visibility.SetNoneVisible();
|
sl@0
|
449 |
layout->SetNonPrintingCharsVisibility(visibility);
|
sl@0
|
450 |
|
sl@0
|
451 |
// Test remapping with custom remapper and flags set to invisible
|
sl@0
|
452 |
INFO_PRINTF1(_L("Test installed behaviour - flags invisible"));
|
sl@0
|
453 |
DoTestL(text, layout, device, view, ECustomRemappingInvisible);
|
sl@0
|
454 |
|
sl@0
|
455 |
// Now set all invisible characters to be visible
|
sl@0
|
456 |
visibility.SetAllVisible();
|
sl@0
|
457 |
layout->SetNonPrintingCharsVisibility(visibility);
|
sl@0
|
458 |
|
sl@0
|
459 |
// Test remapping with custom remapper and flags set to visible
|
sl@0
|
460 |
INFO_PRINTF1(_L("Test installed behaviour - flags visible"));
|
sl@0
|
461 |
DoTestL(text, layout, device, view, ECustomRemappingVisible);
|
sl@0
|
462 |
|
sl@0
|
463 |
// Now we are finished deinstall and delete it
|
sl@0
|
464 |
layout->SetCustomInvisibleCharacterRemapper(NULL);
|
sl@0
|
465 |
remapper = layout->GetCustomInvisibleCharacterRemapper();
|
sl@0
|
466 |
TEST(remapper == NULL);
|
sl@0
|
467 |
delete customRemapper;
|
sl@0
|
468 |
|
sl@0
|
469 |
CleanupStack::PopAndDestroy(offScreenContext);
|
sl@0
|
470 |
CleanupStack::PopAndDestroy(view);
|
sl@0
|
471 |
CleanupStack::PopAndDestroy(device);
|
sl@0
|
472 |
CleanupStack::PopAndDestroy(layout);
|
sl@0
|
473 |
CleanupStack::PopAndDestroy(scheduler);
|
sl@0
|
474 |
__UHEAP_MARKEND;
|
sl@0
|
475 |
}
|
sl@0
|
476 |
|
sl@0
|
477 |
CTCustomCharMappingStep::CTCustomCharMappingStep()
|
sl@0
|
478 |
{
|
sl@0
|
479 |
|
sl@0
|
480 |
}
|
sl@0
|
481 |
|
sl@0
|
482 |
TVerdict CTCustomCharMappingStep::doTestStepL()
|
sl@0
|
483 |
{
|
sl@0
|
484 |
SetTestStepResult(EPass);
|
sl@0
|
485 |
INFO_PRINTF1(_L("Test installation/deinstallatiion"));
|
sl@0
|
486 |
TInt error = RFbsSession::Connect();
|
sl@0
|
487 |
if (error == KErrNotFound)
|
sl@0
|
488 |
{
|
sl@0
|
489 |
FbsStartup();
|
sl@0
|
490 |
error = RFbsSession::Connect();
|
sl@0
|
491 |
}
|
sl@0
|
492 |
TEST(error == KErrNone);
|
sl@0
|
493 |
TRAP(error, RunInstallationTestsL());
|
sl@0
|
494 |
TEST(error == KErrNone);
|
sl@0
|
495 |
INFO_PRINTF1(_L("Test uninstalled behaviour"));
|
sl@0
|
496 |
TRAP(error, RunDefaultBehaviourTestsL());
|
sl@0
|
497 |
TEST(error == KErrNone);
|
sl@0
|
498 |
INFO_PRINTF1(_L("Test behaviour with custom remapper installed"));
|
sl@0
|
499 |
TRAP(error, RunCustomBehaviourTestsL());
|
sl@0
|
500 |
TEST(error == KErrNone);
|
sl@0
|
501 |
RFbsSession::Disconnect();
|
sl@0
|
502 |
return TestStepResult();
|
sl@0
|
503 |
}
|