author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 18 Jan 2010 21:31:10 +0200 | |
changeset 8 | 538db54a451d |
parent 4 | 56f325a607ea |
child 14 | 5d2844f35677 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2008-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 the License "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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// Prototype HCR test driver library |
|
15 |
// |
|
16 |
||
17 |
||
18 |
// -- INCLUDES ---------------------------------------------------------------- |
|
19 |
||
20 |
#include "hcr_uids.h" |
|
21 |
#include "hcr_debug.h" |
|
22 |
||
23 |
#include <kernel/kern_priv.h> |
|
24 |
#include <platform.h> |
|
25 |
#include <u32hal.h> |
|
26 |
#include "d_hcrut.h" |
|
27 |
||
28 |
||
29 |
#include "hcr_pil.h" |
|
30 |
||
31 |
#include <drivers/hcr.h> |
|
32 |
||
33 |
||
34 |
||
35 |
||
36 |
// -- CLASSES ----------------------------------------------------------------- |
|
37 |
||
38 |
||
39 |
class DHcrTestFactory : public DLogicalDevice |
|
40 |
{ |
|
41 |
public: |
|
42 |
virtual TInt Install(); |
|
43 |
virtual void GetCaps(TDes8& aDes) const; |
|
44 |
virtual TInt Create(DLogicalChannelBase*& aChannel); |
|
45 |
}; |
|
46 |
||
47 |
||
48 |
class DHcrTestChannel : public DLogicalChannelBase |
|
49 |
{ |
|
50 |
public: |
|
51 |
DHcrTestChannel(); |
|
52 |
virtual ~DHcrTestChannel(); |
|
53 |
||
54 |
// Inherited from DObject |
|
55 |
virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType); |
|
56 |
||
57 |
// Inherited from DLogicalChannelBase |
|
58 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
59 |
virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2); |
|
60 |
||
61 |
public: |
|
62 |
static void TestTrace(DHcrTestChannel* aSelf); |
|
63 |
||
64 |
private: |
|
65 |
DThread* iClient; |
|
66 |
||
67 |
}; |
|
68 |
||
69 |
namespace HCR { |
|
70 |
class HCRInternalTestObserver |
|
71 |
{ |
|
72 |
public: |
|
73 |
HCRInternalTestObserver() : iHcrInt(0) { return; } ; |
|
74 |
HCRInternalTestObserver(HCR::HCRInternal* aSubject) : |
|
75 |
iHcrInt(aSubject) { return; } ; |
|
76 |
~HCRInternalTestObserver() { return; } ; |
|
77 |
||
78 |
TInt PrintAttirbutes(); |
|
79 |
||
80 |
TInt PrintState(); |
|
81 |
||
82 |
HCR::TRepository* GetVariantImgRepos(); |
|
83 |
HCR::TRepository* GetCoreImgRepos(); |
|
84 |
HCR::TRepository* GetOverrideImgRepos(); |
|
85 |
||
86 |
TInt SwitchRepository(const TText * aFileName, const HCR::HCRInternal::TReposId aId=HCR::HCRInternal::ECoreRepos); |
|
87 |
||
88 |
public: |
|
89 |
||
90 |
HCR::HCRInternal* iHcrInt; |
|
91 |
}; |
|
92 |
} |
|
93 |
||
94 |
TInt Testfunc1(TSuperPage* aSuperPagePtr); |
|
95 |
||
96 |
||
97 |
TInt HCR::HCRInternalTestObserver::PrintAttirbutes() |
|
98 |
{ |
|
99 |
HCR_TRACE1("HCRInternalTestObserver initialised, iVariant=0x%0x\n", iHcrInt->iVariant); |
|
100 |
return KErrNone; |
|
101 |
} |
|
102 |
||
103 |
TInt HCR::HCRInternalTestObserver::PrintState() |
|
104 |
{ |
|
105 |
HCR_TRACE2("iVariant =0x%08X, iVariantStore =0x%08X, \n", iHcrInt->iVariant, iHcrInt->iVariantStore); |
|
106 |
HCR_TRACE2("iCoreImgStore=0x%08X, iOverrideStore=0x%08X, \n", iHcrInt->iCoreImgStore, iHcrInt->iOverrideStore); |
|
107 |
return KErrNone; |
|
108 |
} |
|
109 |
||
110 |
||
111 |
HCR::TRepository* HCR::HCRInternalTestObserver::GetVariantImgRepos() |
|
112 |
{ |
|
113 |
return iHcrInt->iVariantStore; |
|
114 |
} |
|
115 |
||
116 |
HCR::TRepository* HCR::HCRInternalTestObserver::GetCoreImgRepos() |
|
117 |
{ |
|
118 |
return iHcrInt->iCoreImgStore; |
|
119 |
} |
|
120 |
HCR::TRepository* HCR::HCRInternalTestObserver::GetOverrideImgRepos() |
|
121 |
{ |
|
122 |
return iHcrInt->iOverrideStore; |
|
123 |
} |
|
124 |
TInt HCR::HCRInternalTestObserver::SwitchRepository(const TText * aFileName, const HCR::HCRInternal::TReposId aId) |
|
125 |
{ |
|
126 |
NKern::ThreadEnterCS(); |
|
127 |
TInt retVal = iHcrInt->SwitchRepository(aFileName, aId); |
|
128 |
NKern::ThreadLeaveCS(); |
|
129 |
return retVal; |
|
130 |
} |
|
131 |
// -- GLOBALS ----------------------------------------------------------------- |
|
132 |
// |
|
133 |
||
134 |
||
135 |
static HCR::HCRInternal gTestHcrInt; |
|
136 |
static HCR::HCRInternalTestObserver gObserver; |
|
137 |
||
138 |
// -- METHODS ----------------------------------------------------------------- |
|
139 |
// |
|
140 |
// DHcrTestFactory |
|
141 |
// |
|
142 |
||
143 |
TInt DHcrTestFactory::Install() |
|
144 |
{ |
|
145 |
HCR_FUNC("DHcrTestFactory::Install"); |
|
146 |
return SetName(&RHcrTest::Name()); |
|
147 |
} |
|
148 |
||
149 |
void DHcrTestFactory::GetCaps(TDes8& aDes) const |
|
150 |
{ |
|
151 |
HCR_FUNC("DHcrTestFactory::GetCaps"); |
|
152 |
Kern::InfoCopy(aDes,0,0); |
|
153 |
} |
|
154 |
||
155 |
TInt DHcrTestFactory::Create(DLogicalChannelBase*& aChannel) |
|
156 |
{ |
|
157 |
HCR_FUNC("DHcrTestFactory::Create"); |
|
158 |
||
159 |
aChannel=new DHcrTestChannel(); |
|
160 |
if(!aChannel) |
|
161 |
return KErrNoMemory; |
|
162 |
return KErrNone; |
|
163 |
} |
|
164 |
||
165 |
||
166 |
// -- METHODS ----------------------------------------------------------------- |
|
167 |
// |
|
168 |
// DHcrTestChannel |
|
169 |
// |
|
170 |
||
171 |
DHcrTestChannel::DHcrTestChannel() |
|
172 |
{ |
|
173 |
HCR_FUNC("DHcrTestChannel"); |
|
174 |
} |
|
175 |
||
176 |
DHcrTestChannel::~DHcrTestChannel() |
|
177 |
{ |
|
178 |
HCR_FUNC("~DHcrTestChannel"); |
|
179 |
} |
|
180 |
||
181 |
TInt DHcrTestChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/) |
|
182 |
{ |
|
183 |
HCR_FUNC("DHcrTestChannel::DoCreate"); |
|
184 |
||
185 |
iClient = &Kern::CurrentThread(); |
|
186 |
return KErrNone; |
|
187 |
} |
|
188 |
||
189 |
TInt DHcrTestChannel::RequestUserHandle(DThread* aThread, TOwnerType aType) |
|
190 |
{ |
|
191 |
HCR_FUNC("DHcrTestChannel::RequestUserHandle"); |
|
192 |
||
193 |
if (aType!=EOwnerThread || aThread!=iClient) |
|
194 |
return KErrAccessDenied; |
|
195 |
return KErrNone; |
|
196 |
} |
|
197 |
||
198 |
TInt DHcrTestChannel::Request(TInt aReqNo, TAny*, TAny*) |
|
199 |
{ |
|
200 |
HCR_FUNC("DHcrTestChannel::Request"); |
|
201 |
||
202 |
||
203 |
||
204 |
switch(aReqNo) |
|
205 |
{ |
|
206 |
||
207 |
case RHcrTest::ECtrlSanityTestWordSettings: |
|
208 |
{ |
|
209 |
return KErrNone; |
|
210 |
} |
|
211 |
||
212 |
case RHcrTest::ECtrlSanityTestLargeSettings: |
|
213 |
{ |
|
214 |
return KErrNone; |
|
215 |
} |
|
216 |
||
217 |
case RHcrTest::ECtrlGetWordSetting: |
|
218 |
{ |
|
219 |
return KErrNone; |
|
220 |
} |
|
221 |
||
222 |
case RHcrTest::ECtrlGetLargeSetting: |
|
223 |
{ |
|
224 |
return KErrNone; |
|
225 |
} |
|
226 |
||
227 |
case RHcrTest::ECtrlGetManyWordSettings: |
|
228 |
{ |
|
229 |
return KErrNone; |
|
230 |
} |
|
231 |
||
232 |
case RHcrTest::ECtrlGetManyLargeSettings: |
|
233 |
{ |
|
234 |
return KErrNone; |
|
235 |
} |
|
236 |
||
237 |
case RHcrTest::ECtrlSwitchRepository: |
|
238 |
{ |
|
239 |
TInt err = KErrNone; |
|
240 |
||
241 |
// Clear and reset iCoreImgStore |
|
242 |
HCR_TRACE1("--- value of iCoreImgStore:0x%08x before clear", gObserver.GetCoreImgRepos()); |
|
243 |
err = gObserver.SwitchRepository(NULL, HCR::HCRInternal::ECoreRepos); |
|
244 |
||
245 |
HCR_TRACE1("--- value of iCoreImgStore:0x%08x after clear", gObserver.GetCoreImgRepos()); |
|
246 |
if( err != KErrNone ) |
|
247 |
{ |
|
248 |
return err; |
|
249 |
} |
|
250 |
||
251 |
// Clear and reset iOverrideStore |
|
252 |
HCR_TRACE1("--- value of iOverrideStore:0x%08x before clear", gObserver.GetOverrideImgRepos()); |
|
253 |
err = gObserver.SwitchRepository(NULL, HCR::HCRInternal::EOverrideRepos); |
|
254 |
||
255 |
HCR_TRACE1("--- value of iOverrideStore:0x%08x after clear", gObserver.GetOverrideImgRepos()); |
|
256 |
if( err != KErrNone ) |
|
257 |
{ |
|
258 |
return err; |
|
259 |
} |
|
260 |
||
261 |
// Switch iCoreImgStore to a repositore store located in \sys\bin directory |
|
4
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
262 |
const TText * fileInSysBinName = (const TText *)"d_hcrsim_own.ldd"; |
0 | 263 |
err = gObserver.SwitchRepository(fileInSysBinName, HCR::HCRInternal::ECoreRepos); |
264 |
if (err != KErrNone) |
|
4
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
265 |
HCR_TRACE_RETURN(err); |
0 | 266 |
|
267 |
||
268 |
// Switch iOverrideStore to a repositore store located in \sys\Data directory |
|
269 |
const TText * fileInSysDataName = (const TText *)"EMPTY.DAT"; |
|
270 |
err = gObserver.SwitchRepository(fileInSysDataName, HCR::HCRInternal::EOverrideRepos); |
|
271 |
if (err != KErrNone) |
|
4
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
272 |
HCR_TRACE_RETURN(err); |
0 | 273 |
|
274 |
// Try to switch iCoreImgStore to a not existing one and check the SwitchRepository() |
|
275 |
// keeps its original value. |
|
276 |
HCR::TRepository* oldRepos = gObserver.GetCoreImgRepos(); |
|
277 |
HCR_TRACE1("--- value of iCoreImgStore:0x%08x before try to switch to a not exist", oldRepos); |
|
278 |
const TText * wrongFileName = (const TText *)"hcr.ldl"; |
|
279 |
err = gObserver.SwitchRepository(wrongFileName, HCR::HCRInternal::ECoreRepos); |
|
280 |
if ( err != KErrNotFound) |
|
4
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
281 |
HCR_TRACE_RETURN(err); |
0 | 282 |
|
283 |
err = KErrNone; |
|
284 |
||
285 |
HCR::TRepository* newRepos = gObserver.GetCoreImgRepos(); |
|
286 |
HCR_TRACE1("--- value of iCoreImgStore:0x%08x after try to switch to a not exist", newRepos); |
|
287 |
if ( oldRepos != newRepos ) |
|
4
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
288 |
HCR_TRACE_RETURN(KErrGeneral); |
0 | 289 |
|
290 |
// Switch iOverrideStore to a new, existing repository, different the current and check the |
|
291 |
// iOverrideStore value changed. |
|
292 |
oldRepos = gObserver.GetOverrideImgRepos(); |
|
293 |
HCR_TRACE1("--- value of iOverrideStore:0x%08x before try to switch to existing one", oldRepos); |
|
294 |
err = gObserver.SwitchRepository(fileInSysBinName, HCR::HCRInternal::EOverrideRepos); |
|
295 |
if ( err != KErrNone) |
|
4
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
296 |
HCR_TRACE_RETURN(err); |
0 | 297 |
|
298 |
newRepos = gObserver.GetOverrideImgRepos(); |
|
299 |
HCR_TRACE1("--- value of iOverrideStore:0x%08x after try to switch to existing on", newRepos); |
|
300 |
if ( oldRepos == newRepos ) |
|
4
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
301 |
HCR_TRACE_RETURN(KErrGeneral); |
0 | 302 |
|
303 |
return err; |
|
304 |
} |
|
305 |
||
306 |
case RHcrTest::ECtrlFreePhyscialRam: |
|
307 |
{ |
|
308 |
return KErrNone; |
|
309 |
} |
|
310 |
||
311 |
default: |
|
312 |
break; |
|
313 |
} |
|
314 |
||
315 |
return KErrNotSupported; |
|
316 |
} |
|
317 |
||
318 |
||
319 |
// -- GLOBALS ----------------------------------------------------------------- |
|
320 |
||
321 |
||
322 |
DECLARE_STANDARD_LDD() |
|
323 |
{ |
|
324 |
HCR_FUNC("D_HCR_DECLARE_STANDARD_LDD"); |
|
325 |
||
326 |
// Taken from HCR_PIL.CPP InitExtension() method |
|
327 |
||
328 |
HCR::MVariant* varPtr = CreateHCRVariant(); |
|
329 |
if (varPtr==0) |
|
4
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
330 |
return 0; |
0 | 331 |
|
332 |
new(&gTestHcrInt) HCR::HCRInternal(varPtr); |
|
333 |
||
334 |
TInt err = gTestHcrInt.Initialise(); |
|
335 |
if (err != KErrNone) |
|
4
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
336 |
return 0; |
0 | 337 |
|
338 |
new(&gObserver) HCR::HCRInternalTestObserver(&gTestHcrInt); |
|
339 |
||
340 |
// ===== Above would be moved to DoRequest for test caes.... |
|
341 |
||
342 |
return new DHcrTestFactory; |
|
343 |
||
344 |
} |
|
345 |
||
346 |