Update contrib.
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
21 @internalComponent - Internal Symbian test code
27 _LIT(KOpenFont, "DejaVu Sans Condensed");
30 //this is used for winscw breakpoints
31 #define BR _asm( int 3);
34 const TInt KTimeOut = 1000 * 1000;
37 _LIT(KTCacheDeletionProcess,"T_fontsessioncacheproc");
39 /* it is expected that the main in this file will be called to test multiple
40 process cache searching which is in the shared heap.
43 class CRunProc: public CBase
50 inline void setFont(CFont*);
51 inline void setHandle(TInt);
70 inline void CRunProc::setFont(CFont* aFont)
72 iFont = static_cast<CBitmapFont*>(aFont);
75 inline void CRunProc::setHandle(TInt aSessionHandle)
77 iSessionHandle = aSessionHandle;
81 void CRunProc::RunTestL()
84 theTime.UniversalTime();
85 TInt64 randSeed(theTime.Int64());
86 TInt random(Math::Rand(randSeed) % (1000 * 1000));
91 TRequestStatus timerStatus = KRequestPending;
92 TTimeIntervalMicroSeconds32 timeout(KTimeOut);
93 timer.After(timerStatus, timeout);
96 const TUint8 *bitmap = NULL;
98 TOpenFontCharMetrics Metrics;
102 for (ch = 'A'; ch <= 'z'; ch++)
104 if(iFont->GetCharacterData(iSessionHandle, (TInt)ch, Metrics,bitmap))
106 //RDebug::Print(_L("%c hit bitmap[0]=%x"),ch,bitmap[0]);
107 TUint8 testbyte = bitmap[0];
108 testbyte += testbyte;
109 __ASSERT_ALWAYS((testbyte & 0x01) == 0, User::Panic(KTCacheDeletionProcess, KErrGeneral));
114 //RDebug::Print(_L("%c missed"),ch);
117 __ASSERT_ALWAYS(hitcount > 0, User::Panic(KTCacheDeletionProcess, KErrNotFound));
119 while (timerStatus == KRequestPending);
128 User::LeaveIfError(gChunk.Open(1));
129 CleanupClosePushL(gChunk);
132 User::LeaveIfError(User::GetTIntParameter(2,offset));
134 User::LeaveIfError(User::GetTIntParameter(3,SessionHandle));
136 CRunProc *test = new (ELeave) CRunProc;
138 test->setFont(reinterpret_cast<CFont*>(offset + reinterpret_cast<TInt>(gChunk.Base())));
139 test->setHandle(SessionHandle);
140 CleanupStack::PushL(test);
142 RDebug::Print(_L("T_fontsessioncacheproc MainL()"));
145 CleanupStack::PopAndDestroy(2);
148 // Cleanup stack harness
149 GLDEF_C TInt E32Main()
152 CTrapCleanup* cleanupStack = CTrapCleanup::New();
153 TRAPD(error, MainL());
154 __ASSERT_ALWAYS(!error, User::Panic(KTCacheDeletionProcess, error));