sl@0
|
1 |
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <hal.h>
|
sl@0
|
17 |
#include <bitdraw.h>
|
sl@0
|
18 |
#include "TScdvTest.h"
|
sl@0
|
19 |
|
sl@0
|
20 |
GLREF_C TInt ByteSize(TDisplayMode aDisplayMode,TInt aWidth);
|
sl@0
|
21 |
|
sl@0
|
22 |
//===================================================================
|
sl@0
|
23 |
//In order to test multiple screens creation process on the Emulator,
|
sl@0
|
24 |
//you have to extend your epoc.ini file with the following lines
|
sl@0
|
25 |
//_NewScreen_
|
sl@0
|
26 |
//ScreenWidth 200
|
sl@0
|
27 |
//ScreenHeight 300
|
sl@0
|
28 |
//===================================================================
|
sl@0
|
29 |
|
sl@0
|
30 |
CTScdv::CTScdv(CTestStep* aStep) :
|
sl@0
|
31 |
CTGraphicsBase(aStep)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
|
sl@0
|
34 |
}
|
sl@0
|
35 |
|
sl@0
|
36 |
//The method calculates the memory (in bytes) needed for a screen
|
sl@0
|
37 |
//device with aSize size and aDisplayMode mode.
|
sl@0
|
38 |
inline TInt CTScdv::ByteSize(const TSize& aSize, TDisplayMode aDisplayMode)
|
sl@0
|
39 |
{
|
sl@0
|
40 |
return ::ByteSize(aDisplayMode,aSize.iWidth) * aSize.iHeight;
|
sl@0
|
41 |
}
|
sl@0
|
42 |
|
sl@0
|
43 |
//The method creates a screen device for aScreenNo screen number .
|
sl@0
|
44 |
//Possible leaving error codes: KErrNoMemory.
|
sl@0
|
45 |
//Return result: ETrue - the device was created successfully, EFalse - not supported.
|
sl@0
|
46 |
//Successfully created device will be pushed on the cleanup stack.
|
sl@0
|
47 |
TBool CTScdv::CreateScreenDeviceLC(TInt aScreenNo,
|
sl@0
|
48 |
TDisplayMode aDisplayMode,
|
sl@0
|
49 |
CFbsDrawDevice*& aScreenDevice)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
__ASSERT_ALWAYS(aScreenDevice == NULL, User::Invariant());
|
sl@0
|
52 |
TBool res = EFalse;
|
sl@0
|
53 |
TRAPD(err, aScreenDevice = CFbsDrawDevice::NewScreenDeviceL(aScreenNo, aDisplayMode));
|
sl@0
|
54 |
if(err == KErrNone)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
CleanupStack::PushL(aScreenDevice);
|
sl@0
|
57 |
res = ETrue;
|
sl@0
|
58 |
}
|
sl@0
|
59 |
else
|
sl@0
|
60 |
{
|
sl@0
|
61 |
if(err != KErrNotSupported)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
User::LeaveIfError(err);
|
sl@0
|
64 |
}
|
sl@0
|
65 |
}
|
sl@0
|
66 |
return res;
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
//The method initializes aScreenDevice screen device and allocates.
|
sl@0
|
70 |
//a block of memory for it.
|
sl@0
|
71 |
//Possible leaving error codes: KErrNoMemory.
|
sl@0
|
72 |
//The allocated bock of memory will be pushed on the cleanup stack.
|
sl@0
|
73 |
TAny* CTScdv::InitScreenDeviceLC(CFbsDrawDevice* aScreenDevice,
|
sl@0
|
74 |
TDisplayMode aDisplayMode)
|
sl@0
|
75 |
{
|
sl@0
|
76 |
__ASSERT_ALWAYS(aScreenDevice != NULL, User::Invariant());
|
sl@0
|
77 |
|
sl@0
|
78 |
TSize size = aScreenDevice->SizeInPixels();
|
sl@0
|
79 |
TInt bytesToAllocate=ByteSize(size, aDisplayMode);
|
sl@0
|
80 |
const TInt bytesRequire=bytesToAllocate;
|
sl@0
|
81 |
TUint8* devMemory = new TUint8[bytesToAllocate];
|
sl@0
|
82 |
if (!devMemory)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
do {
|
sl@0
|
85 |
bytesToAllocate/=2;
|
sl@0
|
86 |
devMemory=new TUint8[bytesToAllocate];
|
sl@0
|
87 |
} while (devMemory==NULL && bytesToAllocate>0);
|
sl@0
|
88 |
if (devMemory)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
_LIT(KLog1,"Not enought memory!! Allocated %d (0x%x) bytes when %d (0x%x) bytes required.");
|
sl@0
|
91 |
INFO_PRINTF5(KLog1,bytesToAllocate,bytesToAllocate,bytesRequire,bytesRequire);
|
sl@0
|
92 |
_LIT(KLog2,"Display Mode: %S, Screen Size: %d,%d");
|
sl@0
|
93 |
INFO_PRINTF4(KLog2,&ColorModeName(aDisplayMode),size.iWidth,size.iHeight);
|
sl@0
|
94 |
}
|
sl@0
|
95 |
else
|
sl@0
|
96 |
{
|
sl@0
|
97 |
_LIT(KLog,"Failed to Allocate memory!! %d (0x%x) bytes required, Display Mode: %S, Screen Size: %d,%d");
|
sl@0
|
98 |
INFO_PRINTF6(KLog,bytesRequire,bytesRequire,&ColorModeName(aDisplayMode),size.iWidth,size.iHeight);
|
sl@0
|
99 |
User::Leave(KErrNoMemory);
|
sl@0
|
100 |
}
|
sl@0
|
101 |
}
|
sl@0
|
102 |
CleanupStack::PushL(devMemory);
|
sl@0
|
103 |
|
sl@0
|
104 |
aScreenDevice->SetUserDisplayMode(aDisplayMode);
|
sl@0
|
105 |
aScreenDevice->SetAutoUpdate(EFalse);
|
sl@0
|
106 |
aScreenDevice->SetBits(devMemory);
|
sl@0
|
107 |
return devMemory;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
//Mutltiple screen devices creation test
|
sl@0
|
111 |
void CTScdv::TestScreenDeviceCreationL()
|
sl@0
|
112 |
{
|
sl@0
|
113 |
TDisplayMode mode[] = { EColor256, EColor4K, EColor64K, EColor16,
|
sl@0
|
114 |
EColor16MU, EColor16MA, EColor16MAP };
|
sl@0
|
115 |
|
sl@0
|
116 |
const TInt KTestedDevCnt = 2;
|
sl@0
|
117 |
|
sl@0
|
118 |
for(TInt ii=0;ii<TInt(sizeof(mode)/sizeof(mode[0]));++ii)
|
sl@0
|
119 |
{
|
sl@0
|
120 |
//create
|
sl@0
|
121 |
CFbsDrawDevice* dev[KTestedDevCnt];
|
sl@0
|
122 |
Mem::FillZ(dev, sizeof(dev));
|
sl@0
|
123 |
TInt cnt = 0;
|
sl@0
|
124 |
for(cnt=0;cnt<KTestedDevCnt;++cnt)
|
sl@0
|
125 |
{
|
sl@0
|
126 |
TBool res = CreateScreenDeviceLC(cnt, mode[ii], dev[cnt]);
|
sl@0
|
127 |
if(res)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
InitScreenDeviceLC(dev[cnt], mode[ii]);
|
sl@0
|
130 |
_LIT(KLog,"Created Screen Device with mode %S on screen %d");
|
sl@0
|
131 |
INFO_PRINTF3(KLog,&ColorModeName(mode[ii]),cnt);
|
sl@0
|
132 |
//destroy
|
sl@0
|
133 |
CleanupStack::PopAndDestroy(2,dev[cnt]);
|
sl@0
|
134 |
}
|
sl@0
|
135 |
else
|
sl@0
|
136 |
{
|
sl@0
|
137 |
_LIT(KLog,"No support for display mode %S on screen %d");
|
sl@0
|
138 |
const TDesC* name=&ColorModeName(mode[ii]);
|
sl@0
|
139 |
INFO_PRINTF3(KLog, name, cnt);
|
sl@0
|
140 |
RDebug::Print(KLog, name, cnt);
|
sl@0
|
141 |
break;
|
sl@0
|
142 |
}
|
sl@0
|
143 |
}
|
sl@0
|
144 |
}
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
//Bitmap device creation test
|
sl@0
|
148 |
void CTScdv::TestBitmapDeviceCreationL()
|
sl@0
|
149 |
{
|
sl@0
|
150 |
TDisplayMode mode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor16MA, EColor16MAP, EColor64K,
|
sl@0
|
151 |
EGray256, EGray16, EGray4, EGray2, EColor16};
|
sl@0
|
152 |
for(TInt ii=0;ii<TInt(sizeof(mode)/sizeof(mode[0]));++ii)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
//create
|
sl@0
|
155 |
TSize size(10, 20);
|
sl@0
|
156 |
TUint8* bitmapMem = new (ELeave) TUint8[ByteSize(size, mode[ii])];
|
sl@0
|
157 |
CleanupStack::PushL(bitmapMem);
|
sl@0
|
158 |
CFbsDrawDevice* bitmapDev = CFbsDrawDevice::NewBitmapDeviceL(size, mode[ii], ByteSize(size, mode[ii]) / size.iHeight);
|
sl@0
|
159 |
CleanupStack::PushL(bitmapDev);
|
sl@0
|
160 |
//initialize
|
sl@0
|
161 |
bitmapDev->SetAutoUpdate(EFalse);
|
sl@0
|
162 |
bitmapDev->SetBits(bitmapMem);
|
sl@0
|
163 |
//destroy
|
sl@0
|
164 |
CleanupStack::PopAndDestroy(2);//bitmapMem, bitmapDev
|
sl@0
|
165 |
}
|
sl@0
|
166 |
}
|
sl@0
|
167 |
|
sl@0
|
168 |
void CTScdv::RunTestCaseL(TInt aCurTestCase)
|
sl@0
|
169 |
{
|
sl@0
|
170 |
((CTScdvStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
|
sl@0
|
171 |
switch(aCurTestCase)
|
sl@0
|
172 |
{
|
sl@0
|
173 |
case 1:
|
sl@0
|
174 |
INFO_PRINTF1(_L("Mutiple screen devices creation test"));
|
sl@0
|
175 |
/**
|
sl@0
|
176 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0033
|
sl@0
|
177 |
*/
|
sl@0
|
178 |
((CTScdvStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0033"));
|
sl@0
|
179 |
TestScreenDeviceCreationL();
|
sl@0
|
180 |
break;
|
sl@0
|
181 |
case 2:
|
sl@0
|
182 |
INFO_PRINTF1(_L("Bitmap device creation test"));
|
sl@0
|
183 |
/**
|
sl@0
|
184 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0034
|
sl@0
|
185 |
*/
|
sl@0
|
186 |
((CTScdvStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0034"));
|
sl@0
|
187 |
TestBitmapDeviceCreationL();
|
sl@0
|
188 |
break;
|
sl@0
|
189 |
case 3:
|
sl@0
|
190 |
((CTScdvStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
191 |
((CTScdvStep*)iStep)->CloseTMSGraphicsStep();
|
sl@0
|
192 |
TestComplete();
|
sl@0
|
193 |
break;
|
sl@0
|
194 |
}
|
sl@0
|
195 |
((CTScdvStep*)iStep)->RecordTestResultL();
|
sl@0
|
196 |
}
|
sl@0
|
197 |
|
sl@0
|
198 |
//--------------
|
sl@0
|
199 |
__CONSTRUCT_STEP__(Scdv)
|
sl@0
|
200 |
|
sl@0
|
201 |
|
sl@0
|
202 |
void CTScdvStep::TestSetupL()
|
sl@0
|
203 |
{
|
sl@0
|
204 |
TInt temp = 0;
|
sl@0
|
205 |
HAL::Get(HALData::EDisplayColors, temp);//force HAL memory allocation
|
sl@0
|
206 |
}
|