Update contrib.
1 // Copyright (c) 1997-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.
23 #include <graphics/fbsdefs.h>
26 CTGdi::CTGdi(CTestStep* aStep):
27 CTGraphicsBase(aStep),
32 void CTGdi::RunTestCaseL(TInt aCurTestCase)
34 ((CTGdiStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
38 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
42 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
46 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
50 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
51 TestScreenL(EGray256);
54 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
55 TestScreenL(EColor16);
58 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
59 TestScreenL(EColor256);
62 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
63 TestScreenL(EColor4K);
66 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
67 TestScreenL(EColor64K);
70 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
71 TestScreenL(EColor16M);
74 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
75 TestScreenL(EColor16MU);
78 ((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
79 // Test still failing, see DEF094106
80 // TestScreenL(EColor16MA);
83 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
87 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
91 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
95 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
96 TestBitmapL(EGray256);
99 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
100 TestBitmapL(EColor16);
103 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
104 TestBitmapL(EColor256);
107 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
108 TestBitmapL(EColor4K);
111 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
112 TestBitmapL(EColor64K);
115 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
116 TestBitmapL(EColor16M);
119 ((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
120 TestBitmapL(EColor16MU);
123 ((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
124 // Test still failing, see DEF094106
125 // TestBitmapL(EColor16MA);
128 ((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
129 ((CTGdiStep*)iStep)->CloseTMSGraphicsStep();
133 ((CTGdiStep*)iStep)->RecordTestResultL();
139 @SYMTestCaseID GRAPHICS-BITGDI-0030
143 @SYMTestCaseDesc Tests screen creation in various colour modes
145 @SYMTestPriority High
147 @SYMTestStatus Implemented
149 @SYMTestActions Creates a screen in a certain colour mode, draws a bitmap on it then destroys it
151 @SYMTestExpectedResults Test should pass
153 void CTGdi::TestScreenL(TDisplayMode aDispMode)
155 CFbsScreenDevice* device = NULL;
156 TRAPD(err,device = CFbsScreenDevice::NewL(_L("scdv"),aDispMode));
157 if (err == KErrNotSupported)
160 User::LeaveIfError(err);
161 CleanupStack::PushL(device);
162 device->ChangeScreenDevice(NULL);
163 device->SetAutoUpdate(ETrue);
165 DoTestAndDeleteL(device,ETrue);
166 CleanupStack::PopAndDestroy(1,device);
171 @SYMTestCaseID GRAPHICS-BITGDI-0031
175 @SYMTestCaseDesc Tests bitmap creation in various colour modes
177 @SYMTestPriority High
179 @SYMTestStatus Implemented
181 @SYMTestActions Creates a bitmap in a certain colour mode, draws a bitmap on it then destroys it
183 @SYMTestExpectedResults Test should pass
185 void CTGdi::TestBitmapL(TDisplayMode aDispMode)
187 CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
188 CleanupStack::PushL(bitmap);
189 //Creating a Reference Bitmap of screensize to compare the results
190 CFbsScreenDevice* qdevice = NULL;
191 TRAPD(error, qdevice = CFbsScreenDevice::NewL(_L("scdv"),aDispMode));
193 if (error == KErrNotSupported)
195 CleanupStack::PopAndDestroy(bitmap);
200 User::LeaveIfError(error);
203 CleanupStack::PushL(qdevice);
204 qdevice->SetAutoUpdate(ETrue);
205 TSize screensize=qdevice->SizeInPixels();
206 TInt ret = bitmap->Create(screensize,aDispMode);
207 if (ret == KErrNotSupported)
209 CleanupStack::PopAndDestroy(2,bitmap);
214 User::LeaveIfError(ret);
217 CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(bitmap);
218 CleanupStack::PushL(device);
219 DoTestAndDeleteL(device, EFalse);
220 CleanupStack::PopAndDestroy(3,bitmap);
223 void CTGdi::DoTestAndDeleteL(CFbsDevice* aDevice,TBool aScreen)
225 CFbsBitGc* gc = NULL;
226 User::LeaveIfError(aDevice->CreateContext(gc));
227 CleanupStack::PushL(gc);
229 CFbsFont* font = NULL;
230 User::LeaveIfError(aDevice->GetNearestFontToDesignHeightInTwips(font,TFontSpec()));
232 aDevice->ReleaseFont(font);
234 CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
235 CleanupStack::PushL(bmp);
236 TInt ret = bmp->Load(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTblank);
237 User::LeaveIfError(ret);
238 gc->UseBrushPattern(bmp->Handle());
241 INFO_PRINTF2(_L("Gdi screen device testing, mode %d\n"),aDevice->DisplayMode());
243 INFO_PRINTF2(_L("Gdi bitmap device testing, mode %d\n"),aDevice->DisplayMode());
245 TBuf<KFailureSectionNameBufferLength> section;
246 iTestGdi.Construct(aDevice,gc,section);
248 TBool pass = iTestGdi.Test();
252 INFO_PRINTF2(_L("Gdi device test failed section: %S"),§ion);
257 CleanupStack::PopAndDestroy(2,gc);
261 __CONSTRUCT_STEP__(Gdi)
263 void CTGdiStep::TestSetupL()
266 User::LeaveIfError(RFbsSession::Connect());
269 void CTGdiStep::TestClose()
271 RFbsSession::Disconnect();