sl@0: /* sl@0: * Copyright (c) 2006-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: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #include "FNTSTORE.H" sl@0: #include sl@0: sl@0: _LIT(KOpenFont, "DejaVu Sans Condensed"); sl@0: sl@0: #ifdef __WINSCW__ sl@0: //this is used for winscw breakpoints sl@0: #define BR _asm( int 3); sl@0: #endif sl@0: sl@0: const TInt KTimeOut = 1000 * 1000; sl@0: sl@0: sl@0: _LIT(KTCacheDeletionProcess,"T_fontsessioncacheproc"); sl@0: sl@0: /* it is expected that the main in this file will be called to test multiple sl@0: process cache searching which is in the shared heap. sl@0: */ sl@0: sl@0: class CRunProc: public CBase sl@0: { sl@0: public: sl@0: void RunTestL(); sl@0: CRunProc(); sl@0: ~CRunProc(); sl@0: sl@0: inline void setFont(CFont*); sl@0: inline void setHandle(TInt); sl@0: private: sl@0: void CreateFontL(); sl@0: sl@0: private: sl@0: CBitmapFont* iFont; sl@0: TInt iSessionHandle; sl@0: }; sl@0: sl@0: CRunProc::CRunProc() sl@0: { sl@0: sl@0: } sl@0: sl@0: CRunProc::~CRunProc() sl@0: { sl@0: sl@0: } sl@0: sl@0: inline void CRunProc::setFont(CFont* aFont) sl@0: { sl@0: iFont = static_cast(aFont); sl@0: } sl@0: sl@0: inline void CRunProc::setHandle(TInt aSessionHandle) sl@0: { sl@0: iSessionHandle = aSessionHandle; sl@0: } sl@0: sl@0: sl@0: void CRunProc::RunTestL() sl@0: { sl@0: TTime theTime; sl@0: theTime.UniversalTime(); sl@0: TInt64 randSeed(theTime.Int64()); sl@0: TInt random(Math::Rand(randSeed) % (1000 * 1000)); sl@0: User::After(random); sl@0: sl@0: RTimer timer; sl@0: timer.CreateLocal(); sl@0: TRequestStatus timerStatus = KRequestPending; sl@0: TTimeIntervalMicroSeconds32 timeout(KTimeOut); sl@0: timer.After(timerStatus, timeout); sl@0: sl@0: TText ch; sl@0: const TUint8 *bitmap = NULL; sl@0: TSize bitmapsize; sl@0: TOpenFontCharMetrics Metrics; sl@0: do sl@0: { sl@0: TInt hitcount = 0; sl@0: for (ch = 'A'; ch <= 'z'; ch++) sl@0: { sl@0: if(iFont->GetCharacterData(iSessionHandle, (TInt)ch, Metrics,bitmap)) sl@0: { sl@0: //RDebug::Print(_L("%c hit bitmap[0]=%x"),ch,bitmap[0]); sl@0: TUint8 testbyte = bitmap[0]; sl@0: testbyte += testbyte; sl@0: __ASSERT_ALWAYS((testbyte & 0x01) == 0, User::Panic(KTCacheDeletionProcess, KErrGeneral)); sl@0: hitcount++; sl@0: } sl@0: else sl@0: { sl@0: //RDebug::Print(_L("%c missed"),ch); sl@0: } sl@0: } sl@0: __ASSERT_ALWAYS(hitcount > 0, User::Panic(KTCacheDeletionProcess, KErrNotFound)); sl@0: } sl@0: while (timerStatus == KRequestPending); sl@0: sl@0: timer.Cancel(); sl@0: timer.Close(); sl@0: } sl@0: sl@0: void MainL() sl@0: { sl@0: RChunk gChunk; sl@0: User::LeaveIfError(gChunk.Open(1)); sl@0: CleanupClosePushL(gChunk); sl@0: sl@0: TInt offset; sl@0: User::LeaveIfError(User::GetTIntParameter(2,offset)); sl@0: TInt SessionHandle; sl@0: User::LeaveIfError(User::GetTIntParameter(3,SessionHandle)); sl@0: sl@0: CRunProc *test = new (ELeave) CRunProc; sl@0: sl@0: test->setFont(reinterpret_cast(offset + reinterpret_cast(gChunk.Base()))); sl@0: test->setHandle(SessionHandle); sl@0: CleanupStack::PushL(test); sl@0: sl@0: RDebug::Print(_L("T_fontsessioncacheproc MainL()")); sl@0: test->RunTestL(); sl@0: sl@0: CleanupStack::PopAndDestroy(2); sl@0: } sl@0: sl@0: // Cleanup stack harness sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: CTrapCleanup* cleanupStack = CTrapCleanup::New(); sl@0: TRAPD(error, MainL()); sl@0: __ASSERT_ALWAYS(!error, User::Panic(KTCacheDeletionProcess, error)); sl@0: delete cleanupStack; sl@0: __UHEAP_MARKEND; sl@0: return 0; sl@0: }