First public contribution.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // used for timing graphics
20 #define TEST_ROM_BITMAP_NAME _L("Z:\\WSTEST\\TROM.MBM")
31 class TWsTest : public CBase
34 void DoTestL(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2);
35 void SimpleFlush(TInt aParam1, TAny *aParam2);
36 void SpriteSettingL(TInt aParam1, TAny *aParam2);
37 void BitmapDeviceL(TInt aParam, TAny *);
38 void TrivialFunctions(TInt aParam1, TAny *aParam2);
39 void LoadBitmapL(TInt aParam1, TAny *aParam2);
41 void createSpriteBitmapL(CFbsBitmap *aBitmap, CFbsBitmapDevice *&aBitmapDevice, const TSize &aSize, TBool aDoMask);
46 CWsScreenDevice *iDevice;
50 TInt CreateWsTest(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2)
53 TRAPD(err,iTest=new(ELeave) TWsTest());
56 TRAP(err,iTest->DoTestL(aOwningGroup, aFunc, aParam1, aParam2));
62 void TWsTest::DoTestL(TInt aOwningGroup, TFuncType aFunc, TInt aParam1, TAny *aParam2)
65 iDevice=new(ELeave) CWsScreenDevice(iWs);
67 iGroup=RWindowGroup(iWs);
68 iGroup.Construct(ENullWsHandle);
69 iGroup.SetOwningWindowGroup(aOwningGroup);
72 iWindow.Construct(iGroup,ENullWsHandle);
73 iWindow.SetExtent(TPoint(), iDevice->SizeInPixels());
76 iDevice->CreateContext(iGc);
77 iWindow.BeginRedraw();
78 iGc->Activate(iWindow);
85 SimpleFlush(aParam1, aParam2);
88 SpriteSettingL(aParam1, aParam2);
91 BitmapDeviceL(aParam1, aParam2);
93 case ETrivialFunctions:
94 TrivialFunctions(aParam1, aParam2);
97 LoadBitmapL(aParam1, aParam2);
110 void TWsTest::SimpleFlush(TInt aParam, TAny *)
112 TTimeIntervalMicroSeconds32 interval(100000);
116 TTimeIntervalMicroSeconds32 origInterval;
118 iWs.GetDoubleClickSettings(origInterval,origDistance);
119 for(TInt nTimes=0;nTimes<5000-1;nTimes++)
121 iWs.SetDoubleClick(interval,distance);
124 iWs.SetDoubleClick(origInterval,origDistance);
128 for(TInt nTimes=0;nTimes<5000;nTimes++)
129 iWs.GetDoubleClickSettings(interval,distance);
133 TInt SimpleFlushTestFunc(TInt aOwningGroup)
135 return(CreateWsTest(aOwningGroup, ESimpleFlush, 0, NULL));
138 TInt SimpleFlushTestFunc2(TInt aOwningGroup)
140 return(CreateWsTest(aOwningGroup, ESimpleFlush, 1, NULL));
143 GLDEF_D TTimeTestHeader SimpleFlushTest={_S("Simple Flush[1] x5000"),SimpleFlushTestFunc};
144 GLDEF_D TTimeTestHeader SimpleFlushTest2={_S("Simple Flush[2] x5000"),SimpleFlushTestFunc2};
149 TInt ReadWriteThreadFunc(TAny *aParams)
152 RProcess().CommandLine(command);
153 TDesC8 *cmd=&command;
155 thread.Open(_L("TimeTest"));
156 TAny *remotePtr=*(TAny **)aCmd->Ptr();
158 for(TInt count=0;count<100000;count++)
159 thread.ReadL(remotePtr,buf,0);
162 void TWsTest::IPReadWriteL(TInt aParam, TAny *)
165 srcData.Append(_L("1234567890ABCDEF"));
168 *((TAny **)command.Ptr())=&srcData;
169 User::LeaveIfError(process.Create(_L("TimeThread1"),);
170 TRequestStatus status;
171 process.Logon(status);
173 User::WaitForRequest(status);
177 TInt SimpleFlushTestFunc(TInt aOwningGroup)
179 return(CreateWsTest(aOwningGroup, ESimpleFlush, 0, NULL));
182 TInt SimpleFlushTestFunc2(TInt aOwningGroup)
184 return(CreateWsTest(aOwningGroup, ESimpleFlush, 1, NULL));
187 GLDEF_D TTimeTestHeader SimpleFlushTest={_S("Simple Flush[1] x5000"),SimpleFlushTestFunc};
188 GLDEF_D TTimeTestHeader SimpleFlushTest2={_S("Simple Flush[2] x5000"),SimpleFlushTestFunc2};
192 void TWsTest::BitmapDeviceL(TInt aParam, TAny *)
194 CFbsBitmap *bitmap=new(ELeave) CFbsBitmap();
195 User::LeaveIfError(bitmap->Create(TSize(10,10),EGray4));
196 CFbsBitmapDevice *bitmapDevicePerm=NULL;
198 bitmapDevicePerm=CFbsBitmapDevice::NewL(bitmap);
199 for(TInt nTimes=0;nTimes<100;nTimes++)
201 CFbsBitmapDevice *bitmapDevice=CFbsBitmapDevice::NewL(bitmap);
204 delete bitmapDevicePerm;
208 TInt BitmapDeviceTestFunc1(TInt aOwningGroup)
210 return(CreateWsTest(aOwningGroup, EBitmapDevice, 0, NULL));
213 TInt BitmapDeviceTestFunc2(TInt aOwningGroup)
215 return(CreateWsTest(aOwningGroup, EBitmapDevice, 1, NULL));
218 GLDEF_D TTimeTestHeader BitmapDeviceTest1={_S("Bitmap Device (reload)"),BitmapDeviceTestFunc1};
219 GLDEF_D TTimeTestHeader BitmapDeviceTest2={_S("Bitmap Device "),BitmapDeviceTestFunc2};
223 void TWsTest::createSpriteBitmapL(CFbsBitmap *aBitmap, CFbsBitmapDevice *&aBitmapDevice, const TSize &aSize, TBool aDoMask)
225 User::LeaveIfError(aBitmap->Create(aSize,EGray4));
226 aBitmapDevice=CFbsBitmapDevice::NewL(aBitmap);
227 CFbsBitGc *gc=CFbsBitGc::NewL();
228 gc->Activate(aBitmapDevice);
229 gc->SetBrushColor(TRgb::Gray4(aDoMask ? 0 : 2));
230 gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
231 gc->SetPenStyle(CGraphicsContext::ENullPen);
232 gc->DrawRect(TRect(aSize));
233 gc->SetPenStyle(CGraphicsContext::ESolidPen);
234 gc->SetPenColor(TRgb::Gray4(aDoMask ? 3 : 0));
235 gc->SetBrushColor(TRgb::Gray4(aDoMask ? 3 : 1));
236 gc->DrawEllipse(TRect(aSize));
240 void TWsTest::SpriteSettingL(TInt , TAny *)
244 sprite=RWsSprite(iWs);
245 CFbsBitmap *bitmap=new(ELeave) CFbsBitmap();
246 CFbsBitmap *mask=new(ELeave) CFbsBitmap();
247 CFbsBitmapDevice *bitmapDevice=NULL; //To stop warning
248 TRAPD(err,createSpriteBitmapL(bitmap,bitmapDevice,size,EFalse));
250 TRAP(err,createSpriteBitmapL(mask,bitmapDevice,size,ETrue));
252 TSpriteMember spriteData;
253 spriteData.iBitmap=bitmap;
254 spriteData.iMaskBitmap=mask;
255 spriteData.iInvertMask=EFalse;
256 spriteData.iInterval=TTimeIntervalMicroSeconds32(0);
257 User::LeaveIfError(sprite.Construct(iWindow,TPoint(0,0),0));
258 User::LeaveIfError(sprite.AppendMember(spriteData));
259 User::LeaveIfError(sprite.Activate());
260 for(TInt i=0;i<500;i++)
261 sprite.SetPosition(TPoint(i&0x7f,i&0x7f));
267 TInt SpriteSettingTestFunc(TInt aOwningGroup)
269 return(CreateWsTest(aOwningGroup, ESpriteSetting, 0, NULL));
272 GLDEF_D TTimeTestHeader SpriteTest={_S("Sprite Setting"),SpriteSettingTestFunc};
274 void TWsTest::TrivialFunctions(TInt , TAny *)
276 for(TInt i=0;i<100000;i++)
277 iWs.FreeSystemPointerCursorList();
280 TInt TrivialFunctionsTestFunc(TInt aOwningGroup)
282 return(CreateWsTest(aOwningGroup, ETrivialFunctions, 0, NULL));
285 GLDEF_D TTimeTestHeader TrivialFunctionsTest={_S("TrivialFunctions"),TrivialFunctionsTestFunc};
287 void TWsTest::LoadBitmapL(TInt aMode, TAny *)
291 for(TInt count=0;count<10;count++)
295 CFbsBitmap *bit=new(ELeave) CFbsBitmap();
296 User::LeaveIfError(bit->Load(TEST_ROM_BITMAP_NAME,0));
301 CWsBitmap *bit=new(ELeave) CWsBitmap(iWs);
302 User::LeaveIfError(bit->Load(TEST_ROM_BITMAP_NAME,0));
307 else for(TInt count=0;count<100;count++)
311 User::LeaveIfError(fs.Connect());
312 fs.SetNotifyUser(EFalse);
316 User::LeaveIfError(fs.Parse(TEST_ROM_BITMAP_NAME,parse));
320 User::LeaveIfError(RFs::CharToDrive(parse.Drive()[0],drive));
321 TDriveInfo driveinfo;
322 User::LeaveIfError(fs.Drive(driveinfo,drive));
326 User::LeaveIfError(tempfile.Open(fs,TEST_ROM_BITMAP_NAME,EFileShareAny));
328 tempfile.Seek(ESeekAddress,aAddress);
337 TInt LoadBitmapTestFunc(TInt aOwningGroup)
339 return(CreateWsTest(aOwningGroup, ELoadBitmap, 0, NULL));
341 TInt LoadWsBitmapTestFunc(TInt aOwningGroup)
343 return(CreateWsTest(aOwningGroup, ELoadBitmap, 1, NULL));
345 TInt LoadRomFileTestFunc(TInt aOwningGroup)
347 return(CreateWsTest(aOwningGroup, ELoadBitmap, 3, NULL));
350 GLDEF_D TTimeTestHeader BitmapLoadTest={_S("Load Bitmap"),LoadBitmapTestFunc};
351 GLDEF_D TTimeTestHeader WsBitmapLoadTest={_S("Load WsBitmap"),LoadWsBitmapTestFunc};
352 GLDEF_D TTimeTestHeader RomFileTest={_S("Rom File"),LoadRomFileTestFunc};