sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2007-2009 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 |
* Cache Deletion for fntstore multi-processed test code
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
/**
|
sl@0
|
21 |
@file
|
sl@0
|
22 |
@test
|
sl@0
|
23 |
@internalComponent - Internal Symbian test code
|
sl@0
|
24 |
*/
|
sl@0
|
25 |
|
sl@0
|
26 |
#include <e32base.h>
|
sl@0
|
27 |
#include <e32cons.h>
|
sl@0
|
28 |
#include <e32test.h>
|
sl@0
|
29 |
#include <e32std.h>
|
sl@0
|
30 |
#include <e32debug.h>
|
sl@0
|
31 |
#include "FNTSTORE.H"
|
sl@0
|
32 |
#include "FNTBODY.H"
|
sl@0
|
33 |
#include "FNTSTD.H"
|
sl@0
|
34 |
#include <fbs.h>
|
sl@0
|
35 |
#include <bitstd.h>
|
sl@0
|
36 |
#include <bitdev.h>
|
sl@0
|
37 |
|
sl@0
|
38 |
_LIT(KOpenFont, "DejaVu Sans Condensed");
|
sl@0
|
39 |
|
sl@0
|
40 |
#ifdef __WINSCW__
|
sl@0
|
41 |
//this is used for winscw breakpoints
|
sl@0
|
42 |
#define BR _asm( int 3);
|
sl@0
|
43 |
#endif
|
sl@0
|
44 |
|
sl@0
|
45 |
|
sl@0
|
46 |
/* it is expected that the main in this file will be called to test multiple
|
sl@0
|
47 |
process output at the same time a process is being deleted (font and bitmap server
|
sl@0
|
48 |
disconnection. There are normally two instances of this process. Two virtually
|
sl@0
|
49 |
identical processes are required to ensure that the session ID is the same.
|
sl@0
|
50 |
|
sl@0
|
51 |
The first is with aThirdProcess set. This sets output to run in a loop until
|
sl@0
|
52 |
the timeout is completed. These values are input via program arguments.
|
sl@0
|
53 |
|
sl@0
|
54 |
If aThirdProcess is false then only one font creation, draw text,
|
sl@0
|
55 |
font deletion cycle is completed. The test code will then repeatedly run
|
sl@0
|
56 |
this process with aThirdProcess set to false.
|
sl@0
|
57 |
*/
|
sl@0
|
58 |
class TRunProc2: public CBase
|
sl@0
|
59 |
{
|
sl@0
|
60 |
public:
|
sl@0
|
61 |
static TRunProc2* NewL();
|
sl@0
|
62 |
void RunTestL(TInt aThirdProcess, TInt aTimeout);
|
sl@0
|
63 |
~TRunProc2();
|
sl@0
|
64 |
private:
|
sl@0
|
65 |
TRunProc2(){};
|
sl@0
|
66 |
void ConstructL();
|
sl@0
|
67 |
void DrawText();
|
sl@0
|
68 |
void CreateFont();
|
sl@0
|
69 |
|
sl@0
|
70 |
private:
|
sl@0
|
71 |
RFbsSession* iFbs;
|
sl@0
|
72 |
CFbsBitGc* iGc;
|
sl@0
|
73 |
CFbsScreenDevice* iDev;
|
sl@0
|
74 |
};
|
sl@0
|
75 |
|
sl@0
|
76 |
TRunProc2::~TRunProc2()
|
sl@0
|
77 |
{
|
sl@0
|
78 |
delete iGc;
|
sl@0
|
79 |
delete iDev;
|
sl@0
|
80 |
iFbs->Disconnect();
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
void TRunProc2::ConstructL()
|
sl@0
|
84 |
{
|
sl@0
|
85 |
TInt err = RFbsSession::Connect();
|
sl@0
|
86 |
User::LeaveIfError(err);
|
sl@0
|
87 |
iFbs = RFbsSession::GetSession();
|
sl@0
|
88 |
User::LeaveIfNull(iFbs);
|
sl@0
|
89 |
|
sl@0
|
90 |
TDisplayMode mode[13];
|
sl@0
|
91 |
mode[0]=EGray2;
|
sl@0
|
92 |
mode[1]=EGray4;
|
sl@0
|
93 |
mode[2]=EGray16;
|
sl@0
|
94 |
mode[3]=EGray256;
|
sl@0
|
95 |
mode[4]=EColor16;
|
sl@0
|
96 |
mode[5]=EColor256;
|
sl@0
|
97 |
mode[6]=EColor64K;
|
sl@0
|
98 |
mode[7]=EColor16M;
|
sl@0
|
99 |
mode[8]=ERgb;
|
sl@0
|
100 |
mode[9]=EColor4K;
|
sl@0
|
101 |
mode[10]=EColor16MU;
|
sl@0
|
102 |
mode[11]=EColor16MA;
|
sl@0
|
103 |
mode[12]=EColor16MAP;
|
sl@0
|
104 |
|
sl@0
|
105 |
|
sl@0
|
106 |
TInt count;
|
sl@0
|
107 |
for (count=0;count<13;count++)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
TRAP(err, iDev = CFbsScreenDevice::NewL(KNullDesC, mode[count]));
|
sl@0
|
110 |
if (err!=KErrNotSupported)
|
sl@0
|
111 |
{
|
sl@0
|
112 |
break;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
User::LeaveIfNull(iDev);
|
sl@0
|
117 |
|
sl@0
|
118 |
if(err == KErrNone)
|
sl@0
|
119 |
{
|
sl@0
|
120 |
iDev->ChangeScreenDevice(NULL);
|
sl@0
|
121 |
iDev->SetAutoUpdate(ETrue);
|
sl@0
|
122 |
iDev->CreateContext(iGc);
|
sl@0
|
123 |
}
|
sl@0
|
124 |
User::LeaveIfNull(iGc);
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
TRunProc2* TRunProc2::NewL()
|
sl@0
|
128 |
{
|
sl@0
|
129 |
TRunProc2 *ptr = new (ELeave) TRunProc2;
|
sl@0
|
130 |
CleanupStack::PushL(ptr);
|
sl@0
|
131 |
ptr->ConstructL();
|
sl@0
|
132 |
CleanupStack::Pop();
|
sl@0
|
133 |
return ptr;
|
sl@0
|
134 |
}
|
sl@0
|
135 |
|
sl@0
|
136 |
void TRunProc2::CreateFont()
|
sl@0
|
137 |
{
|
sl@0
|
138 |
//make sure that the font is large enough to ensure that the session
|
sl@0
|
139 |
//cache is used.
|
sl@0
|
140 |
TInt height=220;
|
sl@0
|
141 |
|
sl@0
|
142 |
TOpenFontSpec openFontSpec;
|
sl@0
|
143 |
openFontSpec.SetName(KOpenFont);
|
sl@0
|
144 |
openFontSpec.SetHeight(height);
|
sl@0
|
145 |
openFontSpec.SetItalic(EFalse);
|
sl@0
|
146 |
openFontSpec.SetBold(EFalse);
|
sl@0
|
147 |
|
sl@0
|
148 |
TTypeface Typeface;
|
sl@0
|
149 |
Typeface.iName = KOpenFont;
|
sl@0
|
150 |
TFontSpec fs;
|
sl@0
|
151 |
fs.iTypeface = Typeface;
|
sl@0
|
152 |
|
sl@0
|
153 |
fs.iHeight = height;
|
sl@0
|
154 |
CFbsFont* font = NULL;
|
sl@0
|
155 |
TInt err = iDev->GetNearestFontToDesignHeightInPixels(font, fs);
|
sl@0
|
156 |
|
sl@0
|
157 |
User::LeaveIfNull(font);
|
sl@0
|
158 |
|
sl@0
|
159 |
// Use the font
|
sl@0
|
160 |
iGc->UseFont(font);
|
sl@0
|
161 |
iGc->Clear();
|
sl@0
|
162 |
}
|
sl@0
|
163 |
|
sl@0
|
164 |
void TRunProc2::RunTestL(TInt aThirdProcess, TInt aTimeout)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
if (aThirdProcess)
|
sl@0
|
167 |
{
|
sl@0
|
168 |
RTimer timer;
|
sl@0
|
169 |
|
sl@0
|
170 |
timer.CreateLocal();
|
sl@0
|
171 |
TRequestStatus timerStatus=KRequestPending;
|
sl@0
|
172 |
TTimeIntervalMicroSeconds32 timeout(aTimeout);
|
sl@0
|
173 |
timer.After(timerStatus, timeout);
|
sl@0
|
174 |
|
sl@0
|
175 |
CreateFont();
|
sl@0
|
176 |
do
|
sl@0
|
177 |
{
|
sl@0
|
178 |
DrawText();
|
sl@0
|
179 |
}
|
sl@0
|
180 |
while (timerStatus==KRequestPending);
|
sl@0
|
181 |
timer.Cancel();
|
sl@0
|
182 |
iGc->DiscardFont();
|
sl@0
|
183 |
RProcess::Rendezvous(10);
|
sl@0
|
184 |
}
|
sl@0
|
185 |
else
|
sl@0
|
186 |
{
|
sl@0
|
187 |
CreateFont();
|
sl@0
|
188 |
DrawText();
|
sl@0
|
189 |
iGc->DiscardFont();
|
sl@0
|
190 |
RProcess::Rendezvous(1);
|
sl@0
|
191 |
}
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
void TRunProc2::DrawText()
|
sl@0
|
195 |
{
|
sl@0
|
196 |
TText ch[2];
|
sl@0
|
197 |
ch[1]='\0';
|
sl@0
|
198 |
for (ch[0]='A';ch[0]<='Z';ch[0]++)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
TBufC<2> buf(ch);
|
sl@0
|
201 |
iGc->DrawText(buf,TPoint(10,100));
|
sl@0
|
202 |
}
|
sl@0
|
203 |
for (ch[0]='a';ch[0]<='z';ch[0]++)
|
sl@0
|
204 |
{
|
sl@0
|
205 |
TBufC<2> buf(ch);
|
sl@0
|
206 |
iGc->DrawText(buf,TPoint(10,100));
|
sl@0
|
207 |
}
|
sl@0
|
208 |
}
|
sl@0
|
209 |
|
sl@0
|
210 |
void MainL()
|
sl@0
|
211 |
{
|
sl@0
|
212 |
TRunProc2* test= TRunProc2::NewL();
|
sl@0
|
213 |
CleanupStack::PushL(test);
|
sl@0
|
214 |
TInt param;
|
sl@0
|
215 |
TInt timeoutParam;
|
sl@0
|
216 |
User::LeaveIfError(User::GetTIntParameter(1,param));
|
sl@0
|
217 |
User::LeaveIfError(User::GetTIntParameter(2,timeoutParam));
|
sl@0
|
218 |
test->RunTestL(param,timeoutParam);
|
sl@0
|
219 |
CleanupStack::PopAndDestroy();
|
sl@0
|
220 |
}
|
sl@0
|
221 |
|
sl@0
|
222 |
// Cleanup stack harness
|
sl@0
|
223 |
GLDEF_C TInt E32Main()
|
sl@0
|
224 |
{
|
sl@0
|
225 |
__UHEAP_MARK;
|
sl@0
|
226 |
CTrapCleanup* cleanupStack = CTrapCleanup::New();
|
sl@0
|
227 |
TRAPD(error, MainL());
|
sl@0
|
228 |
_LIT(KTCacheDeletionProcess,"TCacheDeletionProcess");
|
sl@0
|
229 |
__ASSERT_ALWAYS(!error, User::Panic(KTCacheDeletionProcess, error));
|
sl@0
|
230 |
delete cleanupStack;
|
sl@0
|
231 |
__UHEAP_MARKEND;
|
sl@0
|
232 |
return 0;
|
sl@0
|
233 |
}
|