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