sl@0
|
1 |
// Copyright (c) 2008-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 the License "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 |
// Prototype HCR test driver library
|
sl@0
|
15 |
//
|
sl@0
|
16 |
|
sl@0
|
17 |
|
sl@0
|
18 |
// -- INCLUDES ----------------------------------------------------------------
|
sl@0
|
19 |
|
sl@0
|
20 |
#include "hcr_uids.h"
|
sl@0
|
21 |
#include "hcr_debug.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
#include <kernel/kern_priv.h>
|
sl@0
|
24 |
#include <platform.h>
|
sl@0
|
25 |
#include <u32hal.h>
|
sl@0
|
26 |
#include "d_hcrut.h"
|
sl@0
|
27 |
#include "hcr_hai.h"
|
sl@0
|
28 |
|
sl@0
|
29 |
#include "hcr_pil.h"
|
sl@0
|
30 |
|
sl@0
|
31 |
#include <drivers/hcr.h>
|
sl@0
|
32 |
|
sl@0
|
33 |
#define TEST_MEMGET(s, d, l) kumemget(d, s, l)
|
sl@0
|
34 |
#define TEST_MEMPUT(d, s, l) kumemput(d, s, l)
|
sl@0
|
35 |
|
sl@0
|
36 |
#include "HcrImageData_102400.h"
|
sl@0
|
37 |
// -- CLASSES -----------------------------------------------------------------
|
sl@0
|
38 |
|
sl@0
|
39 |
class DHcrTestFactory : public DLogicalDevice
|
sl@0
|
40 |
{
|
sl@0
|
41 |
public:
|
sl@0
|
42 |
virtual TInt Install();
|
sl@0
|
43 |
virtual void GetCaps(TDes8& aDes) const;
|
sl@0
|
44 |
virtual TInt Create(DLogicalChannelBase*& aChannel);
|
sl@0
|
45 |
};
|
sl@0
|
46 |
|
sl@0
|
47 |
|
sl@0
|
48 |
class DHcrTestChannel : public DLogicalChannelBase
|
sl@0
|
49 |
{
|
sl@0
|
50 |
public:
|
sl@0
|
51 |
DHcrTestChannel();
|
sl@0
|
52 |
virtual ~DHcrTestChannel();
|
sl@0
|
53 |
|
sl@0
|
54 |
// Inherited from DObject
|
sl@0
|
55 |
virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
|
sl@0
|
56 |
|
sl@0
|
57 |
// Inherited from DLogicalChannelBase
|
sl@0
|
58 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
|
sl@0
|
59 |
virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
|
sl@0
|
60 |
|
sl@0
|
61 |
public:
|
sl@0
|
62 |
static void TestTrace(DHcrTestChannel* aSelf);
|
sl@0
|
63 |
|
sl@0
|
64 |
private:
|
sl@0
|
65 |
DThread* iClient;
|
sl@0
|
66 |
|
sl@0
|
67 |
};
|
sl@0
|
68 |
|
sl@0
|
69 |
namespace HCR {
|
sl@0
|
70 |
class HCRInternalTestObserver
|
sl@0
|
71 |
{
|
sl@0
|
72 |
public:
|
sl@0
|
73 |
HCRInternalTestObserver() : iHcrInt(0) { return; } ;
|
sl@0
|
74 |
HCRInternalTestObserver(HCR::HCRInternal* aSubject) :
|
sl@0
|
75 |
iHcrInt(aSubject) { return; } ;
|
sl@0
|
76 |
~HCRInternalTestObserver() { return; } ;
|
sl@0
|
77 |
|
sl@0
|
78 |
TInt PrintAttirbutes();
|
sl@0
|
79 |
|
sl@0
|
80 |
TInt PrintState();
|
sl@0
|
81 |
|
sl@0
|
82 |
HCR::TRepository* GetVariantImgRepos();
|
sl@0
|
83 |
HCR::TRepository* GetCoreImgRepos();
|
sl@0
|
84 |
HCR::TRepository* GetOverrideImgRepos();
|
sl@0
|
85 |
|
sl@0
|
86 |
HCR::MVariant* GetVariant() {return iHcrInt->iVariant;};
|
sl@0
|
87 |
TInt SwitchRepository(const TText * aFileName, const HCR::HCRInternal::TReposId aId=HCR::HCRInternal::ECoreRepos);
|
sl@0
|
88 |
|
sl@0
|
89 |
TInt CheckIntegrity(void);
|
sl@0
|
90 |
TInt FindSetting(const TSettingId& aId, TSettingType aType, TSettingRef& aSetting);
|
sl@0
|
91 |
|
sl@0
|
92 |
public:
|
sl@0
|
93 |
|
sl@0
|
94 |
HCR::HCRInternal* iHcrInt;
|
sl@0
|
95 |
};
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
TInt Testfunc1(TSuperPage* aSuperPagePtr);
|
sl@0
|
99 |
|
sl@0
|
100 |
|
sl@0
|
101 |
TInt HCR::HCRInternalTestObserver::PrintAttirbutes()
|
sl@0
|
102 |
{
|
sl@0
|
103 |
HCR_TRACE1("HCRInternalTestObserver initialised, iVariant=0x%0x\n", iHcrInt->iVariant);
|
sl@0
|
104 |
return KErrNone;
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
TInt HCR::HCRInternalTestObserver::PrintState()
|
sl@0
|
108 |
{
|
sl@0
|
109 |
HCR_TRACE2("iVariant =0x%08X, iVariantStore =0x%08X, \n", iHcrInt->iVariant, iHcrInt->iVariantStore);
|
sl@0
|
110 |
HCR_TRACE2("iCoreImgStore=0x%08X, iOverrideStore=0x%08X, \n", iHcrInt->iCoreImgStore, iHcrInt->iOverrideStore);
|
sl@0
|
111 |
return KErrNone;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
|
sl@0
|
114 |
|
sl@0
|
115 |
HCR::TRepository* HCR::HCRInternalTestObserver::GetVariantImgRepos()
|
sl@0
|
116 |
{
|
sl@0
|
117 |
return iHcrInt->iVariantStore;
|
sl@0
|
118 |
}
|
sl@0
|
119 |
|
sl@0
|
120 |
HCR::TRepository* HCR::HCRInternalTestObserver::GetCoreImgRepos()
|
sl@0
|
121 |
{
|
sl@0
|
122 |
return iHcrInt->iCoreImgStore;
|
sl@0
|
123 |
}
|
sl@0
|
124 |
HCR::TRepository* HCR::HCRInternalTestObserver::GetOverrideImgRepos()
|
sl@0
|
125 |
{
|
sl@0
|
126 |
return iHcrInt->iOverrideStore;
|
sl@0
|
127 |
}
|
sl@0
|
128 |
TInt HCR::HCRInternalTestObserver::SwitchRepository(const TText * aFileName, const HCR::HCRInternal::TReposId aId)
|
sl@0
|
129 |
{
|
sl@0
|
130 |
NKern::ThreadEnterCS();
|
sl@0
|
131 |
TInt retVal = iHcrInt->SwitchRepository(aFileName, aId);
|
sl@0
|
132 |
NKern::ThreadLeaveCS();
|
sl@0
|
133 |
return retVal;
|
sl@0
|
134 |
}
|
sl@0
|
135 |
|
sl@0
|
136 |
|
sl@0
|
137 |
TInt HCR::HCRInternalTestObserver::CheckIntegrity(void)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
TInt retVal = iHcrInt->CheckIntegrity();
|
sl@0
|
140 |
return retVal;
|
sl@0
|
141 |
}
|
sl@0
|
142 |
|
sl@0
|
143 |
TInt HCR::HCRInternalTestObserver::FindSetting(const TSettingId& aId, TSettingType aType, TSettingRef& aSetting)
|
sl@0
|
144 |
{
|
sl@0
|
145 |
TInt retVal = iHcrInt->FindSetting( aId, aType, aSetting);
|
sl@0
|
146 |
return retVal;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
|
sl@0
|
149 |
// -- GLOBALS -----------------------------------------------------------------
|
sl@0
|
150 |
//
|
sl@0
|
151 |
|
sl@0
|
152 |
|
sl@0
|
153 |
static HCR::HCRInternal gTestHcrInt;
|
sl@0
|
154 |
static HCR::HCRInternalTestObserver gObserver;
|
sl@0
|
155 |
|
sl@0
|
156 |
// -- METHODS -----------------------------------------------------------------
|
sl@0
|
157 |
//
|
sl@0
|
158 |
// DHcrTestFactory
|
sl@0
|
159 |
//
|
sl@0
|
160 |
|
sl@0
|
161 |
TInt DHcrTestFactory::Install()
|
sl@0
|
162 |
{
|
sl@0
|
163 |
HCR_FUNC("DHcrTestFactory::Install");
|
sl@0
|
164 |
return SetName(&RHcrTest::Name());
|
sl@0
|
165 |
}
|
sl@0
|
166 |
|
sl@0
|
167 |
void DHcrTestFactory::GetCaps(TDes8& aDes) const
|
sl@0
|
168 |
{
|
sl@0
|
169 |
HCR_FUNC("DHcrTestFactory::GetCaps");
|
sl@0
|
170 |
Kern::InfoCopy(aDes,0,0);
|
sl@0
|
171 |
}
|
sl@0
|
172 |
|
sl@0
|
173 |
TInt DHcrTestFactory::Create(DLogicalChannelBase*& aChannel)
|
sl@0
|
174 |
{
|
sl@0
|
175 |
HCR_FUNC("DHcrTestFactory::Create");
|
sl@0
|
176 |
|
sl@0
|
177 |
aChannel=new DHcrTestChannel();
|
sl@0
|
178 |
if(!aChannel)
|
sl@0
|
179 |
return KErrNoMemory;
|
sl@0
|
180 |
return KErrNone;
|
sl@0
|
181 |
}
|
sl@0
|
182 |
|
sl@0
|
183 |
|
sl@0
|
184 |
// -- METHODS -----------------------------------------------------------------
|
sl@0
|
185 |
//
|
sl@0
|
186 |
// DHcrTestChannel
|
sl@0
|
187 |
//
|
sl@0
|
188 |
|
sl@0
|
189 |
DHcrTestChannel::DHcrTestChannel()
|
sl@0
|
190 |
{
|
sl@0
|
191 |
HCR_FUNC("DHcrTestChannel");
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
DHcrTestChannel::~DHcrTestChannel()
|
sl@0
|
195 |
{
|
sl@0
|
196 |
HCR_FUNC("~DHcrTestChannel");
|
sl@0
|
197 |
}
|
sl@0
|
198 |
|
sl@0
|
199 |
TInt DHcrTestChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
|
sl@0
|
200 |
{
|
sl@0
|
201 |
HCR_FUNC("DHcrTestChannel::DoCreate");
|
sl@0
|
202 |
|
sl@0
|
203 |
iClient = &Kern::CurrentThread();
|
sl@0
|
204 |
return KErrNone;
|
sl@0
|
205 |
}
|
sl@0
|
206 |
|
sl@0
|
207 |
TInt DHcrTestChannel::RequestUserHandle(DThread* aThread, TOwnerType aType)
|
sl@0
|
208 |
{
|
sl@0
|
209 |
HCR_FUNC("DHcrTestChannel::RequestUserHandle");
|
sl@0
|
210 |
|
sl@0
|
211 |
if (aType!=EOwnerThread || aThread!=iClient)
|
sl@0
|
212 |
return KErrAccessDenied;
|
sl@0
|
213 |
return KErrNone;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
TInt DHcrTestChannel::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/ )
|
sl@0
|
217 |
{
|
sl@0
|
218 |
HCR_FUNC("DHcrTestChannel::Request");
|
sl@0
|
219 |
|
sl@0
|
220 |
switch(aReqNo)
|
sl@0
|
221 |
{
|
sl@0
|
222 |
|
sl@0
|
223 |
case RHcrTest::ECtrlSanityTestWordSettings:
|
sl@0
|
224 |
{
|
sl@0
|
225 |
return KErrNone;
|
sl@0
|
226 |
}
|
sl@0
|
227 |
|
sl@0
|
228 |
case RHcrTest::ECtrlSanityTestLargeSettings:
|
sl@0
|
229 |
{
|
sl@0
|
230 |
return KErrNone;
|
sl@0
|
231 |
}
|
sl@0
|
232 |
|
sl@0
|
233 |
case RHcrTest::ECtrlGetWordSetting:
|
sl@0
|
234 |
{
|
sl@0
|
235 |
TAny* args[3];
|
sl@0
|
236 |
TEST_MEMGET(a1, args, sizeof(args));
|
sl@0
|
237 |
|
sl@0
|
238 |
HCR::TCategoryUid category = (HCR::TCategoryUid) args[0];
|
sl@0
|
239 |
|
sl@0
|
240 |
HCR::TElementId key = (HCR::TElementId) args[1];
|
sl@0
|
241 |
|
sl@0
|
242 |
TInt type = (TInt) args[2];
|
sl@0
|
243 |
|
sl@0
|
244 |
const TText * fileInSysBinName = (const TText *)"filerepos.dat";
|
sl@0
|
245 |
TInt err = gObserver.SwitchRepository(fileInSysBinName, HCR::HCRInternal::ECoreRepos);
|
sl@0
|
246 |
if (err != KErrNone)
|
sl@0
|
247 |
HCR_TRACE_RETURN(err);
|
sl@0
|
248 |
|
sl@0
|
249 |
// Negative tests on HCR::TRepositoryFile; aNum will be 0
|
sl@0
|
250 |
HCR::TRepository* repos = gObserver.GetCoreImgRepos();;
|
sl@0
|
251 |
__NK_ASSERT_DEBUG(repos != NULL);
|
sl@0
|
252 |
|
sl@0
|
253 |
|
sl@0
|
254 |
HCR::SSettingId* ids[1];// = new HCR::SSettingId*[1];
|
sl@0
|
255 |
|
sl@0
|
256 |
TInt32* vals[1];
|
sl@0
|
257 |
TInt* errs[1];
|
sl@0
|
258 |
HCR::TSettingType* types[1];
|
sl@0
|
259 |
|
sl@0
|
260 |
NKern::ThreadEnterCS();
|
sl@0
|
261 |
ids[0] = new HCR::SSettingId();
|
sl@0
|
262 |
vals[0] = new TInt32();
|
sl@0
|
263 |
errs[0] = new TInt();
|
sl@0
|
264 |
types[0] = new HCR::TSettingType();
|
sl@0
|
265 |
|
sl@0
|
266 |
if(ids[0] == NULL || vals[0] == NULL || errs[0] == NULL || types[0] == NULL)
|
sl@0
|
267 |
{
|
sl@0
|
268 |
delete ids[0];
|
sl@0
|
269 |
delete vals[0];
|
sl@0
|
270 |
delete errs[0];
|
sl@0
|
271 |
delete types[0];
|
sl@0
|
272 |
NKern::ThreadLeaveCS();
|
sl@0
|
273 |
HCR_TRACE_RETURN(KErrNoMemory);
|
sl@0
|
274 |
}
|
sl@0
|
275 |
|
sl@0
|
276 |
ids[0]->iCat = category;
|
sl@0
|
277 |
ids[0]->iKey = key;
|
sl@0
|
278 |
|
sl@0
|
279 |
// Negative tests on HCR::TRepositoryFile; aNum will be 0
|
sl@0
|
280 |
TInt r = repos->GetWordSettings(0, ids, vals, types, errs);
|
sl@0
|
281 |
// only expected errors are KErrNotFound or KErrNone
|
sl@0
|
282 |
// thest if there is other error; if yes fail the test
|
sl@0
|
283 |
if(r != KErrNotFound && r != KErrNone && r < KErrNone)
|
sl@0
|
284 |
{
|
sl@0
|
285 |
delete ids[0];
|
sl@0
|
286 |
delete vals[0];
|
sl@0
|
287 |
delete errs[0];
|
sl@0
|
288 |
delete types[0];
|
sl@0
|
289 |
NKern::ThreadLeaveCS();
|
sl@0
|
290 |
HCR_TRACE_RETURN(r);
|
sl@0
|
291 |
}
|
sl@0
|
292 |
|
sl@0
|
293 |
// Negative testing on HCR::TRepositoryFile; try to get words for large value
|
sl@0
|
294 |
if(type > HCR::ETypeLinAddr)
|
sl@0
|
295 |
{
|
sl@0
|
296 |
r = repos->GetWordSettings(1, ids, vals, types, errs);
|
sl@0
|
297 |
if(r != KErrArgument && r != KErrNotFound && r < KErrNone)
|
sl@0
|
298 |
{
|
sl@0
|
299 |
delete ids[0];
|
sl@0
|
300 |
delete vals[0];
|
sl@0
|
301 |
delete errs[0];
|
sl@0
|
302 |
delete types[0];
|
sl@0
|
303 |
NKern::ThreadLeaveCS();
|
sl@0
|
304 |
HCR_TRACE_RETURN(r);
|
sl@0
|
305 |
}
|
sl@0
|
306 |
}
|
sl@0
|
307 |
|
sl@0
|
308 |
HCR::TRepositoryCompiled* compiledRepos = reinterpret_cast<HCR::TRepositoryCompiled*>(gObserver.GetVariantImgRepos());
|
sl@0
|
309 |
__NK_ASSERT_DEBUG(compiledRepos != NULL);
|
sl@0
|
310 |
|
sl@0
|
311 |
ids[0]->iCat = KHCRUID_TestCategory1;
|
sl@0
|
312 |
ids[0]->iKey = key;
|
sl@0
|
313 |
|
sl@0
|
314 |
// Negative tests on HCR::TRepositoryCompiled; aNum will be 0
|
sl@0
|
315 |
r = compiledRepos->GetWordSettings(0, ids, vals, types, errs);
|
sl@0
|
316 |
if(r != KErrNotFound && r != KErrNone && r < KErrNone)
|
sl@0
|
317 |
{
|
sl@0
|
318 |
delete ids[0];
|
sl@0
|
319 |
delete vals[0];
|
sl@0
|
320 |
delete errs[0];
|
sl@0
|
321 |
delete types[0];
|
sl@0
|
322 |
NKern::ThreadLeaveCS();
|
sl@0
|
323 |
HCR_TRACE_RETURN(r);
|
sl@0
|
324 |
}
|
sl@0
|
325 |
|
sl@0
|
326 |
// Negative testing on HCR::TRepositoryFile; try to get words for large value
|
sl@0
|
327 |
if(type > HCR::ETypeLinAddr)
|
sl@0
|
328 |
{
|
sl@0
|
329 |
r = compiledRepos->GetWordSettings(1, ids, vals, types, errs);
|
sl@0
|
330 |
if(r != KErrArgument && r != KErrNotFound && r < KErrNone)
|
sl@0
|
331 |
{
|
sl@0
|
332 |
delete ids[0];
|
sl@0
|
333 |
delete vals[0];
|
sl@0
|
334 |
delete errs[0];
|
sl@0
|
335 |
delete types[0];
|
sl@0
|
336 |
NKern::ThreadLeaveCS();
|
sl@0
|
337 |
HCR_TRACE_RETURN(r);
|
sl@0
|
338 |
}
|
sl@0
|
339 |
}
|
sl@0
|
340 |
|
sl@0
|
341 |
delete ids[0];
|
sl@0
|
342 |
delete vals[0];
|
sl@0
|
343 |
delete errs[0];
|
sl@0
|
344 |
delete types[0];
|
sl@0
|
345 |
NKern::ThreadLeaveCS();
|
sl@0
|
346 |
|
sl@0
|
347 |
return KErrNone;
|
sl@0
|
348 |
}
|
sl@0
|
349 |
|
sl@0
|
350 |
case RHcrTest::ECtrlGetLargeSetting:
|
sl@0
|
351 |
{
|
sl@0
|
352 |
return KErrNone;
|
sl@0
|
353 |
}
|
sl@0
|
354 |
|
sl@0
|
355 |
case RHcrTest::ECtrlGetManyWordSettings:
|
sl@0
|
356 |
{
|
sl@0
|
357 |
return KErrNone;
|
sl@0
|
358 |
}
|
sl@0
|
359 |
|
sl@0
|
360 |
case RHcrTest::ECtrlGetManyLargeSettings:
|
sl@0
|
361 |
{
|
sl@0
|
362 |
return KErrNone;
|
sl@0
|
363 |
}
|
sl@0
|
364 |
|
sl@0
|
365 |
case RHcrTest::ECtrlSwitchRepository:
|
sl@0
|
366 |
{
|
sl@0
|
367 |
TInt err = KErrNone;
|
sl@0
|
368 |
|
sl@0
|
369 |
// Clear and reset iCoreImgStore
|
sl@0
|
370 |
HCR_TRACE1("--- value of iCoreImgStore:0x%08x before clear", gObserver.GetCoreImgRepos());
|
sl@0
|
371 |
err = gObserver.SwitchRepository(NULL, HCR::HCRInternal::ECoreRepos);
|
sl@0
|
372 |
|
sl@0
|
373 |
HCR_TRACE1("--- value of iCoreImgStore:0x%08x after clear", gObserver.GetCoreImgRepos());
|
sl@0
|
374 |
if( err != KErrNone )
|
sl@0
|
375 |
{
|
sl@0
|
376 |
return err;
|
sl@0
|
377 |
}
|
sl@0
|
378 |
|
sl@0
|
379 |
// Clear and reset iOverrideStore
|
sl@0
|
380 |
HCR_TRACE1("--- value of iOverrideStore:0x%08x before clear", gObserver.GetOverrideImgRepos());
|
sl@0
|
381 |
err = gObserver.SwitchRepository(NULL, HCR::HCRInternal::EOverrideRepos);
|
sl@0
|
382 |
|
sl@0
|
383 |
HCR_TRACE1("--- value of iOverrideStore:0x%08x after clear", gObserver.GetOverrideImgRepos());
|
sl@0
|
384 |
if( err != KErrNone )
|
sl@0
|
385 |
{
|
sl@0
|
386 |
return err;
|
sl@0
|
387 |
}
|
sl@0
|
388 |
|
sl@0
|
389 |
// Switch iCoreImgStore to a repositore store located in \sys\bin directory
|
sl@0
|
390 |
const TText * fileInSysBinName = (const TText *)"d_hcrsim_own.ldd";
|
sl@0
|
391 |
err = gObserver.SwitchRepository(fileInSysBinName, HCR::HCRInternal::ECoreRepos);
|
sl@0
|
392 |
if (err != KErrNone)
|
sl@0
|
393 |
HCR_TRACE_RETURN(err);
|
sl@0
|
394 |
|
sl@0
|
395 |
|
sl@0
|
396 |
// Switch iOverrideStore to a repositore store located in \sys\Data directory
|
sl@0
|
397 |
const TText * fileInSysDataName = (const TText *)"EMPTY.DAT";
|
sl@0
|
398 |
err = gObserver.SwitchRepository(fileInSysDataName, HCR::HCRInternal::EOverrideRepos);
|
sl@0
|
399 |
if (err != KErrNone)
|
sl@0
|
400 |
HCR_TRACE_RETURN(err);
|
sl@0
|
401 |
|
sl@0
|
402 |
// Try to switch iCoreImgStore to a not existing one and check the SwitchRepository()
|
sl@0
|
403 |
// keeps its original value.
|
sl@0
|
404 |
HCR::TRepository* oldRepos = gObserver.GetCoreImgRepos();
|
sl@0
|
405 |
HCR_TRACE1("--- value of iCoreImgStore:0x%08x before try to switch to a not exist", oldRepos);
|
sl@0
|
406 |
const TText * wrongFileName = (const TText *)"hcr.ldl";
|
sl@0
|
407 |
err = gObserver.SwitchRepository(wrongFileName, HCR::HCRInternal::ECoreRepos);
|
sl@0
|
408 |
if ( err != KErrNotFound)
|
sl@0
|
409 |
HCR_TRACE_RETURN(err);
|
sl@0
|
410 |
|
sl@0
|
411 |
err = KErrNone;
|
sl@0
|
412 |
|
sl@0
|
413 |
HCR::TRepository* newRepos = gObserver.GetCoreImgRepos();
|
sl@0
|
414 |
HCR_TRACE1("--- value of iCoreImgStore:0x%08x after try to switch to a not exist", newRepos);
|
sl@0
|
415 |
if ( oldRepos != newRepos )
|
sl@0
|
416 |
HCR_TRACE_RETURN(KErrGeneral);
|
sl@0
|
417 |
|
sl@0
|
418 |
// Switch iOverrideStore to a new, existing repository, different the current and check the
|
sl@0
|
419 |
// iOverrideStore value changed.
|
sl@0
|
420 |
oldRepos = gObserver.GetOverrideImgRepos();
|
sl@0
|
421 |
HCR_TRACE1("--- value of iOverrideStore:0x%08x before try to switch to existing one", oldRepos);
|
sl@0
|
422 |
err = gObserver.SwitchRepository(fileInSysBinName, HCR::HCRInternal::EOverrideRepos);
|
sl@0
|
423 |
if ( err != KErrNone)
|
sl@0
|
424 |
HCR_TRACE_RETURN(err);
|
sl@0
|
425 |
|
sl@0
|
426 |
newRepos = gObserver.GetOverrideImgRepos();
|
sl@0
|
427 |
HCR_TRACE1("--- value of iOverrideStore:0x%08x after try to switch to existing on", newRepos);
|
sl@0
|
428 |
if ( oldRepos == newRepos )
|
sl@0
|
429 |
HCR_TRACE_RETURN(KErrGeneral);
|
sl@0
|
430 |
|
sl@0
|
431 |
return err;
|
sl@0
|
432 |
}
|
sl@0
|
433 |
|
sl@0
|
434 |
case RHcrTest::ECtrlNegativeTestsLargeValues:
|
sl@0
|
435 |
{
|
sl@0
|
436 |
//Test that HCR::TRepositoryCompiled::GetLargeValue & HCR::TRepositoryFile::GetLargeValue return KErrArgument
|
sl@0
|
437 |
TAny* args[1];
|
sl@0
|
438 |
TEST_MEMGET(a1, args, sizeof(args));
|
sl@0
|
439 |
// Retrieve structures from client
|
sl@0
|
440 |
TInt expectedError = (TUint) args[0];
|
sl@0
|
441 |
|
sl@0
|
442 |
const TText * fileInSysBinName = (const TText *)"filerepos.dat";
|
sl@0
|
443 |
TInt err = gObserver.SwitchRepository(fileInSysBinName, HCR::HCRInternal::ECoreRepos);
|
sl@0
|
444 |
if (err != KErrNone)
|
sl@0
|
445 |
HCR_TRACE_RETURN(err);
|
sl@0
|
446 |
|
sl@0
|
447 |
// Do test for HCR::TRepositoryFile
|
sl@0
|
448 |
HCR::TRepository* repos = gObserver.GetCoreImgRepos();;
|
sl@0
|
449 |
__NK_ASSERT_DEBUG(repos != NULL);
|
sl@0
|
450 |
|
sl@0
|
451 |
HCR::UValueLarge value;
|
sl@0
|
452 |
HCR::TSettingRef ref(0,0);
|
sl@0
|
453 |
HCR::TSettingId id(1,1); //word setting value in repository
|
sl@0
|
454 |
err = repos->FindSetting(id, ref);
|
sl@0
|
455 |
if(err == KErrNone)
|
sl@0
|
456 |
{
|
sl@0
|
457 |
err = repos->GetLargeValue(ref, value);
|
sl@0
|
458 |
if(err != expectedError)
|
sl@0
|
459 |
{
|
sl@0
|
460 |
HCR_TRACE_RETURN(err);
|
sl@0
|
461 |
}
|
sl@0
|
462 |
}
|
sl@0
|
463 |
|
sl@0
|
464 |
//Do test for HCR::TRepositoryCompiled
|
sl@0
|
465 |
HCR::TRepositoryCompiled* compiledRepos = reinterpret_cast<HCR::TRepositoryCompiled*>(gObserver.GetVariantImgRepos());
|
sl@0
|
466 |
if (compiledRepos == 0)
|
sl@0
|
467 |
{
|
sl@0
|
468 |
HCR_TRACE_RETURN(KErrGeneral);
|
sl@0
|
469 |
}
|
sl@0
|
470 |
|
sl@0
|
471 |
id = HCR::TSettingId(KHCRUID_TestCategory1,1);
|
sl@0
|
472 |
err = compiledRepos->FindSetting(id, ref);
|
sl@0
|
473 |
if(err == KErrNone)
|
sl@0
|
474 |
{
|
sl@0
|
475 |
err = compiledRepos->GetLargeValue(ref, value);
|
sl@0
|
476 |
if(err != expectedError)
|
sl@0
|
477 |
{
|
sl@0
|
478 |
HCR_TRACE_RETURN(err);
|
sl@0
|
479 |
}
|
sl@0
|
480 |
}
|
sl@0
|
481 |
|
sl@0
|
482 |
return KErrNone;
|
sl@0
|
483 |
}
|
sl@0
|
484 |
|
sl@0
|
485 |
|
sl@0
|
486 |
case RHcrTest::ECtrlCheckOverrideReposIntegrity:
|
sl@0
|
487 |
{
|
sl@0
|
488 |
HCR::TRepository* overrideRepos = gObserver.GetOverrideImgRepos(); // Shadowed SMR/HCR
|
sl@0
|
489 |
TInt err = KErrNone;
|
sl@0
|
490 |
|
sl@0
|
491 |
if( 0 != overrideRepos )
|
sl@0
|
492 |
{
|
sl@0
|
493 |
err = overrideRepos->CheckIntegrity();
|
sl@0
|
494 |
|
sl@0
|
495 |
}
|
sl@0
|
496 |
return err;
|
sl@0
|
497 |
}
|
sl@0
|
498 |
|
sl@0
|
499 |
case RHcrTest::ECtrlCheckOverrideRepos102400Content:
|
sl@0
|
500 |
{
|
sl@0
|
501 |
HCR::TRepository* overrideRepos = gObserver.GetOverrideImgRepos(); // Shadowed SMR/HCR
|
sl@0
|
502 |
TInt err = KErrNone;
|
sl@0
|
503 |
|
sl@0
|
504 |
if( 0 != overrideRepos )
|
sl@0
|
505 |
{
|
sl@0
|
506 |
for( TInt index = 0; index < itemsSize; ++index)
|
sl@0
|
507 |
{
|
sl@0
|
508 |
HCR::TSettingId id(items[index].iCategoryUID, items[index].iElementID);
|
sl@0
|
509 |
HCR_TRACE3("--- index:%5d, iCategoryUID:0x%08x, iElementID:0x%08x"
|
sl@0
|
510 |
, index
|
sl@0
|
511 |
, items[index].iCategoryUID
|
sl@0
|
512 |
, items[index].iElementID
|
sl@0
|
513 |
);
|
sl@0
|
514 |
HCR::TSettingRef val(overrideRepos, 0);
|
sl@0
|
515 |
HCR::TSettingType type = (HCR::TSettingType)items[index].iType;
|
sl@0
|
516 |
TInt r = gObserver.FindSetting(id, type, val);
|
sl@0
|
517 |
if( r != KErrNone)
|
sl@0
|
518 |
{
|
sl@0
|
519 |
err = KErrNotFound;
|
sl@0
|
520 |
break;
|
sl@0
|
521 |
}
|
sl@0
|
522 |
HCR::UValueWord valueWord;
|
sl@0
|
523 |
r = overrideRepos->GetValue(val, valueWord);
|
sl@0
|
524 |
HCR_TRACE1("--- value:0x%08x", valueWord.iUInt32);
|
sl@0
|
525 |
if( valueWord.iUInt32 != items[index].iValue)
|
sl@0
|
526 |
{
|
sl@0
|
527 |
err = KErrNotFound;
|
sl@0
|
528 |
break;
|
sl@0
|
529 |
}
|
sl@0
|
530 |
}
|
sl@0
|
531 |
}
|
sl@0
|
532 |
return err;
|
sl@0
|
533 |
}
|
sl@0
|
534 |
|
sl@0
|
535 |
case RHcrTest::ECtrlSwitchFileRepository:
|
sl@0
|
536 |
{
|
sl@0
|
537 |
TInt r;
|
sl@0
|
538 |
TAny* args[2];
|
sl@0
|
539 |
TEST_MEMGET(a1, args, sizeof(args));
|
sl@0
|
540 |
const TText* fileRepName = (TText*) args[0];
|
sl@0
|
541 |
|
sl@0
|
542 |
r = gObserver.SwitchRepository(fileRepName, HCR::HCRInternal::ECoreRepos);
|
sl@0
|
543 |
if (r != KErrNone)
|
sl@0
|
544 |
{
|
sl@0
|
545 |
HCR_TRACE_RETURN(r);
|
sl@0
|
546 |
}
|
sl@0
|
547 |
else
|
sl@0
|
548 |
return r;
|
sl@0
|
549 |
}
|
sl@0
|
550 |
|
sl@0
|
551 |
case RHcrTest::ECtrlCompiledFindSettingsInCategory:
|
sl@0
|
552 |
{
|
sl@0
|
553 |
TInt r = 0;
|
sl@0
|
554 |
//Do test for HCR::TRepositoryCompiled
|
sl@0
|
555 |
TAny* args[3];
|
sl@0
|
556 |
|
sl@0
|
557 |
|
sl@0
|
558 |
//It's a pre-condition to enter critical section before
|
sl@0
|
559 |
//kernel memory allocation
|
sl@0
|
560 |
NKern::ThreadEnterCS();
|
sl@0
|
561 |
TInt32* pFirst = new TInt32;
|
sl@0
|
562 |
TInt32* pLast = new TInt32;
|
sl@0
|
563 |
//We've done with allocation, exit CS
|
sl@0
|
564 |
NKern::ThreadLeaveCS();
|
sl@0
|
565 |
|
sl@0
|
566 |
if(!pFirst || !pLast)
|
sl@0
|
567 |
{
|
sl@0
|
568 |
HCR_TRACE_RETURN(KErrNoMemory);
|
sl@0
|
569 |
}
|
sl@0
|
570 |
|
sl@0
|
571 |
TEST_MEMGET(a1, args, sizeof(args));
|
sl@0
|
572 |
HCR::TCategoryUid catUid = (HCR::TCategoryUid)args[0];
|
sl@0
|
573 |
|
sl@0
|
574 |
|
sl@0
|
575 |
HCR::TRepositoryCompiled* compiledRepos =
|
sl@0
|
576 |
reinterpret_cast<HCR::TRepositoryCompiled*>(gObserver.GetVariantImgRepos());
|
sl@0
|
577 |
if (compiledRepos == 0)
|
sl@0
|
578 |
{
|
sl@0
|
579 |
HCR_TRACE_RETURN(KErrGeneral);
|
sl@0
|
580 |
}
|
sl@0
|
581 |
|
sl@0
|
582 |
//This function return the result of operation r and first element and
|
sl@0
|
583 |
//last element in the category written back to the user side test code
|
sl@0
|
584 |
//variable referenced by pFirst and pLast pointers
|
sl@0
|
585 |
r = compiledRepos->FindNumSettingsInCategory(catUid,
|
sl@0
|
586 |
*pFirst, *pLast);
|
sl@0
|
587 |
|
sl@0
|
588 |
TEST_MEMPUT(args[1], pFirst, sizeof(TInt32));
|
sl@0
|
589 |
TEST_MEMPUT(args[2], pLast, sizeof(TInt32));
|
sl@0
|
590 |
|
sl@0
|
591 |
if(r < 0)
|
sl@0
|
592 |
{HCR_TRACE_RETURN(r);}
|
sl@0
|
593 |
else
|
sl@0
|
594 |
return r;
|
sl@0
|
595 |
}
|
sl@0
|
596 |
|
sl@0
|
597 |
case RHcrTest::ECtrlFileFindSettingsInCategory:
|
sl@0
|
598 |
{
|
sl@0
|
599 |
TInt r;
|
sl@0
|
600 |
TAny* args[3];
|
sl@0
|
601 |
TEST_MEMGET(a1, args, sizeof(args));
|
sl@0
|
602 |
HCR::TCategoryUid catUid = (HCR::TCategoryUid)args[0];
|
sl@0
|
603 |
|
sl@0
|
604 |
//It's a pre-condition to enter critical section before
|
sl@0
|
605 |
//kernel memory allocation
|
sl@0
|
606 |
NKern::ThreadEnterCS();
|
sl@0
|
607 |
TInt32* pFirst = new TInt32;
|
sl@0
|
608 |
TInt32* pLast = new TInt32;
|
sl@0
|
609 |
//We've done with allocation, exit CS
|
sl@0
|
610 |
NKern::ThreadLeaveCS();
|
sl@0
|
611 |
|
sl@0
|
612 |
if(!pFirst || !pLast)
|
sl@0
|
613 |
{
|
sl@0
|
614 |
HCR_TRACE_RETURN(KErrNoMemory);
|
sl@0
|
615 |
}
|
sl@0
|
616 |
|
sl@0
|
617 |
|
sl@0
|
618 |
// Do test for HCR::TRepositoryFile
|
sl@0
|
619 |
HCR::TRepository* repos = gObserver.GetCoreImgRepos();
|
sl@0
|
620 |
__NK_ASSERT_DEBUG(repos != NULL);
|
sl@0
|
621 |
|
sl@0
|
622 |
//This function return the result of operation r and first element and
|
sl@0
|
623 |
//last element in the category written back to the user side test code
|
sl@0
|
624 |
//variable referenced by pFirst and pLast pointers
|
sl@0
|
625 |
r = repos->FindNumSettingsInCategory(catUid,
|
sl@0
|
626 |
*pFirst, *pLast);
|
sl@0
|
627 |
|
sl@0
|
628 |
TEST_MEMPUT(args[1], pFirst, sizeof(TInt32));
|
sl@0
|
629 |
TEST_MEMPUT(args[2], pLast, sizeof(TInt32));
|
sl@0
|
630 |
|
sl@0
|
631 |
if(r < 0)
|
sl@0
|
632 |
{HCR_TRACE_RETURN(r);}
|
sl@0
|
633 |
else
|
sl@0
|
634 |
return r;
|
sl@0
|
635 |
}
|
sl@0
|
636 |
|
sl@0
|
637 |
|
sl@0
|
638 |
|
sl@0
|
639 |
default:
|
sl@0
|
640 |
break;
|
sl@0
|
641 |
}
|
sl@0
|
642 |
|
sl@0
|
643 |
return KErrNotSupported;
|
sl@0
|
644 |
}
|
sl@0
|
645 |
|
sl@0
|
646 |
|
sl@0
|
647 |
// -- GLOBALS -----------------------------------------------------------------
|
sl@0
|
648 |
|
sl@0
|
649 |
|
sl@0
|
650 |
DECLARE_STANDARD_LDD()
|
sl@0
|
651 |
{
|
sl@0
|
652 |
HCR_FUNC("D_HCR_DECLARE_STANDARD_LDD");
|
sl@0
|
653 |
|
sl@0
|
654 |
// Try to initialise without a varian; KErrGeneral error should be returned
|
sl@0
|
655 |
new(&gTestHcrInt) HCR::HCRInternal(NULL);
|
sl@0
|
656 |
TInt err = gTestHcrInt.Initialise();
|
sl@0
|
657 |
if (err != KErrGeneral)
|
sl@0
|
658 |
return 0;
|
sl@0
|
659 |
|
sl@0
|
660 |
|
sl@0
|
661 |
// Taken from HCR_PIL.CPP InitExtension() method
|
sl@0
|
662 |
|
sl@0
|
663 |
HCR::MVariant* varPtr = CreateHCRVariant();
|
sl@0
|
664 |
if (varPtr==0)
|
sl@0
|
665 |
return 0;
|
sl@0
|
666 |
|
sl@0
|
667 |
new(&gTestHcrInt) HCR::HCRInternal(varPtr);
|
sl@0
|
668 |
|
sl@0
|
669 |
err = gTestHcrInt.Initialise();
|
sl@0
|
670 |
if (err != KErrNone)
|
sl@0
|
671 |
return 0;
|
sl@0
|
672 |
|
sl@0
|
673 |
new(&gObserver) HCR::HCRInternalTestObserver(&gTestHcrInt);
|
sl@0
|
674 |
|
sl@0
|
675 |
// ===== Above would be moved to DoRequest for test caes....
|
sl@0
|
676 |
|
sl@0
|
677 |
return new DHcrTestFactory;
|
sl@0
|
678 |
|
sl@0
|
679 |
}
|
sl@0
|
680 |
|
sl@0
|
681 |
|